Function: _sellBase(address baseToken, uint256 baseAmount, uint256 minQuoteAmount, address to, address rebateTo)
Allows selling base token for quote token.
Inputs
baseTokenControl: Controlled by calling function.
Constraints: Checked to be different than zero.
Impact: The base token to swap from.
baseAmountControl: Controlled by calling function.
Constraints: Checked to be above the amount of
baseTokenthat has to be swapped.Impact: The amount of
baseTokento swap.
minQuoteAmountControl: Controlled by calling function.
Constraints: Checked to be above the amount of
quoteTokenthat has to be received.Impact: The minimum expected amount of resulting quote tokens.
toControl: Controlled by calling function.
Constraints: Checked to be different than zero.
Impact: The address to send the swapped
baseToken2to.
rebateToControl: 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
baseTokenis not zero or thequoteToken.Ensure that
tois 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
baseTokenafter 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
quoteAmountworth ofquoteTokento thetoaddress.
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
requireon balance check.Should not allow a swap if
minBaseAmountis not met.