interbtc-api

@interlay/interbtc-api / Exports

@interlay/interbtc-api

Table of contents

Enumerations

Classes

Interfaces

Type Aliases

Variables

Functions

Other

AccountLiquidity

Ƭ AccountLiquidity: Object

The liquidity status of an account, based on the value of its collateral and loans.

Type declaration

Name Type
liquidity MonetaryAmount<WrappedCurrency>
shortfall MonetaryAmount<WrappedCurrency>

Defined in

src/types/loans.ts:70


AssetKey

Ƭ AssetKey: StorageKey<[u32]>

Defined in

src/parachain/asset-registry.ts:36


AssetRegistryMetadataTuple

Ƭ AssetRegistryMetadataTuple: [StorageKey<[u32]>, Option<OrmlTraitsAssetRegistryAssetMetadata>]

Defined in

src/parachain/asset-registry.ts:38


BitcoinNetwork

Ƭ BitcoinNetwork: "mainnet" | "testnet" | "regtest"

Defined in

src/types/bitcoin.ts:3


BlockHeader

Ƭ BlockHeader: Object

Type declaration

Name Type
hashPrevBlock HexString
hash_ HexString
merkleRoot HexString
nonce number
target HexString
timestamp number
version number

Defined in

src/types/bitcoin.ts:5


CollateralCurrencyExt

Ƭ CollateralCurrencyExt: CollateralCurrency | ForeignAsset | LendToken

Defined in

src/types/currency.ts:52


CollateralIdLiteral

Ƭ CollateralIdLiteral: DOT | KSM | KINT | INTR

Defined in

src/types/currency.ts:30


CurrencyExt

Ƭ CurrencyExt: Currency | ForeignAsset | LendToken | LpCurrency

Defined in

src/types/currency.ts:53


CurrencyIdentifier

Ƭ CurrencyIdentifier: NativeCurrencyIdentifier | ForeignAssetIdentifier | LendTokenIdentifier | StableLpTokenIdentifier | StandardLpTokenIdentifier

Defined in

src/types/currency.ts:94


ForeignAsset

Ƭ ForeignAsset: Currency & { foreignAsset: { coingeckoId: string ; id: number } }

Defined in

src/types/currency.ts:39


GovernanceCurrency

Ƭ GovernanceCurrency: typeof GovernanceCurrency[number]

Defined in

src/types/currency.ts:61

src/types/currency.ts:62


GovernanceIdLiteral

Ƭ GovernanceIdLiteral: INTR | KINT

Defined in

src/types/currency.ts:29


HexString

Ƭ HexString: `0x${string}`

Defined in

src/types/encoding.ts:1


IssueLimits

Ƭ IssueLimits: Object

Type declaration

Name Type
singleVaultMaxIssuable MonetaryAmount<WrappedCurrency>
totalMaxIssuable MonetaryAmount<WrappedCurrency>

Defined in

src/parachain/issue.ts:29


LendToken

Ƭ LendToken: Currency & { lendToken: { id: number } }

Defined in

src/types/currency.ts:40


LiquidityPool

Ƭ LiquidityPool: StandardLiquidityPool | StableLiquidityPool | StableLiquidityMetaPool

Defined in

src/parachain/amm/liquidity-pool/types.ts:6


LoanAction

Ƭ LoanAction: "lend" | "withdraw" | "borrow" | "repay"

Defined in

src/types/loans.ts:19


LpCurrency

Ƭ LpCurrency: StandardLpToken | StableLpToken

Defined in

src/types/currency.ts:51


MerkleProof

Ƭ MerkleProof: Object

Type declaration

Name Type
blockHeader BlockHeader
flagBits boolean[]
hashes HexString[]
transactionsCount number

Defined in

src/types/bitcoin.ts:15


MultiPath

Ƭ MultiPath: MultiPathElement[]

Defined in

src/parachain/amm/trade/types.ts:57


MultiPathElement

Ƭ MultiPathElement: MultiPathElementStandard | MultiPathElementStable

Defined in

src/parachain/amm/trade/types.ts:46


MultiPathElementStable

Ƭ MultiPathElementStable: MultiPathElementStablePlain | MultiPathElementStableMeta

Defined in

src/parachain/amm/trade/types.ts:45


Nomination

Ƭ Nomination: NominationData & { type: Parsed }

Defined in

src/parachain/nomination.ts:35


NominationData

Ƭ NominationData: Object

Type declaration

Name Type
amount MonetaryAmount<Currency>
nominatorId AccountId
nonce number
vaultId InterbtcPrimitivesVaultId

Defined in

src/parachain/nomination.ts:27


NominationReward

Ƭ NominationReward: NominationData

Defined in

src/parachain/nomination.ts:36


PHANTOM_DEFAULT

Ƭ PHANTOM_DEFAULT: "default"

Defined in

src/interfaces/default/types.ts:153


PooledCurrencies

Ƭ PooledCurrencies: MonetaryAmount<CurrencyExt>[]

Defined in

src/parachain/amm/types.ts:24


RawNomination

Ƭ RawNomination: NominationData & { type: Raw }

Defined in

src/parachain/nomination.ts:34


StableLpToken

Ƭ StableLpToken: Currency & { stableLpToken: { poolId: number } }

