Comment on page
BondingCurve
A generic RUSD bonding curve
An abstract bonding curve for purchasing RUSD and routing of the purchased asset to PCV.
The amount of PCV it takes in a purchase transaction to bring the curve to a total amount of RUSD issued T is determined by integrating the price function between the current RUSD amount issued C by the bonding curve and the target amount T after the transaction.

Amount of PCV out for a purchase
The quantity T-C is the amount of RUSD received by the transaction. Since C is a known constant, we solve for T by setting the formula equal to a PCV purchase quantity Q and rearranging terms.
The price should be $1 + b times the peg, where b is the variance buffer and the peg is reported as X per RUSD. In the implementation, we use $1 - b because the peg is inverted so the price relationship is also inverted.
Incoming PCV is held temporarily to allow for batch transactions via the
allocate()
function. The PCV allocation gets split into a weighted list of PCV deposit contracts, (see PCVSplitter). While allocations can be called at any time, there is a 100 RUSD incentive for calling it after each 24 hour window. To determine eligibility for the incentive, simply call isTimeEnded()
on the contract. The time until the next incentive is available is remainingTime()
.- Minter💰
Purchase
Allocate
BufferUpdate
IncentiveAmountUpdate
Purchase of RUSD on bonding curve
type | param | description |
address indexed | _to | recipient of RUSD |
uint256 | _amountIn | amount of purchase asset |
uint256 | _amountOut | amount of RUSD |
Allocate held PCV
type | param | description |
address indexed | _caller | the sender of the allocation transaction |
uint256 | _amount | the amount of PCV allocated |
Governance change of Buffer
type | param | description |
uint256 | _buffer | new buffer |
Changes the RUSD reward for calling
allocate()
type | param | description |
uint256 | _incentiveAmount | new incentive amount |
function getCurrentPrice() external view returns (Decimal.D256 memory);
Returns current instantaneous bonding curve price. The price reported as RUSD per X, with X being the underlying asset. This is analogous to the peg reported by the oracle.
Can be inaccurate if outdated, need to call
oracle().isOutdated()
to checkfunction getAverageUSDPrice(uint256 amountIn)
external
view
returns (Decimal.D256 memory);
Returns the average price of a transaction of size
amountIn
ETH along bonding curve. The price here is reported as USD per RUSD.Can be inaccurate if outdated, need to call
oracle().isOutdated()
to checkfunction getAmountOut(uint256 amountIn)
external
view
returns (uint256 amountOut);
Returns the amount
amountOut
of RUSD received for a purchase of amountIn
ETH.Can be inaccurate if outdated, need to call
oracle().isOutdated()
to checkfunction buffer() external view returns (uint256);
The multiplier applied to the peg price.
function BUFFER_GRANULARITY() external view returns (uint256);
The granularity of the buffer. Constant at 10,000.
function totalPurchased() external view returns (uint256);
Returns the cumulative amount of RUSD issued via the bonding curve. Used in the bonding curve formula as the supply amount.
function getTotalPCVHeld() external view returns (uint256);
Returns the amount of PCV held in the contract and ready for allocation.
function incentiveAmount() external view returns (uint256);
Returns the amount of RUSD sent to the keeper who calls
allocate()
while the incentive is active.function purchase(address to, uint256 amountIn)
external
payable
returns (uint256 amountOut);
Purchase
amountOut
RUSD along the bonding curve for amountIn
ETH and send the RUSD to address to
.emits
Purchase
function allocate() external;
Allocate the PCV held by the bonding curve to the weighted PCV allocations returned by
getAllocation()
.emits
Allocate
function setBuffer(uint256 _buffer) external;
Sets the buffer to
_buffer
. Must be less than BUFFER_GRANULARITY
emits
BufferUpdate
function setIncentiveAmount(uint256 _incentiveAmount) external;
Sets the
incentiveAmount
to _incentiveAmount
emits
IncentiveAmountUpdate
function setIncentiveFrequency(uint256 _frequency) external;
emits
DurationUpdate
function setAllocation(
address[] calldata pcvDeposits,
uint256[] calldata ratios
) external;
Sets the PCV allocation to
pcvDeposits
with weights ratios
. The ratios must sum to ALLOCATION_GRANULARITY
which is constant at 10,000.bondingcurve.json
8KB
Code
BondingCurve ABI
ibondingcurve.json
3KB
Code
BondingCurve Interface ABI
Last modified 2yr ago