interbtc-api

@interlay/interbtc-api / Exports / VaultsAPI

Interface: VaultsAPI

Implemented by

Table of contents

Methods

Methods

buildAcceptNewIssuesExtrinsic

buildAcceptNewIssuesExtrinsic(collateralCurrency, acceptNewIssues): SubmittableExtrinsic<"promise", ISubmittableResult>

Build accept new issues extrinsic without sending it.

Parameters

Name Type Description
collateralCurrency CollateralCurrencyExt the collateral currency for which to change the accepting status,
acceptNewIssues boolean Boolean denoting whether issuing should be enabled or not

Returns

SubmittableExtrinsic<"promise", ISubmittableResult>

An accept new issues submittable extrinsic.

Defined in

src/parachain/vaults.ts:356


buildDepositCollateralExtrinsic

buildDepositCollateralExtrinsic(amount): SubmittableExtrinsic<"promise", ISubmittableResult>

Build deposit collateral extrinsic (transaction) without sending it.

Parameters

Name Type Description
amount MonetaryAmount<CollateralCurrencyExt> The amount of extra collateral to lock

Returns

SubmittableExtrinsic<"promise", ISubmittableResult>

A deposit collateral submittable extrinsic.

Defined in

src/parachain/vaults.ts:252


buildRegisterPublicKeyExtrinsic

buildRegisterPublicKeyExtrinsic(publicKey): SubmittableExtrinsic<"promise", ISubmittableResult>

Build extrinsic to register a public key.

This extrinsic can be used together with a register vault extrinsic (see: buildRegisterVaultExtrinsic) to register the first vault for the logged in account id.

Registering the public key should only be done once per account id when it is not associated with a running vault, yet.

Parameters

Name Type Description
publicKey string The BTC public key of the vault to derive deposit keys with the On-Chain Key Derivation Scheme.

Returns

SubmittableExtrinsic<"promise", ISubmittableResult>

A register vault submittable extrinsic.

Defined in

src/parachain/vaults.ts:381


buildRegisterVaultExtrinsic

buildRegisterVaultExtrinsic(collateralAmount): SubmittableExtrinsic<"promise", ISubmittableResult>

Build extrinsic to register a new vault.

Parameters

Name Type Description
collateralAmount MonetaryAmount<CollateralCurrencyExt> The collateral amount to register the vault with - in the new collateral currency.

Returns

SubmittableExtrinsic<"promise", ISubmittableResult>

A register vault submittable extrinsic.

Defined in

src/parachain/vaults.ts:389


buildWithdrawAllCollateralExtrinsic

buildWithdrawAllCollateralExtrinsic(collateralCurrency): Promise<SubmittableExtrinsic<"promise", ISubmittableResult>>

Build withdraw collateral extrinsic (transaction) without sending it.

Parameters

Name Type Description
collateralCurrency CollateralCurrencyExt The collateral currency for which to withdraw all

Returns

Promise<SubmittableExtrinsic<"promise", ISubmittableResult>>

A withdraw collateral submittable extrinsic as promise.

Defined in

src/parachain/vaults.ts:236


buildWithdrawCollateralExtrinsic

buildWithdrawCollateralExtrinsic(amount): Promise<SubmittableExtrinsic<"promise", ISubmittableResult>>

Build withdraw collateral extrinsic (transaction) without sending it.

Parameters

Name Type Description
amount MonetaryAmount<CollateralCurrencyExt> The amount of collateral to withdraw

Returns

Promise<SubmittableExtrinsic<"promise", ISubmittableResult>>

A withdraw collateral submittable extrinsic as promise.

Defined in

src/parachain/vaults.ts:220


calculateCapacity

calculateCapacity(collateral): Promise<MonetaryAmount<Currency>>

Parameters

Name Type Description
collateral MonetaryAmount<CollateralCurrencyExt> Amount of collateral to calculate issuable capacity for

Returns

Promise<MonetaryAmount<Currency>>

Issuable amount by the vault, given the collateral amount

Defined in

src/parachain/vaults.ts:137


computeBackingCollateral