Defined in

src/types/currency.ts:48


StakedBalance

Ƭ StakedBalance: Object

Type declaration

Name Type
amount MonetaryAmount<GovernanceCurrency>
endBlock number

Defined in

src/types/currency.ts:67


StandardLpToken

Ƭ StandardLpToken: Currency & { lpToken: { token0: StandardLpUnderlyingToken ; token1: StandardLpUnderlyingToken } }

Defined in

src/types/currency.ts:44


StandardPooledTokenIdentifier

Ƭ StandardPooledTokenIdentifier: NativeCurrencyIdentifier | ForeignAssetIdentifier | StableLpTokenIdentifier

Defined in

src/types/currency.ts:88


SystemCollateralCeilingTuple

Ƭ SystemCollateralCeilingTuple: [StorageKey<[InterbtcPrimitivesVaultCurrencyPair]>, Option<u128>]

Defined in

src/parachain/asset-registry.ts:40


TickerToData

Ƭ TickerToData<T>: Object

Type parameters

Name
T

Index signature

▪ [ticker: string]: T

Defined in

src/types/loans.ts:53


Transaction

Ƭ Transaction: Object

Type declaration

Name Type
inputs TransactionInput[]
lockAt TransactionLocktime
outputs TransactionOutput[]
version number

Defined in

src/types/bitcoin.ts:48


TransactionInputSource

Ƭ TransactionInputSource: "coinbase" | { fromOutput: [HexString, number] }

Defined in

src/types/bitcoin.ts:22


TransactionLocktime

Ƭ TransactionLocktime: { time: number } | { blockHeight: number }

Defined in

src/types/bitcoin.ts:40


TxStatus

Ƭ TxStatus: Object

Type declaration

Name Type
blockHash? string
blockHeight? number
confirmations number
confirmed boolean

Defined in

src/types/bitcoin.ts:55


UndercollateralizedPosition

Ƭ UndercollateralizedPosition: Object

Type declaration

Name Type
accountId AccountId
borrowPositions BorrowPosition[]
collateralPositions CollateralPosition[]
shortfall MonetaryAmount<WrappedCurrency>

Defined in

src/types/loans.ts:75


UnwrappedAssetRegistryMetadataTuple

Ƭ UnwrappedAssetRegistryMetadataTuple: [StorageKey<[u32]>, OrmlTraitsAssetRegistryAssetMetadata]

Defined in

src/parachain/asset-registry.ts:39


VotingCurrency

Ƭ VotingCurrency: typeof VotingCurrency[number]

Defined in

src/types/currency.ts:64

src/types/currency.ts:65


WrappedAmount

Ƭ WrappedAmount: typeof WrappedAmount[number]

Defined in

src/types/currency.ts:58

src/types/currency.ts:59


WrappedCurrency

Ƭ WrappedCurrency: typeof WrappedCurrency[number]

Defined in

src/types/currency.ts:55

src/types/currency.ts:56


WrappedIdLiteral

Ƭ WrappedIdLiteral: INTERBTC | KBTC

Defined in

src/types/currency.ts:28


ACCOUNT_NOT_SET_ERROR_MESSAGE

Const ACCOUNT_NOT_SET_ERROR_MESSAGE: "cannot sign transaction without setting account"

Defined in

src/utils/constants.ts:13


ATOMIC_UNIT

Const ATOMIC_UNIT: 0

Defined in

src/utils/currency.ts:42


BLOCK_TIME_SECONDS

Const BLOCK_TIME_SECONDS: 12

Defined in

src/utils/constants.ts:17


DEFAULT_STABLE_CONFIRMATIONS

Const DEFAULT_STABLE_CONFIRMATIONS: 6

Defined in

src/parachain/btc-relay.ts:6


FIXEDI128_SCALING_FACTOR

Const FIXEDI128_SCALING_FACTOR: 18

Defined in

src/utils/constants.ts:4


GovernanceCurrency

Const GovernanceCurrency: Currency[]

Defined in

src/types/currency.ts:61

src/types/currency.ts:62


IGNORED_ERROR_MESSAGES

Const IGNORED_ERROR_MESSAGES: string[]

Defined in

src/utils/constants.ts:11


LOANS_REWARD_INDEX_SCALING_FACTOR

Const LOANS_REWARD_INDEX_SCALING_FACTOR: number

Defined in

src/utils/constants.ts:28


MS_PER_YEAR

Const MS_PER_YEAR: Big

Defined in

src/utils/constants.ts:15


NO_LIQUIDATION_VAULT_FOUND_REJECTION

Const NO_LIQUIDATION_VAULT_FOUND_REJECTION: "No liquidation vault found"

Defined in

src/parachain/vaults.ts:418


PERMILL_BASE

Const PERMILL_BASE: 1000000

Defined in

src/utils/constants.ts:7


SLEEP_TIME_MS

Const SLEEP_TIME_MS: 1000

Defined in

src/utils/constants.ts:19


STABLE_POOLS_APPROXIMATION_PRECISION

Const STABLE_POOLS_APPROXIMATION_PRECISION: Big

Defined in

src/utils/constants.ts:26


VotingCurrency

Const VotingCurrency: Currency[]

Defined in

src/types/currency.ts:64

