Assessment reports>Carina Smart Contracts>Threat Model>computeTradeExecution

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

  • trade

    • Control: Full control.

    • Constraints: Each trade must have a valid user signature, tokenInIndex and tokenOutIndex must be within the range of the tokens array, validTo must be greater than or equal to block.timestamp, feeAmount must be less than amountIn, the order cannot have been filled or canceled, and the actual output amount must be greater than or equal to minAmountOut.

    • Impact: Structure representing a trade to be executed in a settlement.

  • recoveredOrder

    • Control: Generated by the internal function recoverOrderFromTrade and not directly controlled by the outside world. However, its content comes from the trade parameter and is indirectly affected by the solver.

    • Constraints: order.validTo must be greater than or equal to block.timestamp, order.feeAmount must be less than order.amountIn, the order ID value in the orderFilledAmount map must be 0, and owner must be a valid address recovered through signature verification.

    • Impact: Recovered trade data containing the extracted order and owner information.

  • tokenInPrice

    • Control: Full control.

    • Constraints: None.

    • Impact: The price of the order's sell token.

  • tokenOutPrice

    • Control: Full control.

    • Constraints: None.

    • Impact: The price of the order's buy token.

  • inTransfer

    • Control: Full control.

    • Constraints: None.

    • Impact: Memory location for the computed executed sell-amount transfer.

  • outTransfer

    • Control: Full control.

    • Constraints: None.

    • Impact: Memory location for the computed executed buy-amount transfer.

  • feeTransfer

    • Control: Full control.

    • Constraints: None.

    • Impact: Memory location for the computed fee transfer.

Branches and code coverage

Intended branches

Negative behavior

Zellic © 2025Back to top ↑