BaseCurve
Inherits: IBaseCurve
Author: 0xIntuition
Abstract contract for a bonding curve. Defines the interface for converting assets to shares and vice versa.
This contract is designed to be inherited by other bonding curve contracts, providing a common interface for converting between assets and shares.
These curves handle the pure mathematical relationship for share price. Pool ratio adjustments (such as accomodating for the effect of fees, supply burn, airdrops, etc) are handled by the EthMultiVault instead of the curves themselves.
State Variables
name
The name of the curve
string public name;
Functions
constructor
Construct the curve with a unique name
constructor(string memory _name);
Parameters
Name | Type | Description |
---|---|---|
_name | string | Unique name for the curve |
maxShares
The maximum number of shares that this curve can handle without overflowing.
Checked by the EthMultiVault before transacting
function maxShares() external view virtual returns (uint256);
maxAssets
The maximum number of assets that this curve can handle without overflowing.
Checked by the EthMultiVault before transacting
function maxAssets() external view virtual returns (uint256);
previewDeposit
Preview how many shares would be minted for a deposit of assets
function previewDeposit(uint256 assets, uint256 totalAssets, uint256 totalShares)
external
view
virtual
returns (uint256 shares);
Parameters
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to deposit |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The number of shares that would be minted |
previewMint
Preview how many assets would be required to mint a specific amount of shares
function previewMint(uint256 shares, uint256 totalShares, uint256 totalAssets)
external
view
virtual
returns (uint256 assets);
Parameters
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to mint |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The number of assets that would be required to mint the shares |
previewWithdraw
Preview how many shares would be redeemed for a withdrawal of assets
function previewWithdraw(uint256 assets, uint256 totalAssets, uint256 totalShares)
external
view
virtual
returns (uint256 shares);
Parameters
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to withdraw |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The number of shares that would need to be redeemed |
previewRedeem
Preview how many assets would be returned for burning a specific amount of shares
function previewRedeem(uint256 shares, uint256 totalShares, uint256 totalAssets)
external
view
virtual
returns (uint256 assets);
Parameters
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to burn |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The number of assets that would be returned |
convertToShares
Convert assets to shares at a specific point on the curve
function convertToShares(uint256 assets, uint256 totalAssets, uint256 totalShares)
external
view
virtual
returns (uint256 shares);
Parameters
Name | Type | Description |
---|---|---|
assets | uint256 | Quantity of assets to convert to shares |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The number of shares equivalent to the given assets |
convertToAssets
Convert shares to assets at a specific point on the curve
function convertToAssets(uint256 shares, uint256 totalShares, uint256 totalAssets)
external
view
virtual
returns (uint256 assets);
Parameters
Name | Type | Description |
---|---|---|
shares | uint256 | Quantity of shares to convert to assets |
totalShares | uint256 | Total quantity of shares already awarded by the curve |
totalAssets | uint256 | Total quantity of assets already staked into the curve |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The number of assets equivalent to the given shares |
currentPrice
Get the current price of a share
function currentPrice(uint256 totalShares) public view virtual returns (uint256 sharePrice);
Parameters
Name | Type | Description |
---|---|---|
totalShares | uint256 | Total quantity of shares already awarded by the curve |
Returns
Name | Type | Description |
---|---|---|
sharePrice | uint256 | The current price of a share, scaled by 1e18 |