Function: computeTradeExecution(ISettlement.Trade trade, RecoveredOrder recoveredOrder, uint256 tokenInPrice, uint256 tokenOutPrice, TransferHelper.TransferFromData inTransfer, TransferHelper.TransferData outTransfer, TransferHelper.TransferData feeTransfer)
This function is responsible for calculating the specific execution details of a single transaction. It is a crucial function in the Settlement contract's transaction-settlement process. It calculates the actual execution amount of the transaction based on the provided clearing price and verifies all transaction constraints.
Inputs
tradeControl: Full control.
Constraints: Each trade must have a valid user signature,
tokenInIndexandtokenOutIndexmust be within the range of thetokensarray,validTomust be greater than or equal toblock.timestamp,feeAmountmust be less thanamountIn, the order cannot have been filled or canceled, and the actual output amount must be greater than or equal tominAmountOut.Impact: Structure representing a trade to be executed in a settlement.
recoveredOrderControl: Generated by the internal function
recoverOrderFromTradeand not directly controlled by the outside world. However, its content comes from thetradeparameter and is indirectly affected by the solver.Constraints:
order.validTomust be greater than or equal toblock.timestamp,order.feeAmountmust be less thanorder.amountIn, the order ID value in theorderFilledAmountmap must be0, andownermust be a valid address recovered through signature verification.Impact: Recovered trade data containing the extracted order and owner information.
tokenInPriceControl: Full control.
Constraints: None.
Impact: The price of the order's sell token.
tokenOutPriceControl: Full control.
Constraints: None.
Impact: The price of the order's buy token.
inTransferControl: Full control.
Constraints: None.
Impact: Memory location for the computed executed sell-amount transfer.
outTransferControl: Full control.
Constraints: None.
Impact: Memory location for the computed executed buy-amount transfer.
feeTransferControl: Full control.
Constraints: None.
Impact: Memory location for the computed fee transfer.
Branches and code coverage
Intended branches
Negative behavior