src/types/currency.ts:65


WrappedAmount

Const WrappedAmount: typeof InterBtcAmount[]

Defined in

src/types/currency.ts:58

src/types/currency.ts:59


WrappedCurrency

Const WrappedCurrency: Currency[]

Defined in

src/types/currency.ts:55

src/types/currency.ts:56


addHexPrefix

addHexPrefix(str): string

Ensure the 0x hex prefix is present

Parameters

Name Type
str string

Returns

string

Defined in

src/utils/encoding.ts:85


addressOrPairAsAccountId

addressOrPairAsAccountId(api, addyOrpair): AccountId

Parameters

Name Type
api ApiPromise
addyOrpair AddressOrPair

Returns

AccountId

Defined in

src/utils/encoding.ts:222


adjustToThreshold

adjustToThreshold(amount, threshold): MonetaryAmount<CurrencyExt>

Parameters

Name Type
amount MonetaryAmount<CurrencyExt>
threshold Big

Returns

MonetaryAmount<CurrencyExt>

Defined in

src/utils/loans.ts:36


allocateAmountsToVaults

allocateAmountsToVaults(vaultsWithAvailableAmounts, amountToAllocate): Map<InterbtcPrimitivesVaultId, MonetaryAmount<WrappedCurrency>>

Given a list of vaults with availabilities (e.g. collateral for issue, tokens for redeem) and an amount to allocate, selects one or more vaults to fulfil the request. If the amount cannot be allocated by a single vault, greedily selects the vault with highest available amount and tries again for the remainder. If at leaast one vault can fulfil a request alone, a random one among them is selected.

Parameters

Name Type
vaultsWithAvailableAmounts Map<InterbtcPrimitivesVaultId, MonetaryAmount<Currency>>
amountToAllocate MonetaryAmount<Currency>

Returns

Map<InterbtcPrimitivesVaultId, MonetaryAmount<WrappedCurrency>>

Defined in

src/utils/issueRedeem.ts:21


atomicToBaseAmount

atomicToBaseAmount(atomicAmount, currency): Big

Parameters

Name Type
atomicAmount BigSource
currency Currency

Returns

Big

Defined in

src/utils/currency.ts:48


bufferToHexString

bufferToHexString(buffer): HexString

Parameters

Name Type
buffer Buffer

Returns

HexString

Defined in

src/utils/encoding.ts:401


calculateAnnualizedRewardAmount

calculateAnnualizedRewardAmount(amountPerBlock, blockTimeMs): Big

Parameters

Name Type
amountPerBlock Big
blockTimeMs number

Returns

Big

Defined in

src/utils/rewards.ts:4


calculateBorrowLimit

calculateBorrowLimit(totalBorrowedAmount, totalCollateralThresholdAdjustedAmount): MonetaryAmount<CurrencyExt>

Parameters

Name Type
totalBorrowedAmount MonetaryAmount<CurrencyExt>
totalCollateralThresholdAdjustedAmount MonetaryAmount<CurrencyExt>

Returns

MonetaryAmount<CurrencyExt>

Defined in

src/utils/loans.ts:39


calculateBorrowLimitBtcChangeFactory

calculateBorrowLimitBtcChangeFactory(loanAssets, totalBorrowedBtc, totalCollateralThresholdAdjustedCollateralBtc): (action: LoanAction, amount: MonetaryAmount<CurrencyExt>) => MonetaryAmount<Currency>

Parameters

Name Type
loanAssets TickerToData<LoanAsset>
totalBorrowedBtc MonetaryAmount<Currency>
totalCollateralThresholdAdjustedCollateralBtc MonetaryAmount<Currency>

Returns

fn

▸ (action, amount): MonetaryAmount<Currency>

Parameters
Name Type
action LoanAction
amount MonetaryAmount<CurrencyExt>
Returns

MonetaryAmount<Currency>

Defined in

src/utils/loans.ts:76


calculateCollateralAmountBtc

calculateCollateralAmountBtc(action, currentCollateralAmountBtc, actionAmountBtc): MonetaryAmount<Currency>

Parameters

Name Type
action LoanAction
currentCollateralAmountBtc MonetaryAmount<Currency>
actionAmountBtc MonetaryAmount<Currency>

Returns

MonetaryAmount<Currency>

Defined in

src/utils/loans.ts:21


calculateLtv

calculateLtv(collateralAmount, borrowedAmount): Big

Parameters

Name Type
collateralAmount MonetaryAmount<CurrencyExt>
borrowedAmount MonetaryAmount<CurrencyExt>

Returns

Big

Defined in

src/utils/loans.ts:65


calculateLtvAndThresholdsChangeFactory

calculateLtvAndThresholdsChangeFactory(loanAssets, totalBorrowedBtc, totalCollateralBtc, totalCollateralThresholdAdjustedCollateralBtc, totalLiquidationThresholdAdjustedCollateralBtc): (action: LoanAction, amount: MonetaryAmount<CurrencyExt>) => { collateralThresholdWeightedAverage: Big ; liquidationThresholdWeightedAverage: Big ; ltv: Big }

Parameters

