interbtc-api

@interlay/interbtc-api / Exports / RedeemAPI

Interface: RedeemAPI

Implemented by

Table of contents

Methods

Methods

buildCancelRedeemExtrinsic

buildCancelRedeemExtrinsic(redeemId, reimburse): SubmittableExtrinsic<"promise", ISubmittableResult>

Build a cancel redeem extrinsic (transaction) without sending it.

Parameters

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

Returns

SubmittableExtrinsic<"promise", ISubmittableResult>

A cancel redeem submittable extrinsic.

Defined in

src/parachain/redeem.ts:119


buildExecuteRedeemExtrinsic

buildExecuteRedeemExtrinsic(redeemId, btcTxId): Promise<SubmittableExtrinsic<"promise", ISubmittableResult>>

Build a redeem execution extrinsic (transaction) without sending it.

Parameters

Name Type Description
redeemId string The ID returned by the issue request transaction
btcTxId string Bitcoin transaction ID

Returns

Promise<SubmittableExtrinsic<"promise", ISubmittableResult>>

An execute redeem submittable extrinsic.

Defined in

src/parachain/redeem.ts:95


buildLiquidationRedeemExtrinsic

buildLiquidationRedeemExtrinsic(amount, collateralCurrency): SubmittableExtrinsic<"promise", ISubmittableResult>

Build liquidation redeem extrinsic (without sending it) to burn wrapped tokens for a premium

Parameters

Name Type Description
amount MonetaryAmount<Currency> The amount of wrapped tokens to burn
collateralCurrency CollateralCurrencyExt Liquidated collateral currency to use when burning wrapped tokens

Returns

SubmittableExtrinsic<"promise", ISubmittableResult>

A liquidation redeem submittable extrinsic.

Defined in

src/parachain/redeem.ts:185


buildRequestRedeemExtrinsic

buildRequestRedeemExtrinsic(vaultId, amount, btcAddress): SubmittableExtrinsic<"promise", ISubmittableResult>

Build a request redeem extrinsic (transaction) without sending it.

Parameters

Name Type Description
vaultId InterbtcPrimitivesVaultId ID of the vault to redeem with.
amount MonetaryAmount<Currency> Wrapped token amount to redeem
btcAddress string Bitcoin transaction ID

Returns

SubmittableExtrinsic<"promise", ISubmittableResult>

A request redeem submittable extrinsic.

Defined in

src/parachain/redeem.ts:50


burn

burn(amount, collateralCurrency): ExtrinsicData

Burn wrapped tokens for a premium

Parameters

Name Type Description
amount MonetaryAmount<Currency> The amount of wrapped tokens to burn
collateralCurrency CollateralCurrencyExt Liquidated collateral currency to use when burning wrapped tokens

Returns

ExtrinsicData

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

Defined in

src/parachain/redeem.ts:196


cancel

cancel(redeemId, 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

Parameters

Name Type Description
redeemId string The ID returned by the redeem request transaction
reimburse? boolean (Optional) In case of redeem failure: - (Default) false = retry redeeming, with a different Vault - true = accept reimbursement in wrapped token

Returns

ExtrinsicData

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

Defined in

src/parachain/redeem.ts:134


execute

execute(requestId, btcTxId): Promise<ExtrinsicData>

Send a redeem execution transaction

Parameters

Name Type Description
requestId string -
btcTxId string Bitcoin transaction ID

Returns

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.

Defined in

src/parachain/redeem.ts:108


getBurnExchangeRate

getBurnExchangeRate(collateralCurrency): Promise<ExchangeRate<Currency, CollateralCurrencyExt>>

Parameters

Name Type Description
collateralCurrency CollateralCurrencyExt Currency whose exchange rate with BTC to fetch

Returns

Promise<ExchangeRate<Currency, CollateralCurrencyExt>>

The exchange rate (collateral currency to wrapped token currency) used when burning tokens

Defined in

src/parachain/redeem.ts:207


getCurrentInclusionFee

getCurrentInclusionFee(): Promise<MonetaryAmount<Currency>>

Returns

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

Defined in

src/parachain/redeem.ts:214


getDustValue

getDustValue(): Promise<MonetaryAmount<Currency>>

Returns

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

Defined in

src/parachain/redeem.ts:162


getFeeRate

getFeeRate(): Promise<Big>

Returns

Promise<Big>

The fee charged for redeeming. For instance, “0.005” stands for 0.5%

Defined in

src/parachain/redeem.ts:166


getFeesToPay

getFeesToPay(amount): Promise<MonetaryAmount<Currency>>

Parameters

Name Type Description
amount MonetaryAmount<Currency> The amount of wrapped tokens for which to compute the redeem fees

Returns

Promise<MonetaryAmount<Currency>>

The fees

Defined in

src/parachain/redeem.ts:171


getMaxBurnableTokens

getMaxBurnableTokens(collateralCurrency): Promise<MonetaryAmount<Currency>>

Parameters

Name Type Description
collateralCurrency CollateralCurrencyExt Liquidated collateral currency to use when burning wrapped tokens

Returns

Promise<MonetaryAmount<Currency>>

The maximum amount of tokens that can be burned through a liquidation redeem

Defined in

src/parachain/redeem.ts:201


getPremiumRedeemFeeRate

getPremiumRedeemFeeRate(): Promise<Big>

Returns

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.

Defined in

src/parachain/redeem.ts:177


getRedeemPeriod

getRedeemPeriod(): Promise<number>

Returns

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.

Defined in

src/parachain/redeem.ts:151


getRequestById

getRequestById(redeemId): Promise<Redeem>

Parameters

Name Type Description
redeemId string | H256 The ID of the redeem request to fetch

Returns

Promise<Redeem>

A redeem request object

Defined in

src/parachain/redeem.ts:156


getRequestsByIds

getRequestsByIds(redeemIds): Promise<Redeem[]>

Parameters

Name Type
redeemIds (string | H256)[]

Returns

Promise<Redeem[]>

Defined in

src/parachain/redeem.ts:157


list

list(): Promise<Redeem[]>

Returns

Promise<Redeem[]>

An array containing the redeem requests

Defined in

src/parachain/redeem.ts:40


request

request(amount, btcAddressEnc, vaultId?, atomic?, availableVaults?): Promise<ExtrinsicData>

Create a redeem request transaction

Parameters

Name Type Description
amount MonetaryAmount<Currency> Wrapped token amount to redeem
btcAddressEnc string Bitcoin address where the redeemed BTC should be sent
vaultId? InterbtcPrimitivesVaultId (optional) ID of the vault to redeem with.
atomic? boolean (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.
availableVaults? Map<InterbtcPrimitivesVaultId, MonetaryAmount<Currency>> (optional) A list of all vaults usable for redeem. If not provided, will fetch from the parachain.

Returns

Promise<ExtrinsicData>

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

Defined in

src/parachain/redeem.ts:65


requestAdvanced

requestAdvanced(amountsPerVault, btcAddressEnc, atomic): ExtrinsicData

Create a batch of aggregated redeem transactions (to one or more vaults)

Parameters

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.

Returns

ExtrinsicData

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).

Defined in

src/parachain/redeem.ts:82


setRedeemPeriod

setRedeemPeriod(blocks): ExtrinsicData

Parameters

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.

Returns

ExtrinsicData

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

Remarks

Testnet utility function

Defined in

src/parachain/redeem.ts:143