interbtc-api

@interlay/interbtc-api / Exports / StableLiquidityPool

Class: StableLiquidityPool

Hierarchy

Implements

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new StableLiquidityPool(type, lpToken, actuallyPooledCurrencies, pooledCurrencies, rewardAmountsYearly, tradingFee, poolId, amplificationCoefficient, totalSupply, isEmpty): StableLiquidityPool

Parameters

Name Type
type STABLE_PLAIN | STABLE_META
lpToken StableLpToken
actuallyPooledCurrencies PooledCurrencies
pooledCurrencies PooledCurrencies
rewardAmountsYearly MonetaryAmount<CurrencyExt>[]
tradingFee Big
poolId number
amplificationCoefficient Big
totalSupply MonetaryAmount<StableLpToken>
isEmpty boolean

Returns

StableLiquidityPool

Overrides

LiquidityPoolCalculator\<StableLpToken\>.constructor

Defined in

src/parachain/amm/liquidity-pool/stable.ts:10

Properties

actuallyPooledCurrencies

actuallyPooledCurrencies: PooledCurrencies

Defined in

src/parachain/amm/liquidity-pool/stable.ts:14


amplificationCoefficient

amplificationCoefficient: Big

Defined in

src/parachain/amm/liquidity-pool/stable.ts:20


isEmpty

isEmpty: boolean

Implementation of

LiquidityPoolBase.isEmpty

Defined in

src/parachain/amm/liquidity-pool/stable.ts:22


lpToken

lpToken: StableLpToken

Implementation of

LiquidityPoolBase.lpToken

Defined in

src/parachain/amm/liquidity-pool/stable.ts:12


poolId

poolId: number

Defined in

src/parachain/amm/liquidity-pool/stable.ts:19


pooledCurrencies

pooledCurrencies: PooledCurrencies

Implementation of

LiquidityPoolBase.pooledCurrencies

Inherited from

LiquidityPoolCalculator.pooledCurrencies

Defined in

src/parachain/amm/liquidity-pool/stable.ts:16


rewardAmountsYearly

rewardAmountsYearly: MonetaryAmount<CurrencyExt>[]

Implementation of

LiquidityPoolBase.rewardAmountsYearly

Defined in

src/parachain/amm/liquidity-pool/stable.ts:17


totalSupply

totalSupply: MonetaryAmount<StableLpToken>

Implementation of

LiquidityPoolBase.totalSupply

Inherited from

LiquidityPoolCalculator.totalSupply

Defined in

src/parachain/amm/liquidity-pool/stable.ts:21


tradingFee

tradingFee: Big

Implementation of

LiquidityPoolBase.tradingFee

Defined in

src/parachain/amm/liquidity-pool/stable.ts:18


type

type: STABLE_PLAIN | STABLE_META

Implementation of

LiquidityPoolBase.type

Defined in

src/parachain/amm/liquidity-pool/stable.ts:11

Accessors

_feePerToken

get _feePerToken(): Big

Returns

Big

Defined in

src/parachain/amm/liquidity-pool/stable.ts:35


xp

get xp(): Big[]

Returns

Big[]

Defined in

src/parachain/amm/liquidity-pool/stable.ts:194

Methods

_distance

_distance(x, y): Big

Parameters

Name Type
x Big
y Big

Returns

Big

Defined in

src/parachain/amm/liquidity-pool/stable.ts:31


_getD

_getD(amountsInBaseDenomination, amp): Big

Parameters

Name Type
amountsInBaseDenomination Big[]
amp Big

Returns

Big

Defined in

src/parachain/amm/liquidity-pool/stable.ts:41


_getY

_getY(inIndex, outIndex, inBalance, normalizedBalances): Big

Parameters

Name Type
inIndex number
outIndex number
inBalance Big
normalizedBalances Big[]

Returns

Big

Defined in

src/parachain/amm/liquidity-pool/stable.ts:74


_getYD

_getYD(A, index, xp, D): Big

Parameters

Name Type
A Big
index number
xp Big[]
D Big

Returns

Big

Defined in

src/parachain/amm/liquidity-pool/stable.ts:115


_sortAmounts

_sortAmounts(amounts): MonetaryAmount<CurrencyExt>[]

Sort amounts in same order as actuallyPooledCurrencies.

Parameters

Name Type Description
amounts MonetaryAmount<CurrencyExt>[] Array of monetary

Returns

MonetaryAmount<CurrencyExt>[]