Name Type
loanAssets TickerToData<LoanAsset>
totalBorrowedBtc MonetaryAmount<Currency>
totalCollateralBtc MonetaryAmount<Currency>
totalCollateralThresholdAdjustedCollateralBtc MonetaryAmount<Currency>
totalLiquidationThresholdAdjustedCollateralBtc MonetaryAmount<Currency>

Returns

fn

▸ (action, amount): Object

Parameters
Name Type
action LoanAction
amount MonetaryAmount<CurrencyExt>
Returns

Object

Name Type
collateralThresholdWeightedAverage Big
liquidationThresholdWeightedAverage Big
ltv Big

Defined in

src/utils/loans.ts:98


calculateThreshold

calculateThreshold(collateralAmount, thresholdAdjustedCollateralAmount): Big

Parameters

Name Type
collateralAmount MonetaryAmount<CurrencyExt>
thresholdAdjustedCollateralAmount MonetaryAmount<CurrencyExt>

Returns

Big

Defined in

src/utils/loans.ts:55


calculateTotalBorrowedBtcChange

calculateTotalBorrowedBtcChange(action, currentTotalBorrowedBtc, actionAmountBtc): MonetaryAmount<Currency>

Parameters

Name Type
action LoanAction
currentTotalBorrowedBtc MonetaryAmount<Currency>
actionAmountBtc MonetaryAmount<Currency>

Returns

MonetaryAmount<Currency>

Defined in

src/utils/loans.ts:6


computeLazyDistribution

computeLazyDistribution(stake, perToken, tally): Big

Parameters

Name Type
stake Big
perToken Big
tally Big

Returns

Big

Defined in

src/utils/currency.ts:44


computePriceImpact

computePriceImpact(path, inputAmount, outputAmount): Big

Parameters

Name Type
path MultiPath
inputAmount MonetaryAmount<CurrencyExt>
outputAmount MonetaryAmount<CurrencyExt>

Returns

Big

Defined in

src/parachain/amm/trade/utils.ts:64


convertMoment

convertMoment(moment): Date

Parameters

Name Type
moment Moment

Returns

Date

Defined in

src/utils/encoding.ts:335


createAPIRegistry

createAPIRegistry(): TypeRegistry

Returns

TypeRegistry

Defined in

src/factory.ts:57


createExchangeRateOracleKey

createExchangeRateOracleKey(api, collateralCurrency): InterbtcPrimitivesOracleKey

Parameters

Name Type
api ApiPromise
collateralCurrency CurrencyExt

Returns

InterbtcPrimitivesOracleKey

Defined in

src/utils/currency.ts:76


createFeeEstimationOracleKey

createFeeEstimationOracleKey(api): InterbtcPrimitivesOracleKey

Parameters

Name Type
api ApiPromise

Returns

InterbtcPrimitivesOracleKey

Defined in

src/utils/currency.ts:72


createInterBtcApi

createInterBtcApi(endpoint, network?, account?, autoConnect?): Promise<InterBtcApi>

Parameters

Name Type Default value
endpoint string undefined
network BitcoinNetwork "mainnet"
account? AddressOrPair undefined
autoConnect? number | false undefined

Returns

Promise<InterBtcApi>

Defined in

src/factory.ts:39


createProvider

createProvider(endpoint, autoConnect?): ProviderInterface

Parameters

Name Type
endpoint string
autoConnect? number | false

Returns

ProviderInterface

Defined in

src/factory.ts:12


createSubstrateAPI

createSubstrateAPI(endpoint, autoConnect?, noInitWarn?): Promise<ApiPromise>

Parameters

Name Type
endpoint string
autoConnect? number | false
noInitWarn? boolean

Returns

Promise<ApiPromise>

Defined in

src/factory.ts:22


currencyIdToMonetaryCurrency

currencyIdToMonetaryCurrency(api, currencyId): Promise<CurrencyExt>

Parameters

Name Type
api ApiPromise
currencyId InterbtcPrimitivesCurrencyId

Returns

Promise<CurrencyExt>

Defined in

src/utils/currency.ts:185


decodeBtcAddress

decodeBtcAddress(address, network): { p2pkh: string } | { p2sh: string } | { p2wpkhv0: string } | { p2wshv0: string }

Parameters

Name Type
address string
network Network

Returns

{ p2pkh: string } | { p2sh: string } | { p2wpkhv0: string } | { p2wshv0: string }

Defined in

src/utils/bitcoin.ts:71


decodeBytesAsString

decodeBytesAsString(bytes): string

Convert Bytes to a string. Will remove 0x prefix if present.

Parameters

Name Type Description
bytes Bytes Bytes to decode

Returns

string

the decoded string

Defined in

src/utils/encoding.ts:133


decodeFixedPointType

decodeFixedPointType(x): Big

Parameters

Name Type
x SignedFixedPoint | UnsignedFixedPoint

Returns

Big

Defined in

src/utils/encoding.ts:122


decodeNumberOrHex

decodeNumberOrHex(value): Big

Parameters

Name Type
value NumberOrHex

Returns

Big

Defined in

src/utils/encoding.ts:386


decodePermill

decodePermill(amount, inPercentage?): Big

Parameters

Name Type Default value
amount Permill undefined
inPercentage boolean false

Returns

Big

Defined in

src/utils/encoding.ts:378


decodeRpcVaultId

