@interlay/interbtc-api / Exports / StableLiquidityPool
LiquidityPoolCalculator
<StableLpToken
>
↳ StableLiquidityPool
• new StableLiquidityPool(type
, lpToken
, actuallyPooledCurrencies
, pooledCurrencies
, rewardAmountsYearly
, tradingFee
, poolId
, amplificationCoefficient
, totalSupply
, isEmpty
): StableLiquidityPool
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 |
LiquidityPoolCalculator\<StableLpToken\>.constructor
src/parachain/amm/liquidity-pool/stable.ts:10
• actuallyPooledCurrencies: PooledCurrencies
src/parachain/amm/liquidity-pool/stable.ts:14
• amplificationCoefficient: Big
src/parachain/amm/liquidity-pool/stable.ts:20
• isEmpty: boolean
src/parachain/amm/liquidity-pool/stable.ts:22
• lpToken: StableLpToken
src/parachain/amm/liquidity-pool/stable.ts:12
• poolId: number
src/parachain/amm/liquidity-pool/stable.ts:19
• pooledCurrencies: PooledCurrencies
LiquidityPoolBase.pooledCurrencies
LiquidityPoolCalculator.pooledCurrencies
src/parachain/amm/liquidity-pool/stable.ts:16
• rewardAmountsYearly: MonetaryAmount
<CurrencyExt
>[]
LiquidityPoolBase.rewardAmountsYearly
src/parachain/amm/liquidity-pool/stable.ts:17
• totalSupply: MonetaryAmount
<StableLpToken
>
LiquidityPoolCalculator.totalSupply
src/parachain/amm/liquidity-pool/stable.ts:21
• tradingFee: Big
src/parachain/amm/liquidity-pool/stable.ts:18
• type: STABLE_PLAIN
| STABLE_META
src/parachain/amm/liquidity-pool/stable.ts:11
• get
_feePerToken(): Big
Big
src/parachain/amm/liquidity-pool/stable.ts:35
• get
xp(): Big
[]
Big
[]
src/parachain/amm/liquidity-pool/stable.ts:194
▸ _distance(x
, y
): Big
Name | Type |
---|---|
x |
Big |
y |
Big |
Big
src/parachain/amm/liquidity-pool/stable.ts:31
▸ _getD(amountsInBaseDenomination
, amp
): Big
Name | Type |
---|---|
amountsInBaseDenomination |
Big [] |
amp |
Big |
Big
src/parachain/amm/liquidity-pool/stable.ts:41
▸ _getY(inIndex
, outIndex
, inBalance
, normalizedBalances
): Big
Name | Type |
---|---|
inIndex |
number |
outIndex |
number |
inBalance |
Big |
normalizedBalances |
Big [] |
Big
src/parachain/amm/liquidity-pool/stable.ts:74
▸ _getYD(A
, index
, xp
, D
): Big
Name | Type |
---|---|
A |
Big |
index |
number |
xp |
Big [] |
D |
Big |
Big
src/parachain/amm/liquidity-pool/stable.ts:115
▸ _sortAmounts(amounts
): MonetaryAmount
<CurrencyExt
>[]
Sort amounts in same order as actuallyPooledCurrencies
.
Name | Type | Description |
---|---|---|
amounts |
MonetaryAmount <CurrencyExt >[] |
Array of monetary |
MonetaryAmount
<CurrencyExt
>[]
Amounts containing currency amounts at the same index as this.actuallyPooledCurrencies
Throws
When currencies of amounts
differ from actuallyPooledCurrencies
src/parachain/amm/liquidity-pool/stable.ts:156
▸ _xp(amounts
): Big
[]
Name | Type |
---|---|
amounts |
MonetaryAmount <CurrencyExt >[] |
Big
[]
src/parachain/amm/liquidity-pool/stable.ts:27
▸ calculateRemoveLiquidityOneToken(tokenLPAmount
, outputCurrencyIndex
): [MonetaryAmount
<CurrencyExt
>, MonetaryAmount
<CurrencyExt
>]
Name | Type |
---|---|
tokenLPAmount |
MonetaryAmount <StableLpToken > |
outputCurrencyIndex |
number |
[MonetaryAmount
<CurrencyExt
>, MonetaryAmount
<CurrencyExt
>]
src/parachain/amm/liquidity-pool/stable.ts:223
▸ calculateSwap(inputIndex
, outputIndex
, inputAmount
): MonetaryAmount
<CurrencyExt
>
Name | Type |
---|---|
inputIndex |
number |
outputIndex |
number |
inputAmount |
MonetaryAmount <CurrencyExt > |
MonetaryAmount
<CurrencyExt
>
src/parachain/amm/liquidity-pool/stable.ts:263
▸ calculateTokenAmount(amounts
, deposit
): MonetaryAmount
<StableLpToken
>
Name | Type | Description |
---|---|---|
amounts |
PooledCurrencies |
Array of monetary amount for each pooled currency of this pool. |
deposit |
boolean |
True for deposit, false for withdrawal |
MonetaryAmount
<StableLpToken
>
LP token amount that will be minted/burned after operation.
src/parachain/amm/liquidity-pool/stable.ts:204
▸ getLiquidityDepositInputAmounts(amount
): MonetaryAmount
<CurrencyExt
>[]
Calculates how much of pooled currencies needs to be deposited into pool with current ratio of currencies.
Name | Type | Description |
---|---|---|
amount |
MonetaryAmount <CurrencyExt > |
Amount of one of the pooled currencies. |
MonetaryAmount
<CurrencyExt
>[]
Monetary amounts of all pooled currencies in balanced proportion.
Throws
If pool is empty. Note: handle by checking isEmpty
property of pool.
LiquidityPoolCalculator.getLiquidityDepositInputAmounts
src/parachain/amm/liquidity-pool/calculator.ts:29
▸ getLiquidityDepositLpTokenAmount(amount
): MonetaryAmount
<StableLpToken
>
Calculates expected amount of LP token account will get after depositing
amount
of pooled currency into pool.
Name | Type | Description |
---|---|---|
amount |
MonetaryAmount <CurrencyExt > |
Amount of one of the pooled currencies. |
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.
LiquidityPoolCalculator.getLiquidityDepositLpTokenAmount
src/parachain/amm/liquidity-pool/calculator.ts:47
▸ getLiquidityWithdrawalPooledCurrencyAmounts(amount
): MonetaryAmount
<CurrencyExt
>[]
Calculates expected amount of pooled currencies account will get
after withdrawing amount
of LP token.
Name | Type | Description |
---|---|---|
amount |
MonetaryAmount <StableLpToken > |
Amount of liquidity in LP token to be withdrawn. |
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.
LiquidityPoolCalculator.getLiquidityWithdrawalPooledCurrencyAmounts
src/parachain/amm/liquidity-pool/calculator.ts:64
▸ getTokenIndex(currency
): number
Name | Type |
---|---|
currency |
CurrencyExt |
number
src/parachain/amm/liquidity-pool/stable.ts:188
▸ involvesToken(currency
): boolean
Name | Type |
---|---|
currency |
CurrencyExt |
boolean