Swap APIs & SDKs

Keep KyberSwap route gas context consistent

Keep route-ranking gas assumptions separate from execution gas limits in a KyberSwap adapter.

Gas affects both route economics and whether a transaction has enough execution resources. Those are related calculations, but the fields should not be treated as interchangeable.

The KyberSwap V1 field map lists route-request gas settings separately from build-time gas estimation and response gas values. Consult the current schema for each field's units and meaning before transferring an older integration's defaults.

Compare routes under consistent assumptions

Suppose two hypothetical routes return different token outputs and require different amounts of gas. Ranking one using a current gas price and the other using yesterday's cached price makes the comparison unreliable even if both output estimates are otherwise reasonable.

Record the gas-price context alongside the quote request. When comparing route alternatives, use the same cost basis or show that the estimates came from different contexts. Do not label an output-only ordering as a net-cost ranking.

A route estimate is not a wallet fee guarantee

The eventual transaction's gas limit and fee parameters belong to execution review. Network conditions, caller state and the final encoded path can differ from the conditions used to rank candidate routes.

Keep units visible in the adapter types: gas units, native currency per gas unit and a converted fiat estimate represent different quantities. A missing conversion price should produce an unavailable fiat estimate, not a zero network cost.

Diagnose changes without changing the trade

Log the quote's gas context, build result and final fee envelope as distinct stages. If displayed cost rises, this record helps identify whether routing changed, the gas market changed or the wallet chose different fee settings.

A useful fixture keeps token output constant while changing the gas-price input. Check that cost-sensitive ranking changes only where intended and that no amount field is accidentally overwritten by a gas value.

Sources & verification (1)

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

  1. Upgrading to APIv1

    GET route summary then POST build; sender and recipient

    https://github.com/KyberNetwork/kyberswap-documentation/blob/main/developer-guide/aggregator-api/how-to-guides/execute-a-swap-with-the-aggregator-api/upgrading-to-apiv1.md

Continue reading

Swap API integration: quote, approve, simulate, submit