BondingCurve

A generic FEI bonding curve

Contract

BondingCurve.sol implements IBondingCurve, OracleRef, PCVSplitter

Description

An bonding curve for purchasing FEI and routing of the purchased asset to PCV.

Post scale, the price should be $1 + b times the peg, where b is the variance buffer and the peg is reported as X per FEI. In the implementation, we use $1 - b because the peg is inverted so the price relationship is also inverted.

Allocation

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 500 FEI 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💰

Events

Purchase
Allocate
ScaleUpdate
BufferUpdate
IncentiveAmountUpdate
Purchase

Purchase of FEI on bonding curve

type

param

description

address indexed

_to

recipient of FEI

uint256

_amountIn

amount of purchase asset

uint256

_amountOut

amount of FEI

Allocate

Allocate held PCV

type

param

description

address indexed

_caller

the sender of the allocation transaction

uint256

_amount

the amount of PCV allocated

ScaleUpdate

Governance change of Scale target

type

param

description

uint256

_scale

new Scale target

BufferUpdate

Governance change of Buffer

type

param

description

uint256

_buffer

new buffer

IncentiveAmountUpdate

Changes the FEI reward for calling allocate()

type

param

description

uint256

_incentiveAmount

new incentive amount

Read-Only Functions

getCurrentPrice

function getCurrentPrice() external view returns (Decimal.D256 memory);

Returns current instantaneous bonding curve price. The price reported as FEI 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 check

getAverageUSDPrice

function 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 FEI.

Can be inaccurate if outdated, need to call oracle().isOutdated() to check

getAmountOut

function getAmountOut(uint256 amountIn)
external
view
returns (uint256 amountOut);

Returns the amount amountOutof FEI received for a purchase of amountIn ETH.

Can be inaccurate if outdated, need to call oracle().isOutdated() to check

scale

function scale() external view returns (uint256);

The target totalPurchased after which the bonding curve price switches to a fixed premium on the peg.

atScale

function atScale() external view returns (bool);

Returns true when totalPurchased() is greater than scale()

buffer

function buffer() external view returns (uint256);

The multiplier applied to the peg price when post-Scale.

BUFFER_GRANULARITY

function BUFFER_GRANULARITY() external view returns (uint256);

The granularity of the buffer. Constant at 10,000.

totalPurchased

function totalPurchased() external view returns (uint256);

Returns the cumulative amount of FEI issued via the bonding curve. Used in the bonding curve formula as the supply amount.

getTotalPCVHeld

function getTotalPCVHeld() external view returns (uint256);

Returns the amount of PCV held in the contract and ready for allocation.

incentiveAmount

function incentiveAmount() external view returns (uint256);

Returns the amount of FEI sent to the keeper who calls allocate() while the incentive is active.

Public State-Changing Functions

purchase

function purchase(address to, uint256 amountIn)
external
payable
returns (uint256 amountOut);

Purchase amountOut FEI along the bonding curve for amountIn ETH and send the FEI to address to.

emits Purchase

This method is pausable

EOA-Only 👤 State-Changing Functions

allocate

function allocate() external;

Allocate the PCV held by the bonding curve to the weighted PCV allocations returned by getAllocation().

emits Allocate

This method is pausable

Governor-Only⚖️ State-Changing Functions

setBuffer

function setBuffer(uint256 _buffer) external;

Sets the buffer to _buffer. Must be less than BUFFER_GRANULARITY

emits BufferUpdate

setScale

function setScale(uint256 _scale) external;

Sets the Scale target to _scale

emits ScaleUpdate

setIncentiveAmount

function setIncentiveAmount(uint256 _incentiveAmount) external;

Sets the incentiveAmount to _incentiveAmount

emits IncentiveAmountUpdate

setIncentiveFrequency

function setIncentiveFrequency(uint256 _frequency) external;

Sets the Timed duration to _frequency

emits DurationUpdate

setAllocation

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.

ABIs