@interlay/interbtc-api / Exports / DefaultReplaceAPI
• new DefaultReplaceAPI(api
, btcNetwork
, electrsAPI
, wrappedCurrency
): DefaultReplaceAPI
Name | Type |
---|---|
api |
ApiPromise |
btcNetwork |
Network |
electrsAPI |
ElectrsAPI |
wrappedCurrency |
Currency |
• Private
api: ApiPromise
• Private
btcNetwork: Network
• Private
electrsAPI: ElectrsAPI
• Private
wrappedCurrency: Currency
▸ accept(oldVault
, amount
, collateral
, btcAddress
): ExtrinsicData
Accept a replace request
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 |
A submittable extrinsic and an event that is emitted when extrinsic is submitted.
▸ buildAcceptReplaceExtrinsic(oldVault
, amount
, collateral
, btcAddress
): SubmittableExtrinsic
<"promise"
, ISubmittableResult
>
Build an accept replace extrinsic (transaction) without sending it.
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 |
SubmittableExtrinsic
<"promise"
, ISubmittableResult
>
An accept replace submittable extrinsic.
ReplaceAPI.buildAcceptReplaceExtrinsic
▸ buildExecuteReplaceExtrinsic(requestId
, btcTxId
): Promise
<SubmittableExtrinsic
<"promise"
, ISubmittableResult
>>
Build an execute replace extrinsic (transaction) without sending it.
Name | Type | Description |
---|---|---|
requestId |
string |
The ID generated by the replace request transaction |
btcTxId |
string |
Bitcoin transaction ID |
Promise
<SubmittableExtrinsic
<"promise"
, ISubmittableResult
>>
An execute replace submittable extrinsic.
ReplaceAPI.buildExecuteReplaceExtrinsic
▸ buildRequestReplaceExtrinsic(amount
, collateralCurrency
): SubmittableExtrinsic
<"promise"
, ISubmittableResult
>
Build a request replace extrinsic (transaction) without sending it.
Name | Type | Description |
---|---|---|
amount |
MonetaryAmount <Currency > |
Wrapped token amount to replace. |
collateralCurrency |
CollateralCurrencyExt |
Collateral currency to have replaced |
SubmittableExtrinsic
<"promise"
, ISubmittableResult
>
A request replace submittable extrinsic.
ReplaceAPI.buildRequestReplaceExtrinsic
▸ buildWithdrawReplaceExtrinsic(amount
, collateralCurrency
): SubmittableExtrinsic
<"promise"
, ISubmittableResult
>
Build a withdraw replace extrinsic (transaction) without sending it.
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 |
SubmittableExtrinsic
<"promise"
, ISubmittableResult
>
A withdraw replace submittable extrinsic.
ReplaceAPI.buildWithdrawReplaceExtrinsic
▸ execute(requestId
, btcTxId
): Promise
<ExtrinsicData
>
Execute a replace request
Name | Type | Description |
---|---|---|
requestId |
string |
The ID generated by the replace request transaction |
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.
▸ getDustValue(): Promise
<MonetaryAmount
<Currency
>>
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
▸ getNewVaultReplaceRequests(vaultAccountId
): Promise
<ReplaceRequestExt
[]>
Name | Type |
---|---|
vaultAccountId |
AccountId |
Promise
<ReplaceRequestExt
[]>
▸ getOldVaultReplaceRequests(vaultAccountId
): Promise
<ReplaceRequestExt
[]>
Name | Type |
---|---|
vaultAccountId |
AccountId |
Promise
<ReplaceRequestExt
[]>
▸ getReplacePeriod(): Promise
<BlockNumber
>
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.
▸ getRequestById(replaceId
, atBlock?
): Promise
<ReplaceRequestExt
>
Name | Type | Description |
---|---|---|
replaceId |
string | H256 |
The ID of the replace request to fetch |
atBlock? |
BlockHash |
- |
Promise
<ReplaceRequestExt
>
A replace request object
▸ list(): Promise
<ReplaceRequestExt
[]>
Promise
<ReplaceRequestExt
[]>
An array containing the replace requests
▸ map(): Promise
<Map
<H256
, ReplaceRequestExt
>>
Promise
<Map
<H256
, ReplaceRequestExt
>>
A mapping from the replace request ID to the replace request object
▸ 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.
Name | Type | Description |
---|---|---|
vaultAccountId |
AccountId |
The AccountId of the vault used to filter replace requests |
Promise
<ReplaceRequestExt
[]>
An array with replace requests involving said vault
▸ parseRequestsAsync(requestPairs
): Promise
<[H256
, ReplaceRequestExt
][]>
Name | Type |
---|---|
requestPairs |
[H256 , InterbtcPrimitivesReplaceReplaceRequest ][] |
Promise
<[H256
, ReplaceRequestExt
][]>
▸ request(amount
, collateralCurrency
): ExtrinsicData
Name | Type | Description |
---|---|---|
amount |
MonetaryAmount <Currency > |
Amount issued, denoted in Bitcoin, to have replaced by another vault |
collateralCurrency |
CollateralCurrencyExt |
Collateral currency to have replaced |
A submittable extrinsic and an event that is emitted when extrinsic is submitted.
▸ withdraw(amount
, collateralCurrency
): ExtrinsicData
Wihdraw a replace request
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 |
A submittable extrinsic and an event that is emitted when extrinsic is submitted.