@interlay/interbtc-api / Exports / DefaultAMMAPI
• new DefaultAMMAPI(api, tokensAPI): DefaultAMMAPI
| Name | Type |
|---|---|
api |
ApiPromise |
tokensAPI |
TokensAPI |
• Private api: ApiPromise
• Private tokensAPI: TokensAPI
▸ _getClaimableFarmingRewardsByPool(accountId, lpToken): Promise<MonetaryAmount<CurrencyExt>[]>
| Name | Type |
|---|---|
accountId |
AccountId |
lpToken |
LpCurrency |
Promise<MonetaryAmount<CurrencyExt>[]>
▸ _getFarmingRewardCurrencyIds(lpTokenCurrencyId): Promise<InterbtcPrimitivesCurrencyId[]>
| Name | Type |
|---|---|
lpTokenCurrencyId |
InterbtcPrimitivesCurrencyId |
Promise<InterbtcPrimitivesCurrencyId[]>
▸ _getLiquidityDepositStablePoolParams(amounts, pool, maxSlippageComplement, deadline, recipient): ExtrinsicData
| Name | Type |
|---|---|
amounts |
PooledCurrencies |
pool |
StableLiquidityPool |
maxSlippageComplement |
number |
deadline |
number |
recipient |
AddressOrPair |
▸ _getLiquidityDepositStandardPoolParams(amounts, pool, maxSlippageComplement, deadline): ExtrinsicData
| Name | Type |
|---|---|
amounts |
PooledCurrencies |
pool |
StandardLiquidityPool |
maxSlippageComplement |
number |
deadline |
number |
▸ _getLiquidityWithdrawalStablePoolParams(amount, pool, maxSlippageComplement, recipient, deadline): ExtrinsicData
| Name | Type |
|---|---|
amount |
MonetaryAmount<StableLpToken> |
pool |
StableLiquidityPool |
maxSlippageComplement |
number |
recipient |
AddressOrPair |
deadline |
number |
▸ _getLiquidityWithdrawalStandardPoolParams(amount, pool, maxSlippageComplement, recipient, deadline): ExtrinsicData
| Name | Type |
|---|---|
amount |
MonetaryAmount<StandardLpToken> |
pool |
StandardLiquidityPool |
maxSlippageComplement |
number |
recipient |
AddressOrPair |
deadline |
number |
▸ _getPoolRewardAmountsYearly(lpTokenCurrencyId, blockTimeMs): Promise<MonetaryAmount<CurrencyExt>[]>
| Name | Type |
|---|---|
lpTokenCurrencyId |
InterbtcPrimitivesCurrencyId |
blockTimeMs |
number |
Promise<MonetaryAmount<CurrencyExt>[]>
▸ _getStableBasePooledCurrenciesAdjustedToLpTokenAmount(basePooledCurrencies, lpTokenTotalSupply, metaPoolLpTokenAmount): MonetaryAmount<CurrencyExt>[]
| Name | Type |
|---|---|
basePooledCurrencies |
PooledCurrencies |
lpTokenTotalSupply |
MonetaryAmount<StableLpToken> |
metaPoolLpTokenAmount |
MonetaryAmount<StableLpToken> |
MonetaryAmount<CurrencyExt>[]
▸ _getStableLiquidityPool(poolId, poolData, blockTimeMs, metaPoolLpTokenAmount?): Promise<null | StableLiquidityPool>
| Name | Type |
|---|---|
poolId |
number |
poolData |
DexStablePrimitivesPool |
blockTimeMs |
number |
metaPoolLpTokenAmount? |
MonetaryAmount<StableLpToken> |
Promise<null | StableLiquidityPool>
▸ _getStableLiquidityPoolData(poolId, poolData, blockTimeMs, metaPoolLpTokenAmount?): Promise<null | { actuallyPooledCurrencies: MonetaryAmount<CurrencyExt>[] ; amplificationCoefficient: Big ; lpToken: StableLpToken ; totalSupply: MonetaryAmount<StableLpToken> ; tradingFee: Big ; yearlyRewards: MonetaryAmount<CurrencyExt>[] }>
| Name | Type |
|---|---|
poolId |
number |
poolData |
DexStablePrimitivesPool |
blockTimeMs |
number |
metaPoolLpTokenAmount? |
MonetaryAmount<StableLpToken> |
Promise<null | { actuallyPooledCurrencies: MonetaryAmount<CurrencyExt>[] ; amplificationCoefficient: Big ; lpToken: StableLpToken ; totalSupply: MonetaryAmount<StableLpToken> ; tradingFee: Big ; yearlyRewards: MonetaryAmount<CurrencyExt>[] }>
▸ _getStableLpTokens(): Promise<StableLpToken[]>
Promise<StableLpToken[]>
▸ _getStableMetaPoolBasePool(poolData, pooledCurrencies, blockTimeMs): Promise<StableLiquidityPool>
| Name | Type |
|---|---|
poolData |
DexStablePrimitivesMetaPool |
pooledCurrencies |
PooledCurrencies |
blockTimeMs |
number |
Promise<StableLiquidityPool>
▸ _getStablePoolAmplificationCoefficient(poolId): Promise<Big>
| Name | Type |
|---|---|
poolId |
number |
Promise<Big>
▸ _getStablePoolPooledCurrencies(currencyIds, balances): Promise<MonetaryAmount<CurrencyExt>[]>
| Name | Type |
|---|---|
currencyIds |
InterbtcPrimitivesCurrencyId[] |
balances |
u128[] |
Promise<MonetaryAmount<CurrencyExt>[]>
▸ _getStandardLiquidityPool(pairCurrencies, lpTokenCurrencyId, pairStatus, blockTimeMs): Promise<null | StandardLiquidityPool>
| Name | Type |
|---|---|
pairCurrencies |
[InterbtcPrimitivesCurrencyId, InterbtcPrimitivesCurrencyId] |
lpTokenCurrencyId |
InterbtcPrimitivesCurrencyId |
pairStatus |
DexGeneralPrimitivesPairStatus |
blockTimeMs |
number |
Promise<null | StandardLiquidityPool>
▸ _getStandardLpTokens(): Promise<StandardLpToken[]>
Promise<StandardLpToken[]>
▸ _getStandardPoolReserveBalances(token0, token1, pairAccount): Promise<[MonetaryAmount<CurrencyExt>, MonetaryAmount<CurrencyExt>]>
| Name | Type |
|---|---|
token0 |
CurrencyExt |
token1 |
CurrencyExt |
pairAccount |
AccountId |
Promise<[MonetaryAmount<CurrencyExt>, MonetaryAmount<CurrencyExt>]>
▸ _poolHasZeroLiquidity(pooledCurrencies): boolean
| Name | Type |
|---|---|
pooledCurrencies |
PooledCurrencies |
boolean
▸ _swapThroughStandardAndStablePools(trade, minimumAmountOut, recipient, deadline): ExtrinsicData
| Name | Type |
|---|---|
trade |
Trade |
minimumAmountOut |
MonetaryAmount<CurrencyExt> |
recipient |
AddressOrPair |
deadline |
string | number |
▸ _swapThroughStandardPoolsOnly(trade, minimumAmountOut, recipient, deadline): ExtrinsicData
| Name | Type |
|---|---|
trade |
Trade |
minimumAmountOut |
MonetaryAmount<CurrencyExt> |
recipient |
AddressOrPair |
deadline |
string | number |
▸ addLiquidity(amounts, pool, maxSlippage, deadline, recipient): Promise<ExtrinsicData>
Adds liquidity to liquidity pool
| Name | Type | Description |
|---|---|---|
amounts |
PooledCurrencies |
Array of monetary amounts of pooled currencies sorted in the same order as in the pool. |
pool |
LiquidityPool |
Type of liquidity pool. |
maxSlippage |
number |
Maximum allowed slippage. |
deadline |
number |
Deadline block number. |
recipient |
AddressOrPair |
Recipient of the liquidity pool token. |
Promise<ExtrinsicData>
A submittable extrinsic and an event that is emitted when extrinsic is submitted.
▸ claimFarmingRewards(claimableRewards): ExtrinsicData
Claim all pending farming rewards.
| Name | Type | Description |
|---|---|---|
claimableRewards |
Map<LpCurrency, MonetaryAmount<CurrencyExt>[]> |
Map of LpToken -> Array of reward monetary amounts -> supposed to be output of getClaimableFarmingRewards |
A submittable extrinsic and an event that is emitted when extrinsic is submitted.
▸ getClaimableFarmingRewards(accountId, accountLiquidity, pools): Promise<Map<LpCurrency, MonetaryAmount<CurrencyExt>[]>>
Get claimable farming reward amounts for all farmed liquidity provided by account.
| Name | Type | Description |
|---|---|---|
accountId |
AccountId |
Account id for which to get claimable rewards. |
accountLiquidity |
MonetaryAmount<LpCurrency>[] |
Amount of liquidity the account has provided. |
pools |
LiquidityPool[] |
All liquidity pools. |
Promise<Map<LpCurrency, MonetaryAmount<CurrencyExt>[]>>
Map of LpCurrency -> Array of reward monetary amounts.
AMMAPI.getClaimableFarmingRewards
▸ getLiquidityPools(): Promise<LiquidityPool[]>
Get all liquidity pools.
Promise<LiquidityPool[]>
All liquidity pools.
▸ getLiquidityProvidedByAccount(accountId): Promise<MonetaryAmount<LpCurrency>[]>
Get liquidity provided by account.
| Name | Type | Description |
|---|---|---|
accountId |
AccountId |
Account to get provided liquidity information about. |
Promise<MonetaryAmount<LpCurrency>[]>
Array of LP token amounts that represent account’s positions in respective liquidity pools.
AMMAPI.getLiquidityProvidedByAccount
▸ getLpTokens(): Promise<LpCurrency[]>
Get all LP tokens.
Promise<LpCurrency[]>
Array of all standard and stable LP tokens.
▸ getOptimalTrade(inputAmount, outputCurrency, pools): null | Trade
Get optimal trade for provided trade type and amount.
| Name | Type | Description |
|---|---|---|
inputAmount |
MonetaryAmount<CurrencyExt> |
Amount to be exchanged. |
outputCurrency |
CurrencyExt |
Currency to purchase. |
pools |
LiquidityPool[] |
Array of all liquidity pools. |
null | Trade
Optimal trade information or null if the trade is not possible.
▸ getStableLiquidityPools(blockTimeMs): Promise<StableLiquidityPool[]>
| Name | Type |
|---|---|
blockTimeMs |
number |
Promise<StableLiquidityPool[]>
▸ getStandardLiquidityPools(blockTimeMs): Promise<StandardLiquidityPool[]>
| Name | Type |
|---|---|
blockTimeMs |
number |
Promise<StandardLiquidityPool[]>
▸ removeLiquidity(amount, pool, maxSlippage, deadline, recipient): Promise<ExtrinsicData>
Removes liquidity from pool.
| Name | Type | Description |
|---|---|---|
amount |
MonetaryAmount<LpCurrency> |
Amount of LP token to be removed |
pool |
LiquidityPool |
Liquidity pool to remove from. |
maxSlippage |
number |
Maximum allowed slippage. |
deadline |
number |
Deadline block number. |
recipient |
AddressOrPair |
Recipient of the pooled currencies. |
Promise<ExtrinsicData>
A submittable extrinsic and an event that is emitted when extrinsic is submitted.
Note
Removes amount of liquidity in LP token, breaks it down and transfers to account.
▸ swap(trade, minimumAmountOut, recipient, deadline): ExtrinsicData
Swap assets.
| Name | Type | Description |
|---|---|---|
trade |
Trade |
Trade object containing information about the trade. |
minimumAmountOut |
MonetaryAmount<CurrencyExt> |
Minimum output amount to be received. |
recipient |
AddressOrPair |
Recipient address. |
deadline |
string | number |
Deadline block for the swap transaction. |
A submittable extrinsic and an event that is emitted when extrinsic is submitted.
▸ getStableLpTokenFromPoolData(poolId, basePoolData): StableLpToken
| Name | Type |
|---|---|
poolId |
number |
basePoolData |
DexStablePrimitivesBasePool |
▸ getStablePoolInfo(poolData): null | DexStablePrimitivesBasePool
| Name | Type |
|---|---|
poolData |
DexStablePrimitivesPool |
null | DexStablePrimitivesBasePool