Constants
ORDER_LIVE
Stored value for a live order. NOT a boolean because storing a boolean is more expensive than storing a uint256.
uint256 constant ORDER_LIVE = 1;
ORDER_DEAD
Stored value for a dead order. 0 is chosen because it is the default
value for a mapping, which means all orders are dead unless explicitly made
live.
uint256 constant ORDER_DEAD = 0;
CALCULATE_ORDER_ENTRYPOINT
Entrypoint to a calculate the amount and ratio of an order.
SourceIndexV2 constant CALCULATE_ORDER_ENTRYPOINT = SourceIndexV2.wrap(0);
HANDLE_IO_ENTRYPOINT
Entrypoint to handle the final internal vault movements resulting from matching multiple calculated orders.
SourceIndexV2 constant HANDLE_IO_ENTRYPOINT = SourceIndexV2.wrap(1);
CALCULATE_ORDER_MIN_OUTPUTS
Minimum outputs for calculate order are the amount and ratio.
uint256 constant CALCULATE_ORDER_MIN_OUTPUTS = 2;
CALCULATE_ORDER_MAX_OUTPUTS
Maximum outputs for calculate order are the amount and ratio.
uint16 constant CALCULATE_ORDER_MAX_OUTPUTS = 2;
HANDLE_IO_MIN_OUTPUTS
Handle IO has no outputs as it only responds to vault movements.
uint256 constant HANDLE_IO_MIN_OUTPUTS = 0;
HANDLE_IO_MAX_OUTPUTS
Handle IO has no outputs as it only response to vault movements.
uint16 constant HANDLE_IO_MAX_OUTPUTS = 0;
CALLING_CONTEXT_COLUMNS
Orderbook context is actually fairly complex. The calling context column is populated before calculate order, but the remaining columns are only available to handle IO as they depend on the full evaluation of calculuate order, and cross referencing against the same from the counterparty, as well as accounting limits such as current vault balances, etc. The token address and decimals for vault inputs and outputs IS available to the calculate order entrypoint, but not the final vault balances/diff.
uint256 constant CALLING_CONTEXT_COLUMNS = 4;
CONTEXT_BASE_COLUMN
Base context from LibContext.
uint256 constant CONTEXT_BASE_COLUMN = 0;
CONTEXT_CALLING_CONTEXT_COLUMN
Contextual data available to both calculate order and handle IO. The order hash, order owner and order counterparty. IMPORTANT NOTE that the typical base context of an order with the caller will often be an unrelated clearer of the order rather than the owner or counterparty.
uint256 constant CONTEXT_CALLING_CONTEXT_COLUMN = 1;
CONTEXT_CALCULATIONS_COLUMN
Calculations column contains the DECIMAL RESCALED calculations but otherwise provided as-is according to calculate order entrypoint
uint256 constant CONTEXT_CALCULATIONS_COLUMN = 2;
CONTEXT_VAULT_INPUTS_COLUMN
Vault inputs are the literal token amounts and vault balances before and after for the input token from the perspective of the order. MAY be significantly different to the calculated amount due to insufficient vault balances from either the owner or counterparty, etc.
uint256 constant CONTEXT_VAULT_INPUTS_COLUMN = 3;
CONTEXT_VAULT_OUTPUTS_COLUMN
Vault outputs are the same as vault inputs but for the output token from the perspective of the order.
uint256 constant CONTEXT_VAULT_OUTPUTS_COLUMN = 4;
CONTEXT_VAULT_IO_TOKEN
Row of the token address for vault inputs and outputs columns.
uint256 constant CONTEXT_VAULT_IO_TOKEN = 0;
CONTEXT_VAULT_IO_TOKEN_DECIMALS
Row of the token decimals for vault inputs and outputs columns.
uint256 constant CONTEXT_VAULT_IO_TOKEN_DECIMALS = 1;
CONTEXT_VAULT_IO_VAULT_ID
Row of the vault ID for vault inputs and outputs columns.
uint256 constant CONTEXT_VAULT_IO_VAULT_ID = 2;
CONTEXT_VAULT_IO_BALANCE_BEFORE
Row of the vault balance before the order was cleared for vault inputs and outputs columns.
uint256 constant CONTEXT_VAULT_IO_BALANCE_BEFORE = 3;
CONTEXT_VAULT_IO_BALANCE_DIFF
Row of the vault balance difference after the order was cleared for
vault inputs and outputs columns. The diff is ALWAYS POSITIVE as it is a
uint256 so it must be added to input balances and subtraced from output
balances.
uint256 constant CONTEXT_VAULT_IO_BALANCE_DIFF = 4;
CONTEXT_VAULT_IO_ROWS
Length of a vault IO column.
uint256 constant CONTEXT_VAULT_IO_ROWS = 5;
CALLER_META_HASH
Hash of the caller contract metadata for construction.
bytes32 constant CALLER_META_HASH = bytes32(0x4383dd3c5a557f161038940161f880963e1d4a31e8f2da771427b891956ad831);