Function: _sellQuote(address baseToken, uint256 quoteAmount, uint256 minBaseAmount, address to, address rebateTo)
Allows swapping from quoteToken
to baseToken
.
Inputs
baseToken
Control: Controlled by calling function.
Constraints: Checked to be different than zero and
quoteToken
.Impact: The base token to swap from.
quoteAmount
Control: Controlled by calling function.
Constraints: Checked to be above the amount of
quoteToken
that has to be swapped.Impact: The amount of
quoteToken
to swap.
minBaseAmount
Control: Controlled by calling function.
Constraints: Checked to be above the amount of
baseToken
that has to be received.Impact: The minimum amount of
baseToken
to receive.
to
Control: Controlled by calling function.
Constraints: Checked to be different than zero.
Impact: The address to send the swapped
baseToken2
to.
rebateTo
Control: Controlled by calling function.
Constraints: None.
Impact: The address to send the rebate to.
Branches and code coverage
Intended branches
Ensure that the spread changes after the swap. Currently not enforced.
Ensure that
baseToken
is not zero or thequoteToken
.Ensure that
to
is not zero.Ensure that the current balance minus the reserve is above
quoteAmount
(i.e., that tokens have been transferred beforehand).Should post the new price of
baseToken
after the swap on thewooOracle
.Should calculate the swap fee and account for it in the
unclaimedFee
.Update the reserves of the quote and base tokens.
Transfer the resulting
baseAmount
worth ofbaseToken
to theto
address.
Negative behavior
Should not be callable when the contract is paused.
Should not reenter.
Should not allow swapping between the same tokens.
Should not allow performing the swap if no tokens have been transferred beforehand. Ensured in the
require
on balance check.Should not allow a swap if
minBaseAmount
is not met.