Settlement
The Settlement module provides tools for encoding trades, interactions, and prices into the format required by the settlement contract.
SettlementEncoder
The SettlementEncoder class serves as the primary interface for building settlement transactions.
Creating an Encoder
Trade Encoding
Two methods handle trade encoding:
The TradeExecution interface supports partial fills by specifying executed amounts:
Interaction Encoding
Generating Settlement Data
Trade Flags
Trade flags encode order characteristics into a single bitfield:
TokenRegistry
The TokenRegistry class manages token-to-index mapping, reducing gas costs by referencing tokens by index rather than address:
Interaction Stages
EncodedSettlement
The final output is a tuple containing:
Best Practices
- Maintain consistent token ordering for predictable indices
- Use high precision for clearing prices to minimize rounding errors
- Always specify
executedAmount for partially fillable orders
- Select appropriate interaction stages based on execution timing requirements
Last modified on March 4, 2026