Delegate Bundler

DelegateBundler.sol is the execution engine that enables complex, multi-step DeFi strategies to happen in a single transaction.

What It Does

DeFi strategies often require multiple steps. For example, opening a leveraged position on Uniswap V3 might need:

  1. Approve token A for the Uniswap position manager
  2. Approve token B for the Uniswap position manager
  3. Mint a new concentrated liquidity position

Without bundling, each step would be a separate transaction — slow, expensive, and if step 3 fails, you've already spent gas on steps 1 and 2.

The DelegateBundler wraps all steps into a single atomic transaction: either everything succeeds, or everything reverts.

How It Works

EIP-712 Signatures

Instead of the delegate calling the blockchain directly, they sign a structured message (EIP-712) that describes what they want to do. This signature is then submitted to the bundler contract, which:

  1. Verifies the signature matches the delegate's address
  2. Checks the nonce hasn't been used before (replay protection)
  3. Validates the deadline hasn't passed (time-bound execution)
  4. Routes each operation to the appropriate protocol module
  5. Executes all operations through the user's Safe

Why EIP-712?

EIP-712 creates human-readable signatures. When a user or delegate signs, their wallet shows exactly what's being authorized — not just a hex blob. This is critical for security transparency.

Nonce and Deadline System

Mechanism Purpose
Nonce Each signature has a unique number. Once used, it can't be replayed.
Deadline Each signature has an expiration timestamp. Old signatures can't be resubmitted.

These two mechanisms together prevent:

  • Replay attacks — submitting the same signed transaction twice
  • Stale execution — executing an outdated strategy when market conditions have changed

Example: Opening a Uniswap V3 Position

DelegateBundler.executeUniswapV3OpenPosition(
    safe: 0x123...        // The user's Safe address
    delegate: 0xabc...    // The operator's address
    calls: [
        approve(USDC, positionManager, 1000),
        approve(ETH, positionManager, 0.5),
        mint(pool, tickLower, tickUpper, amount0, amount1)
    ]
    signature: 0xdef...   // EIP-712 signature from delegate
    nonce: 42             // Unique execution nonce
    deadline: 1708099200  // Expires in 1 hour
)

Contract Location

smart-wallets/contracts/DelegateBundler.sol

results matching ""

    No results matching ""