Skip to content
Fossa

Index DEX data

Identify program accounts, process state changes, and interpret executed trades.

Identify account records

An account record contains its address, owning program, and raw data. The owning program separates DEX state from token-program state. The discriminator at the start of the data identifies the DEX account type.

This function classifies raw records with the generated discriminator constants. Classification alone does not validate an account’s fields or derived address. See account validation.

Process pool state

After validation, Pool supplies the mint pair, vault addresses, reserve accounting, lifecycle, and fee recipients. Integer wrappers expose values through .get().

The projection below receives an already decoded pool. It separates a trading curve, a curve at its target, and an AMM. It does not infer trades from reserve changes. Retain the account address and observation position with the projected values.

Derived dataRequired state
Approved pairsGlobal and quote Config. reference_pool identifies the model-price reference.
Prices and launch progressPool reserves, virtual reserves, status, target, and both mint decimals.
Transfer taxesBoth mint owners and the active epoch’s transfer-fee schedules.
LP positionsUser balances for pool.lp_mint, circulating LP supply, and locked_lp.
Token identitySupported mint metadata and its referenced document. The pool has no name, image, or website field.
Backing valueRouter model-group state, backing-vault balance, and current model-token supply.

Mints and token accounts belong to their token program. They are separate records from DEX-owned state. Backing balances are separate from AMM reserves.

Build trade history

Account records describe state. They do not identify every trade. The current DEX source defines no dedicated trade-event format. An executed transaction supplies instruction data, account keys, execution status, and token-transfer results.

  1. Require successful execution metadata. Missing metadata means the result is unknown.
  2. Resolve instruction account indices, including loaded addresses.
  3. Identify instructions whose program ID matches the DEX. Decode their generated discriminators and arguments.
  4. For swap or swap_exact_out, map the nested Trade accounts to the pool’s stored mints and user accounts.
  5. Interpret a_to_b = false as quote-to-base and true as base-to-quote.
  6. Associate the executed token transfers with that invocation. Record gross input, net output, token units, signature, slot, and instruction position.

A cross-program invocation (CPI) appears as an inner instruction. Transactions can contain several DEX calls, so the signature alone does not identify one trade. Signature plus outer and inner instruction positions distinguishes those calls.

For a clipped final buy, SwapArgs.amount can exceed executed input. Executed transfers determine volume. Transaction-wide balance changes cannot always separate several swaps. Failed transactions do not contribute successful trade volume.

Interpret state changes

InstructionState change to identify
initialize_curveNew pool, fixed base supply, curve status, and revoked base mint authority.
initialize_poolNew AMM, two net deposits, and minted LP supply.
swap, swap_exact_outReserve changes, accrued trade fees, and user transfers.
add_liquidity, remove_liquidityLP supply changes and proportional reserve transfers.
graduateBase burn, cleared virtual reserves, locked LP units, and AMM status.
collect_feesReduced fee counters and transfers to the authorized fee owner.
collect_transfer_taxIncreased tax_collected and tokens received by the distributor.

A reserve delta alone does not establish buy volume. Several actions can occur between account observations. Likewise, tax collection does not establish a holder payout.

A slot alone cannot order multiple writes within that slot. Preserve the execution position or account-write ordering supplied with the record. Distinguish provisional records from confirmed state. If a new account format cannot be decoded, treat it as unsupported rather than empty.