import { ApiPromise } from "@polkadot/api";
import { SubmittableExtrinsic } from "@polkadot/api/submittable/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 { FeeAPI } from "./fee";
import { ElectrsAPI } from "../external";
import { TransactionAPI } from "./transaction";
import { CollateralCurrencyExt, Issue, WrappedCurrency } from "../types";
import { AssetRegistryAPI } from "../parachain/asset-registry";
export declare type IssueLimits = {
    singleVaultMaxIssuable: MonetaryAmount<WrappedCurrency>;
    totalMaxIssuable: MonetaryAmount<WrappedCurrency>;
};
/**
 * @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<InterbtcPrimitivesVaultId, MonetaryAmount<WrappedCurrency>>): Promise<IssueLimits>;
    /**
     * 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 retries (optional) Number of times to retry issuing, if some of the requests fail. Defaults to 0.
     * @param availableVaults (optional) A list of all vaults usable for issue. If not provided, will fetch from the parachain.
     * @returns An array of type {issueId, issueRequest} if the requests succeeded. The function throws an error otherwise.
     */
    request(amount: MonetaryAmount<WrappedCurrency>, vaultAccountId?: AccountId, collateralCurrency?: CollateralCurrencyExt, atomic?: boolean, retries?: number, availableVaults?: Map<InterbtcPrimitivesVaultId, MonetaryAmount<WrappedCurrency>>): Promise<Issue[]>;
    /**
     * Send 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.
     * @returns An array of `Issue` objects, if the requests succeeded.
     * @throws Rejects the promise if none of the requests succeeded (or if at least one failed, when atomic=true).
     */
    requestAdvanced(amountsPerVault: Map<InterbtcPrimitivesVaultId, MonetaryAmount<WrappedCurrency>>, atomic: boolean): Promise<Issue[]>;
    /**
     * Send 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
     */
    execute(requestId: string, btcTxId: string): Promise<void>;
    /**
     * Send 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
     */
    cancel(issueId: string): Promise<void>;
    /**
     * @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.
     */
    setIssuePeriod(blocks: number): Promise<void>;
    /**
     *
     * @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<number>;
    /**
     * @returns An array containing the issue requests
     */
    list(): Promise<Issue[]>;
    /**
     * @param issueId The ID of the issue request to fetch
     * @returns An issue request object
     */
    getRequestById(issueId: H256 | string): Promise<Issue>;
    /**
     * @param issueId The IDs of the batch of issue request to fetch
     * @returns The issue request objects
     */
    getRequestsByIds(issueIds: (H256 | string)[]): Promise<Issue[]>;
    /**
     * @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<MonetaryAmount<WrappedCurrency>>;
    /**
     * @returns The fee charged for issuing. For instance, "0.005" stands for 0.5%
     */
    getFeeRate(): Promise<Big>;
    /**
     * @param amount The amount, in BTC, for which to compute the issue fees
     * @returns The fees, in BTC
     */
    getFeesToPay(amount: MonetaryAmount<WrappedCurrency>): Promise<MonetaryAmount<WrappedCurrency>>;
    /**
     * @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<MonetaryAmount<WrappedCurrency>>;
}
export declare class DefaultIssueAPI implements IssueAPI {
    private api;
    private btcNetwork;
    private electrsAPI;
    private wrappedCurrency;
    private feeAPI;
    private vaultsAPI;
    private transactionAPI;
    private assetRegistryAPI;
    constructor(api: ApiPromise, btcNetwork: Network, electrsAPI: ElectrsAPI, wrappedCurrency: WrappedCurrency, feeAPI: FeeAPI, vaultsAPI: VaultsAPI, transactionAPI: TransactionAPI, assetRegistryAPI: AssetRegistryAPI);
    getRequestLimits(vaults?: Map<InterbtcPrimitivesVaultId, MonetaryAmount<WrappedCurrency>>): Promise<IssueLimits>;
    /**
     * @param events The EventRecord array returned after sending an issue request transaction
     * @returns The issueId associated with the request. If the EventRecord array does not
     * contain issue request events, the function throws an error.
     */
    private getIssueIdsFromEvents;
    request(amount: MonetaryAmount<WrappedCurrency>, vaultAccountId?: AccountId, collateralCurrency?: CollateralCurrencyExt, atomic?: boolean, retries?: number, cachedVaults?: Map<InterbtcPrimitivesVaultId, MonetaryAmount<WrappedCurrency>>): Promise<Issue[]>;
    craftRequestTx(vaultId: InterbtcPrimitivesVaultId, amount: MonetaryAmount<WrappedCurrency>): Promise<SubmittableExtrinsic<"promise">>;
    requestAdvanced(amountsPerVault: Map<InterbtcPrimitivesVaultId, MonetaryAmount<WrappedCurrency>>, atomic: boolean): Promise<Issue[]>;
    execute(requestId: string, btcTxId: string): Promise<void>;
    cancel(requestId: string): Promise<void>;
    setIssuePeriod(blocks: number): Promise<void>;
    getIssuePeriod(): Promise<number>;
    list(): Promise<Issue[]>;
    getFeesToPay(amount: MonetaryAmount<WrappedCurrency>): Promise<MonetaryAmount<WrappedCurrency>>;
    getDustValue(): Promise<MonetaryAmount<WrappedCurrency>>;
    getFeeRate(): Promise<Big>;
    getRequestById(issueId: H256 | string): Promise<Issue>;
    getRequestsByIds(issueIds: (H256 | string)[]): Promise<Issue[]>;
    getVaultIssuableAmount(vaultAccountId: AccountId, collateralCurrency: CollateralCurrencyExt): Promise<MonetaryAmount<WrappedCurrency>>;
}
