Assessment reports>SyncSwap>Threat Models>withdrawAlternative

Function: withdrawAlternative(address token, address to, uint256 amount, uint8 mode)

Allows to withdraw assets from the vault; in case an ETH/WETH withdrawal is requested, allows to specify whether the output should be ETH or WETH.

Inputs

  • token

    • Control: Arbitrary.

    • Constraints: None.

    • Impact: Determines the asset to be transferred.

  • to

    • Control: Arbitrary.

    • Constraints: None.

    • Impact: Determines the recipient of the withdrawal.

  • amount

    • Control: Arbitrary.

    • Constraints: balances[token][msg.sender] >= amount.

    • Impact: Determines the amount to be transferred.

  • mode

    • Control: Arbitrary.

    • Constraints: None.

    • Impact: Determines the behavior of ETH/WETH transfers.

Branches and code coverage (including function calls)

Intended branches

Handles ERC20 withdrawals.

Handles ETH mode 2 withdrawals (wraps and transfers WETH).

Handles ETH mode 0/1 withdrawals (transfers ETH).

Handles WETH mode 1 (transfers ETH).

Handles WETH mode 0/2 (transfers WETH).

Negative behavior

Reverts if user balance is insufficient.

Function call analysis

External calls have the same profile of transfer.

Zellic © 2024Back to top ↑