swaps icon indicating copy to clipboard operation
swaps copied to clipboard

feat: expose quote preparation [APP-2659]

Open derHowie opened this issue 7 months ago • 1 comments

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 executing
  • prepareFillCrosschainQuote - Extracts transaction data from crosschain quotes without executing
  • BatchCall interface - Standardized format for transaction data ({ data, to, value })

Refactored Functions

  • fillQuote - Now uses prepareFillQuote internally (reduced from ~100 to 13 lines)
  • fillCrosschainQuote - Now uses prepareFillCrosschainQuote internally (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

derHowie avatar May 29 '25 15:05 derHowie