@interlay/interbtc-api / Exports / DefaultRedeemAPI
• new DefaultRedeemAPI(api, btcNetwork, electrsAPI, wrappedCurrency, vaultsAPI, oracleAPI, transactionAPI, systemAPI): DefaultRedeemAPI
| Name | Type |
|---|---|
api |
ApiPromise |
btcNetwork |
Network |
electrsAPI |
ElectrsAPI |
wrappedCurrency |
Currency |
vaultsAPI |
VaultsAPI |
oracleAPI |
OracleAPI |
transactionAPI |
TransactionAPI |
systemAPI |
SystemAPI |
• Private api: ApiPromise
• Private btcNetwork: Network
• Private electrsAPI: ElectrsAPI
• Private oracleAPI: OracleAPI
• Private systemAPI: SystemAPI
• Private transactionAPI: TransactionAPI
• Private vaultsAPI: VaultsAPI
• Private wrappedCurrency: Currency
▸ buildCancelRedeemExtrinsic(redeemId, reimburse): SubmittableExtrinsic<"promise", ISubmittableResult>
Build a cancel redeem extrinsic (transaction) without sending it.
| Name | Type | Description |
|---|---|---|
redeemId |
string |
The ID returned by the redeem request transaction |
reimburse |
boolean |
In case of redeem failure: - false = retry redeeming, with a different Vault - true = accept reimbursement in wrapped token |
SubmittableExtrinsic<"promise", ISubmittableResult>
A cancel redeem submittable extrinsic.
RedeemAPI.buildCancelRedeemExtrinsic
▸ buildExecuteRedeemExtrinsic(redeemId, btcTxId): Promise<SubmittableExtrinsic<"promise", ISubmittableResult>>
Build a redeem execution extrinsic (transaction) without sending it.
| Name | Type | Description |
|---|---|---|
redeemId |
string |
The ID returned by the issue request transaction |
btcTxId |
string |
Bitcoin transaction ID |
Promise<SubmittableExtrinsic<"promise", ISubmittableResult>>
An execute redeem submittable extrinsic.
RedeemAPI.buildExecuteRedeemExtrinsic
▸ buildLiquidationRedeemExtrinsic(amount, collateralCurrency): SubmittableExtrinsic<"promise", ISubmittableResult>
Build liquidation redeem extrinsic (without sending it) to burn wrapped tokens for a premium
| Name | Type | Description |
|---|---|---|
amount |
MonetaryAmount<Currency> |
The amount of wrapped tokens to burn |
collateralCurrency |
CollateralCurrencyExt |
Liquidated collateral currency to use when burning wrapped tokens |
SubmittableExtrinsic<"promise", ISubmittableResult>
A liquidation redeem submittable extrinsic.
RedeemAPI.buildLiquidationRedeemExtrinsic
▸ buildRequestRedeemExtrinsic(vaultId, amount, btcAddressEnc): SubmittableExtrinsic<"promise", ISubmittableResult>
Build a request redeem extrinsic (transaction) without sending it.
| Name | Type | Description |
|---|---|---|
vaultId |
InterbtcPrimitivesVaultId |
ID of the vault to redeem with. |
amount |
MonetaryAmount<Currency> |
Wrapped token amount to redeem |
btcAddressEnc |
string |
Bitcoin transaction ID |
SubmittableExtrinsic<"promise", ISubmittableResult>
A request redeem submittable extrinsic.
RedeemAPI.buildRequestRedeemExtrinsic
▸ burn(amount, collateralCurrency): ExtrinsicData
Burn wrapped tokens for a premium
| Name | Type | Description |
|---|---|---|
amount |
MonetaryAmount<Currency> |
The amount of wrapped tokens to burn |
collateralCurrency |
CollateralCurrencyExt |
Liquidated collateral currency to use when burning wrapped tokens |
A submittable extrinsic and an event that is emitted when extrinsic is submitted.
▸ cancel(requestId, reimburse?): ExtrinsicData
Send a redeem cancellation transaction. After the redeem period has elapsed, the redeemal request can be cancelled. As a result, the griefing collateral of the vault will be slashed and sent to the redeemer
| Name | Type | Default value | Description |
|---|---|---|---|
requestId |
string |
undefined |
The ID returned by the redeem request transaction |
reimburse |
boolean |
false |
(Optional) In case of redeem failure: - (Default) false = retry redeeming, with a different Vault - true = accept reimbursement in wrapped token |
A submittable extrinsic and an event that is emitted when extrinsic is submitted.
▸ execute(requestId, btcTxId): Promise<ExtrinsicData>
Send a redeem execution transaction
| Name | Type | Description |
|---|---|---|
requestId |
string |
- |
btcTxId |
string |
Bitcoin transaction ID |
Promise<ExtrinsicData>
A submittable extrinsic and an event that is emitted when extrinsic is submitted.
Remarks
If txId is not set, the merkleProof and rawTx must both be set.
▸ getBurnExchangeRate(collateralCurrency): Promise<ExchangeRate<Currency, CollateralCurrencyExt>>
| Name | Type | Description |
|---|---|---|
collateralCurrency |
CollateralCurrencyExt |
Currency whose exchange rate with BTC to fetch |
Promise<ExchangeRate<Currency, CollateralCurrencyExt>>
The exchange rate (collateral currency to wrapped token currency) used when burning tokens
▸ getCurrentInclusionFee(): Promise<MonetaryAmount<Currency>>
Promise<MonetaryAmount<Currency>>
The current inclusion fee based on the expected number of bytes in the transaction, and the inclusion fee rate reported by the oracle
RedeemAPI.getCurrentInclusionFee
▸ getDustValue(): Promise<MonetaryAmount<Currency>>
Promise<MonetaryAmount<Currency>>
The minimum amount of wrapped tokens that is accepted for redeem requests; any lower values would risk the bitcoin client to reject the payment
▸ getFeeRate(): Promise<Big>
Promise<Big>
The fee charged for redeeming. For instance, “0.005” stands for 0.5%
▸ getFeesToPay(amount): Promise<MonetaryAmount<Currency>>
| Name | Type | Description |
|---|---|---|
amount |
MonetaryAmount<Currency> |
The amount of wrapped tokens for which to compute the redeem fees |
Promise<MonetaryAmount<Currency>>
The fees
▸ getMaxBurnableTokens(collateralCurrency): Promise<MonetaryAmount<Currency>>
| Name | Type | Description |
|---|---|---|
collateralCurrency |
CollateralCurrencyExt |
Liquidated collateral currency to use when burning wrapped tokens |
Promise<MonetaryAmount<Currency>>
The maximum amount of tokens that can be burned through a liquidation redeem
RedeemAPI.getMaxBurnableTokens
▸ getPremiumRedeemFeeRate(): Promise<Big>
Promise<Big>
If users execute a redeem with a Vault flagged for premium redeem, they can earn a premium, slashed from the Vault’s collateral. This value is a percentage of the redeemed amount.
RedeemAPI.getPremiumRedeemFeeRate
▸ getRedeemPeriod(): Promise<number>
Promise<number>
The time difference in number of blocks between a redeem request is created and required completion time by a vault. The redeem period has an upper limit to ensure the user gets their BTC in time and to potentially punish a vault for inactivity or stealing BTC.
▸ getRequestById(redeemId): Promise<Redeem>
| Name | Type | Description |
|---|---|---|
redeemId |
string | H256 |
The ID of the redeem request to fetch |
Promise<Redeem>
A redeem request object
▸ getRequestsByIds(redeemIds): Promise<Redeem[]>
| Name | Type |
|---|---|
redeemIds |
(string | H256)[] |
Promise<Redeem[]>
▸ list(): Promise<Redeem[]>
Promise<Redeem[]>
An array containing the redeem requests
▸ request(amount, btcAddressEnc, vaultId?, atomic?, cachedVaults?): Promise<ExtrinsicData>
Create a redeem request transaction
| Name | Type | Default value | Description |
|---|---|---|---|
amount |
MonetaryAmount<Currency> |
undefined |
Wrapped token amount to redeem |
btcAddressEnc |
string |
undefined |
Bitcoin address where the redeemed BTC should be sent |
vaultId? |
InterbtcPrimitivesVaultId |
undefined |
(optional) ID of the vault to redeem with. |
atomic |
boolean |
true |
(optional) Whether the request should be handled atomically or not. Only makes a difference if more than one vault is needed to fulfil it. Defaults to false. |
cachedVaults? |
Map<InterbtcPrimitivesVaultId, MonetaryAmount<Currency>> |
undefined |
(optional) A list of all vaults usable for redeem. If not provided, will fetch from the parachain. |
Promise<ExtrinsicData>
A submittable extrinsic and an event that is emitted when extrinsic is submitted.
▸ requestAdvanced(amountsPerVault, btcAddressEnc, atomic): ExtrinsicData
Create a batch of aggregated redeem transactions (to one or more vaults)
| Name | Type | Description |
|---|---|---|
amountsPerVault |
Map<InterbtcPrimitivesVaultId, MonetaryAmount<Currency>> |
A mapping of vaults to redeem from, and wrapped token amounts to redeem using each vault |
btcAddressEnc |
string |
Bitcoin address where the redeemed BTC should be sent |
atomic |
boolean |
Whether the issue request should be handled atomically or not. Only makes a difference if more than one vault is needed to fulfil it. |
A submittable extrinsic and an event that is emitted when extrinsic is submitted.
Throws
Rejects the promise if none of the requests succeeded (or if at least one failed, when atomic=true).
▸ setRedeemPeriod(blocks): ExtrinsicData
| Name | Type | Description |
|---|---|---|
blocks |
number |
The time difference in number of blocks between a redeem request is created and required completion time by a vault. The redeem period has an upper limit to ensure the user gets their BTC in time and to potentially punish a vault for inactivity or stealing BTC. |
A submittable extrinsic and an event that is emitted when extrinsic is submitted.
Remarks
Testnet utility function