Token Approval Mechanism
Before executing any transaction that spends ERC20 tokens (swap, bridge, zap, etc.), the DZap contract must be approved to access those tokens. The SDK provides multiple approval modes to handle different scenarios optimally.Recommended Approval Flow
Approval Modes Deep Dive
1. Default Mode (Standard ERC20)
Traditional approval directly to the DZap contract.- Implementation
- Characteristics
- Best For
2. Permit2 Mode
Uses Uniswap’s Permit2 for gas-efficient repeated approvals.- Implementation
- Characteristics
- Benefits
3. EIP-2612 Permit Mode
Direct permit signatures to DZap contract for supported tokens.- Implementation
- Characteristics
- Benefits
4. Auto Permit Mode (Recommended)
Automatically selects the optimal approval method.- Decision Logic
- Usage
Security Considerations
Limit Exposure
Use exact amounts for high-value or infrequent transactions
Monitor Allowances
Regularly audit and revoke unnecessary approvals
Use Permits When Possible
Permits reduce approval attack surface
Set Expiration Times
Use reasonable deadlines for permit signatures