computeBackingCollateral(vaultId, nonce?): Promise<MonetaryAmount<CollateralCurrencyExt>>

Parameters

Name Type Description
vaultId InterbtcPrimitivesVaultId Vault ID object
nonce? number Nonce of the staking pool

Returns

Promise<MonetaryAmount<CollateralCurrencyExt>>

The entire collateral backing a vault’s issued tokens.

Defined in

src/parachain/vaults.ts:304


computeReward

computeReward(vaultAccountId, collateralCurrency, rewardCurrency): Promise<MonetaryAmount<Currency>>

Compute the total reward, including the staking (local) pool and the rewards (global) pool

Parameters

Name Type Description
vaultAccountId AccountId The vault ID whose reward pool to check
collateralCurrency CollateralCurrencyExt -
rewardCurrency Currency The reward currency, e.g. kBTC, KINT, interBTC, INTR

Returns

Promise<MonetaryAmount<Currency>>

A Monetary.js amount object, representing the total reward in the given currency

Defined in

src/parachain/vaults.ts:321


depositCollateral

depositCollateral(amount): ExtrinsicData

Parameters

Name Type Description
amount MonetaryAmount<CollateralCurrencyExt> The amount of extra collateral to lock

Returns

ExtrinsicData

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Defined in

src/parachain/vaults.ts:260


get

get(vaultAccountId, collateralCurrency): Promise<VaultExt>

Get a vault by account ID and collateral currency. Rejects if no vault exists.

Parameters

Name Type Description
vaultAccountId AccountId The ID of the vault to fetch
collateralCurrency CollateralCurrencyExt Collateral used by vault

Returns

Promise<VaultExt>

A vault object, rejects if no vault with the given ID and currency pair exists

Defined in

src/parachain/vaults.ts:67


getAPY

getAPY(vaultAccountId, collateralCurrency): Promise<Big>

Get the total APY for a vault based on the income in wrapped and collateral tokens divided by the locked collateral.

Parameters

Name Type Description
vaultAccountId AccountId The vault account ID
collateralCurrency CollateralCurrencyExt The currency specification, a Monetary.js object or ForeignAsset

Returns

Promise<Big>

the APY as a percentage string

Note

this does not account for interest compounding

Defined in

src/parachain/vaults.ts:198


getBlockRewardAPY

getBlockRewardAPY(vaultAccountId, collateralCurrency): Promise<Big>

Gets the estimated APY for just the block rewards (in governance tokens).

Parameters

Name Type
vaultAccountId AccountId
collateralCurrency CollateralCurrencyExt

Returns

Promise<Big>

the APY as a percentage

Defined in

src/parachain/vaults.ts:205


getCollateral

getCollateral(vaultId, collateralCurrency): Promise<MonetaryAmount<CollateralCurrencyExt>>

Parameters

Name Type Description
vaultId AccountId -
collateralCurrency CollateralCurrencyExt The currency specification, a Monetary.js object or ForeignAsset

Returns

Promise<MonetaryAmount<CollateralCurrencyExt>>

The collateral of a vault, taking slashes into account.

Defined in

src/parachain/vaults.ts:271


getExchangeRateForLiquidation

getExchangeRateForLiquidation(vaultAccountId, collateralCurrency): Promise<undefined | Big>

Get the target exchange rate at which a vault will be forced to liquidate, given its current locked collateral and issued as well as to be issued tokens.

Parameters

Name Type Description
vaultAccountId AccountId The vault’s account ID
collateralCurrency CollateralCurrencyExt The collateral currency for the vault with the account id above

Returns

Promise<undefined | Big>

The theoretical collateral per wrapped currency rate below which the vault would be liquidated. Returns undefined if a value cannot be calculated, eg. if the vault has no issued tokens.

Defined in

src/parachain/vaults.ts:412


getGovernanceReward

getGovernanceReward(vaultAccountId, vaultCollateral, governanceCurrency): Promise<MonetaryAmount<Currency>>

Parameters

