@interlay/interbtc-api / Exports / VaultsAPI
▸ buildAcceptNewIssuesExtrinsic(collateralCurrency
, acceptNewIssues
): SubmittableExtrinsic
<"promise"
, ISubmittableResult
>
Build accept new issues extrinsic without sending it.
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 |
SubmittableExtrinsic
<"promise"
, ISubmittableResult
>
An accept new issues submittable extrinsic.
▸ buildDepositCollateralExtrinsic(amount
): SubmittableExtrinsic
<"promise"
, ISubmittableResult
>
Build deposit collateral extrinsic (transaction) without sending it.
Name | Type | Description |
---|---|---|
amount |
MonetaryAmount <CollateralCurrencyExt > |
The amount of extra collateral to lock |
SubmittableExtrinsic
<"promise"
, ISubmittableResult
>
A deposit collateral submittable extrinsic.
▸ 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.
Name | Type | Description |
---|---|---|
publicKey |
string |
The BTC public key of the vault to derive deposit keys with the On-Chain Key Derivation Scheme. |
SubmittableExtrinsic
<"promise"
, ISubmittableResult
>
A register vault submittable extrinsic.
▸ buildRegisterVaultExtrinsic(collateralAmount
): SubmittableExtrinsic
<"promise"
, ISubmittableResult
>
Build extrinsic to register a new vault.
Name | Type | Description |
---|---|---|
collateralAmount |
MonetaryAmount <CollateralCurrencyExt > |
The collateral amount to register the vault with - in the new collateral currency. |
SubmittableExtrinsic
<"promise"
, ISubmittableResult
>
A register vault submittable extrinsic.
▸ buildWithdrawAllCollateralExtrinsic(collateralCurrency
): Promise
<SubmittableExtrinsic
<"promise"
, ISubmittableResult
>>
Build withdraw collateral extrinsic (transaction) without sending it.
Name | Type | Description |
---|---|---|
collateralCurrency |
CollateralCurrencyExt |
The collateral currency for which to withdraw all |
Promise
<SubmittableExtrinsic
<"promise"
, ISubmittableResult
>>
A withdraw collateral submittable extrinsic as promise.
▸ buildWithdrawCollateralExtrinsic(amount
): Promise
<SubmittableExtrinsic
<"promise"
, ISubmittableResult
>>
Build withdraw collateral extrinsic (transaction) without sending it.
Name | Type | Description |
---|---|---|
amount |
MonetaryAmount <CollateralCurrencyExt > |
The amount of collateral to withdraw |
Promise
<SubmittableExtrinsic
<"promise"
, ISubmittableResult
>>
A withdraw collateral submittable extrinsic as promise.
▸ calculateCapacity(collateral
): Promise
<MonetaryAmount
<Currency
>>
Name | Type | Description |
---|---|---|
collateral |
MonetaryAmount <CollateralCurrencyExt > |
Amount of collateral to calculate issuable capacity for |
Promise
<MonetaryAmount
<Currency
>>
Issuable amount by the vault, given the collateral amount
▸ computeBackingCollateral(vaultId
, nonce?
): Promise
<MonetaryAmount
<CollateralCurrencyExt
>>
Name | Type | Description |
---|---|---|
vaultId |
InterbtcPrimitivesVaultId |
Vault ID object |
nonce? |
number |
Nonce of the staking pool |
Promise
<MonetaryAmount
<CollateralCurrencyExt
>>
The entire collateral backing a vault’s issued tokens.
▸ computeReward(vaultAccountId
, collateralCurrency
, rewardCurrency
): Promise
<MonetaryAmount
<Currency
>>
Compute the total reward, including the staking (local) pool and the rewards (global) pool
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 |
Promise
<MonetaryAmount
<Currency
>>
A Monetary.js amount object, representing the total reward in the given currency
▸ depositCollateral(amount
): ExtrinsicData
Name | Type | Description |
---|---|---|
amount |
MonetaryAmount <CollateralCurrencyExt > |
The amount of extra collateral to lock |
A submittable extrinsic and an event that is emitted when extrinsic is submitted.
▸ get(vaultAccountId
, collateralCurrency
): Promise
<VaultExt
>
Get a vault by account ID and collateral currency. Rejects if no vault exists.
Name | Type | Description |
---|---|---|
vaultAccountId |
AccountId |
The ID of the vault to fetch |
collateralCurrency |
CollateralCurrencyExt |
Collateral used by vault |
Promise
<VaultExt
>
A vault object, rejects if no vault with the given ID and currency pair exists
▸ 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.
Name | Type | Description |
---|---|---|
vaultAccountId |
AccountId |
The vault account ID |
collateralCurrency |
CollateralCurrencyExt |
The currency specification, a Monetary.js object or ForeignAsset |
Promise
<Big
>
the APY as a percentage string
Note
this does not account for interest compounding
▸ getBlockRewardAPY(vaultAccountId
, collateralCurrency
): Promise
<Big
>
Gets the estimated APY for just the block rewards (in governance tokens).
Name | Type |
---|---|
vaultAccountId |
AccountId |
collateralCurrency |
CollateralCurrencyExt |
Promise
<Big
>
the APY as a percentage
▸ getCollateral(vaultId
, collateralCurrency
): Promise
<MonetaryAmount
<CollateralCurrencyExt
>>
Name | Type | Description |
---|---|---|
vaultId |
AccountId |
- |
collateralCurrency |
CollateralCurrencyExt |
The currency specification, a Monetary.js object or ForeignAsset |
Promise
<MonetaryAmount
<CollateralCurrencyExt
>>
The collateral of a vault, taking slashes into account.
▸ 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.
Name | Type | Description |
---|---|---|
vaultAccountId |
AccountId |
The vault’s account ID |
collateralCurrency |
CollateralCurrencyExt |
The collateral currency for the vault with the account id above |
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.
▸ getGovernanceReward(vaultAccountId
, vaultCollateral
, governanceCurrency
): Promise
<MonetaryAmount
<Currency
>>
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 |
Promise
<MonetaryAmount
<Currency
>>
The total reward collected by the vault
▸ getIssuableTokensFromVault(vaultAccountId
, collateralCurrency
): Promise
<MonetaryAmount
<Currency
>>
Returns issuable amount for a given vault
Name | Type | Description |
---|---|---|
vaultAccountId |
AccountId |
The vault account ID |
collateralCurrency |
CollateralCurrencyExt |
The currency specification, a Monetary.js object or ForeignAsset |
Promise
<MonetaryAmount
<Currency
>>
The issuable amount of a vault
▸ getIssuedAmount(vaultAccountId
, collateralCurrency
): Promise
<MonetaryAmount
<Currency
>>
Name | Type | Description |
---|---|---|
vaultAccountId |
AccountId |
The vault account ID |
collateralCurrency |
CollateralCurrencyExt |
The currency specification, a Monetary.js object or `ForeignAsset |
Promise
<MonetaryAmount
<Currency
>>
The amount of wrapped tokens issued by the given vault
▸ getLiquidationCollateralThreshold(collateralCurrency
): Promise
<Big
>
Name | Type |
---|---|
collateralCurrency |
CollateralCurrencyExt |
Promise
<Big
>
The lower bound for vault collateralization. If a Vault’s collateral rate drops below this, automatic liquidation (forced Redeem) is triggered.
▸ getLiquidationVault(collateralCurrency
): Promise
<SystemVaultExt
>
Name | Type |
---|---|
collateralCurrency |
CollateralCurrencyExt |
Promise
<SystemVaultExt
>
A vault object representing the liquidation vault
▸ getMaxNominationRatio(collateralCurrency
): Promise
<Big
>
Name | Type | Description |
---|---|---|
collateralCurrency |
CollateralCurrencyExt |
The collateral currency specification, a Monetary.js object or ForeignAsset |
Promise
<Big
>
The maximum collateral a vault can accept as nomination, as a ratio of its own collateral
▸ getMinimumCollateral(collateralCurrency
): Promise
<MonetaryAmount
<CollateralCurrencyExt
>>
Get the minimum secured collateral amount required to activate a vault
Name | Type | Description |
---|---|---|
collateralCurrency |
CollateralCurrencyExt |
The currency specification, a Monetary.js object or ForeignAsset |
Promise
<MonetaryAmount
<CollateralCurrencyExt
>>
the minimum collateral to register a vault
▸ 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.
Name | Type | Description |
---|---|---|
vaultAccountId |
AccountId |
The ID of the vault to fetch |
collateralCurrency |
CollateralCurrencyExt |
Collateral used by vault |
Promise
<null
| VaultExt
>
A vault object, or null if no vault with the given ID and currency pair exists
▸ getPremiumRedeemThreshold(collateralCurrency
): Promise
<Big
>
Name | Type |
---|---|
collateralCurrency |
CollateralCurrencyExt |
Promise
<Big
>
The collateral rate at which users receive a premium allocated from the Vault’s collateral, when performing a redeem with this Vault.
▸ getPremiumRedeemVaults(): Promise
<Map
<InterbtcPrimitivesVaultId
, MonetaryAmount
<Currency
>>>
Promise
<Map
<InterbtcPrimitivesVaultId
, MonetaryAmount
<Currency
>>>
Vaults below the premium redeem threshold, sorted in descending order of their redeemable tokens
▸ getPunishmentFee(): Promise
<Big
>
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.
▸ 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
Name | Type | Description |
---|---|---|
vaultAccountId |
AccountId |
The vault account ID |
collateralCurrency |
CollateralCurrencyExt |
The currency specification, a Monetary.js object or ForeignAsset |
Promise
<MonetaryAmount
<CollateralCurrencyExt
>>
The required collateral the vault needs to deposit to stay above the threshold limit
▸ getSecureCollateralThreshold(collateralCurrency
): Promise
<Big
>
Get the global secure collateral threshold.
Name | Type |
---|---|
collateralCurrency |
CollateralCurrencyExt |
Promise
<Big
>
The global over-collateralization rate for collateral locked by Vaults, necessary for issuing wrapped tokens
▸ getStakingCapacity(vaultAccountId
, collateralCurrency
): Promise
<MonetaryAmount
<CollateralCurrencyExt
>>
Name | Type | Description |
---|---|---|
vaultAccountId |
AccountId |
The vault account ID |
collateralCurrency |
CollateralCurrencyExt |
The currency specification, a Monetary.js object or ForeignAsset |
Promise
<MonetaryAmount
<CollateralCurrencyExt
>>
Staking capacity, as a collateral currency (e.g. DOT)
▸ getTotalIssuableAmount(): Promise
<MonetaryAmount
<Currency
>>
Promise
<MonetaryAmount
<Currency
>>
The total amount of wrapped tokens that can be issued, considering the collateral locked by the vaults
▸ getTotalIssuedAmount(): Promise
<MonetaryAmount
<Currency
>>
Promise
<MonetaryAmount
<Currency
>>
The total amount of wrapped tokens issued by the vaults
▸ 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.
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 |
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.
▸ getVaultsWithIssuableTokens(): Promise
<Map
<InterbtcPrimitivesVaultId
, MonetaryAmount
<Currency
>>>
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.
▸ getVaultsWithRedeemableTokens(): Promise
<Map
<InterbtcPrimitivesVaultId
, MonetaryAmount
<Currency
>>>
Promise
<Map
<InterbtcPrimitivesVaultId
, MonetaryAmount
<Currency
>>>
Vaults with redeemable tokens, sorted in descending order.
▸ getWrappedCurrency(): Currency
Currency
The wrapped currency issued by the vaults
▸ getWrappedReward(vaultAccountId
, vaultCollateral
, rewardCurrency
): Promise
<MonetaryAmount
<Currency
>>
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 |
Promise
<MonetaryAmount
<Currency
>>
The total reward collected by the vault
▸ isVaultFlaggedForTheft(vaultId
, btcTxId
): Promise
<boolean
>
Name | Type | Description |
---|---|---|
vaultId |
InterbtcPrimitivesVaultId |
The vault ID |
btcTxId |
string |
ID of the Bitcoin transaction to check |
Promise
<boolean
>
A bollean value
▸ list(atBlock?
): Promise
<VaultExt
[]>
Name | Type |
---|---|
atBlock? |
BlockHash |
Promise
<VaultExt
[]>
An array containing the vaults with non-zero backing collateral
▸ 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.
Name | Type | Description |
---|---|---|
collateralAmount |
MonetaryAmount <CollateralCurrencyExt > |
The collateral amount to register the vault with - in the new collateral currency |
A submittable extrinsic and an event that is emitted when extrinsic is submitted.
▸ selectRandomVaultIssue(amount
): Promise
<InterbtcPrimitivesVaultId
>
Name | Type | Description |
---|---|---|
amount |
MonetaryAmount <Currency > |
Wrapped tokens amount to issue |
Promise
<InterbtcPrimitivesVaultId
>
A vault that has sufficient collateral to issue the given amount
▸ selectRandomVaultRedeem(amount
): Promise
<InterbtcPrimitivesVaultId
>
Name | Type | Description |
---|---|---|
amount |
MonetaryAmount <Currency > |
Wrapped tokens amount to redeem |
Promise
<InterbtcPrimitivesVaultId
>
A vault that has issued sufficient wrapped tokens to redeem the given amount
▸ toggleIssueRequests(vaultId
, acceptNewIssues
): Promise
<ExtrinsicData
>
Enables or disables issue requests for given vault
Name | Type | Description |
---|---|---|
vaultId |
InterbtcPrimitivesVaultId |
The vault ID whose issuing will be toggled |
acceptNewIssues |
boolean |
Boolean denoting whether issuing should be enabled or not |
Promise
<ExtrinsicData
>
A submittable extrinsic and an event that is emitted when extrinsic is submitted.
▸ withdrawAllCollateral(collateralCurrency
): Promise
<ExtrinsicData
>
Name | Type | Description |
---|---|---|
collateralCurrency |
CollateralCurrencyExt |
The collateral currency for which to withdraw all |
Promise
<ExtrinsicData
>
A submittable extrinsic and an event that is emitted when extrinsic is submitted.
▸ withdrawCollateral(amount
): Promise
<ExtrinsicData
>
Name | Type | Description |
---|---|---|
amount |
MonetaryAmount <CollateralCurrencyExt > |
The amount of collateral to withdraw |
Promise
<ExtrinsicData
>
A submittable extrinsic and an event that is emitted when extrinsic is submitted.