swaps
swaps copied to clipboard
feat: expose quote preparation [APP-2659]
Add EIP-7702 Batching Support
Overview
This PR introduces support for EIP-7702 transaction batching by adding new transaction preparation functions.
What's New
New Functions
prepareFillQuote- Extracts transaction data from regular quotes without executingprepareFillCrosschainQuote- Extracts transaction data from crosschain quotes without executingBatchCallinterface - Standardized format for transaction data ({ data, to, value })
Refactored Functions
fillQuote- Now usesprepareFillQuoteinternally (reduced from ~100 to 13 lines)fillCrosschainQuote- Now usesprepareFillCrosschainQuoteinternally (reduced from ~15 to 10 lines)
Backward Compatibility
- Zero breaking changes to existing API
- All existing functions work exactly as before
- Maintains full feature parity
Usage Examples
Traditional Usage (unchanged)
const tx = await fillQuote(quote, options, wallet, permit, chainId, referrer);
New Batching Usage
// Prepare multiple transactions for batching
const swapCalldata = await prepareFillQuote(quote1, options, wallet, permit, chainId);
// Execute as batch with EIP-7702
await executeBatchedTransaction({
calls: [approveCalldata, swapCalldata],
walletClient,
publicClient,
});
Safety & Testing
- Added proper type safety with null checks for optional fields
- Maintains all existing error handling and validation
- All transaction preparation logic identical between prepare and execute paths
- No changes to core swap logic or contract interactions