Inverse Bonding Curve

The Inverse Bonding Curve contract is responsible for handling mints and burns of ibAssets. The contract stores the balance of the relevant reserve assets, used for the mints and burns.

A Inverse Bonding Curve contract is deployed per ibAsset type. New Inverse Bonding Curve contracts are deployed through the IBC Factory contract.

Events

CurveInitialized

Emitted at inverse bonding curve initialization.

event CurveInitialized(
    address indexed from,
    address indexed reserveTokenAddress
    uint256 reserve,
    uint256 supply,
    uint256 initialPrice,
    uint256 parameterInvariant
);
Parameter
Type
Description

from*

address

Address of initializer

reserveTokenAddress*

address

Contract address of reserve asset

reserve

uint256

Reserve value at initialization

supply

uint256

Supply value at initialization

initialPrice

uint256

ibAsset price at initialization

parameterInvariant

uint256

Curve invariant at initialization

* = indexable

LiquidityAdded

Emitted when new liquidity has been added to the inverse bonding curve.

event LiquidityAdded(
    address indexed from, 
    address indexed recipient, 
    uint256 amountIn, 
    uint256 amountOut, 
    uint256 newParameterInvariant
); 
Parameter
Type
Description

from*

address

Address of LP

recipient*

address

Address that received minted LP tokens

amountIn

uint256

Amount of reserve assets added

amountOut

uint256

Amount of LP tokens minted

newParameterInvariant

uint256

Curve invariant after LP addition

* = indexable

LiquidityRemoved

Emitted when liquidity has been removed from the inverse bonding curve.

event LiquidityRemoved(
    address indexed from, 
    address indexed recipient, 
    uint256 amountIn, 
    uint256 reserveAmountOut, 
    uint256 inverseTokenCredit, 
    uint256 inverseTokenBurned, 
    uint256 newParameterInvariant
); 
Parameter
Type
Description

from*

address

Address of LP

recipient*

address

Address that received removed reserves

amountIn

uint256

Amount of LP tokens burnt

reserveAmountOut

uint256

Amount of reserve assets withdrawn

inverseTokenCredit

uint256

ibAsset credit of LP prior to removal

inverseTokenBurned

uint256

Amount of ibAssets burnt

newParameterInvariant

uint256

Curve invariant after LP removal

* = indexable

TokenStaked

Emitted when ibAssets are staked.

event TokenStaked(
    address indexed from, 
    address indexed recipient, 
    uint256 amount
); 
Parameter
Type
Description

from*

address

Address of staker

recipient*

address

Address to stake ibAssets to

amount

uint256

Stake amount

* = indexable

TokenUnstaked

Emitted when ibAssets are unstaked.

event TokenUnstaked(
    address indexed from, 
    address indexed recipient, 
    uint256 amount
); 
Parameter
Type
Description

from*

address

Address of unstaker

recipient*

address

Address to receive unstaked ibAssets

amount

uint256

Unstake amount

* = indexable

TokenBought

Emitted when ibAssets are bought / minted.

event TokenBought(
    address indexed from, 
    address indexed recipient, 
    uint256 amountIn, 
    uint256 amountOut
); 
Parameter
Type
Description

from*

address

Address of buyer / minter

recipient*

address

Receiver of minted ibAssets

amountIn

uint256

Reserve asset amount used in buy

amountOut

uint256

ibAsset amount minted from buy

* = indexable

TokenSold

Emitted when ibAssets are sold / burnt.

event TokenSold(
    address indexed from, 
    address indexed recipient, 
    uint256 amountIn, 
    uint256 amountOut
); 
Parameter
Type
Description

from*

address

Address of seller / burner

recipient*

address

Receiver of returned reserve assets

amountIn

uint256

ibAsset amount burnt in sell

amountOut

uint256

Reserve asset amount returned in sell

* = indexable

RewardClaimed

Emitted when accrued LP and ibAsset staking rewards are claimed.

event RewardClaimed(
    address indexed from, 
    address indexed recipient, 
    uint256 inverseTokenAmount, 
    uint256 reserveAmount
); 
Parameter
Type
Description

from*

address

Address of reward claimer

recipient*

address

Address receiving claimed rewards

inverseTokenAmount

uint256

Amount of rewards in ibAssets

reserveAmount

uint256

Amount of rewards in reserve assets

* = indexable

State-Changing Functions

addLiquidity

Adds liquidity reserves to the inverse bonding curve.

function addLiquidity(
    address recipient, 
    uint256 reserveIn, 
    uint256[2] memory priceLimits
) external whenNotPaused 
Parameter
Type
Description

recipient

address

Address to receive LP tokens

reserveIn

uint256

Amount of reserve assets provided for liquidity add

priceLimits

uint256[2]

Minimum and maximum ibAsset prices to conduct LP - reverts if ibAsset price is lower or higher than specified values

removeLiquidity

Removes liquidity reserves from the inverse bonding curve.

function removeLiquidity(
    address recipient, 
    uint256 inverseTokenIn, 
    uint256[2] memory priceLimits
) external whenNotPaused 
Parameter
Type
Description

