import { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';
import type { ServiceSearchCriteria } from '../../lib/resolver.js';
import type { ToJSONSerializable } from '../../lib/utils/json.js';
import { KeetaAnchorUserError } from '../../lib/error.js';
import type { HTTPSignedField } from '../../lib/http-server/common.js';
import type { KeetaNetAccount, KeetaNetStorageAccount, KeetaNetToken, KeetaNetTokenPublicKeyString } from '../../lib/asset.js';
export type { KeetaNetAccount, KeetaNetStorageAccount, KeetaNetToken, KeetaNetTokenPublicKeyString } from '../../lib/asset.js';
/**
 * Parses a cost token from its serialized public key string form,
 * reconstituting a KeetaNetToken instance.
 */
export declare function parseFXCostToken(input: KeetaNetToken | string): KeetaNetToken;
export type ConversionInput = {
    /**
     * The currency code to convert from (i.e., what the user has).
     */
    from: ServiceSearchCriteria<'fx'>['inputCurrencyCode'] | KeetaNetToken;
    /**
     * The currency code to convert to (i.e., what the user wants).
     */
    to: ServiceSearchCriteria<'fx'>['outputCurrencyCode'] | KeetaNetToken;
    /**
     * The amount to convert. This is a bigint representing the
     * amount in the currency specified by either `from` or `to`, as
     * specified by the `affinity` property.
     */
    amount: bigint;
    /**
     * Indicates whether the amount specified is in terms of the `from`
     * currency (i.e., the user has this much) or the `to` currency
     * (i.e., the user wants this much).
     */
    affinity: 'from' | 'to';
    /**
     * Optional preferred token in which the fee/cost should be
     * denominated. Must be one of the operator's advertised
     * acceptedCostAssets, if specified.
     */
    preferredCostAsset?: KeetaNetTokenPublicKeyString;
};
export type ConversionInputCanonical = {
    [k in keyof ConversionInput]: k extends 'amount' ? bigint : k extends 'from' ? KeetaNetToken : k extends 'to' ? KeetaNetToken : ConversionInput[k] extends undefined ? never : ConversionInput[k];
};
export type ConversionInputCanonicalJSON = ToJSONSerializable<ConversionInputCanonical>;
export type KeetaFXAnchorClientCreateExchangeRequest = {
    block: InstanceType<typeof KeetaNetLib.Block>;
} & ({
    quote: KeetaFXAnchorQuote;
} | {
    request: ConversionInputCanonical;
});
export type KeetaFXAnchorClientCreateExchangeRequestJSON = {
    block: string;
} & ({
    quote: KeetaFXAnchorQuoteJSON;
    request?: undefined;
} | {
    quote?: undefined;
    request: ConversionInputCanonicalJSON;
});
export type KeetaFXAnchorEstimate = {
    /**
     * Conversion request that was provided
     */
    request: ConversionInputCanonical;
    /**
     * Amount after the conversion as specified by either `from` or `to`, as specified by the `affinity` property in the request.
     */
    convertedAmount: bigint;
    /**
     * Outer bound of the converted amount.
     * if affinity is 'to', this is the maximum amount the user would need to send, if its 'from', this is the minimum amount the user would receive.
     */
    convertedAmountBound?: bigint;
    /**
     * The expected cost of the fx request, in the form of a
     * token and a range of minimum and maximum expected costs
     */
    expectedCost: {
        min: bigint;
        max: bigint;
        token: KeetaNetToken;
    };
} & ({
    /**
     * Indicates that the exchange cannot be performed if false, and no quote can be issued
     */
    canPerformExchange: false;
} | ({
    /**
     * Indicates that the exchange can be performed if true or undefined, but a quote may or may not be required before proceeding with the exchange
     */
    canPerformExchange?: true;
} & ({
    /**
     * Indicates that a quote is required before proceeding with the exchange
     */
    requiresQuote: false;
    /**
     * Liquidity provider account if the user is not going to request a quote before the exchange
     */
    account: KeetaNetAccount | KeetaNetStorageAccount;
} | {
    /**
     * Indicates that a quote is required before proceeding with the exchange, defaults to true
     */
    requiresQuote?: true;
})));
export type KeetaFXAnchorEstimateResponse = ({
    ok: true;
    estimate: ToJSONSerializable<KeetaFXAnchorEstimate>;
} | {
    ok: false;
    error: string;
});
export type KeetaFXAnchorQuote = {
    /**
     * Conversion request that was provided
     */
    request: ConversionInputCanonical;
    /**
     * The public key of the liquidity provider account
     */
    account: KeetaNetAccount | KeetaNetStorageAccount;
    /**
     * Amount after the conversion as specified by either `from` or `to`, as specified by the `affinity` property in the request.
     */
    convertedAmount: bigint;
    /**
     * The cost of the fx request, in the form of a
     * token and amount that should be included with the swap
     */
    cost: {
        amount: bigint;
        token: KeetaNetToken;
    };
    /**
     * Signature information to verify the quote
     */
    signed: HTTPSignedField;
};
export type KeetaFXAnchorQuoteJSON = ToJSONSerializable<KeetaFXAnchorQuote>;
export type KeetaFXAnchorQuoteResponse = ({
    ok: true;
    quote: ToJSONSerializable<KeetaFXAnchorQuote>;
} | {
    ok: false;
    error: string;
});
export type KeetaFXAnchorExchange = {
    /**
     * ID used to identify the conversion request
     */
    exchangeID: string;
} & ({
    /**
     * Status of the exchange request
     */
    status: 'pending' | 'failed';
} | {
    /**
     * Status of the exchange request
     */
    status: 'completed';
    /**
     * Blockhash where the exchange was completed -- the user-supplied
     * blockhash for their portion of the exchange transaction can be
     * used to look up the transaction on-chain as well, but we return
     * a value here so that it can be looked up without needing to store
     * that initial block.
     */
    blockhash: string;
});
export type KeetaFXAnchorExchangeResponse = (KeetaFXAnchorExchange & {
    ok: true;
}) | (Partial<KeetaFXAnchorExchange> & {
    ok: false;
    error: string;
});
export declare const isKeetaFXAnchorEstimateResponse: (input: unknown) => input is KeetaFXAnchorEstimateResponse;
export declare const isKeetaFXAnchorQuoteResponse: (input: unknown) => input is KeetaFXAnchorQuoteResponse;
export declare const isKeetaFXAnchorExchangeResponse: (input: unknown) => input is KeetaFXAnchorExchangeResponse;
export declare const assertKeetaNetTokenPublicKeyString: (input: unknown) => KeetaNetTokenPublicKeyString;
export declare const assertConversionInputCanonicalJSON: (input: unknown) => ConversionInputCanonicalJSON;
export declare const assertKeetaFXAnchorClientCreateExchangeRequestJSON: (input: unknown) => KeetaFXAnchorClientCreateExchangeRequestJSON;
declare class KeetaFXAnchorQuoteValidationFailedError extends KeetaAnchorUserError {
    static readonly name: string;
    private readonly KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID;
    private static readonly KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID;
    constructor(message?: string);
    static isInstance(input: unknown): input is KeetaFXAnchorQuoteValidationFailedError;
    static fromJSON(input: unknown): Promise<InstanceType<typeof this>>;
}
declare class KeetaFXAnchorQuoteRequiredError extends KeetaAnchorUserError {
    static readonly name: string;
    private readonly KeetaFXAnchorQuoteRequiredErrorObjectTypeID;
    private static readonly KeetaFXAnchorQuoteRequiredErrorObjectTypeID;
    constructor(message?: string);
    static isInstance(input: unknown): input is KeetaFXAnchorQuoteRequiredError;
    static fromJSON(input: unknown): Promise<InstanceType<typeof this>>;
}
declare class KeetaFXAnchorQuoteIssuanceDisabledError extends KeetaAnchorUserError {
    static readonly name: string;
    private readonly KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID;
    private static readonly KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID;
    constructor(message?: string);
    static isInstance(input: unknown): input is KeetaFXAnchorQuoteIssuanceDisabledError;
    static fromJSON(input: unknown): Promise<InstanceType<typeof this>>;
}
export declare const Errors: {
    QuoteValidationFailed: typeof KeetaFXAnchorQuoteValidationFailedError;
    QuoteRequired: typeof KeetaFXAnchorQuoteRequiredError;
    QuoteIssuanceDisabled: typeof KeetaFXAnchorQuoteIssuanceDisabledError;
};
//# sourceMappingURL=common.d.ts.map