Approvals and settlement
What the taker approves, what the wallet sends, and how the trade settles on chain.
A firm quote settles on chain in one transaction from the taker wallet. Two addresses matter, and both come from the API:
| Address | Where to read it | What you do with it |
|---|---|---|
| Allowance target (the spender) | GET /v2/limits, assets[].sides.<buy|sell>.allowance_target | Approve token_in to it |
| Transaction target | Firm quote, execution.transaction.to | Send the packet to it, on execution.transaction.chain_id |
Today both are the Rave SettlementRouter for that chain (see Contracts). Read them from the API on every integration path anyway, and never hard-code them.
Approve before the firm quote
Do this once per (token_in, chain_id, spender) and re-check when the amount grows:
- Read the allowance target from
/v2/limitsfor the entry whosetoken.chain_idmatches your chain. - Check the allowance:
token_in.allowance(owner, allowance_target)on that chain. If it coversamount, skip to step 5. - Approve:
token_in.approve(allowance_target, amount)from the taker wallet. Approveamount, or a larger amount you are comfortable pre-approving. - Wait for the approval receipt.
- Request a fresh firm quote, so
expiresand the price are current. - Submit
execution.transactionunchanged beforeexpires.
# Allowance target per symbol, chain and side
curl -s "$RAVE_API/v2/limits?chain_id=56" -H "Authorization: Bearer ***" \
| jq '.assets[] | {symbol, chain_id: .token.chain_id, buy: .sides.buy.allowance_target, sell: .sides.sell.allowance_target}'What the wallet sends
execution.transaction is a complete packet: to, data, value and chain_id. value is usually "0"; the trade value is in data. Pass all four unchanged to the wallet or RPC.
Never edit the transactionDo not change
to,dataorvalue, and do not send the packet on another chain. The router checks the signed terms on chain; an edited packet reverts or is refused.
How settlement works
- The router pulls at most
amount_inoftoken_infrom the taker. Delivering more thanamount_indoes not revert; the surplus stays with the caller. - The output token is sent to
recipient. - The router refuses to execute the same quote twice, but every new firm quote is a new trade. See Transaction safety before you retry anything.
- A packet reverts if it is submitted after
expires, if the allowance is short, or if less thanamount_inarrives on anexactside. On avariableside Rave settles what arrived (see Variable Input).
Reverts are covered in Errors.
Updated 25 days ago