Name Type Description
vaultAccountId AccountId The vault ID whose reward pool to check
vaultCollateral CollateralCurrencyExt Collateral used by the vault
governanceCurrency Currency The fee reward currency

Returns

Promise<MonetaryAmount<Currency>>

The total reward collected by the vault

Defined in

src/parachain/vaults.ts:343


getIssuableTokensFromVault

getIssuableTokensFromVault(vaultAccountId, collateralCurrency): Promise<MonetaryAmount<Currency>>

Returns issuable amount for a given vault

Parameters

Name Type Description
vaultAccountId AccountId The vault account ID
collateralCurrency CollateralCurrencyExt The currency specification, a Monetary.js object or ForeignAsset

Returns

Promise<MonetaryAmount<Currency>>

The issuable amount of a vault

Defined in

src/parachain/vaults.ts:281


getIssuedAmount

getIssuedAmount(vaultAccountId, collateralCurrency): Promise<MonetaryAmount<Currency>>

Parameters

Name Type Description
vaultAccountId AccountId The vault account ID
collateralCurrency CollateralCurrencyExt The currency specification, a Monetary.js object or `ForeignAsset

Returns

Promise<MonetaryAmount<Currency>>

The amount of wrapped tokens issued by the given vault

Defined in

src/parachain/vaults.ts:120


getLiquidationCollateralThreshold

getLiquidationCollateralThreshold(collateralCurrency): Promise<Big>

Parameters

Name Type
collateralCurrency CollateralCurrencyExt

Returns

Promise<Big>

The lower bound for vault collateralization. If a Vault’s collateral rate drops below this, automatic liquidation (forced Redeem) is triggered.

Defined in

src/parachain/vaults.ts:173


getLiquidationVault

getLiquidationVault(collateralCurrency): Promise<SystemVaultExt>

Parameters

Name Type
collateralCurrency CollateralCurrencyExt

Returns

Promise<SystemVaultExt>

A vault object representing the liquidation vault

Defined in

src/parachain/vaults.ts:265


getMaxNominationRatio

getMaxNominationRatio(collateralCurrency): Promise<Big>

Parameters

Name Type Description
collateralCurrency CollateralCurrencyExt The collateral currency specification, a Monetary.js object or ForeignAsset

Returns

Promise<Big>

The maximum collateral a vault can accept as nomination, as a ratio of its own collateral

Defined in

src/parachain/vaults.ts:289


getMinimumCollateral

getMinimumCollateral(collateralCurrency): Promise<MonetaryAmount<CollateralCurrencyExt>>

Get the minimum secured collateral amount required to activate a vault

Parameters

Name Type Description
collateralCurrency CollateralCurrencyExt The currency specification, a Monetary.js object or ForeignAsset

Returns

Promise<MonetaryAmount<CollateralCurrencyExt>>

the minimum collateral to register a vault

Defined in

src/parachain/vaults.ts:114


getOrNull

getOrNull(vaultAccountId, collateralCurrency): Promise<null | VaultExt>

Get a vault by account ID and collateral currency. Does not reject if the vault does not exist, but returns null instead.

Parameters

Name Type Description
vaultAccountId AccountId The ID of the vault to fetch
collateralCurrency CollateralCurrencyExt Collateral used by vault

Returns

Promise<null | VaultExt>

A vault object, or null if no vault with the given ID and currency pair exists

Defined in

src/parachain/vaults.ts:60


getPremiumRedeemThreshold

getPremiumRedeemThreshold(collateralCurrency): Promise<Big>

Parameters

Name Type
collateralCurrency CollateralCurrencyExt

Returns

Promise<Big>

The collateral rate at which users receive a premium allocated from the Vault’s collateral, when performing a redeem with this Vault.

Defined in

src/parachain/vaults.ts:179


getPremiumRedeemVaults

getPremiumRedeemVaults(): Promise<Map<InterbtcPrimitivesVaultId, MonetaryAmount<Currency>>>

Returns

Promise<Map<InterbtcPrimitivesVaultId, MonetaryAmount<Currency>>>

Vaults below the premium redeem threshold, sorted in descending order of their redeemable tokens

Defined in

src/parachain/vaults.ts:151


getPunishmentFee

getPunishmentFee(): Promise<Big>

Returns

Promise<Big>

Fee that a Vault has to pay, as a percentage, if it fails to execute redeem or replace requests (for redeem, on top of the slashed wrapped-token-to-collateral value of the request). The fee is paid in collateral currency based on the wrapped token amount at the current exchange rate.

Defined in

src/parachain/vaults.ts:212


getRequiredCollateralForVault

getRequiredCollateralForVault(vaultAccountId, collateralCurrency): Promise<MonetaryAmount<CollateralCurrencyExt>>

Get the amount of collateral required for the given vault to be at the current SecureCollateralThreshold with the current exchange rate

Parameters

Name Type Description
vaultAccountId AccountId The vault account ID
collateralCurrency CollateralCurrencyExt The currency specification, a Monetary.js object or ForeignAsset

Returns

Promise<MonetaryAmount<CollateralCurrencyExt>>

The required collateral the vault needs to deposit to stay above the threshold limit

Defined in

src/parachain/vaults.ts:105


getSecureCollateralThreshold

getSecureCollateralThreshold(collateralCurrency): Promise<Big>

Get the global secure collateral threshold.

Parameters

Name Type
collateralCurrency CollateralCurrencyExt

Returns

Promise<Big>

The global over-collateralization rate for collateral locked by Vaults, necessary for issuing wrapped tokens

Defined in

src/parachain/vaults.ts:186


getStakingCapacity

getStakingCapacity(vaultAccountId, collateralCurrency): Promise<MonetaryAmount<CollateralCurrencyExt>>

Parameters

Name Type Description
vaultAccountId AccountId The vault account ID
collateralCurrency CollateralCurrencyExt The currency specification, a Monetary.js object or ForeignAsset

Returns

Promise<MonetaryAmount<CollateralCurrencyExt>>

Staking capacity, as a collateral currency (e.g. DOT)

Defined in

src/parachain/vaults.ts:295


getTotalIssuableAmount

getTotalIssuableAmount(): Promise<MonetaryAmount<Currency>>

Returns

Promise<MonetaryAmount<Currency>>

The total amount of wrapped tokens that can be issued, considering the collateral locked by the vaults

Defined in

src/parachain/vaults.ts:132


getTotalIssuedAmount

getTotalIssuedAmount(): Promise<MonetaryAmount<Currency>>

Returns

Promise<MonetaryAmount<Currency>>

The total amount of wrapped tokens issued by the vaults

Defined in

src/parachain/vaults.ts:127


getVaultCollateralization

getVaultCollateralization(vaultAccountId, collateralCurrency, newCollateral?, onlyIssued?): Promise<undefined | Big>

Get the collateralization of a single vault measured by dividing the value of issued (wrapped) tokens by the value of total locked collateral.

Parameters

Name Type Description
vaultAccountId AccountId the vault account id
collateralCurrency CollateralCurrencyExt Collateral used by vault
newCollateral? MonetaryAmount<CollateralCurrencyExt> use this instead of the vault’s actual collateral
onlyIssued? boolean optional, defaults to false. Specifies whether the collateralization should only include the issued tokens, leaving out unsettled (“to-be-issued”) tokens

Returns

Promise<undefined | Big>

the vault collateralization

Remarks

Undefined collateralization is handled as infinite collateralization in the UI. If no tokens have been issued, the collateralFunds / issuedFunds ratio divides by zero, which means collateralization is infinite.

Defined in

src/parachain/vaults.ts:82


getVaultsWithIssuableTokens

getVaultsWithIssuableTokens(): Promise<Map<InterbtcPrimitivesVaultId, MonetaryAmount<Currency>>>

Returns

Promise<Map<InterbtcPrimitivesVaultId, MonetaryAmount<Currency>>>

Vaults with issuable tokens, not sorted in any particular order.

Remarks

The result is not sorted as an attempt to randomize the assignment of requests to vaults.

Defined in

src/parachain/vaults.ts:156


getVaultsWithRedeemableTokens

getVaultsWithRedeemableTokens(): Promise<Map<InterbtcPrimitivesVaultId, MonetaryAmount<Currency>>>

Returns

Promise<Map<InterbtcPrimitivesVaultId, MonetaryAmount<Currency>>>

Vaults with redeemable tokens, sorted in descending order.

Defined in

src/parachain/vaults.ts:160


getWrappedCurrency

getWrappedCurrency(): Currency

Returns

Currency

The wrapped currency issued by the vaults

Defined in

src/parachain/vaults.ts:312


getWrappedReward

getWrappedReward(vaultAccountId, vaultCollateral, rewardCurrency): Promise<MonetaryAmount<Currency>>

Parameters

Name Type Description
vaultAccountId AccountId The vault ID whose reward pool to check
vaultCollateral CollateralCurrencyExt Collateral used by the vault
rewardCurrency Currency The fee reward currency

Returns

Promise<MonetaryAmount<Currency>>

The total reward collected by the vault

Defined in

src/parachain/vaults.ts:332


isVaultFlaggedForTheft

isVaultFlaggedForTheft(vaultId, btcTxId): Promise<boolean>

Parameters

Name Type Description
vaultId InterbtcPrimitivesVaultId The vault ID
btcTxId string ID of the Bitcoin transaction to check

Returns

Promise<boolean>

A bollean value

Defined in

src/parachain/vaults.ts:166


list

list(atBlock?): Promise<VaultExt[]>

Parameters

Name Type
atBlock? BlockHash

Returns

Promise<VaultExt[]>

An array containing the vaults with non-zero backing collateral

Defined in

src/parachain/vaults.ts:52


registerNewCollateralVault

registerNewCollateralVault(collateralAmount): ExtrinsicData

Registers a new vault for the current account ID with a new collateral amount. Only applicable if the connected account ID already has a running vault with a different collateral currency.

Rejects with an Error if unable to register.

Parameters

Name Type Description
collateralAmount MonetaryAmount<CollateralCurrencyExt> The collateral amount to register the vault with - in the new collateral currency

Returns

ExtrinsicData

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Defined in

src/parachain/vaults.ts:402


selectRandomVaultIssue

selectRandomVaultIssue(amount): Promise<InterbtcPrimitivesVaultId>

Parameters

Name Type Description
amount MonetaryAmount<Currency> Wrapped tokens amount to issue

Returns

Promise<InterbtcPrimitivesVaultId>

A vault that has sufficient collateral to issue the given amount

Defined in

src/parachain/vaults.ts:142


selectRandomVaultRedeem

selectRandomVaultRedeem(amount): Promise<InterbtcPrimitivesVaultId>

Parameters

Name Type Description
amount MonetaryAmount<Currency> Wrapped tokens amount to redeem

Returns

Promise<InterbtcPrimitivesVaultId>

A vault that has issued sufficient wrapped tokens to redeem the given amount

Defined in

src/parachain/vaults.ts:147


toggleIssueRequests

toggleIssueRequests(vaultId, acceptNewIssues): Promise<ExtrinsicData>

Enables or disables issue requests for given vault

Parameters

Name Type Description
vaultId InterbtcPrimitivesVaultId The vault ID whose issuing will be toggled
acceptNewIssues boolean Boolean denoting whether issuing should be enabled or not

Returns

Promise<ExtrinsicData>

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Defined in

src/parachain/vaults.ts:367


withdrawAllCollateral

withdrawAllCollateral(collateralCurrency): Promise<ExtrinsicData>

Parameters

Name Type Description
collateralCurrency CollateralCurrencyExt The collateral currency for which to withdraw all

Returns

Promise<ExtrinsicData>

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Defined in

src/parachain/vaults.ts:244


withdrawCollateral

withdrawCollateral(amount): Promise<ExtrinsicData>

Parameters

Name Type Description
amount MonetaryAmount<CollateralCurrencyExt> The amount of collateral to withdraw

Returns

Promise<ExtrinsicData>

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Defined in

src/parachain/vaults.ts:228