Skip to main content

GPv2Interaction API

The GPv2Interaction library enables settlement contracts to execute arbitrary external contract calls during trading settlements, supporting complex strategies like liquidity sourcing and protocol integrations.

Data Structure

Functions

execute

Performs the actual contract interaction using inline assembly for gas optimization. Propagates revert reasons if calls fail.

selector

Extracts the 4-byte function selector from calldata for event logging.

Settlement Integration

Interactions run at three distinct phases:

Common Use Cases

  • DEX swaps for liquidity sourcing (Uniswap, Balancer, Curve)
  • Token wrapping/unwrapping (WETH)
  • Approval grants to external protocols
  • Trade routing through aggregators like 1inch
  • EIP-2612 permit calls for gasless approvals

Security

Interactions cannot target the vaultRelayer contract. Only authorized solvers may submit settlements with interactions. Reentrancy guards prevent attack vectors. Misbehaving solvers face financial penalties.

Best Practices

  • Order interactions by settlement phase carefully
  • Ensure all calls succeed (failures cause the entire settlement to revert)
  • Use type-safe encoding methods (e.g., abi.encodeWithSelector) rather than manual byte manipulation
Last modified on March 4, 2026