Assessment reports>WOOFi Swap>Threat Model>swap

Function: swap(address fromToken, address toToken, uint256 fromAmount, uint256 minToAmount, address payable to, address rebateTo)

Performs a swap between two tokens.

Inputs

  • fromToken

    • Control: Fully controlled by the caller.

    • Constraints: None. Checked that it is ETH or not.

    • Impact: The token to swap from.

  • toToken

    • Control: Fully controlled by the caller.

    • Constraints: None. Checked that it is ETH or not.

    • Impact: The token to swap to.

  • fromAmount

    • Control: Fully controlled by the caller.

    • Constraints: None. Checked that it is greater than zero.

    • Impact: The amount of fromToken to swap.

  • minToAmount

    • Control: Fully controlled by the caller.

    • Constraints: None. Checked that it is greater than zero.

    • Impact: The minimum amount of toToken to receive.

  • to

    • Control: Fully controlled by the caller.

    • Constraints: None. Checked that it is not the zero address.

    • Impact: The destination address to send the swapped tokens to.

  • rebateTo

    • Control: Fully controlled by the caller.

    • Constraints: None.

    • Impact: The address to send the rebate to.

Branches and code coverage

Intended branches

  • Ensure that the tokens are not identical.

  • Ensure fromToken is not the zero address.

  • Ensure toToken is not the zero address.

  • Ensure to is not the zero address.

  • If fromToken is ETH, we assume the deposit is native; thus, msg.value should be greater than or equal to fromAmount. Deposit to WETH and transfer to wooPool.

  • If fromToken is not ETH, transfer fromAmount from the sender to the wooPool.

Negative behavior

  • Should not reenter.

Zellic © 2024Back to top ↑