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
tokenTypeControl: From the
redeemfunction.Constraints: Bond or leverage token.
Impact: Type of token to redeem.
depositAmountControl: From the
redeemfunction.Constraints: None.
Impact: The amount of derivative tokens to redeem.
minAmountControl: From the
redeemfunction.Constraints: None.
Impact: The minimum amount of reserve tokens to receive.
onBehalfOfControl: From the
redeemfunction.Constraints: None.
Impact: Address to receive the reserve tokens.
Branches and code coverage
Intended branches
Invoke the
simulateRedeemfunction.Check the return value of the
simulateRedeemfunction 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.