Quote a Trade
Use quoteMultiswapForSettlement for an execution preview with USD display information. Use quoteMultiswapForExecution for token and accounting quantities alone.
Inputs
type ReserveAsset = {
tokenAddress: Address;
fee: bigint; // packed Float
reserve: bigint; // packed Float
scale: bigint; // packed Float
};
type QuoteAmount = { token: ReserveAsset; amount: bigint };
type QuoteAllocation = {
token: ReserveAsset;
allocation: bigint;
minAmount: bigint;
};
Every numeric quote field above is a packed Float represented by ABI int256. Use the reference client’s conversion helpers. For an integer token amount, bnToFloat(amount, tokenDecimals) creates the quote amount. Quote allocations represent fractions summing exactly to one.
Use current Reserve Asset snapshots. Set quote-time minimums to zero while discovering the output; execution minimums are computed afterward.
const result = await publicClient.readContract({
address: dispatcher,
abi: quoteAbi,
functionName: "quoteMultiswapForSettlement",
args: [pool, payQuoteAmounts, receiveQuoteAllocations],
blockNumber,
});
This example assumes configured clients and ABI, a selected block, and the populated inputs described above.
Output
The settlement view returns pay quotes, receive quotes, fee quotes, normalized receive allocations, and priceOfUSD. The execution view returns the first four.
Each QuoteItem contains tokenAddress, reserves, surplus, rewards, treasury, valueChange, and valueFlow.
Token buckets are positive movement amounts with roles determined by the side. Pay buckets are destinations; receive buckets are sources. valueFlow is signed, while valueChange is the scale update.
Net receive amount
Convert each token bucket separately to the token’s integer base units, then sum the receive quote’s buckets. This follows settlement’s per-bucket rounding.
The user’s receive quote is already net of the receive fee. Use that net receive quote directly when computing the user’s minimum.
Compute each execution minimum from that net amount. For a basis-point tolerance, an integer calculation can use:
const minAmount = quotedNetAmount * (10_000n - slippageBps) / 10_000n;
Validate that the tolerance is in range and represents the user’s choice. Keep monetary amounts as integers throughout the calculation.
Freshness
Preserve array order through quote, signature, and settlement. Requote after material changes to reserves, scales, elasticity, fees, or Surplus. Execution reconstructs live state and applies the submitted minimums.
Continue with Execute a Trade.