Last updated
Last updated
Inherits: IFM_BC_Bancor_Redeeming_VirtualSupply_v1, IFundingManager_v1, VirtualIssuanceSupplyBase_v1, VirtualCollateralSupplyBase_v1, RedeemingBondingCurveBase_v1
Author: Inverter Network
This contract enables the issuance and redeeming of tokens on a bonding curve, using a virtual supply for both the issuance and the collateral as input. It integrates Aragon's {BancorFormula} to manage the calculations for token issuance and redemption rates based on specified reserve ratios.
Inherits {BondingCurveBase_v1}, {RedeemingBondingCurveBase_v1}, {VirtualIssuanceSupplyBase_v1}, and {VirtualCollateralSupplyBase_v1}. Implements formulaWrapper functions for bonding curve calculations using the {BancorFormula}. {Orchestrator_v1} Admin manages configuration such as virtual supplies and reserve ratios. Ensure interaction adheres to defined transactional limits and decimal precision requirements to prevent computational overflows or underflows.
The interface of the Bancor Formula used to calculate the issuance and redeeming amount.
Value is used to convert deposit amount to 18 decimals, which is required by the {BancorFormula}. which is required by the Bancor formula.
Parts per million used for calculation the reserve ratio for the Bancor formula.
The reserve ratio for buying determines the rate of price growth. It is a measure of the fraction of the Token's value that is held in reserve. The value is a number between 0 and 100%, expressed in PPM. A higher reserve ratio means slower price growth. See Bancor Formula contract for reference.
The reserve ratio for selling determines the rate of price growth. It is a measure of the fraction of the Token's value that is held in reserve. The value is a number between 0 and 100%, expressed in PPM. A higher reserve ratio means slower price growth. See Bancor Formula contract for reference.
Token that is accepted by this funding manager for deposits.
Token decimals of the Orchestrator token, which is used as collateral and stores within implementation for gas saving.
Token decimals of the issuance token, which is stored within the implementation for gas saving.
Storage gap for future upgrades.
See {IERC165-supportsInterface}.
Modifier to guarantee the buying and selling functionalities are closed.
Buy tokens on behalf of a specified receiver address. This function is subject to a transactional limit, determined by the deposit token's decimal precision and the underlying bonding curve algorithm.
Redirects to the internal function _buyOrder
by passing the receiver address and deposit amount. Important: The {BancorFormula} has an upper computational limit of (10^38). For tokens with 18 decimal places, this effectively leaves a maximum allowable deposit amount of (10^20). While this is substantially large, it is crucial to be aware of this constraint. Transactions exceeding this limit will be reverted.
Parameters
Buy tokens for the sender's address. This function is subject to a transactional limit, determined by the deposit token's decimal precision and the underlying bonding curve algorithm.
Redirects to the internal function _buyOrder
by passing the sender's address and deposit amount. Important: The {BancorFormula} has an upper computational limit of (10^38). While this is substantially large, it is crucial to be aware of this constraint. Transactions exceeding this limit will be reverted.
Parameters
Redeem tokens and direct the proceeds to a specified receiver address. This function is subject to a transactional limit, determined by the issuing token's decimal precision and the underlying bonding curve algorithm.
Redirects to the internal function _sellOrder
by passing the receiver address and deposit amount. Important: The {BancorFormula} has an upper computational limit of (10^26). For tokens with 18 decimal places, this effectively leaves a maximum allowable deposit amount of (10^8), or 100,000,000. Transactions exceeding this limit will be reverted.
Parameters
Redeem collateral for the sender's address. This function is subject to a transactional limit, determined by the issuing token's decimal precision and the underlying bonding curve algorithm.
Redirects to the internal function _sellOrder
by passing the sender's address and deposit amount. Important: The {BancorFormula} has an upper computational limit of (10^26). For tokens with 18 decimal places, this effectively leaves a maximum allowable deposit amount of (10^8), or 100,000,000. Transactions exceeding this limit will be reverted.
Parameters
Returns reserve ratio set for buying, used in the {BancorFormula} contract.
Returns
Returns reserve ratio set for selling, used in the {BancorFormula} contract.
Returns
Calculates and returns the static price for buying the issuance token. The return value is formatted in PPM.
Calculates the static price for either selling or buying the issuance token, based on the provided issuance token supply, collateral supply, and buy or sell reserve ratio. Note: The reserve ratio specifies whether the sell or buy price is returned. The formula used is: PPM * PPM * collateralSupply / (issuanceTokenSupply * reserveRatio). The formula is based on Aragon's BatchedBancorMarketMaker, which can be found here: https://github.com/AragonBlack/fundraising/blob/5ad1332955bab9d36cfad345ae92b7ad7dc0bdbe/apps/batched-bancor-market-maker/contracts/BatchedBancorMarketMaker.sol#L415
Returns
Calculates and returns the static price for selling the issuance token. The return value is formatted in PPM.
Returns
Returns the token.
Returns
Transfer a specified amount of Tokens to a designated receiver address.
This function MUST be restricted to be called only by the {Orchestrator_v1}.
Parameters
Sets the virtual issuance supply to a new value.
This function calls the internal function _setVirtualIssuanceSupply
. The function must be implemented by the downstream contract. The downstream contract should manage access control for setting the supply.
Parameters
Sets the virtual collateral supply to a new value.
This function should call the internal function _setVirtualCollateralSupply
. The function must be implemented by the downstream contract. The downstream contract should manage access control for setting the supply.
Parameters
Set the reserve ratio used for issuing tokens on a bonding curve.
This function can only be called by the {Orchestrator_v1} admin.
Parameters
Set the reserve ratio used for redeeming tokens on a bonding curve.
This function can only be called by the {Orchestrator_v1} admin.
Parameters
Calculates the amount of tokens to mint for a given deposit amount using the {BancorFormula}. This internal function is an override of {BondingCurveBase_v1}'s abstract function. It handles decimal conversions and calculations through the bonding curve.
Parameters
Returns
Calculates the amount of collateral to be received when redeeming a given amount of tokens. This internal function is an override of {RedeemingBondingCurveBase_v1}'s abstract function. It handles decimal conversions and calculations through the bonding curve. Note the {BancorFormula} assumes 18 decimals for all tokens.
Parameters
Returns
Sets the issuance token for the Bonding Curve Funding Manager. This function overrides the internal function set in {BondingCurveBase_v1}, adding an input validation specific for the {BancorFormula} utilizing implementation, after which it updates the issuanceToken
state variable and caches the decimals as issuanceTokenDecimals
.
Parameters
Internal function to directly set the virtual collateral supply to a new value.
Parameters
Internal function to directly set the virtual issuance supply to a new value. Virtual supply cannot be zero, or result in rounded down being zero when conversion is done for use in the Bancor Formulat.
Parameters
Sets the reserve ratio for buying tokens. The function will revert if the ratio is greater than the constant PPM.
Parameters
Sets the reserve ratio for selling tokens. Similar to its counterpart for buying, this function sets the reserve ratio for selling tokens. The function will revert if the ratio is greater than the constant PPM.
Parameters
Validates the reserve ratio for buying and selling. The function will revert if the ratio is greater than the constant PPM.
Parameters
Checks if the buy and sell functionality is closed.
Handles incoming collateral tokens by transferring them from the provider.
Parameters
Handles issuance tokens by minting them to the receiver.
Parameters
Handles collateral tokens by transferring them to the receiver.
Parameters