import { ApiPromise } from "@polkadot/api"; import { SubmittableExtrinsic } from "@polkadot/api/submittable/types"; import { ISubmittableResult } from "@polkadot/types/types"; import { AccountId, H256 } from "@polkadot/types/interfaces"; import { Network } from "bitcoinjs-lib"; import Big from "big.js"; import { MonetaryAmount } from "@interlay/monetary-js"; import { InterbtcPrimitivesVaultId } from "@polkadot/types/lookup"; import { VaultsAPI } from "./vaults"; import { ElectrsAPI } from "../external"; import { TransactionAPI } from "./transaction"; import { CollateralCurrencyExt, CurrencyExt, ExtrinsicData, Issue, WrappedCurrency } from "../types"; export type IssueLimits = { singleVaultMaxIssuable: MonetaryAmount; totalMaxIssuable: MonetaryAmount; }; /** * @category BTC Bridge */ export interface IssueAPI { /** * Gets the threshold for issuing with a single vault, and the maximum total * issue request size. Additionally passes the list of vaults for caching. * @param vaults (optional) A list of the vaults available to issue from. If not provided, will fetch from the * parachain (incurring an extra request). * @returns An object of type {singleVault, maxTotal, vaultsCache} */ getRequestLimits(vaults?: Map>): Promise; /** * Build an issue request extrinsic (transaction) without sending it. * * @param vaultId The vault ID of the vault to issue with. * @param amount wrapped token amount to issue. * @param griefingCollateralCurrency (optional) Currency in which griefing collateral will be locked. * @returns An execute issue submittable extrinsic. */ buildRequestIssueExtrinsic(vaultId: InterbtcPrimitivesVaultId, amount: MonetaryAmount, griefingCollateralCurrency?: CurrencyExt): SubmittableExtrinsic<"promise", ISubmittableResult>; /** * Request issuing wrapped tokens (e.g. interBTC, kBTC). * @param amount wrapped token amount to issue. * @param vaultId (optional) Account ID of the vault to issue with. * @param collateralCurrency (optional) Collateral currency for backing wrapped tokens * @param atomic (optional) Whether the issue request should be handled atomically or not. Only makes a difference * if more than one vault is needed to fulfil it. Defaults to false. * @param availableVaults (optional) A list of all vaults usable for issue. If not provided, will fetch from the parachain. * @param griefingCollateralCurrency (optional) Currency in which griefing collateral will be locked. * @returns {Promise} An extrinsic with event. */ request(amount: MonetaryAmount, vaultAccountId?: AccountId, collateralCurrency?: CollateralCurrencyExt, atomic?: boolean, availableVaults?: Map>, griefingCollateralCurrency?: CurrencyExt): Promise; /** * Create a batch of aggregated issue transactions (to one or more vaults). * @param amountsPerVault A mapping of vaults to issue from, and wrapped token amounts to issue using each vault * @param atomic Whether the issue request should be handled atomically or not. Only makes a difference if more than * one vault is needed to fulfil it. * @param griefingCollateralCurrency (optional) Currency in which griefing collateral will be locked. * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ requestAdvanced(amountsPerVault: Map>, atomic: boolean, griefingCollateralCurrency?: CurrencyExt): ExtrinsicData; /** * Build an issue execution extrinsic (transaction) without sending it. * * @param issueId The ID returned by the issue request transaction * @param btcTxId Bitcoin transaction ID * @returns An execute issue submittable extrinsic. */ buildExecuteIssueExtrinsic(issueId: string, btcTxId: string): Promise>; /** * Create an issue execution transaction * @remarks If `txId` is not set, the `merkleProof` and `rawTx` must both be set. * * @param issueId The ID returned by the issue request transaction * @param btcTxId Bitcoin transaction ID * @returns {Promise} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ execute(requestId: string, btcTxId: string): Promise; /** * Build a cancel issue extrinsic (transaction) without sending it. * * @param issueId The ID returned by the issue request transaction * @returns A cancel issue submittable extrinsic. */ buildCancelIssueExtrinsic(issueId: string): SubmittableExtrinsic<"promise", ISubmittableResult>; /** * Create an issue cancellation transaction. After the issue period has elapsed, * the issuance request can be cancelled. As a result, the griefing collateral * of the requester will be slashed and sent to the vault that had prepared to issue. * @param issueId The ID returned by the issue request transaction * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ cancel(issueId: string): ExtrinsicData; /** * @remarks Testnet utility function * @param blocks The time difference in number of blocks between an issue request is created * and required completion time by a user. The issue period has an upper limit * to prevent griefing of vault collateral. * @returns {ExtrinsicData} A submittable extrinsic and an event that is emitted when extrinsic is submitted. */ setIssuePeriod(blocks: number): ExtrinsicData; /** * * @returns The time difference in number of blocks between an issue request is created * and required completion time by a user. The issue period has an upper limit * to prevent griefing of vault collateral. */ getIssuePeriod(): Promise; /** * @returns An array containing the issue requests */ list(): Promise; /** * @param issueId The ID of the issue request to fetch * @returns An issue request object */ getRequestById(issueId: H256 | string): Promise; /** * @param issueId The IDs of the batch of issue request to fetch * @returns The issue request objects */ getRequestsByIds(issueIds: (H256 | string)[]): Promise; /** * @returns The minimum amount of wrapped tokens that is accepted for issue requests; any lower values would * risk the bitcoin client to reject the payment */ getDustValue(): Promise>; /** * @returns The fee charged for issuing. For instance, "0.005" stands for 0.5% */ getFeeRate(): Promise; /** * @param amount The amount, in BTC, for which to compute the issue fees * @returns The fees, in BTC */ getFeesToPay(amount: MonetaryAmount): Promise>; /** * @param vaultAccountId The vault account ID * @param collateralCurrency The currency specification, a `Monetary.js` object * @returns The amount of wrapped tokens issuable by this vault */ getVaultIssuableAmount(vaultAccountId: AccountId, collateralCurrency: CollateralCurrencyExt): Promise>; } export declare class DefaultIssueAPI implements IssueAPI { private api; private btcNetwork; private electrsAPI; private wrappedCurrency; private vaultsAPI; private transactionAPI; constructor(api: ApiPromise, btcNetwork: Network, electrsAPI: ElectrsAPI, wrappedCurrency: WrappedCurrency, vaultsAPI: VaultsAPI, transactionAPI: TransactionAPI); getRequestLimits(vaults?: Map>): Promise; request(amount: MonetaryAmount, vaultAccountId?: AccountId, collateralCurrency?: CollateralCurrencyExt, atomic?: boolean, cachedVaults?: Map>, griefingCollateralCurrency?: CurrencyExt): Promise; buildRequestIssueExtrinsic(vaultId: InterbtcPrimitivesVaultId, amount: MonetaryAmount, griefingCollateralCurrency?: CurrencyExt): SubmittableExtrinsic<"promise", ISubmittableResult>; requestAdvanced(amountsPerVault: Map>, atomic: boolean, griefingCollateralCurrency?: CurrencyExt): ExtrinsicData; buildExecuteIssueExtrinsic(requestId: string, btcTxId: string): Promise>; execute(requestId: string, btcTxId: string): Promise; buildCancelIssueExtrinsic(requestId: string): SubmittableExtrinsic<"promise", ISubmittableResult>; cancel(requestId: string): ExtrinsicData; setIssuePeriod(blocks: number): ExtrinsicData; getIssuePeriod(): Promise; list(): Promise; getFeesToPay(amount: MonetaryAmount): Promise>; getDustValue(): Promise>; getFeeRate(): Promise; getRequestById(issueId: H256 | string): Promise; getRequestsByIds(issueIds: (H256 | string)[]): Promise; getVaultIssuableAmount(vaultAccountId: AccountId, collateralCurrency: CollateralCurrencyExt): Promise>; }