import { ApiPromise } from "@polkadot/api";
import { SubmittableExtrinsic } from "@polkadot/api/submittable/types";
import { H256 } from "@polkadot/types/interfaces";
import { Network } from "bitcoinjs-lib";
import Big from "big.js";
import { Bitcoin, ExchangeRate, MonetaryAmount } from "@interlay/monetary-js";
import { ISubmittableResult } from "@polkadot/types/types";
import { InterbtcPrimitivesVaultId } from "@polkadot/types/lookup";
import { VaultsAPI } from "./vaults";
import { ElectrsAPI } from "../external";
import { TransactionAPI } from "./transaction";
import { OracleAPI } from "./oracle";
import { CollateralCurrencyExt, Redeem, WrappedCurrency } from "../types";
import { AssetRegistryAPI } from "../parachain/asset-registry";
import { SystemAPI } from "./system";
/**
 * @category BTC Bridge
 */
export interface RedeemAPI {
    /**
     * @returns An array containing the redeem requests
     */
    list(): Promise<Redeem[]>;
    /**
     * Build a request redeem extrinsic (transaction) without sending it.
     *
     * @param vaultId ID of the vault to redeem with.
     * @param amount Wrapped token amount to redeem
     * @param btcAddress Bitcoin transaction ID
     * @returns A request redeem submittable extrinsic.
     */
    buildRequestRedeemExtrinsic(vaultId: InterbtcPrimitivesVaultId, amount: MonetaryAmount<WrappedCurrency>, btcAddress: string): SubmittableExtrinsic<"promise", ISubmittableResult>;
    /**
     * Send a redeem request transaction
     * @param amount Wrapped token amount to redeem
     * @param btcAddressEnc Bitcoin address where the redeemed BTC should be sent
     * @param vaultId (optional) ID of the vault to redeem with.
     * @param atomic (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.
     * @param retries (optional) Number of times to retry redeeming, if some of the requests fail. Defaults to 0.
     * @param availableVaults (optional) A list of all vaults usable for redeem. If not provided, will fetch from the parachain.
     * @returns An array of type {redeemId, redeemRequest} if the requests succeeded. The function throws an error otherwise.
     */
    request(amount: MonetaryAmount<WrappedCurrency>, btcAddressEnc: string, vaultId?: InterbtcPrimitivesVaultId, atomic?: boolean, retries?: number, availableVaults?: Map<InterbtcPrimitivesVaultId, MonetaryAmount<WrappedCurrency>>): Promise<Redeem[]>;
    /**
     * Send a batch of aggregated redeem transactions (to one or more vaults)
     * @param amountsPerVault A mapping of vaults to redeem from, and wrapped token amounts to redeem using each vault
     * @param btcAddressEnc Bitcoin address where the redeemed BTC should be sent
     * @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 type {redeemId, vault} 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>>, btcAddressEnc: string, atomic: boolean): Promise<Redeem[]>;
    /**
     * Build a redeem execution extrinsic (transaction) without sending it.
     *
     * @param redeemId The ID returned by the issue request transaction
     * @param btcTxId Bitcoin transaction ID
     * @returns An execute redeem submittable extrinsic.
     */
    buildExecuteRedeemExtrinsic(redeemId: string, btcTxId: string): Promise<SubmittableExtrinsic<"promise", ISubmittableResult>>;
    /**
     * Send a redeem execution transaction
     * @remarks If `txId` is not set, the `merkleProof` and `rawTx` must both be set.
     *
     * @param redeemId The ID generated by the redeem request transaction
     * @param btcTxId Bitcoin transaction ID
     */
    execute(requestId: string, btcTxId: string): Promise<void>;
    /**
     * Build a cancel redeem extrinsic (transaction) without sending it.
     *
     * @param redeemId The ID returned by the redeem request transaction
     * @param reimburse In case of redeem failure:
     *  - `false` = retry redeeming, with a different Vault
     *  - `true` = accept reimbursement in wrapped token
     * @returns A cancel redeem submittable extrinsic.
     */
    buildCancelRedeemExtrinsic(redeemId: string, reimburse: boolean): SubmittableExtrinsic<"promise", ISubmittableResult>;
    /**
     * 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
     * @param redeemId The ID returned by the redeem request transaction
     * @param reimburse (Optional) In case of redeem failure:
     *  - (Default) `false` = retry redeeming, with a different Vault
     *  - `true` = accept reimbursement in wrapped token
     */
    cancel(redeemId: string, reimburse?: boolean): Promise<void>;
    /**
     * @remarks Testnet utility function
     * @param blocks 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.
     */
    setRedeemPeriod(blocks: number): Promise<void>;
    /**
     *
     * @returns 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.
     */
    getRedeemPeriod(): Promise<number>;
    /**
     * @param redeemId The ID of the redeem request to fetch
     * @returns A redeem request object
     */
    getRequestById(redeemId: H256 | string): Promise<Redeem>;
    getRequestsByIds(redeemIds: (H256 | string)[]): Promise<Redeem[]>;
    /**
     * @returns The minimum amount of wrapped tokens that is accepted for redeem requests; any lower values would
     * risk the bitcoin client to reject the payment
     */
    getDustValue(): Promise<MonetaryAmount<WrappedCurrency>>;
    /**
     * @returns The fee charged for redeeming. For instance, "0.005" stands for 0.5%
     */
    getFeeRate(): Promise<Big>;
    /**
     * @param amount The amount of wrapped tokens for which to compute the redeem fees
     * @returns The fees
     */
    getFeesToPay(amount: MonetaryAmount<WrappedCurrency>): Promise<MonetaryAmount<WrappedCurrency>>;
    /**
     * @returns 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.
     */
    getPremiumRedeemFeeRate(): Promise<Big>;
    /**
     * Build liquidation redeem extrinsic (without sending it) to burn wrapped tokens for a premium
     * @param amount The amount of wrapped tokens to burn
     * @param collateralCurrency Liquidated collateral currency to use when burning wrapped tokens
     * @returns A liquidation redeem submittable extrinsic.
     */
    buildLiquidationRedeemExtrinsic(amount: MonetaryAmount<WrappedCurrency>, collateralCurrency: CollateralCurrencyExt): SubmittableExtrinsic<"promise", ISubmittableResult>;
    /**
     * Burn wrapped tokens for a premium
     * @param amount The amount of wrapped tokens to burn
     * @param collateralCurrency Liquidated collateral currency to use when burning wrapped tokens
     */
    burn(amount: MonetaryAmount<WrappedCurrency>, collateralCurrency: CollateralCurrencyExt): Promise<void>;
    /**
     * @param collateralCurrency Liquidated collateral currency to use when burning wrapped tokens
     * @returns The maximum amount of tokens that can be burned through a liquidation redeem
     */
    getMaxBurnableTokens(collateralCurrency: CollateralCurrencyExt): Promise<MonetaryAmount<WrappedCurrency>>;
    /**
     * @param collateralCurrency Currency whose exchange rate with BTC to fetch
     * @returns The exchange rate (collateral currency to wrapped token currency)
     * used when burning tokens
     */
    getBurnExchangeRate(collateralCurrency: CollateralCurrencyExt): Promise<ExchangeRate<Bitcoin, typeof collateralCurrency>>;
    /**
     * @returns The current inclusion fee based on the expected number of bytes
     * in the transaction, and the inclusion fee rate reported by the oracle
     */
    getCurrentInclusionFee(): Promise<MonetaryAmount<WrappedCurrency>>;
}
export declare class DefaultRedeemAPI implements RedeemAPI {
    private api;
    private btcNetwork;
    private electrsAPI;
    private wrappedCurrency;
    private vaultsAPI;
    private oracleAPI;
    private transactionAPI;
    private assetRgistryAPI;
    private systemAPI;
    constructor(api: ApiPromise, btcNetwork: Network, electrsAPI: ElectrsAPI, wrappedCurrency: WrappedCurrency, vaultsAPI: VaultsAPI, oracleAPI: OracleAPI, transactionAPI: TransactionAPI, assetRgistryAPI: AssetRegistryAPI, systemAPI: SystemAPI);
    private getRedeemIdsFromEvents;
    request(amount: MonetaryAmount<WrappedCurrency>, btcAddressEnc: string, vaultId?: InterbtcPrimitivesVaultId, atomic?: boolean, retries?: number, cachedVaults?: Map<InterbtcPrimitivesVaultId, MonetaryAmount<WrappedCurrency>>): Promise<Redeem[]>;
    buildRequestRedeemExtrinsic(vaultId: InterbtcPrimitivesVaultId, amount: MonetaryAmount<WrappedCurrency>, btcAddressEnc: string): SubmittableExtrinsic<"promise", ISubmittableResult>;
    requestAdvanced(amountsPerVault: Map<InterbtcPrimitivesVaultId, MonetaryAmount<WrappedCurrency>>, btcAddressEnc: string, atomic: boolean): Promise<Redeem[]>;
    buildExecuteRedeemExtrinsic(redeemId: string, btcTxId: string): Promise<SubmittableExtrinsic<"promise", ISubmittableResult>>;
    execute(requestId: string, btcTxId: string): Promise<void>;
    buildCancelRedeemExtrinsic(redeemId: string, reimburse: boolean): SubmittableExtrinsic<"promise", ISubmittableResult>;
    cancel(requestId: string, reimburse?: boolean): Promise<void>;
    buildLiquidationRedeemExtrinsic(amount: MonetaryAmount<WrappedCurrency>, collateralCurrency: CollateralCurrencyExt): SubmittableExtrinsic<"promise", ISubmittableResult>;
    burn(amount: MonetaryAmount<WrappedCurrency>, collateralCurrency: CollateralCurrencyExt): Promise<void>;
    setRedeemPeriod(blocks: number): Promise<void>;
    getRedeemPeriod(): Promise<number>;
    getMaxBurnableTokens(collateralCurrency: CollateralCurrencyExt): Promise<MonetaryAmount<WrappedCurrency>>;
    getBurnExchangeRate(collateralCurrency: CollateralCurrencyExt): Promise<ExchangeRate<Bitcoin, typeof collateralCurrency>>;
    getCurrentInclusionFee(): Promise<MonetaryAmount<WrappedCurrency>>;
    list(): Promise<Redeem[]>;
    getFeesToPay(amount: MonetaryAmount<WrappedCurrency>): Promise<MonetaryAmount<WrappedCurrency>>;
    getFeeRate(): Promise<Big>;
    getDustValue(): Promise<MonetaryAmount<WrappedCurrency>>;
    getPremiumRedeemFeeRate(): Promise<Big>;
    getRequestById(redeemId: H256 | string): Promise<Redeem>;
    getRequestsByIds(redeemIds: (H256 | string)[]): Promise<Redeem[]>;
}
