Before Bebop can settle a trade, the settlement contract needs permission to move your sell tokens. This is standard ERC-20 behavior - you callDocumentation Index
Fetch the complete documentation index at: https://docs.bebop.xyz/llms.txt
Use this file to discover all available pages before exploring further.
approve() on the token contract, authorizing the settlement contract to transfer up to a specified amount.
This applies to both the RFQ API and Aggregation API.
Which Contract to Approve
Every quote response includes anapprovalTarget field - this is the address you approve. Always use this value rather than hardcoding.
Check Existing Allowance
Before approving, check whether the token already has sufficient allowance. This avoids unnecessary gas spend on redundant approval transactions.Approve if Needed
If the current allowance is less than the trade amount, submit an approval transaction. Most integrators approve the maximum amount (2^256 - 1) so they only need to do this once per token.
Using It with Quotes
After receiving a quote from either API, check and approve before signing and broadcasting:Approval Strategies
Max approval (recommended for programmatic integrators): Approve2^256 - 1 once per token. Saves gas on subsequent trades since you never need to re-approve. This is the standard approach for solvers and aggregators.
Exact approval: Approve only the exact trade amount each time. More conservative, but costs gas on every trade. Some compliance-sensitive integrations prefer this.
Permit2
In gasless mode (gasless=true), you can use approval_type=Permit2 to replace the per-contract on-chain approval with a one-time approval of the Permit2 contract. Token spending is then authorized via off-chain EIP-712 signatures rather than separate approve() transactions for each settlement contract.
With approval_type=Standard (the default for gasless), the user must have approved the settlement contract beforehand - the same as self-execution.
The Permit2 signing flow differs between APIs:
- Aggregation API: The order is wrapped inside a
PermitBatchWitnessTransferFrommessage - you sign one combined message with the Permit2 domain. See the Aggregation API quickstart. - RFQ API: Order signing is unchanged (
BebopSettlementdomain, same types). You generate a separatePermitBatchsignature and include it in the/orderPOST body. See the RFQ gasless guide.
Permit2 is supported in gasless mode on both the RFQ API and Aggregation API. It is not compatible with self-execution on either API.