OrderIOCalculationV2

Git Source

All information resulting from an order calculation that allows for vault IO to be calculated and applied, then the handle IO entrypoint to be dispatched.

struct OrderIOCalculationV2 {
    OrderV2 order;
    uint256 outputIOIndex;
    Output18Amount outputMax;
    uint256 IORatio;
    uint256[][] context;
    StateNamespace namespace;
    uint256[] kvs;
}

Properties

NameTypeDescription
orderOrderV2
outputIOIndexuint256
outputMaxOutput18AmountThe UNSCALED maximum output calculated by the order expression. WILL BE RESCALED ACCORDING TO TOKEN DECIMALS to an 18 fixed point decimal number for the purpose of calculating actual vault movements. The output max is CAPPED AT THE OUTPUT VAULT BALANCE OF THE ORDER OWNER. The order is guaranteed that the total output of this single clearance cannot exceed this (subject to rescaling). It is up to the order expression to track values over time if the output max is to impose a global limit across many transactions and counterparties.
IORatiouint256The UNSCALED order ratio as input/output from the perspective of the order. As each counterparty's input is the other's output, the IORatio calculated by each order is inverse of its counterparty. IORatio is SCALED ACCORDING TO TOKEN DECIMALS to allow 18 decimal fixed point math over the vault balances. I.e. 1e18 returned from the expression is ALWAYS "one" as ECONOMIC EQUIVALENCE between two tokens, but this will be rescaled according to the decimals of the token. For example, if DAI and USDT have a ratio of 1e18 then in reality 1e12 DAI will move in the vault for every 1 USDT that moves, because DAI has 1e18 decimals per $1 peg and USDT has 1e6 decimals per $1 peg. THE ORDER DEFINES THE DECIMALS for each token, NOT the token itself, because the token MAY NOT report its decimals as per it being optional in the ERC20 specification.
contextuint256[][]The entire 2D context array, initialized from the context passed into the order calculations and then populated with the order calculations and vault IO before being passed back to handle IO entrypoint.
namespaceStateNamespaceThe StateNamespace to be passed to the store for calculate IO state changes.
kvsuint256[]KVs returned from calculate order entrypoint to pass to the store before calling handle IO entrypoint.