Amounts containing currency amounts at the same index as this.actuallyPooledCurrencies

Throws

When currencies of amounts differ from actuallyPooledCurrencies

Defined in

src/parachain/amm/liquidity-pool/stable.ts:156


_xp

_xp(amounts): Big[]

Parameters

Name Type
amounts MonetaryAmount<CurrencyExt>[]

Returns

Big[]

Defined in

src/parachain/amm/liquidity-pool/stable.ts:27


calculateRemoveLiquidityOneToken

calculateRemoveLiquidityOneToken(tokenLPAmount, outputCurrencyIndex): [MonetaryAmount<CurrencyExt>, MonetaryAmount<CurrencyExt>]

Parameters

Name Type
tokenLPAmount MonetaryAmount<StableLpToken>
outputCurrencyIndex number

Returns

[MonetaryAmount<CurrencyExt>, MonetaryAmount<CurrencyExt>]

Defined in

src/parachain/amm/liquidity-pool/stable.ts:223


calculateSwap

calculateSwap(inputIndex, outputIndex, inputAmount): MonetaryAmount<CurrencyExt>

Parameters

Name Type
inputIndex number
outputIndex number
inputAmount MonetaryAmount<CurrencyExt>

Returns

MonetaryAmount<CurrencyExt>

Defined in

src/parachain/amm/liquidity-pool/stable.ts:263


calculateTokenAmount

calculateTokenAmount(amounts, deposit): MonetaryAmount<StableLpToken>

Parameters

Name Type Description
amounts PooledCurrencies Array of monetary amount for each pooled currency of this pool.
deposit boolean True for deposit, false for withdrawal

Returns

MonetaryAmount<StableLpToken>

LP token amount that will be minted/burned after operation.

Defined in

src/parachain/amm/liquidity-pool/stable.ts:204


getLiquidityDepositInputAmounts

getLiquidityDepositInputAmounts(amount): MonetaryAmount<CurrencyExt>[]

Calculates how much of pooled currencies needs to be deposited into pool with current ratio of currencies.

Parameters

Name Type Description
amount MonetaryAmount<CurrencyExt> Amount of one of the pooled currencies.

Returns

MonetaryAmount<CurrencyExt>[]

Monetary amounts of all pooled currencies in balanced proportion.

Throws

If pool is empty. Note: handle by checking isEmpty property of pool.

Inherited from

LiquidityPoolCalculator.getLiquidityDepositInputAmounts

Defined in

src/parachain/amm/liquidity-pool/calculator.ts:29


getLiquidityDepositLpTokenAmount

getLiquidityDepositLpTokenAmount(amount): MonetaryAmount<StableLpToken>

Calculates expected amount of LP token account will get after depositing amount of pooled currency into pool.

Parameters

Name Type Description
amount MonetaryAmount<CurrencyExt> Amount of one of the pooled currencies.

Returns

MonetaryAmount<StableLpToken>

Expected amount of lp token that will be received after amount is added to pool.

Note

This method assumes all pooled currencies will be added in balance.

Throws

If pool is empty. Note: handle by checking isEmpty property of pool.

Inherited from

LiquidityPoolCalculator.getLiquidityDepositLpTokenAmount

Defined in

src/parachain/amm/liquidity-pool/calculator.ts:47


getLiquidityWithdrawalPooledCurrencyAmounts

getLiquidityWithdrawalPooledCurrencyAmounts(amount): MonetaryAmount<CurrencyExt>[]

Calculates expected amount of pooled currencies account will get after withdrawing amount of LP token.

Parameters

Name Type Description
amount MonetaryAmount<StableLpToken> Amount of liquidity in LP token to be withdrawn.

Returns

MonetaryAmount<CurrencyExt>[]

Amounts of pooled currencies to be returned to account.

Note

This method assumes all pooled currencies will be withdrawn in balance.

Throws

If pool is empty. Note: handle by checking isEmpty property of pool.

Inherited from

LiquidityPoolCalculator.getLiquidityWithdrawalPooledCurrencyAmounts

Defined in

src/parachain/amm/liquidity-pool/calculator.ts:64


getTokenIndex

getTokenIndex(currency): number

Parameters

Name Type
currency CurrencyExt

Returns

number

Defined in

src/parachain/amm/liquidity-pool/stable.ts:188


involvesToken

involvesToken(currency): boolean

Parameters

Name Type
currency CurrencyExt

Returns

boolean

Defined in

src/parachain/amm/liquidity-pool/stable.ts:182