Overview
Interactions allow settlements to execute arbitrary smart contract calls at specific stages during settlement execution. This enables advanced functionality like:- EIP-2612 permit calls for gasless approvals
- AMM trades to source liquidity
- Token wrapping/unwrapping
- Protocol integrations
- Post-settlement cleanup
Interaction Interface
The core interaction data structure:The address of the smart contract to interact with. Must be a valid Ethereum address.
The amount of ETH to send with the call (in wei). Set to
0 for calls that don’t require ETH.The encoded function call data. Use ethers.js
Interface.encodeFunctionData() to generate this.InteractionLike Type
A convenience type that makesvalue and callData optional:
InteractionLike, omitted fields default to:
value:0callData:"0x"
Interaction Stages
Interactions are executed at specific stages during settlement:Stage Details
- PRE
- INTRA
- POST
Pre-settlement interactions execute before any token transfers occur.Use cases:
- EIP-2612 permit calls for gasless approvals
- Setting up allowances
- Token wrapping (e.g., ETH → WETH)
- Pre-trade state initialization
Helper Functions
normalizeInteraction
Normalizes anInteractionLike to a full Interaction:
value:0if not specifiedcallData:"0x"if not specified
normalizeInteractions
Normalizes an array of interactions:Creating Interactions
Basic Interaction
Interaction with ETH
Using with SettlementEncoder
encodeInteraction
Add an interaction to a settlement:If no stage is specified,
InteractionStage.INTRA is used by default.Common Use Cases
EIP-2612 Permit
Uniswap V2 Swap
WETH Wrap/Unwrap
Curve Pool Swap
Complete Example
Best Practices
Stage Selection
Choose the correct stage based on when token balances need to be available. Pre for setup, Intra for trading, Post for cleanup.
Gas Optimization
Minimize the number of interactions and calldata size to reduce gas costs.
Error Handling
Interactions that fail will cause the entire settlement to revert. Ensure all calls will succeed.
Reentrancy
Be cautious of reentrancy when interactions call untrusted contracts or transfer ETH.
Next Steps
Settlement Encoding
Learn more about encoding settlements
Orders
Review order creation and management
