Skip to main content

Slippage

Slippage is the maximum price difference you’re willing to accept between the quoted rate and the executed rate. It protects against price movement during the time between quoting and on-chain execution.

Choosing a slippage value

Pass slippage as a percentage (not a fraction) to the partner quote endpoint:
The partner API allows 0 to 5. Up to 4 decimal places are supported (for example 0.5 or 1.25).

What happens when slippage is exceeded

The on-chain transaction reverts. You pay gas but no tokens are swapped and no tokens are lost. The user keeps their full balance.

Quote and execution timing

The partner quote returns both the output and transaction. Pool and RFQ state can still change before confirmation. Best practice: A display quote may be shown while the user reviews, but request a fresh partner quote when they click “Swap” and execute it immediately.

Handling reverts

If a swap transaction reverts on-chain, it’s usually one of these:

Safe retry pattern

Retry network failures while requesting a quote with bounded backoff. After a transaction is signed, broadcast, or reverted, never reuse its calldata and never silently raise the user’s slippage; obtain fresh user intent and a fresh quote.

Gas on HyperEVM

The partner response returns gas plus either legacy or EIP-1559 fee fields. Inspect tx.type and never submit both fee models.
If you need to override gas, set a higher limit — never lower:

Rate limiting

Partner limits are assigned with the API key. Confirm the production quota during onboarding. To stay within it:
  • Debounce quote requests — Don’t re-fetch on every keystroke. Do not cache executable responses in a CDN, service worker, or persistent store.
  • Poll at reasonable intervals — For price feeds, 15–30 seconds is sufficient. Prices refresh every ~5 seconds on the backend.
  • Batch token lookups — Use GET /{chainId}/tokens to fetch all tokens in one call instead of fetching individually.
If you hit the rate limit, the API returns HTTP 429. Back off and retry:

Approval best practices

  • Use the returned target — Approve only the allowanceTarget returned by the partner quote; never assume one router address applies forever.
  • Prefer exact approval — Approving sellAmount limits exposure. Partners may choose a larger allowance only after their own security review.
  • Wait and refresh — After approval confirmation, request a new partner quote before swapping.
  • Native tokens skip approval — HYPE (0xeeee...eeee) doesn’t need approval. Skip the allowance check for native tokens.

Amounts and decimals

All amounts in the API are in wei (the token’s smallest unit). Each token has its own decimals value. Use viem’s parseUnits and formatUnits to convert:
Always use the token’s actual decimals value from the API — don’t hardcode 18. Some tokens use 6, 8, or other values.