Swap APIs & SDKs

Refresh a KyberSwap route after an approval delay

Requote KyberSwap after a meaningful delay and retire stale build responses without losing the user’s selected trade.

An approval delay can outlast the useful lifetime of a KyberSwap route. Keep the user's intended pair and amount, but refresh the route before constructing the transaction they will submit.

The EVM API specification recommends short client-side route caching and refreshing before a delayed swap. A cache timer is an application freshness policy, not a guarantee that liquidity will remain executable until that timer expires.

Refresh at decision boundaries

Useful boundaries include approval confirmation, returning from an inactive tab and reopening a review after the user changed networks. These events can invalidate either market assumptions or account context.

Give every route and build a generation identifier. If a refresh starts while an older build request is in flight, the older result must not become active merely because it arrives later. Disabling the confirmation button while construction is pending prevents a stale transaction from surviving behind a fresh price label.

Review changed terms

Compare the new input amount, estimated output, minimum output, fees and recipient with the reviewed intent. If meaningful terms changed, let the user review them again. Refreshing should not silently increase slippage to recover a route that no longer meets the selected bounds.

Do not treat a build failure as permission to resend the identical summary forever. Distinguish malformed request data from changed market conditions and provider unavailability; each suggests a different next action.

Keep approval separate

A completed approval can remain useful even when the old route is discarded. Read the new route's allowance requirements before deciding another approval is needed. The interface should explain that the route was updated, rather than presenting the already confirmed permission as a failed transaction.

Test a delayed approval followed by a worse quote. The refreshed payload should require the intended review step while retaining the approval receipt in history.

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. EVM swaps API specification

    Route and build parameters, sender and gas context

    https://github.com/KyberNetwork/kyberswap-documentation/blob/main/developer-guide/aggregator-api/aggregator-api-specification/evm-swaps.md

Continue reading

Swap API integration: quote, approve, simulate, submit