Assessment reports>WOOFi Swap>Threat Model>_sellBase

Function: _sellBase(address baseToken, uint256 baseAmount, uint256 minQuoteAmount, address to, address rebateTo)

Allows selling base token for quote token.

Inputs

  • baseToken

    • Control: Controlled by calling function.

    • Constraints: Checked to be different than zero.

    • Impact: The base token to swap from.

  • baseAmount

    • Control: Controlled by calling function.

    • Constraints: Checked to be above the amount of baseToken that has to be swapped.

    • Impact: The amount of baseToken to swap.

  • minQuoteAmount

    • Control: Controlled by calling function.

    • Constraints: Checked to be above the amount of quoteToken that has to be received.

    • Impact: The minimum expected amount of resulting quote tokens.

  • 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 the quoteToken.

  • 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 the wooOracle.

  • Should calculate the swap fee and account for it in the unclaimedFee.

  • Update the reserves of the quote and base tokens.

  • Transfer the resulting quoteAmount worth of quoteToken to the to 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.

Zellic © 2024Back to top ↑