/execute answers with one executionType. Your code branches on that one field.
Every answer carries a
quoteToken. Use that one, not the one from /quote, for
/submit-signature, /submit-transaction and /status.
TRANSACTION
calls in order, each once the one before it has succeeded, and stop if
one reverts. (In the rare case calls is missing, send the same fields in that order yourself.) calls is everything to send, already in order: approval.reset, approval, the
swap (transaction), then your fee (fee.transaction) when one applies.
- Send the swap with
transaction.gasLimitas its gas limit when it’s set (viem:gas: BigInt(gasLimit)). - When
batchistrue, you may send all ofcallsin one atomic wallet batch (EIP-5792wallet_sendCalls) instead. Simulate the batch first and fall back to one by one if it fails.
chainId: -2), transaction.serialized is a base64 versioned transaction. Sign it
and send it from the user’s own wallet, with confirmed commitment. Any fee is already inside it.
With submit. Only on quotes sent with broadcastViaRavn: true. Don’t broadcast it: sign
transaction.serialized and post it to /submit-transaction.
SIGNATURE
- Send
approval(andapproval.resetfirst, when present) and wait for it to be mined. Gasless orders still pull the tokens through an allowance: without it the order is accepted and then silently never fills. - Sign
typedData. WhenapprovalDatais present, sign it too. - Post both signatures to
/submit-signature. It returns thestatusRefto poll with.
DEPOSIT
deposit.amount of the quote’s input token to deposit.address. Ready-made
versions come with the answer:
No approval is needed. When
deposit.expiresAt is set, send the deposit right away and never after
that time: some routes need it to have arrived by then. Send a native-coin deposit from a
regular wallet, not from a smart contract: some venues don’t credit coin a contract moves.
You can also show the address and a QR code and let the user send it from any wallet. That’s how
native Bitcoin is usually paid.
Approvals
approval is a ready-to-send ERC-20 approve(spender, amount), sent to the token contract.
- Wait for it to be mined before the swap. Otherwise the swap reverts and the user pays gas for nothing.
- RAVN leaves it out when the user’s allowance already covers the swap. When RAVN couldn’t read the allowance it’s included anyway; skip it if your own read shows enough.
- That read sees only mined transactions. Run one swap per token and spender at a time: a second
swap started while the first is pending can come back without the
approvalit needs. approval.resetappears for tokens like Ethereum USDT that can’t change one non-zero allowance to another. Send it first.- The spender is
approval.spender. Don’t assume it’stransaction.to. unlimitedRecommended: truemeans the venue would rather you approve once for a large amount.datastill approves the exact amount; raising it is your call.
AUTHORIZE steps (Hinkal)
A fourth type, only for Hinkal private swaps you opt into withauthorizeSteps: true. The paying wallet signs twice before the TRANSACTION comes. See
Private swaps.