decodeRpcVaultId(api, vaultId): Promise<InterbtcPrimitivesVaultId>

Parameters

Name Type
api ApiPromise
vaultId VaultId

Returns

Promise<InterbtcPrimitivesVaultId>

Defined in

src/utils/encoding.ts:191


encodeBtcAddress

encodeBtcAddress(address, network): string

Parameters

Name Type
address BitcoinAddress
network Network

Returns

string

Defined in

src/utils/bitcoin.ts:19


encodeSwapParamsForStandardAndStablePools

encodeSwapParamsForStandardAndStablePools(api, trade, minimumAmountOut): Object

Parameters

Name Type
api ApiPromise
trade Trade
minimumAmountOut MonetaryAmount<CurrencyExt>

Returns

Object

Name Type
amountIn string
amountOutMin string
path ({ Stable: { basePoolId: number ; fromCurrency: InterbtcPrimitivesCurrencyId ; mode: string ; poolId: number ; toCurrency: InterbtcPrimitivesCurrencyId } } | { Normal: InterbtcPrimitivesCurrencyId[] })[]

Defined in

src/parachain/amm/encoding.ts:25


encodeSwapParamsForStandardPoolsOnly

encodeSwapParamsForStandardPoolsOnly(api, trade, minimumAmountOut): Object

Parameters

Name Type
api ApiPromise
trade Trade
minimumAmountOut MonetaryAmount<CurrencyExt>

Returns

Object

Name Type
amountIn string
amountOutMin string
path InterbtcPrimitivesCurrencyId[]

Defined in

src/parachain/amm/encoding.ts:8


encodeUnsignedFixedPoint

encodeUnsignedFixedPoint(api, x): UnsignedFixedPoint

Parameters

Name Type
api ApiPromise
x Big

Returns

UnsignedFixedPoint

Defined in

src/utils/encoding.ts:137


encodeVaultId

encodeVaultId(api, id): Promise<string>

Parameters

Name Type
api ApiPromise
id InterbtcPrimitivesVaultId

Returns

Promise<string>

Defined in

src/utils/encoding.ts:343


ensureHashEncoded

ensureHashEncoded(api, hash): H256

Ensure a hash value is an encoded H256

Parameters

Name Type Description
api ApiPromise The polkadot API promise used to encode if necessary
hash string | H256 The either H256 or string encoded hash

Returns

H256

Defined in

src/utils/encoding.ts:94


filterNonEmptyPools

filterNonEmptyPools(pools): LiquidityPool[]

Parameters

Name Type
pools LiquidityPool[]

Returns

LiquidityPool[]

Defined in

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


findBestTradeRecursively

findBestTradeRecursively(inputAmount, outputCurrency, pairs, hopLimit, path?, initialInputAmount?): null | Trade

Recursive function to find best trade path for provided trading pairs, input amount, output currencies and limited amount of hops between pools.

Parameters

Name Type Default value Description
inputAmount MonetaryAmount<CurrencyExt> undefined Input currency amount to be exchanged.
outputCurrency CurrencyExt undefined Output currency to be received.
pairs TradingPair[] undefined Array of all trading pairs to include in search.
hopLimit number undefined Maximum number of hops between liquidity pools.
path MultiPath [] Recursively generated parameter containing current trading path.
initialInputAmount MonetaryAmount<CurrencyExt> inputAmount Initial input amount.

Returns

null | Trade

Defined in

src/parachain/amm/utils.ts:20


getAPITypes

getAPITypes(): RegistryTypes

Returns

RegistryTypes

Defined in

src/factory.ts:49


getAllTradingPairs

getAllTradingPairs(pools): TradingPair[]

Get all trading pairs based on provided pools.

Parameters

Name Type
pools LiquidityPool[]

Returns

TradingPair[]

All trading pairs.

Defined in

src/parachain/amm/liquidity-pool/utils.ts:25


getBitcoinNetwork

getBitcoinNetwork(network?): Network

Parameters

Name Type Default value
network BitcoinNetwork "mainnet"

Returns

Network

Defined in

src/interbtc-api.ts:32


getCollateralCurrencies

getCollateralCurrencies(api): Promise<CollateralCurrencyExt[]>

Get all collateral currencies (tokens as well as foreign assets).

Will return all collateral currencies for which the parachain has a system collateral ceiling value greater than zero.

Parameters

Name Type Description
api ApiPromise ApiPromise instance to query the parachain

Returns

Promise<CollateralCurrencyExt[]>

An array of collateral currencies.

Defined in

src/utils/currency.ts:103


getCurrencyIdentifier

getCurrencyIdentifier(currency): CurrencyIdentifier

Parameters

Name Type
currency CurrencyExt

Returns

CurrencyIdentifier

Defined in

src/utils/currency.ts:166


getForeignAssetFromId

getForeignAssetFromId(api, id): Promise<ForeignAsset>

Get foreign asset by its id.

Parameters

Name Type Description
api ApiPromise -
id number | u32 The id of the foreign asset.

Returns

Promise<ForeignAsset>

The foreign asset.

Defined in

src/utils/currency.ts:233


getIssueRequestsFromExtrinsicResult

getIssueRequestsFromExtrinsicResult(interBtcApi, result): Promise<Issue[]>

