Fei Protocol
Search…
BondingCurve
A generic FEI bonding curve

Contract

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 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 held PCV
type
param
description
address indexed
_caller
the sender of the allocation transaction
uint256
_amount
the amount of PCV allocated
Governance change of Scale target
type
param
description
uint256
_scale
new Scale target
Governance change of Buffer
type
param
description
uint256
_buffer
new buffer
Changes the FEI reward for calling allocate()
type
param
description
uint256
_incentiveAmount
new incentive amount

Read-Only Functions

getCurrentPrice

1
function getCurrentPrice() external view returns (Decimal.D256 memory);
Copied!
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

1
function getAverageUSDPrice(uint256 amountIn)
2
external
3
view
4
returns (Decimal.D256 memory);
Copied!
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

1
function getAmountOut(uint256 amountIn)
2
external
3
view
4
returns (uint256 amountOut);
Copied!
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

1
function scale() external view returns (uint256);
Copied!
The target totalPurchased after which the bonding curve price switches to a fixed premium on the peg.

atScale

1
function atScale() external view returns (bool);
Copied!
Returns true when totalPurchased() is greater than scale()

buffer

1
function buffer() external view returns (uint256);
Copied!
The multiplier applied to the peg price when post-Scale.

BUFFER_GRANULARITY

1
function BUFFER_GRANULARITY() external view returns (uint256);
Copied!
The granularity of the buffer. Constant at 10,000.

totalPurchased

1
function totalPurchased() external view returns (uint256);
Copied!
Returns the cumulative amount of FEI issued via the bonding curve. Used in the bonding curve formula as the supply amount.

getTotalPCVHeld

1
function getTotalPCVHeld() external view returns (uint256);
Copied!
Returns the amount of PCV held in the contract and ready for allocation.

incentiveAmount

1
function incentiveAmount() external view returns (uint256);
Copied!
Returns the amount of FEI sent to the keeper who calls allocate() while the incentive is active.

Public State-Changing Functions

purchase

1
function purchase(address to, uint256 amountIn)
2
external
3
payable
4
returns (uint256 amountOut);
Copied!
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

1
function allocate() external;
Copied!
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

1
function setBuffer(uint256 _buffer) external;
Copied!
Sets the buffer to _buffer. Must be less than BUFFER_GRANULARITY
emits BufferUpdate

setScale

1
function setScale(uint256 _scale) external;
Copied!
Sets the Scale target to _scale
emits ScaleUpdate

setIncentiveAmount

1
function setIncentiveAmount(uint256 _incentiveAmount) external;
Copied!
Sets the incentiveAmount to _incentiveAmount
emits IncentiveAmountUpdate

setIncentiveFrequency

1
function setIncentiveFrequency(uint256 _frequency) external;
Copied!
Sets the Timed duration to _frequency
emits DurationUpdate

setAllocation

1
function setAllocation(
2
address[] calldata pcvDeposits,
3
uint256[] calldata ratios
4
) external;
Copied!
Sets the PCV allocation to pcvDeposits with weights ratios. The ratios must sum to ALLOCATION_GRANULARITY which is constant at 10,000.

ABIs

BondingCurve.json
9KB
Code
BondingCurve ABI
IBondingCurve.json
4KB
Code
BondingCurve Interface ABI
Last modified 5mo ago