ExpTokenBasedFormula
This contract provides functions for calculating the purchase and sale return values on an exponential token-based curve using a scaling factor. The formula converts a desired token amount into a reserve token cost and the sale of a token amount into a reserve token return.
State Variables
MAX_SCALE
Max reserve ratio in basis points
WAD
Wei as decimal precision for calculations
Functions
_calculateExpTokenBasedPurchaseCost
Returns the purchase cost for a given conversion (in the reserve token) for a desired amount (in the main token).
Parameters
supply
uint256
token total supply
initialCost
uint256
initial cost of the token
scalingFactor
uint32
scaling factor, represented in basis points, 1-10000
amount
uint256
amount of tokens to purchase
Returns
purchaseCost
uint256
cost of the conversion
_calculateExpTokenBasedSaleReturn
Returns the sale value for a given amount (in the main token) as a conversion into the reserve token.
Parameters
supply
uint256
token total supply
initialCost
uint256
initial cost of the token
scalingFactor
uint32
scaling factor, represented in basis points, 1-10000
amount
uint256
amount of tokens to sell
Returns
saleReturn
uint256
return of the conversion