Skip to main content

LinearVRGDALib

Git Source

Authors: Brendan Asselstine [email protected], Original authors FrankieIsLost [email protected] and transmissions11 [email protected]

Sell tokens roughly according to an issuance schedule.

Functions

getDecayConstant

Computes the decay constant using the priceDeltaScale

function getDecayConstant(UD2x18 _priceDeltaScale) internal pure returns (SD59x18);

Parameters

NameTypeDescription
_priceDeltaScaleUD2x18The price change per time unit

Returns

NameTypeDescription
<none>SD59x18The decay constant

getPerTimeUnit

Gets the desired number of claims to be sold per second

function getPerTimeUnit(uint256 _count, uint256 _durationSeconds) internal pure returns (SD59x18);

Parameters

NameTypeDescription
_countuint256The total number of claims
_durationSecondsuint256The duration over which claiming should occur

Returns

NameTypeDescription
<none>SD59x18The target number of claims per second

getVRGDAPrice

Calculate the price of a token according to the VRGDA formula

This function has some cases where some calculations might overflow. If an overflow will occur and the calculation would have resulted in a high price, then the max uint256 value is returned. If an overflow would happen where a low price would be returned, then zero is returned.

function getVRGDAPrice(
uint256 _targetPrice,
uint256 _timeSinceStart,
uint256 _sold,
SD59x18 _perTimeUnit,
SD59x18 _decayConstant
) internal pure returns (uint256);

Parameters

NameTypeDescription
_targetPriceuint256The target price of sale scaled by 1e18
_timeSinceStartuint256Time passed since the VRGDA began, scaled by 1e18
_solduint256The total number of tokens that have been sold so far
_perTimeUnitSD59x18The target number of claims to sell per second
_decayConstantSD59x18The decay constant for the VRGDA formula

Returns

NameTypeDescription
<none>uint256The price of a token according to VRGDA, scaled by 1e18

getMaximumPriceDeltaScale

Computes the fee delta so that the min fee will reach the max fee in the given time

function getMaximumPriceDeltaScale(uint256 _minFee, uint256 _maxFee, uint256 _time) internal pure returns (UD2x18);

Parameters

NameTypeDescription
_minFeeuint256The fee at the start
_maxFeeuint256The fee after the time has elapsed
_timeuint256The elapsed time to reach _maxFee

Returns

NameTypeDescription
<none>UD2x18The price delta scale that will ensure the _minFee grows to the _maxFee in _time