Function: _create(TokenType tokenType, uint256 depositAmount, uint256 minAmount, address onBehalfOf)
This function is used to create bond or leverage tokens by depositing reserve tokens. It is internal and is called by the create
function. The function calculates the amount of new tokens to create based on the current pool state and oracle price.
Inputs
tokenType
Control: From the
create
function.Constraints: Bond or leverage token.
Impact: Type of token to create.
depositAmount
Control: From the
create
function.Constraints: None.
Impact: The amount of reserve tokens to deposit.
minAmount
Control: From the
create
function.Constraints: None.
Impact: The minimum amount of output tokens to receive.
onBehalfOf
Control: From the
create
function.Constraints: None.
Impact: Address to receive the new tokens.
Branches and code coverage
Intended branches
Invoke the
simulateCreate
function.Check the return value of the
simulateCreate
function to check if the amount is higher than the minimum amount.Mint new tokens.
Transfer reserve tokens to the contract from the caller.
Negative behavior
Revert if the amount is lower than the minimum amount.
Revert if the amount is zero.