Integration engineering

Compare quotes after separating output and network cost

Compare net quote economics by identifying included fees, separate gas costs and uncertainty in token-to-USD conversions.

Compare like-for-like output before subtracting anything. A provider may already deduct an integrator fee from its output amount, while another may report gross output and a separate charge. Subtracting every fee field again can reverse a ranking incorrectly.

Annotate costs before arithmetic

For each adapter, document which output field reaches the user, which fees it includes, what remains payable separately and the unit of every cost. Keep expected output distinct from minimum output. A comparison of one provider's estimate against another's worst-case bound is not meaningful.

The OKX quote reference distinguishes token amounts and estimated network costs. PancakeSwap documents its own fixed-point gas-cost field. Their labels cannot be combined without unit conversion.

A hypothetical ranking

Assume route A delivers 100 output tokens and costs the equivalent of 1 token in separate gas. Route B delivers 99.5 tokens and costs 0.2 token equivalent. Their estimated economic results are 99 and 99.3 respectively. This illustration assumes the conversion rate is reliable and neither cost has already been deducted.

If gas must be paid in native currency, the user still receives the quoted output token amount; the converted subtraction is an economic comparison, not an on-chain token balance change. Show both facts.

Make uncertainty explicit

If a USD price is missing or stale, avoid a precise net ranking. Present raw output and known costs, or mark the comparison incomplete. Keep the valuation timestamp and source with the calculation.

Fixtures should include an already-net quote, a gross quote, a missing conversion and a fee charged in a third token. These cases expose double subtraction and false zero-cost assumptions.

Sources & verification (2)

Source-check date is recorded in the article details. URLs are provided for manual verification. Use Copy to keep this page open.

  1. Get Quotes

    v6 quote schema, chainIndex, amount units and native sentinel

    https://web3.okx.com/onchainos/dev-docs/trade/dex-get-quote
  2. Response payloads

    Candidate response shapes

    https://developer.pancakeswap.finance/contracts/unified-swap-api/payloads

Continue reading

Swap API integration: quote, approve, simulate, submit