Parameters

Name Type
interBtcApi InterBtcApi
result ISubmittableResult

Returns

Promise<Issue[]>

Defined in

src/utils/issueRedeem.ts:85


getRPCTypes

getRPCTypes(): Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>

Returns

Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>

Defined in

src/factory.ts:53


getRedeemRequestsFromExtrinsicResult

getRedeemRequestsFromExtrinsicResult(interBtcApi, result): Promise<Redeem[]>

Parameters

Name Type
interBtcApi InterBtcApi
result ISubmittableResult

Returns

Promise<Redeem[]>

Defined in

src/utils/issueRedeem.ts:94


getRequestIdsFromEvents

getRequestIdsFromEvents(events, eventToFind, api): Hash[]

Parameters

Name Type Description
events EventRecord[] The EventRecord array returned after sending a transaction
eventToFind AugmentedEvent<ApiTypes, AnyTuple> -
api ApiPromise -

Returns

Hash[]

The id associated with the transaction. If the EventRecord array does not contain required events, the function throws an error.

Defined in

src/utils/issueRedeem.ts:67


getSS58Prefix

getSS58Prefix(api): number

Parameters

Name Type
api ApiPromise

Returns

number

Defined in

src/utils/encoding.ts:374


getStableLpTokenFromCurrencyId

getStableLpTokenFromCurrencyId(api, currencyId): Promise<StableLpToken>

Get stable LP token currency lib type from currencyId primitive.

Parameters

Name Type Description
api ApiPromise -
currencyId InterbtcPrimitivesCurrencyId Id of stable LP token.

Returns

Promise<StableLpToken>

Lib type currency object for stable LP token.

Defined in

src/utils/currency.ts:308


getStableSwapOutputAmount

getStableSwapOutputAmount(path, inputAmount): MonetaryAmount<CurrencyExt>

Parameters

Name Type
path MultiPathElementStable
inputAmount MonetaryAmount<CurrencyExt>

Returns

MonetaryAmount<CurrencyExt>

Defined in

src/parachain/amm/liquidity-pool/utils.ts:177


getStandardLpTokenFromCurrencyId

getStandardLpTokenFromCurrencyId(api, currencyId): Promise<StandardLpToken>

Get standard LP token currency lib type from currencyId primitive.

Parameters

Name Type Description
api ApiPromise -
currencyId InterbtcPrimitivesCurrencyId Id of standard LP token.

Returns

Promise<StandardLpToken>

Lib type currency object for standard LP token.

Defined in

src/utils/currency.ts:277


getTotalAmountBtc

getTotalAmountBtc(positions, loanAssets): MonetaryAmount<Currency>

Parameters

Name Type
positions LoanPosition[]
loanAssets TickerToData<LoanAsset>

Returns

MonetaryAmount<Currency>

Defined in

src/utils/loans.ts:45


getTxProof

getTxProof(electrsAPI, userTxId): Promise<{ coinbaseProof: PartialTxProof ; userTxProof: PartialTxProof }>

Parameters

Name Type
electrsAPI ElectrsAPI
userTxId string

Returns

Promise<{ coinbaseProof: PartialTxProof ; userTxProof: PartialTxProof }>

Defined in

src/utils/bitcoin.ts:160


getUnderlyingCurrencyFromLendTokenId

getUnderlyingCurrencyFromLendTokenId(api, lendTokenId): Promise<CurrencyExt>

Get underlying currency of lend token id,

Parameters

Name Type Description
api ApiPromise -
lendTokenId InterbtcPrimitivesCurrencyId Currency id of the lend token to get currency from

Returns

Promise<CurrencyExt>

Underlying CurrencyExt for provided lend token

Defined in

src/utils/currency.ts:260


intoAccountTruncating

intoAccountTruncating(api, palletId): AccountId

Parameters

Name Type
api ApiPromise
palletId Uint8Array

Returns

AccountId

Defined in

src/utils/encoding.ts:47


isCurrency

isCurrency(currencyExt): currencyExt is Currency

Parameters

Name Type
currencyExt CurrencyExt

Returns

currencyExt is Currency

Defined in

src/utils/currency.ts:138


isCurrencyEqual

isCurrencyEqual(currency, otherCurrency): boolean

Parameters

Name Type
currency CurrencyExt
otherCurrency CurrencyExt

Returns

boolean

Defined in

src/utils/currency.ts:147


isForeignAsset

isForeignAsset(currencyExt): currencyExt is ForeignAsset

Parameters

Name Type
currencyExt CurrencyExt

Returns

currencyExt is ForeignAsset

Defined in

src/utils/currency.ts:118


isLendToken

isLendToken(currencyExt): currencyExt is LendToken

Parameters

Name Type
currencyExt CurrencyExt

Returns

currencyExt is LendToken

Defined in

src/utils/currency.ts:124


isStableLpToken

isStableLpToken(currencyExt): currencyExt is StableLpToken

Parameters

Name Type
currencyExt CurrencyExt

Returns

currencyExt is StableLpToken

Defined in

src/utils/currency.ts:134


isStableMetaMultiPathElement

isStableMetaMultiPathElement(pathElement): pathElement is MultiPathElementStableMeta

Parameters

Name Type
pathElement MultiPathElement

Returns

