Skip to content

OverviewArchitecture

Overview

Architecture

Components

flowchart TB
  subgraph Clients
    UI[Lane front<br/>separate project]
    App[Wallets / apps / bots]
  end
  subgraph API process [API process - api/src]
    S[server.ts<br/>Fastify HTTP + WS]
    I[indexer.ts<br/>pool state]
    R[router.ts<br/>pathfinding + estimators]
    P[plan.ts<br/>exact quotes + splits]
    K[keeper.ts<br/>order filler + fee converter]
    PR[probe.ts<br/>honeypot/tax probe]
    L[launchpad.ts]
    A[account.ts / orders.ts]
  end
  subgraph Chain [Elysium]
    EX[Executor]
    OB[OrderBook]
    FC[FeeCollector]
    POOLS[V2 / V3 / V4 pools]
    LP[Launchpad router]
  end
  RPC[(RPC / WS)]
  RD[(Redis, optional)]
  UI --> S
  App --> S
  S --> R --> I
  S --> P --> EX
  S --> PR
  S --> L --> LP
  S --> A
  K --> P
  K --> OB
  K --> FC
  I <--> RPC
  I <--> RD
  EX --> POOLS
  OB --> EX
  FC --> EX
ComponentFileRole
HTTP/WS serverapi/src/server.tsValidation, /v1/* routes, simulation, API keys, rate limits, static UI
Indexerapi/src/indexer.tsFactory discovery, pool state, ticks, reorgs, snapshots, token metadata
Routerapi/src/router.tsPath search, V2/V3/V4 estimators, spot prices, hop encoding
Plannerapi/src/plan.tsExact batched quotes, gas-aware ranking, split allocation. Shared by /quote and the keeper
Keeperapi/src/keeper.tsFills due limit/DCA slices, refunds expired orders, converts collected fees
Probeapi/src/probe.ts + TokenProbe.solBuy → transfer → sell simulation to measure taxes and detect honeypots
Launchpadapi/src/launchpad.tsBonding-curve quotes for pre-graduation tokens
Orders / accountapi/src/orders.ts, api/src/account.tsEvent-indexed orders, portfolio, history
Event storeapi/src/store.tsSQLite record of every swap/liquidity event in USD, price samples, TVL, Lane swaps, revenue, notifications (details)
Data routesapi/src/data-routes.ts, api/src/pnl.tsPools, charts, activity, candles, analytics, PnL, transfers
Keys and share cardsapi/src/keys.ts, api/src/share.tsSelf-serve API keys and usage; PNG share cards
Configapi/src/config.ts + api/networks/*.jsonEverything chain-specific, plus env settings
Executorcontracts/src/Executor.solExecutes and quotes routes; takes the fee
OrderBookcontracts/src/OrderBook.solEscrow for limit/DCA orders; keeper-only fills
FeeCollectorcontracts/src/FeeCollector.solReceives fees; converts them to a target token for the treasury

Process model

Everything off-chain runs in one Node.js process (pnpm start): the indexer, the HTTP server, the keeper and the fee converter. Routing reads the indexer's in-memory maps directly, so there's no cache to keep in sync and no network hop between "the indexer" and "the router".

Scaling out:

  • Run several instances behind a load balancer with REDIS_URL set. They share the snapshot (each new instance boots from the latest state instead of backfilling) and the rate-limit counters.
  • Run the keeper on one instance only. The event store is a local SQLite file: with several instances, each keeps its own (point them at one volume, or give one instance the data routes) (set KEEPER_PRIVATE_KEY there and nowhere else), so two keepers don't race for the same slice.

Data flow of a quote

sequenceDiagram
  participant C as Client
  participant S as API
  participant I as Indexer (memory)
  participant N as RPC node
  participant E as Executor (eth_call)
  C->>S: GET /v1/quote?in&out&amount&recipient
  S->>I: candidate paths + estimates
  S->>N: multicall [Executor.quote x20] + feeBps + gasPrice
  N->>E: run swaps, revert with amounts
  S->>N: multicall [split legs at 5%..95%]
  S->>N: allowance, balanceOf, eth_estimateGas(tx)
  S-->>C: amountOut, minOut, splits, tx, approval, simulation

On-chain state vs off-chain state

StateLives inLost on restart?
Pool reserves, ticks, liquidityIndexer memory + snapshotNo (snapshot + replay)
Token metadata, probe resultsIndexer memory + snapshotNo
OrdersOrderBook contract (source of truth), indexed from eventsNo
FeesForwarded each swap to the FeeCollectorn/a
Rate-limit countersMemory, or RedisYes without Redis (harmless)
Events, prices, TVL history, Lane swaps, notifications, API keys and usageSQLite data/events.db (Railway volume)No

The API is stateless with respect to users: no accounts, no sessions, no stored quotes.

Next: API at a glance

lane.markets · Make the most of every move.