@@ -65,122 +65,27 @@ import {LibBytes32Array} from "rain-solmem-0.1.28/src/lib/LibBytes32Array.sol";
6565import {LibBytes32Matrix} from "rain-solmem-0.1.28/src/lib/LibBytes32Matrix.sol " ;
6666
6767import {LibFormatDecimalFloat} from "rain-math-float-0.3.10/src/lib/format/LibFormatDecimalFloat.sol " ;
68-
69- /// This will exist in a future version of Open Zeppelin if their main branch is
70- /// to be believed.
71- error ReentrancyGuardReentrantCall ();
72-
73- /// Thrown when the `msg.sender` modifying an order is not its owner.
74- /// @param owner The owner of the order.
75- error NotOrderOwner (address owner );
76-
77- /// Thrown when the input and output tokens don't match, in either direction.
78- error TokenMismatch ();
79-
80- /// Thrown when the minimum input is not met.
81- /// @param minimumIO The minimum io required.
82- /// @param actualIO The io that was achieved.
83- error MinimumIO (Float minimumIO , Float actualIO );
84-
85- /// Thrown when two orders have the same owner during clear.
86- error SameOwner ();
87-
88- /// Thrown when calculate order expression offers too few outputs.
89- /// @param outputs The outputs the expression offers.
90- error UnsupportedCalculateOutputs (uint256 outputs );
91-
92- /// Thrown when a negative vault balance is being recorded.
93- /// @param vaultBalance The negative vault balance being recorded.
94- error NegativeVaultBalance (Float vaultBalance );
95-
96- /// Thrown when a negative amount is being applied to a vault balance.
97- /// @param amount The negative amount being applied.
98- error NegativeVaultBalanceChange (Float amount );
99-
100- /// Thrown when a negative pull is attempted.
101- error NegativePull ();
102-
103- /// Thrown when a negative push is attempted.
104- error NegativePush ();
105-
106- /// Throws when a negative bounty is calculated.
107- error NegativeBounty ();
108-
109- /// Thrown when clear output amounts are both zero.
110- error ClearZeroAmount ();
111-
112- /// @dev Stored value for a live order. NOT a boolean because storing a boolean
113- /// is more expensive than storing a uint256.
114- uint256 constant ORDER_LIVE = 1 ;
115-
116- /// @dev Stored value for a dead order. `0` is chosen because it is the default
117- /// value for a mapping, which means all orders are dead unless explicitly made
118- /// live.
119- uint256 constant ORDER_DEAD = 0 ;
120-
121- /// @dev Entrypoint to a calculate the amount and ratio of an order.
122- SourceIndexV2 constant CALCULATE_ORDER_ENTRYPOINT = SourceIndexV2.wrap (0 );
123- /// @dev Entrypoint to handle the final internal vault movements resulting from
124- /// matching multiple calculated orders.
125- SourceIndexV2 constant HANDLE_IO_ENTRYPOINT = SourceIndexV2.wrap (1 );
126-
127- /// @dev Minimum outputs for calculate order are the amount and ratio.
128- uint256 constant CALCULATE_ORDER_MIN_OUTPUTS = 2 ;
129- /// @dev Maximum outputs for calculate order are the amount and ratio.
130- uint16 constant CALCULATE_ORDER_MAX_OUTPUTS = 2 ;
131-
132- /// @dev Handle IO has no outputs as it only responds to vault movements.
133- uint256 constant HANDLE_IO_MIN_OUTPUTS = 0 ;
134- /// @dev Handle IO has no outputs as it only responds to vault movements.
135- uint16 constant HANDLE_IO_MAX_OUTPUTS = 0 ;
136-
137- /// All information resulting from an order calculation that allows for vault IO
138- /// to be calculated and applied, then the handle IO entrypoint to be dispatched.
139- /// @param outputMax The maximum output calculated by the order expression as a
140- /// Float. WILL BE RESCALED ACCORDING TO TOKEN DECIMALS (read via TOFU) for the
141- /// purpose of calculating actual vault movements.
142- /// The output max is CAPPED AT THE OUTPUT VAULT BALANCE OF THE ORDER OWNER.
143- /// The order is guaranteed that the total output of this single clearance cannot
144- /// exceed this (subject to rescaling). It is up to the order expression to track
145- /// values over time if the output max is to impose a global limit across many
146- /// transactions and counterparties.
147- /// @param IORatio The order ratio as input/output from the perspective of the
148- /// order, as a Float. As each counterparty's input is the other's output, the
149- /// IORatio calculated by each order is inverse of its counterparty. IORatio is
150- /// RESCALED ACCORDING TO TOKEN DECIMALS (read via TOFU) when applied to vault
151- /// balances. I.e. a ratio of `1` is ALWAYS "one" as ECONOMIC EQUIVALENCE
152- /// between two tokens, but this will be rescaled according to the decimals of
153- /// the token. For example, if DAI and USDT have a ratio of `1` then in reality
154- /// `1e12` DAI will move in the vault for every `1` USDT that moves, because DAI
155- /// has `1e18` decimals per $1 peg and USDT has `1e6` decimals per $1 peg.
156- /// @param context The entire 2D context array, initialized from the context
157- /// passed into the order calculations and then populated with the order
158- /// calculations and vault IO before being passed back to handle IO entrypoint.
159- /// @param namespace The `StateNamespace` to be passed to the store for calculate
160- /// IO state changes.
161- /// @param kvs KVs returned from calculate order entrypoint to pass to the store
162- /// before calling handle IO entrypoint.
163- struct OrderIOCalculationV4 {
164- OrderV4 order;
165- uint256 outputIOIndex;
166- Float outputMax;
167- //solhint-disable-next-line var-name-mixedcase
168- Float IORatio;
169- bytes32 [][] context;
170- StateNamespace namespace;
171- bytes32 [] kvs;
172- }
173-
174- /// The input and output tokens shared by every order in a `takeOrders4` batch,
175- /// and the taker IO still remaining to fill as the batch is processed.
176- /// @param inputToken The input token every order in the batch must use.
177- /// @param outputToken The output token every order in the batch must use.
178- /// @param remainingTakerIO The taker IO left to fill across the batch.
179- struct TakeOrdersIO {
180- address inputToken;
181- address outputToken;
182- Float remainingTakerIO;
183- }
68+ import {
69+ NotOrderOwner,
70+ TokenMismatch,
71+ MinimumIO,
72+ SameOwner,
73+ UnsupportedCalculateOutputs,
74+ NegativeVaultBalance,
75+ NegativeVaultBalanceChange,
76+ NegativePull,
77+ NegativePush,
78+ NegativeBounty,
79+ ClearZeroAmount
80+ } from "../../error/ErrRaindexV6.sol " ;
81+ import {ORDER_LIVE, ORDER_DEAD} from "../../constant/OrderLiveness.sol " ;
82+ import {
83+ CALCULATE_ORDER_ENTRYPOINT,
84+ HANDLE_IO_ENTRYPOINT,
85+ CALCULATE_ORDER_MIN_OUTPUTS
86+ } from "../../constant/OrderEntrypoints.sol " ;
87+ import {OrderIOCalculationV4} from "../../struct/OrderIOCalculationV4.sol " ;
88+ import {TakeOrdersIO} from "../../struct/TakeOrdersIO.sol " ;
18489
18590/// @title RaindexV6
18691/// See `IRaindexV6` for more documentation.
0 commit comments