Discover Pools and Read State
The Dispatcher’s direct ledger subaccounts provide candidate pool addresses. Validate each candidate before presenting it as a trading market.
const pools = await publicClient.readContract({
address: dispatcher,
abi: ledgerAbi,
functionName: "subAccounts",
args: [dispatcher],
blockNumber,
});
The example assumes a configured client, matching ABI, Dispatcher address, and an explicitly selected block number.
Identify a pool
Read poolSummary(pool) or targetTokenAddress(pool) to distinguish initialized pool state from other subaccounts. Apply the deployment’s published pool list if the integration is intentionally limited to that list.
A summary includes total scale, USD conversion, target token, Treasury, reserve and claim counts, and anchor addresses. Scale and price values use packed Float encoding.
Read the reserves
Page through reserveAssetInfos(pool, start, limit). Choose a page size supported by the RPC and iterate through the registry.
A Reserve Asset read supplies its address, reserve, scale, fee, metadata, decimals, and role/ledger flags. reserveAsset(pool, token) supplies the quote snapshot for an individual asset.
Keep the snapshot coherent
Read summary, parameters, and participating assets at the same block. A quote assembled from mixed blocks can combine incompatible balances and scales.
Cache token metadata where appropriate; refresh financial state before quoting. Normal trading requires initialized, valid reserve state for each registered token.
Continue with Quote a Trade.