Function: swap(address fromToken, address toToken, uint256 fromAmount, uint256 minToAmount, address payable to, address rebateTo)
Performs a swap between two tokens.
Inputs
fromTokenControl: Fully controlled by the caller.
Constraints: None. Checked that it is ETH or not.
Impact: The token to swap from.
toTokenControl: Fully controlled by the caller.
Constraints: None. Checked that it is ETH or not.
Impact: The token to swap to.
fromAmountControl: Fully controlled by the caller.
Constraints: None. Checked that it is greater than zero.
Impact: The amount of
fromTokento swap.
minToAmountControl: Fully controlled by the caller.
Constraints: None. Checked that it is greater than zero.
Impact: The minimum amount of
toTokento receive.
toControl: 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.
rebateToControl: 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
fromTokenis not the zero address.Ensure
toTokenis not the zero address.Ensure
tois not the zero address.If
fromTokenis ETH, we assume the deposit is native; thus,msg.valueshould be greater than or equal tofromAmount. Deposit toWETHand transfer towooPool.If
fromTokenis not ETH, transferfromAmountfrom the sender to thewooPool.
Negative behavior
Should not reenter.