pathElement is MultiPathElementStableMeta

Defined in

src/parachain/amm/trade/types.ts:52


isStableMetaPool

isStableMetaPool(pool): pool is StableLiquidityMetaPool

Parameters

Name Type
pool LiquidityPool

Returns

pool is StableLiquidityMetaPool

Defined in

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


isStableMultiPathElement

isStableMultiPathElement(pathElement): pathElement is MultiPathElementStable

Parameters

Name Type
pathElement MultiPathElement

Returns

pathElement is MultiPathElementStable

Defined in

src/parachain/amm/trade/types.ts:50


isStablePlainMultiPathElement

isStablePlainMultiPathElement(pathElement): pathElement is MultiPathElementStablePlain

Parameters

Name Type
pathElement MultiPathElement

Returns

pathElement is MultiPathElementStablePlain

Defined in

src/parachain/amm/trade/types.ts:54


isStablePool

isStablePool(pool): pool is StableLiquidityPool | StableLiquidityMetaPool

Parameters

Name Type
pool LiquidityPool

Returns

pool is StableLiquidityPool | StableLiquidityMetaPool

Defined in

src/parachain/amm/liquidity-pool/types.ts:9


isStandardLpToken

isStandardLpToken(currencyExt): currencyExt is StandardLpToken

Parameters

Name Type
currencyExt CurrencyExt

Returns

currencyExt is StandardLpToken

Defined in

src/utils/currency.ts:130


isStandardMultiPathElement

isStandardMultiPathElement(pathElement): pathElement is MultiPathElementStandard

Parameters

Name Type
pathElement MultiPathElement

Returns

pathElement is MultiPathElementStandard

Defined in

src/parachain/amm/trade/types.ts:48


isStandardPool

isStandardPool(pool): pool is StandardLiquidityPool

Parameters

Name Type
pool LiquidityPool

Returns

pool is StandardLiquidityPool

Defined in

src/parachain/amm/liquidity-pool/types.ts:8


monetaryAmountToRawString

monetaryAmountToRawString(amount): string

Parameters

Name Type
amount MonetaryAmount<CurrencyExt>

Returns

string

Defined in

src/utils/encoding.ts:393


newAccountId

newAccountId(api, accountId): AccountId

Parameters

Name Type
api ApiPromise
accountId string

Returns

AccountId

Defined in

src/utils/encoding.ts:176


newCollateralBTCExchangeRate

newCollateralBTCExchangeRate(rate, counterCurrency, useBaseUnits?): ExchangeRate<Bitcoin, Currency>

Parameters

Name Type Default value
rate Big undefined
counterCurrency Currency undefined
useBaseUnits boolean false

Returns

ExchangeRate<Bitcoin, Currency>

Defined in

src/utils/currency.ts:61


newCurrencyId

newCurrencyId(api, currency): InterbtcPrimitivesCurrencyId

Parameters

Name Type
api ApiPromise
currency CurrencyExt

Returns

InterbtcPrimitivesCurrencyId

Defined in

src/utils/encoding.ts:213


newExtrinsicStatus

newExtrinsicStatus(api, type): ExtrinsicStatus

Parameters

Name Type
api ApiPromise
type "Ready" | "Future" | "Broadcast" | "InBlock" | "Retracted" | "FinalityTimeout" | "Finalized" | "Usurped" | "Dropped" | "Invalid"

Returns

ExtrinsicStatus

Defined in

src/utils/encoding.ts:397


newForeignAssetId

newForeignAssetId(api, id): u32

Parameters

Name Type
api ApiPromise
id number

Returns

u32

Defined in

src/utils/encoding.ts:218


newMonetaryAmount

newMonetaryAmount<CurrencyT>(amount, currency, base?): MonetaryAmount<CurrencyT>

Type parameters

Name Type
CurrencyT extends CurrencyExt

Parameters

Name Type Default value
amount BigSource undefined
currency CurrencyT undefined
base boolean false

Returns

MonetaryAmount<CurrencyT>

Defined in

src/utils/currency.ts:52


newVaultCurrencyPair

newVaultCurrencyPair(api, collateralCurrency, wrappedCurrency): InterbtcPrimitivesVaultCurrencyPair

Parameters

Name Type
api ApiPromise
collateralCurrency CollateralCurrencyExt
wrappedCurrency Currency

Returns

InterbtcPrimitivesVaultCurrencyPair

Defined in

src/utils/encoding.ts:200


newVaultId

newVaultId(api, accountId, collateralCurrency, wrappedCurrency): InterbtcPrimitivesVaultId

Parameters

Name Type
api ApiPromise
accountId string
collateralCurrency CollateralCurrencyExt
wrappedCurrency Currency

Returns

InterbtcPrimitivesVaultId

Defined in

src/utils/encoding.ts:180


parseEscrowLockedBalance

parseEscrowLockedBalance(governanceCurrency, escrowLockedBalance): StakedBalance

Parameters

Name Type
governanceCurrency Currency
escrowLockedBalance EscrowLockedBalance

Returns

StakedBalance

Defined in

src/types/currency.ts:133


parseIssueRequest

parseIssueRequest(api, vaultsAPI, req, network, id): Promise<Issue>

Parameters

