GPv2Trade API
TheGPv2Trade library is a Solidity utility for encoding and decoding trade data in settlement batches, enabling gas-efficient batch settlements.
Data Structure
Functions
extractOrder
Converts trade data into a full order struct while extracting the signing scheme from packed flags.extractFlags
Unpacks a singleuint256 value into separate order parameters.
Flag Encoding
The library uses a bitfield approach where individual bits represent different order properties:
The default
0x00 represents the most common case: a fill-or-kill sell order by an externally owned account using EIP-712 signatures.
Supported Signing Schemes
Gas Efficiency
The encoding reduces calldata costs by:- Using token indices instead of full addresses
- Packing multiple values into single storage slots
- Optimizing for zero bytes in calldata (cheaper on Ethereum)