import { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';
import { getDefaultResolver } from '../../config.js';
import type { UserClient as KeetaNetUserClient } from '@keetanetwork/keetanet-client';
import type { Logger } from '../../lib/log/index.ts';
import type Resolver from '../../lib/resolver.ts';
import type { ServiceMetadata, SharedLookupCriteria } from '../../lib/resolver.ts';
import type { BrandedString } from '../../lib/utils/brand.ts';
import type { ConversionInput, ConversionInputCanonical, KeetaFXAnchorEstimate, KeetaFXAnchorExchange, KeetaFXAnchorQuote, KeetaNetTokenPublicKeyString } from './common.ts';
import type { AnchorMetadataLegalField, SharedAnchorMetadataLegalExtension } from '../../lib/metadata.types.js';
/**
 * An opaque type that represents a provider ID.
 */
type ProviderID = BrandedString<'FXProviderID'>;
type AccountOptions = {
    /**
     * The account to use for signing requests. If not provided, the
     * account associated with the provided client will be used. If there
     * is no account associated with the client, an error occurs.
     */
    signer?: InstanceType<typeof KeetaNetLib.Account>;
    /**
     * Account to perform changes on. If not provided, the account
     * associated with the provided client will be used. If there is no
     * account associated with the client, an error occurs.
     */
    account?: InstanceType<typeof KeetaNetLib.Account>;
};
/**
 * The configuration options for the FX Anchor client.
 */
export type KeetaFXAnchorClientConfig = {
    /**
     * The ID of the client. This is used to identify the client in logs.
     * If not provided, a random ID will be generated.
     */
    id?: string;
    /**
     * The logger to use for logging messages. If not provided, no logging
     * will be done.
     */
    logger?: Logger | undefined;
    /**
     * The resolver to use for resolving FX Anchor services. If not
     * provided, a default resolver will be created using the provided
     * client and network (if the network is also not provided and the
     * client is not a UserClient, an error occurs).
     */
    resolver?: Resolver;
    /**
     * The account to use for signing requests. If not provided, the
     * account associated with the provided client will be used. If there
     * is no account associated with the client, an error occurs.
     */
    signer?: InstanceType<typeof KeetaNetLib.Account>;
    /**
     * Account to perform changes on. If not provided, the account
     * associated with the provided client will be used. If there is no
     * account associated with the client, an error occurs.
     */
    account?: InstanceType<typeof KeetaNetLib.Account>;
} & Omit<NonNullable<Parameters<typeof getDefaultResolver>[1]>, 'client'> & AccountOptions;
type KeetaFXAnchorOperations = {
    [operation in keyof NonNullable<ServiceMetadata['services']['fx']>[string]['operations']]: (params?: {
        [key: string]: string;
    }) => URL;
};
interface KeetaFXServiceInfo extends SharedAnchorMetadataLegalExtension {
    operations: {
        [operation in keyof KeetaFXAnchorOperations]: Promise<KeetaFXAnchorOperations[operation]>;
    };
    from: NonNullable<ServiceMetadata['services']['fx']>[string]['from'];
}
interface KeetaFXAnchorBaseConfig {
    client: KeetaNetUserClient;
    logger?: Logger | undefined;
}
declare class KeetaFXAnchorBase {
    protected readonly logger?: Logger | undefined;
    protected readonly client: KeetaNetUserClient;
    constructor(config: KeetaFXAnchorBaseConfig);
}
export declare class KeetaFXAnchorProviderBase extends KeetaFXAnchorBase {
    #private;
    readonly serviceInfo: KeetaFXServiceInfo;
    readonly providerID: ProviderID;
    readonly conversion: ConversionInputCanonical;
    readonly options: Pick<AccountOptions, 'account'> | undefined;
    private readonly parent;
    constructor(serviceInfo: KeetaFXServiceInfo, providerID: ProviderID, conversion: ConversionInputCanonical, parent: KeetaFXAnchorClient, options?: Pick<AccountOptions, 'account'>);
    getEstimate(): Promise<KeetaFXAnchorEstimate>;
    /**
     * Get a quote from the provider.  If an estimate is provided, it will
     * be used to validate the quote is within the tolerance range.
     *
     * @param estimate An optional estimate to validate the quote against
     * @param tolerance The tolerance, in percentage points, to allow the
     *                  quote to vary from the estimate.  For example, a
     *                  tolerance of 1.0 allows the quote to be 100% more
     *                  or less than the estimate.  The default is 0.10
     *                  (10%).
     * @returns A promise that resolves to the quote response
     */
    getQuote(estimate?: KeetaFXAnchorEstimate, tolerance?: number): Promise<KeetaFXAnchorQuote>;
    createExchange(input: {
        quote: KeetaFXAnchorQuote;
    } | {
        estimate: KeetaFXAnchorEstimate;
    }, block?: InstanceType<typeof KeetaNetLib.Block>): Promise<KeetaFXAnchorExchange>;
    getExchangeStatus(exchangeID: string): Promise<KeetaFXAnchorExchange>;
}
declare class KeetaFXAnchorExchangeWithProvider {
    readonly provider: KeetaFXAnchorProviderBase;
    readonly exchange: KeetaFXAnchorExchange;
    constructor(provider: KeetaFXAnchorProviderBase, exchange: KeetaFXAnchorExchange);
    getExchangeStatus(): Promise<KeetaFXAnchorExchange>;
}
interface CanCreateExchange {
    readonly isQuote: boolean;
    get request(): ConversionInputCanonical;
    createExchange(block?: InstanceType<typeof KeetaNetLib.Block>): Promise<KeetaFXAnchorExchangeWithProvider>;
}
declare class KeetaFXAnchorQuoteWithProvider implements CanCreateExchange {
    readonly provider: KeetaFXAnchorProviderBase;
    readonly quote: KeetaFXAnchorQuote;
    readonly isQuote: true;
    constructor(provider: KeetaFXAnchorProviderBase, quote: KeetaFXAnchorQuote);
    get request(): ConversionInputCanonical;
    createExchange(block?: InstanceType<typeof KeetaNetLib.Block>): Promise<KeetaFXAnchorExchangeWithProvider>;
    /**
     * Re-fetch the quote from the provider.
     *
     * @returns a new KeetaFXAnchorQuoteWithProvider with the updated quote
     */
    refetch(): Promise<KeetaFXAnchorQuoteWithProvider>;
}
declare class KeetaFXAnchorEstimateWithProvider implements CanCreateExchange {
    readonly provider: KeetaFXAnchorProviderBase;
    readonly estimate: KeetaFXAnchorEstimate;
    readonly isQuote: false;
    constructor(provider: KeetaFXAnchorProviderBase, estimate: KeetaFXAnchorEstimate);
    get request(): ConversionInputCanonical;
    getQuote(tolerance?: number): Promise<KeetaFXAnchorQuoteWithProvider>;
    createExchange(block?: InstanceType<typeof KeetaNetLib.Block>): Promise<KeetaFXAnchorExchangeWithProvider>;
    /**
     * Re-fetch the estimate from the provider.
     *
     * @returns a new KeetaFXAnchorEstimateWithProvider with the updated estimate
     */
    refetch(): Promise<KeetaFXAnchorEstimateWithProvider>;
}
interface GetProvidersOptions extends AccountOptions {
    requiredOperations?: (keyof KeetaFXAnchorOperations)[];
}
interface GetPricesAssetReturnValue {
    value: bigint;
    averageConvertedAmount: number;
    providerEstimates: KeetaFXAnchorEstimateWithProvider[];
}
export interface GetPricesArgs<Asset extends ConversionInput['from']> {
    assets: Asset[];
    priceIn: ConversionInput['from'];
    conversionValue?: bigint | ((input: Asset) => bigint | Promise<bigint>);
    conversionAffinity?: ConversionInput['affinity'];
}
declare class KeetaFXAnchorClient extends KeetaFXAnchorBase {
    #private;
    readonly resolver: Resolver;
    readonly id: string;
    constructor(client: KeetaNetUserClient, config?: KeetaFXAnchorClientConfig);
    private canonicalizeConversionTokens;
    private canonicalizeConversionInput;
    listPossibleConversions(input: Partial<Pick<ConversionInput, 'from' | 'to'>>, options?: AccountOptions, sharedCriteria?: SharedLookupCriteria): Promise<{
        conversions: KeetaNetTokenPublicKeyString[];
    } | null>;
    getBaseProvidersForConversion(request: ConversionInput, options?: GetProvidersOptions, sharedCriteria?: SharedLookupCriteria): Promise<KeetaFXAnchorProviderBase[] | null>;
    getEstimates(request: ConversionInput, options?: Omit<GetProvidersOptions, 'requiredOperations'>, sharedCriteria?: SharedLookupCriteria): Promise<KeetaFXAnchorEstimateWithProvider[] | null>;
    getQuotes(request: ConversionInput, options?: AccountOptions, sharedCriteria?: SharedLookupCriteria): Promise<KeetaFXAnchorQuoteWithProvider[] | null>;
    getQuotesOrEstimates(request: ConversionInput, options?: AccountOptions, sharedCriteria?: SharedLookupCriteria): Promise<(KeetaFXAnchorQuoteWithProvider | KeetaFXAnchorEstimateWithProvider)[] | null>;
    getPrices<Asset extends ConversionInput['from']>(input: GetPricesArgs<Asset>): Promise<Map<Asset, GetPricesAssetReturnValue | null>>;
    getLegalDisclaimersById(providerID: string): Promise<NonNullable<AnchorMetadataLegalField['disclaimers']> | null>;
}
export default KeetaFXAnchorClient;
//# sourceMappingURL=client.d.ts.map