Assessment reports>Odos>Threat Models>swap

Function: swap(swapTokenInfo tokenInfo, byte[] pathDefinition, address executor, uint32 referralCode)

This function allows the caller to perform a swap. The exact operation to be performed is encoded in the pathDefinition, and execution is delegated to the executor address. A referral code can be specified for statistical purposes as well as for collecting fee referral codes that support that.

Inputs

  • tokenInfo

    • Control: Arbitrary.

    • Constraints: inputAmount field must be consistent with the value of the transaction.

    • Impact: Specifies the token (and amount) to be exchanged as well as the destination of the transfers.

  • pathDefinition

    • Control: Arbitrary.

    • Constraints: None.

    • Impact: Passed to the executor — determines the operation to be executed.

  • executor

    • Control: Arbitrary.

    • Constraints: None.

    • Impact: Determines the address of the executor to be invoked.

  • referralCode

    • Control: Arbitrary.

    • Constraints: None.

    • Impact: Referral code used for statistics and referral fees.

Branches and code coverage (including function calls)

Intended branches

  • Performs a swap using ETH as input.

  • Performs a swap using a token as input.

Negative behavior

  • Execution is reverted if inputAmount does not match the message value.

  • Execution reverts if inputToken == outputToken.

  • Execution reverts if the minimum output amount is zero.

  • Execution reverts if the minimum output is less than the quote output.

  • Execution reverts if the output is too low (slippage).

Function call analysis

  • rootFunction -> _swapApproval

    • What is controllable? All arguments.

    • If return value controllable, how is it used and how can it go wrong? Not used.

    • What happens if it reverts, reenters, or does other unusual control flow? Reverts are propagated upwards; reentrancy is a potential concern, but slippage checks mitigate that.

Zellic © 2024Back to top ↑