Function: _swapBaseToBase(address baseToken1, address baseToken2, uint256 base1Amount, uint256 minBase2Amount, address to, address rebateTo)
Allows swapping between two base tokens.
Inputs
baseToken1Control: Controlled by calling function.
Constraints: Checked to be different than zero and
quoteToken.Impact: The base token to swap from.
baseToken2Control: Controlled by calling function.
Constraints: Checked to be different than zero and
quoteToken.Impact: The base token to swap to.
base1AmountControl: Controlled by calling function.
Constraints: Checks that current balance is above that minus reserve.
Impact: The amount of
baseToken1to swap.
minBase2AmountControl: Controlled by calling function.
Constraints: Checked to be above the amount of
baseToken2that has to be received.Impact: The minimum amount of
baseToken2to receive.
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 each of the swaps. Currently not enforced.
Ensure that
baseToken1is not zero or thequoteToken.Ensure that
baseToken2is not zero or thequoteToken.Ensure that
tois not zero.Ensure that the current balance minus the reserve is above
base1Amount(i.e., that tokens have been transferred beforehand).Should post the new price of
baseToken1after the first swap on thewooOracle.Should calculate the swap fee and account for it in the
unclaimedFee.Update the reserves of the quote and base tokens.
Should post the new price of the
baseToken2after the second swap on thewooOracle.Should transfer the resulting
base2Amountworth ofbaseToken2to thetoaddress.
Negative behavior
Should not be callable when the contract is paused.
Should not re-enter.
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
minBase2Amountis not met.