Approvals
Buying a BNB-paired token with BNB needs no approval: the BNB is sent with the trade.
Spending a token (selling, or buying a token that’s paired with USDT and paying in USDT) needs two one-time steps, through Permit2, the standard approval contract:
- The token approves Permit2. Once per token, ever.
- Permit2 approves our router. Once per token, for 30 days.
The build answer lists what’s missing as requires, in order, each a ready transaction with an explain. Send them, wait for each to be mined, then build the trade again: the new build is simulated for real, because the approvals now exist. After that, every trade is one transaction.
let built = await build('/build/sell', request);while (built.requires.length) { for (const step of built.requires) await send(step.tx); built = await build('/build/sell', request);}await send(built.tx);