Name Type
api ApiPromise
vaultsAPI VaultsAPI
req InterbtcPrimitivesIssueIssueRequest
network Network
id string | H256

Returns

Promise<Issue>

Defined in

src/utils/encoding.ts:250


parseOrmlTokensAccountData

parseOrmlTokensAccountData(data, currency): ChainBalance

Parameters

Name Type
data OrmlTokensAccountData
currency CurrencyExt

Returns

ChainBalance

Defined in

src/types/currency.ts:124


parseRedeemRequest

parseRedeemRequest(api, vaultsAPI, req, network, id, redeemPeriod, activeBlockCount): Promise<Redeem>

Parameters

Name Type
api ApiPromise
vaultsAPI VaultsAPI
req InterbtcPrimitivesRedeemRedeemRequest
network Network
id string | H256
redeemPeriod number
activeBlockCount number

Returns

Promise<Redeem>

Defined in

src/utils/encoding.ts:308


parseRedeemRequestStatus

parseRedeemRequestStatus(req, redeemPeriod, activeBlockCount): RedeemStatus

Parameters

Name Type
req InterbtcPrimitivesRedeemRedeemRequest
redeemPeriod number
activeBlockCount number

Returns

RedeemStatus

Defined in

src/utils/encoding.ts:278


parseReplaceRequest

parseReplaceRequest(api, req, network, wrappedCurrency, id): Promise<ReplaceRequestExt>

Parameters

Name Type
api ApiPromise
req InterbtcPrimitivesReplaceReplaceRequest
network Network
wrappedCurrency Currency
id string | H256

Returns

Promise<ReplaceRequestExt>

Defined in

src/utils/encoding.ts:227


parseSystemVault

parseSystemVault(api, vault, wrappedCurrency, collateralCurrency): Promise<SystemVaultExt>

Parameters

Name Type
api ApiPromise
vault VaultRegistrySystemVault
wrappedCurrency Currency
collateralCurrency CollateralCurrencyExt

Returns

Promise<SystemVaultExt>

Defined in

src/utils/encoding.ts:158


queryNominationsMap

queryNominationsMap(api, map, vaultId): Promise<number | undefined>

Parameters

Name Type
api ApiPromise
map Map<InterbtcPrimitivesVaultId, number>
vaultId InterbtcPrimitivesVaultId

Returns

Promise<number | undefined>

Defined in

src/utils/encoding.ts:361


reverseEndianness

reverseEndianness(bytes): Uint8Array

Converts endianness of a Uint8Array

Parameters

Name Type Description
bytes Uint8Array Uint8Array, to be converted LE<>BE

Returns

Uint8Array

Defined in

src/utils/encoding.ts:55


reverseEndiannessHex

reverseEndiannessHex(hex): string

Reverse the endianness of the given hex string

Parameters

Name Type
hex string

Returns

string

Dev

Will remove 0x prefix if present

Defined in

src/utils/encoding.ts:107


setRawStorage

setRawStorage(api, key, value, account, isLittleEndian?): Promise<void>

Parameters

Name Type Default value
api ApiPromise undefined
key string undefined
value Codec undefined
account AddressOrPair undefined
isLittleEndian boolean true

Returns

Promise<void>

Defined in

src/utils/storage.ts:8


setStorageAtKey

setStorageAtKey(api, key, data, sudoAccount): Promise<void>

Parameters

Name Type
api ApiPromise
key string
data `0x${string}`
sudoAccount AddressOrPair

Returns

Promise<void>

Defined in

src/utils/storage.ts:18


sleep

sleep(ms): Promise<void>

Parameters

Name Type
ms number

Returns

Promise<void>

Defined in

src/utils/constants.ts:21


storageKeyToNthInner

storageKeyToNthInner<T>(s, n?): T

Type parameters

Name Type
T extends Codec

Parameters

Name Type Default value
s StorageKey<T[]> undefined
n number 0

Returns

T

Defined in

src/utils/encoding.ts:145


stripHexPrefix

stripHexPrefix(str): string

Remove the 0x hex prefix if present

Parameters

Name Type
str string

Returns

string

Defined in

src/utils/encoding.ts:77


toVoting

toVoting(governanceCurrency): Currency

Parameters

Name Type
governanceCurrency Currency

Returns

Currency

Defined in

src/utils/currency.ts:84


tokenSymbolToCurrency

tokenSymbolToCurrency(tokenSymbol): Currency

A method that will only try to find a hard-coded currencies. Only for use when we are certain the currency is not a foreign asset.

Parameters

Name Type Description
tokenSymbol InterbtcPrimitivesTokenSymbol the InterbtcPrimitivesTokenSymbol to look up

Returns

Currency

Defined in

src/utils/currency.ts:211


uint8ArrayToString

uint8ArrayToString(bytes): string

Converts a Uint8Array to string

Parameters

Name Type
bytes Uint8Array

Returns

string

Dev

Will remove 0x prefix if present

Defined in

src/utils/encoding.ts:118


unwrapRawExchangeRate

unwrapRawExchangeRate(option): UnsignedFixedPoint | undefined

Parameters

Name Type
option Option<UnsignedFixedPoint>

Returns

UnsignedFixedPoint | undefined

Defined in

src/utils/encoding.ts:339