interbtc-api

@interlay/interbtc-api / Exports / DefaultReplaceAPI

Class: DefaultReplaceAPI

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new DefaultReplaceAPI(api, btcNetwork, electrsAPI, wrappedCurrency): DefaultReplaceAPI

Parameters

Name Type
api ApiPromise
btcNetwork Network
electrsAPI ElectrsAPI
wrappedCurrency Currency

Returns

DefaultReplaceAPI

Defined in

src/parachain/replace.ts:154

Properties

api

Private api: ApiPromise

Defined in

src/parachain/replace.ts:155


btcNetwork

Private btcNetwork: Network

Defined in

src/parachain/replace.ts:156


electrsAPI

Private electrsAPI: ElectrsAPI

Defined in

src/parachain/replace.ts:157


wrappedCurrency

Private wrappedCurrency: Currency

Defined in

src/parachain/replace.ts:158

Methods

accept

accept(oldVault, amount, collateral, btcAddress): ExtrinsicData

Accept a replace request

Parameters

Name Type Description
oldVault AccountId ID of the old vault that to be (possibly partially) replaced
amount MonetaryAmount<Currency> Amount of issued tokens to be replaced
collateral MonetaryAmount<CollateralCurrencyExt> The collateral for replacement
btcAddress string The address that old-vault should transfer the btc to

Returns

ExtrinsicData

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

Implementation of

ReplaceAPI.accept

Defined in

src/parachain/replace.ts:209


buildAcceptReplaceExtrinsic

buildAcceptReplaceExtrinsic(oldVault, amount, collateral, btcAddress): SubmittableExtrinsic<"promise", ISubmittableResult>

Build an accept replace extrinsic (transaction) without sending it.

Parameters

Name Type Description
oldVault AccountId account ID of the old vault that to be (possibly partially) replaced
amount MonetaryAmount<Currency> Amount of issued tokens to be replaced
collateral MonetaryAmount<CollateralCurrencyExt> The collateral for replacement
btcAddress string The address that old-vault should transfer the btc to

Returns

SubmittableExtrinsic<"promise", ISubmittableResult>

An accept replace submittable extrinsic.

Implementation of

ReplaceAPI.buildAcceptReplaceExtrinsic

Defined in

src/parachain/replace.ts:190


buildExecuteReplaceExtrinsic

buildExecuteReplaceExtrinsic(requestId, btcTxId): Promise<SubmittableExtrinsic<"promise", ISubmittableResult>>

Build an execute replace extrinsic (transaction) without sending it.

Parameters

Name Type Description
requestId string The ID generated by the replace request transaction
btcTxId string Bitcoin transaction ID

Returns

Promise<SubmittableExtrinsic<"promise", ISubmittableResult>>

An execute replace submittable extrinsic.

Implementation of

ReplaceAPI.buildExecuteReplaceExtrinsic

Defined in

src/parachain/replace.ts:219


buildRequestReplaceExtrinsic

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

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

Parameters

Name Type Description
amount MonetaryAmount<Currency> Wrapped token amount to replace.
collateralCurrency CollateralCurrencyExt Collateral currency to have replaced

Returns

SubmittableExtrinsic<"promise", ISubmittableResult>

A request replace submittable extrinsic.

Implementation of

ReplaceAPI.buildRequestReplaceExtrinsic

Defined in

src/parachain/replace.ts:161


buildWithdrawReplaceExtrinsic

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

Build a withdraw replace extrinsic (transaction) without sending it.

Parameters

Name Type Description
amount MonetaryAmount<Currency> The amount of wrapped tokens to withdraw from the amount requested to have replaced.
collateralCurrency CollateralCurrencyExt Collateral currency to have replaced

Returns

SubmittableExtrinsic<"promise", ISubmittableResult>

A withdraw replace submittable extrinsic.

Implementation of

ReplaceAPI.buildWithdrawReplaceExtrinsic

Defined in

src/parachain/replace.ts:176


execute

execute(requestId, btcTxId): Promise<ExtrinsicData>

Execute a replace request

Parameters

