Function: _redeem(TokenType tokenType, uint256 depositAmount, uint256 minAmount, address onBehalfOf)

This function is used to redeem bond or leverage tokens for reserve tokens. It is internal and is called by the redeem function. The function calculates the amount of reserve tokens to receive based on the current pool state and oracle price.

Inputs

  • tokenType

    • Control: From the redeem function.

    • Constraints: Bond or leverage token.

    • Impact: Type of token to redeem.

  • depositAmount

    • Control: From the redeem function.

    • Constraints: None.

    • Impact: The amount of derivative tokens to redeem.

  • minAmount

    • Control: From the redeem function.

    • Constraints: None.

    • Impact: The minimum amount of reserve tokens to receive.

  • onBehalfOf

    • Control: From the redeem function.

    • Constraints: None.

    • Impact: Address to receive the reserve tokens.

Branches and code coverage

Intended branches

  • Invoke the simulateRedeem function.

  • Check the return value of the simulateRedeem function to check if the amount is higher than the minimum amount.

  • Burn derivative tokens.

  • Transfer reserve tokens to the recipient.

Negative behavior

  • Revert if the amount is lower than the minimum amount.

  • Revert if the amount is zero.

Zellic © 2025Back to top ↑