The curve contract enables users to be able to mint and burn BZZ Tokens with the selected collateral currency (DAI).
The full interface of publicly callable functions for the Token contract can be found here.
The curve contract inherits ownable
and I_Curve
. For more information around the ownable
risks, see admin permissions and risks: Ownable.
Below is a function by function breakdown of the curve contract.
Below is a function by function breakdown of the view
(non state changing) curve functions.
Purpose: The buyPrice
function allows a user to check how much it will cost them in the collateral token (DAI) to buy the desired amount of the bonded token (BZZ).
Parameters:
- The
_amount
of bonded tokens (BZZ) the user would like to buy.
Returns:
- The
collateralRequired
in the collateral token (DAI) to buy the desired amount of bonded tokens.
Possible Exceptions:
- If the curve has not been initialised the function will revert with
"Curve inactive"
.
Purpose: The sellReward
function allows a user to check how much they can get in collateral tokens (DAI) for selling the desired amount of bonded tokens (BZZ).
Parameters:
- The
_amount
of bonded tokens (BZZ) the user would like to sell.
Returns:
- The
collateralReward
in collateral token (DAI) the user would receive for selling the specified amount of bonded tokens (BZZ).
Possible Exceptions:
- If the curve has not been initialised the function will revert with
"Curve inactive"
.
Purpose: Allows a user to check that the curve contract has been initialised and has not been shut down.
Parameters:
- N/A
Returns:
- Will return
true
if the curve is initialised and active. Will returnfalse
if the curve has not been initialised or if the curve has been shut down.
Possible Exceptions:
- N/A
Purpose: Allows a user to check how much collateral token (DAI) would be needed to initialise the curve given the _initialSupply
passed in. This allows a user to know how many collateral tokens to approve the curve as a spender on in order to initialise the contract.
Parameters:
- The
_initialSupply
expected.
Returns:
- The amount of collateral tokens needed in order to back fill the curve for all the minted tokens.
Possible Exceptions:
- N/A. Note that this function will not revert if the
_initialSupply
is less than the required pre-mint amount.
Purpose: Allows a user to check the address of the bonded token (BZZ).
Parameters:
- N/A
Returns:
- The address of the bonded token.
Possible Exceptions:
- N/A
Purpose: Allows a user to check the address off the collateral token (DAI).
Parameters:
- N/A
Returns:
- The address of the collateral token.
Possible Exceptions:
- N/A
Below is a function by function breakdown of the state modifying curve functions.
This function will initialise the curve so that it can start functioning as the bonded curve to the bonded token. This function requires the caller to have approved the curve for the required collateral amount (this can be checked by calling requiredCollateral
). The user will also need to have the same required amount of collateral token in their wallet.
Purpose: Allows a user to initialise the curve contract, and back fill the collateral token need for the pre-mint amount.
Parameters:
- N/A
Returns:
- N/A
Possible Exceptions:
- If the curve has already been initialised the revert message will be
"Curve is init"
. - If the curve has not been given
minterRole
permissions on the bonded token the revert message will be"Curve is not minter"
. - If the bonded tokens supply is less than the expected pre-mint amount the revert message will be
"Curve equation requires pre-mint"
. - If the calling address has not both approved and has the required collateral to back fill the curve in collateral tokens for the pre-mint amount the revert message will be
"Failed to collateralized the curve"
.
Purpose: Allows the user to mint bonded tokens in exchange for the collateral token cost.
Parameters:
- The
_amount
of bonded tokens the user wants to buy. - The
_maxCollateralSpend
is the max amount of collateral tokens the user wants to spend in order to buy the desired amount of bonded tokens.
Returns:
- The
success
state of the mint. Iftrue
the mint executed successfully.
Events:
// Emitted when tokens are minted
event mintTokens(
address indexed buyer, // The address of the buyer
uint256 amount, // The amount of bonded tokens to mint
uint256 pricePaid, // The price in collateral tokens
uint256 maxSpend // The max amount of collateral to spend
);
Possible Exceptions:
- If the cost to buy the
_amount
of bonded tokens is higher than the users_maxCollateralSpend
amount, the revert message will be"Price exceeds max spend"
. - If the user has not approved the curve as a spender of the required amount of collateral the revert message will be
"Transferring collateral failed"
. - If the bonded token mint fails the revert message will be
"Minting tokens failed"
. Note that should this revert message be received there is a fatal flaw. This message should not be received.
Purpose: Allows the user to sell bonded tokens in exchange for the collateral token reward.
Parameters:
- The
_amount
of tokens the user would like to sell. - The
_minCollateralReward
is the minimum amount of collateral the user is willing to receive in exchange for their bonded tokens.
Returns:
- The
success
state of the burn. Iftrue
the burn executed successfully.
Events:
// Emitted when tokens are burnt
event burnTokens(
address indexed seller, // The address of the seller
uint256 amount, // The amount of bonded tokens to sell
uint256 rewardReceived, // The collateral tokens received
uint256 minReward // The min collateral reward for tokens
);
Possible Exceptions:
- If the reward for selling the
_amount
of bonded tokens is lower than the_minCollateralReward
the revert message will be"Reward under min sell"
. - If the curve fails to send the user the required amount of collateral tokens the revert message will be
"Transferring collateral failed"
. Note that should this revert message be received there is a fatal flaw. This message should not be received.
Purpose: Allows the owner to shut down the curve, so that the bonding curve can no longer mint or burn user tokens.
Parameters:
- N/A
Returns:
- N/A
Events:
// Emitted when the curve is permanently shut down
event shutDownOccurred(address indexed owner);
Possible Exceptions:
- Should the curve already be removed as a
minterRole
from the token the revert message will be"Roles: account does not have role"
. Note that should this revert message be received there is a fatal flaw. This message should not be received.