Name Type Description
requestId string The ID generated by the replace request transaction
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

ReplaceAPI.execute

Defined in

src/parachain/replace.ts:228


getDustValue

getDustValue(): Promise<MonetaryAmount<Currency>>

Returns

Promise<MonetaryAmount<Currency>>

The minimum amount of btc that is accepted for replace requests; any lower values would risk the bitcoin client to reject the payment

Implementation of

ReplaceAPI.getDustValue

Defined in

src/parachain/replace.ts:233


getNewVaultReplaceRequests

getNewVaultReplaceRequests(vaultAccountId): Promise<ReplaceRequestExt[]>

Parameters

Name Type
vaultAccountId AccountId

Returns

Promise<ReplaceRequestExt[]>

Defined in

src/parachain/replace.ts:326


getOldVaultReplaceRequests

getOldVaultReplaceRequests(vaultAccountId): Promise<ReplaceRequestExt[]>

Parameters

Name Type
vaultAccountId AccountId

Returns

Promise<ReplaceRequestExt[]>

Defined in

src/parachain/replace.ts:320


getReplacePeriod

getReplacePeriod(): Promise<BlockNumber>

Returns

Promise<BlockNumber>

The time difference in number of blocks between when a replace request is created and required completion time by a vault. The replace period has an upper limit to prevent griefing of vault collateral.

Implementation of

ReplaceAPI.getReplacePeriod

Defined in

src/parachain/replace.ts:238


getRequestById

getRequestById(replaceId, atBlock?): Promise<ReplaceRequestExt>

Parameters

Name Type Description
replaceId string | H256 The ID of the replace request to fetch
atBlock? BlockHash -

Returns

Promise<ReplaceRequestExt>

A replace request object

Implementation of

ReplaceAPI.getRequestById

Defined in

src/parachain/replace.ts:291


list

list(): Promise<ReplaceRequestExt[]>

Returns

Promise<ReplaceRequestExt[]>

An array containing the replace requests

Implementation of

ReplaceAPI.list

Defined in

src/parachain/replace.ts:242


map

map(): Promise<Map<H256, ReplaceRequestExt>>

Returns

Promise<Map<H256, ReplaceRequestExt>>

A mapping from the replace request ID to the replace request object

Implementation of

ReplaceAPI.map

Defined in

src/parachain/replace.ts:262


mapReplaceRequests

mapReplaceRequests(vaultAccountId): Promise<ReplaceRequestExt[]>

Fetch the replace requests associated with a vault. In the returned requests, the vault is either the replaced or the replacing one.

Parameters

Name Type Description
vaultAccountId AccountId The AccountId of the vault used to filter replace requests

Returns

Promise<ReplaceRequestExt[]>

An array with replace requests involving said vault

Implementation of

ReplaceAPI.mapReplaceRequests

Defined in

src/parachain/replace.ts:308


parseRequestsAsync

parseRequestsAsync(requestPairs): Promise<[H256, ReplaceRequestExt][]>

Parameters

Name Type
requestPairs [H256, InterbtcPrimitivesReplaceReplaceRequest][]

Returns

Promise<[H256, ReplaceRequestExt][]>

Defined in

src/parachain/replace.ts:332


request

request(amount, collateralCurrency): ExtrinsicData

Parameters

Name Type Description
amount MonetaryAmount<Currency> Amount issued, denoted in Bitcoin, to have replaced by another vault
collateralCurrency CollateralCurrencyExt Collateral currency to have replaced

Returns

ExtrinsicData

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

Implementation of

ReplaceAPI.request

Defined in

src/parachain/replace.ts:171


withdraw

withdraw(amount, collateralCurrency): ExtrinsicData

Wihdraw a replace request

Parameters

Name Type Description
amount MonetaryAmount<Currency> The amount of wrapped tokens to withdraw from the amount requested to have replaced.
collateralCurrency CollateralCurrencyExt Collateral currency of the request

Returns

ExtrinsicData

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

Implementation of

ReplaceAPI.withdraw

Defined in

src/parachain/replace.ts:185