interbtc-api

@interlay/interbtc-api / Exports / DefaultRedeemAPI

Class: DefaultRedeemAPI

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new DefaultRedeemAPI(api, btcNetwork, electrsAPI, wrappedCurrency, vaultsAPI, oracleAPI, transactionAPI, systemAPI): DefaultRedeemAPI

Parameters

Name Type
api ApiPromise
btcNetwork Network
electrsAPI ElectrsAPI
wrappedCurrency Currency
vaultsAPI VaultsAPI
oracleAPI OracleAPI
transactionAPI TransactionAPI
systemAPI SystemAPI

Returns

DefaultRedeemAPI

Defined in

src/parachain/redeem.ts:218

Properties

api

Private api: ApiPromise

Defined in

src/parachain/redeem.ts:219


btcNetwork

Private btcNetwork: Network

Defined in

src/parachain/redeem.ts:220


electrsAPI

Private electrsAPI: ElectrsAPI

Defined in

src/parachain/redeem.ts:221


oracleAPI

Private oracleAPI: OracleAPI

Defined in

src/parachain/redeem.ts:224


systemAPI

Private systemAPI: SystemAPI

Defined in

src/parachain/redeem.ts:226


transactionAPI

Private transactionAPI: TransactionAPI

Defined in

src/parachain/redeem.ts:225


vaultsAPI

Private vaultsAPI: VaultsAPI

Defined in

src/parachain/redeem.ts:223


wrappedCurrency

Private wrappedCurrency: Currency

Defined in

src/parachain/redeem.ts:222

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.

Implementation of

RedeemAPI.buildCancelRedeemExtrinsic

Defined in

src/parachain/redeem.ts:292


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.

Implementation of

RedeemAPI.buildExecuteRedeemExtrinsic

Defined in

src/parachain/redeem.ts:278


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.

Implementation of

RedeemAPI.buildLiquidationRedeemExtrinsic

Defined in

src/parachain/redeem.ts:305


buildRequestRedeemExtrinsic

buildRequestRedeemExtrinsic(vaultId, amount, btcAddressEnc): 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
btcAddressEnc string Bitcoin transaction ID

Returns

SubmittableExtrinsic<"promise", ISubmittableResult>

A request redeem submittable extrinsic.

Implementation of

RedeemAPI.buildRequestRedeemExtrinsic

Defined in

src/parachain/redeem.ts:253


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.

Implementation of

RedeemAPI.burn

Defined in

src/parachain/redeem.ts:314


cancel

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

Parameters

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

Returns

ExtrinsicData

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

Implementation of

RedeemAPI.cancel

Defined in

src/parachain/redeem.ts:300


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.

Implementation of

RedeemAPI.execute

Defined in

src/parachain/redeem.ts:287


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

Implementation of

RedeemAPI.getBurnExchangeRate

Defined in

src/parachain/redeem.ts:350


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

Implementation of

RedeemAPI.getCurrentInclusionFee

Defined in

src/parachain/redeem.ts:365


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

Implementation of

RedeemAPI.getDustValue

Defined in

src/parachain/redeem.ts:412


getFeeRate

getFeeRate(): Promise<Big>

Returns

Promise<Big>

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

Implementation of

RedeemAPI.getFeeRate

Defined in

src/parachain/redeem.ts:407


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

Implementation of

RedeemAPI.getFeesToPay

Defined in

src/parachain/redeem.ts:402


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

Implementation of

RedeemAPI.getMaxBurnableTokens

Defined in

src/parachain/redeem.ts:330


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.

Implementation of

RedeemAPI.getPremiumRedeemFeeRate

Defined in

src/parachain/redeem.ts:417


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.

Implementation of

RedeemAPI.getRedeemPeriod

Defined in

src/parachain/redeem.ts:325


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

Implementation of

RedeemAPI.getRequestById

Defined in

src/parachain/redeem.ts:422


getRequestsByIds

getRequestsByIds(redeemIds): Promise<Redeem[]>

Parameters

Name Type
redeemIds (string | H256)[]

Returns

Promise<Redeem[]>

Implementation of

RedeemAPI.getRequestsByIds

Defined in

src/parachain/redeem.ts:427


list

list(): Promise<Redeem[]>

Returns

Promise<Redeem[]>

An array containing the redeem requests

Implementation of

RedeemAPI.list

Defined in

src/parachain/redeem.ts:374


request

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

Create a redeem request transaction

Parameters

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.

Returns

Promise<ExtrinsicData>

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

Implementation of

RedeemAPI.request

Defined in

src/parachain/redeem.ts:229


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

Implementation of

RedeemAPI.requestAdvanced

Defined in

src/parachain/redeem.ts:266


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

Implementation of

RedeemAPI.setRedeemPeriod

Defined in

src/parachain/redeem.ts:319