recipient

address

Address to receive removed reserve assets

inverseTokenIn

uint256

Amount of additional ibAssets posted for LP removal

priceLimits

uint256[2]

Minimum and maximum ibAsset prices to conduct LP - reverts if ibAsset price is lower or higher than specified values

buyTokens

Buys / mints new ibAsset tokens with provided reserve assets.

function buyTokens(
    address recipient, 
    uint256 reserveIn, 
    uint256 exactAmountOut, 
    uint256[2] memory priceLimits, 
    uint256[2] memory reserveLimits
) external whenNotPaused 
Parameter
Type
Description

recipient

address

Address to receive minted ibAssets

reserveIn

uint256

Amount of reserve assets provided for minting

exactAmountOut

uint256

Exact amount ibAssets to be minted

priceLimits

uint256[2]

Minimum and maximum effective ibAsset buy prices to conduct buy - reverts if buy price is lower or higher than specified values

reserveLimits

uint256[2]

Minimum and maximum curve reserve amounts to conduct buy - reverts if the curve's reserves are lower or higher than specified values

sellTokens

Sells / burns ibAsset tokens to receive reserve assets.

function sellTokens(
    address recipient, 
    uint256 inverseTokenIn, 
    uint256[2] memory priceLimits, 
    uint256[2] memory reserveLimits
) external whenNotPaused 
Parameter
Type
Description

recipient

address

Address to receive reserve assets

inverseTokenIn

uint256

Amount of ibAssets to burn

priceLimits

uint256[2]

Minimum and maximum effective ibAsset sell prices to conduct sell - reverts if sell price is lower or higher than specified values

reserveLimits

uint256[2]

Minimum and maximum curve reserve amounts to conduct sell - reverts if the curve's reserves are lower or higher than specified values

stake

Stakes specified amount of ibAssets.

function stake(address recipient, uint256 amount) external whenNotPaused 
Parameter
Type
Description

recipient

address

Address to stake ibAssets to

amount

uint256

Amount of ibAssets to stake

unstake

Unstakes specified amount of ibAssets.

function unstake(address recipient, uint256 amount) external whenNotPaused 
Parameter
Type
Description

recipient

uint256

Address to receive unstaked ibAssets

amount

uint256

Amount of ibAssets to unstake

claimReward

Claims accrued LP and staking rewards.

function claimReward(address recipient) external whenNotPaused 
Parameter
Type
Description

recipient

address

Address to receive accrued rewards

Read-Only Functions

liquidityPositionOf

Gets the LP position data for the specified address.

function liquidityPositionOf(address account) external view returns (
    uint256 lpTokenAmount, 
    uint256 inverseTokenCredit
)
Parameter
Type
Description

account

address

Address of account to fetch LP position information

stakingBalanceOf

Gets the staked ibAsset amount for the specified address.

function stakingBalanceOf(address account) external view returns (uint256) 
Parameter
Type
Description

account

address

Address of holder to get ibAsset staking balance

inverseTokenAddress

Gets the contract address of the relevant ibAsset token contract.

function inverseTokenAddress() external view returns (address)
Parameter
Type
Description

reserveTokenAddress

Gets the contract address of the relevant reserve asset token contract.

function reserveTokenAddress() external view returns (address)
Parameter
Type
Description

curveParameters

Gets the parameter values of the inverse bonding curve.

function curveParameters() external view returns (CurveParameter memory parameters) 
Parameter
Type
Description

rewardOf

Gets the accrued reward amounts for the specified address.

function rewardOf(address recipient) external view returns (
    uint256 inverseTokenForLp, 
    uint256 inverseTokenForStaking, 
    uint256 reserveForLp, 
    uint256 reserveForStaking, 
)
Parameter
Type
Description

recipient

address

Address to check accrued rewards

rewardOfProtocol

Gets the accrued reward amounts of the protocol creator.

function rewardOfProtocol() external view returns (
    uint256 inverseTokenReward, 
    uint256 reserveReward
) 
Parameter
Type
Description

totalStaked

Gets the total staked ibAsset amount.

function totalStaked() external view returns (uint256)
Parameter
Type
Description

rewardEMAPerSecond

Gets the EMA-adjusted per-token per-second reward amounts for the specified reward type.

function blockRewardEMA(RewardType rewardType) external view returns (
    uint256 inverseTokenReward, 
    uint256 reserveReward
)
Parameter
Type
Description

rewardType

RewardType

Type of rewards to specify

rewardType

enum RewardType {
    LP, // 0
    STAKING, // 1
    PROTOCOL // 2
}
Parameter
Description

LP

Reward type is LP rewards

STAKING

Reward type is ibAsset staking rewards

PROTOCOL

Reward type is protocol creator rewards

rewardState

Gets the total reward information for the entire protocol.

function rewardState() external view returns (
    uint256[MAX_FEE_TYPE_COUNT][MAX_FEE_STATE_COUNT] memory totalReward,
    uint256[MAX_FEE_TYPE_COUNT][MAX_FEE_STATE_COUNT] memory totalPendingReward
)
Parameter
Type
Description

Last updated