import winston from "winston";
import { AnyObject, BigNumber, DefaultLogLevels, DepositSearchResult, EventSearchConfig, MakeOptional, Address } from "../../utils";
import { BridgedToHubPoolWithBlock, ClaimedRelayerRefundWithBlock, Deposit, DepositWithBlock, Fill, FillStatus, FillWithBlock, RelayData, RelayerRefundExecutionWithBlock, RootBundleRelayWithBlock, SlowFillRequestWithBlock, SortableEvent, SpeedUpWithBlock, TokensBridged } from "../../interfaces";
import { BaseAbstractClient, UpdateFailureReason } from "../BaseAbstractClient";
import { AcrossConfigStoreClient } from "../AcrossConfigStoreClient";
import { HubPoolClient } from "../HubPoolClient";
export type SpokePoolUpdateSuccess = {
    success: true;
    currentTime: number;
    events: SortableEvent[][];
    searchEndBlock: number;
};
export type SpokePoolUpdateFailure = {
    success: false;
    reason: UpdateFailureReason;
};
export type SpokePoolUpdate = SpokePoolUpdateSuccess | SpokePoolUpdateFailure;
export declare const knownEventNames: string[];
/**
 * SpokePoolClient is a client for the SpokePool contract. It is responsible for querying the SpokePool contract
 * for events and storing them in memory. It also provides some convenience methods for querying the stored events.
 */
export declare abstract class SpokePoolClient extends BaseAbstractClient {
    readonly logger: winston.Logger;
    readonly hubPoolClient: HubPoolClient | null;
    readonly chainId: number;
    deploymentBlock: number;
    abstract readonly type: string;
    protected currentTime: number;
    protected duplicateDepositHashes: {
        [depositHash: string]: DepositWithBlock[];
    };
    protected depositHashesToFills: {
        [depositHash: string]: FillWithBlock[];
    };
    protected speedUps: {
        [depositorAddress: string]: {
            [depositId: string]: SpeedUpWithBlock[];
        };
    };
    protected slowFillRequests: {
        [relayDataHash: string]: SlowFillRequestWithBlock;
    };
    protected depositRoutes: {
        [originToken: string]: {
            [DestinationChainId: number]: boolean;
        };
    };
    protected tokensBridged: TokensBridged[];
    protected rootBundleRelays: RootBundleRelayWithBlock[];
    protected relayerRefundExecutions: RelayerRefundExecutionWithBlock[];
    protected claimedRelayerRefunds: ClaimedRelayerRefundWithBlock[];
    protected bridgedToHubPool: BridgedToHubPoolWithBlock[];
    protected configStoreClient: AcrossConfigStoreClient | undefined;
    protected invalidFills: Set<string>;
    readonly depositHashes: {
        [depositHash: string]: DepositWithBlock;
    };
    spokePoolAddress: Address | undefined;
    fills: {
        [OriginChainId: number]: FillWithBlock[];
    };
    /**
     * Creates a new SpokePoolClient.
     * @param logger A logger instance.
     * @param hubPoolClient An optional HubPoolClient instance. This is used to fetch spoke data that is not stored on the SpokePool contract but is stored on the HubPool contract.
     * @param chainId The chain ID of the chain that this client is querying.
     * @param deploymentBlock The block number that the SpokePool contract was deployed at.
     * @param eventSearchConfig An optional EventSearchConfig object that controls how far back in history the client will search for events. If not provided, the client will only search for events from the deployment block.
     */
    protected constructor(logger: winston.Logger, hubPoolClient: HubPoolClient | null, chainId: number, deploymentBlock: number, eventSearchConfig?: MakeOptional<EventSearchConfig, "to">);
    /**
     * Retrieves a list of unique deposits from the SpokePool contract destined for the given destination chain ID.
     * @param destinationChainId The destination chain ID.
     * @returns A list of deposits.
     */
    getDepositsForDestinationChain(destinationChainId: number): DepositWithBlock[];
    /**
     * Retrieves a list of duplicate deposits matching the given deposit's deposit hash.
     * @notice A duplicate is considered any deposit sent after the original deposit with the same deposit hash.
     * @param deposit The deposit to find duplicates for.
     * @returns A list of duplicate deposits. Does NOT include the original deposit
     * unless the original deposit is a duplicate.
     */
    private _getDuplicateDeposits;
    /**
     * Returns a list of all deposits including any duplicate ones. Designed only to be used in use cases where
     * all deposits are required, regardless of duplicates. For example, the Dataworker can use this to refund
     * expired deposits including for duplicates.
     * @param destinationChainId
     * @returns A list of deposits
     */
    getDepositsForDestinationChainWithDuplicates(destinationChainId: number): DepositWithBlock[];
    /**
     * Retrieves a list of deposits from the SpokePool contract that are associated with this spoke pool.
     * @returns A list of deposits.
     * @note This method returns all deposits, regardless of destination chain ID in sorted order.
     */
    getDeposits(filter?: {
        fromBlock: number;
        toBlock: number;
    }): DepositWithBlock[];
    /**
     * Retrieves a list of the tokens that have been bridged.
     * @returns A list of tokens.
     */
    getTokensBridged(): TokensBridged[];
    /**
     * Retrieves a mapping of tokens and their associated destination chain IDs that can be bridged.
     * @returns A mapping of tokens and their associated destination chain IDs in a nested mapping.
     */
    getDepositRoutes(): {
        [originToken: string]: {
            [DestinationChainId: number]: boolean;
        };
    };
    /**
     * Retrieves a list of fills from the SpokePool contract.
     * @returns A list of fills.
     */
    getFills(): FillWithBlock[];
    /**
     * Retrieves a list of fills from a specific origin chain ID.
     * @param originChainId The origin chain ID.
     * @returns A list of fills.
     */
    getFillsForOriginChain(originChainId: number): FillWithBlock[];
    /**
     * Retrieves a list of fills from a specific relayer address.
     * @param relayer The relayer address.
     * @returns A list of fills.
     */
    getFillsForRelayer(relayer: Address): FillWithBlock[];
    /**
     * Retrieves a list of fills from a given block range.
     * @param startingBlock The starting block number.
     * @param endingBlock The ending block number.
     * @returns A list of fills.
     */
    getFillsWithBlockInRange(startingBlock: number, endingBlock: number): FillWithBlock[];
    /**
     * Retrieves a list of root bundle relays from the SpokePool contract.
     * @returns A list of root bundle relays.
     */
    getRootBundleRelays(): RootBundleRelayWithBlock[];
    /**
     * Retrieves the ID of the latest root bundle.
     * @returns The ID of the latest root bundle. This will be 0 if no root bundles have been relayed.
     */
    getLatestRootBundleId(): number;
    /**
     * Retrieves a list of relayer refund executions from the SpokePool contract.
     * @returns A list of relayer refund executions.
     */
    getRelayerRefundExecutions(): RelayerRefundExecutionWithBlock[];
    /**
     * Retrieves a list of claimed relayer refunds from the SpokePool contract.
     * @returns A list of claimed relayer refunds.
     */
    getClaimedRelayerRefunds(): ClaimedRelayerRefundWithBlock[];
    /**
     * Retrieves a list of bridged to hub pool events from the SpokePool contract.
     * @returns A list of bridged to hub pool events.
     */
    getBridgedToHubPoolEvents(): BridgedToHubPoolWithBlock[];
    /**
     * Appends a speed up signature to a specific deposit.
     * @param deposit The deposit to append the speed up signature to.
     * @returns A new deposit instance with the speed up signature appended to the deposit.
     */
    appendMaxSpeedUpSignatureToDeposit(deposit: DepositWithBlock): DepositWithBlock;
    /**
     * Find a deposit based on its deposit ID.
     * @notice If evaluating a fill, be sure to verify it against the resulting deposit.
     * @param depositId The unique ID of the deposit being queried.
     * @returns The corresponding deposit if found, undefined otherwise.
     */
    getDeposit(depositId: BigNumber): DepositWithBlock | undefined;
    /**
     * Retrieves a list of slow fill requests from the SpokePool contract.
     * @returns A list of slow fill requests.
     */
    getSlowFillRequests(): SlowFillRequestWithBlock[];
    /**
     * Find a SlowFillRequested event based on its deposit RelayData.
     * @param relayData RelayData field for the SlowFill request.
     * @returns The corresponding SlowFillRequest event if found, otherwise undefined.
     */
    getSlowFillRequest(relayData: Omit<RelayData, "message"> & {
        messageHash: string;
    }): SlowFillRequestWithBlock | undefined;
    /**
     * Retrieves a list of slow fill requests for deposits from a specific origin chain ID.
     * @param originChainId The origin chain ID.
     * @returns A list of slow fill requests.
     */
    getSlowFillRequestsForOriginChain(originChainId: number): SlowFillRequestWithBlock[];
    /**
     * Retrieves speed up requests grouped by depositor and depositId.
     * @returns A mapping of depositor addresses to deposit ids with their corresponding speed up requests.
     */
    getSpeedUps(): {
        [depositorAddress: string]: {
            [depositId: string]: SpeedUpWithBlock[];
        };
    };
    /**
     * Find a corresponding deposit for a given fill.
     * @param fill The fill to find a corresponding deposit for.
     * @returns The corresponding deposit if found, undefined otherwise.
     */
    getDepositForFill(fill: Fill): DepositWithBlock | undefined;
    getFillsForDeposit(deposit: Deposit): FillWithBlock[];
    isDepositFilled(deposit: Deposit): boolean;
    /**
     * Find the unfilled amount for a given deposit. This is the full deposit amount minus the total filled amount.
     * @param deposit The deposit to find the unfilled amount for.
     * @param fillCount The number of fills that have been applied to this deposit.
     * @param invalidFills The invalid fills that have been applied to this deposit.
     * @returns The unfilled amount.
     */
    getValidUnfilledAmountForDeposit(deposit: Deposit): {
        unfilledAmount: BigNumber;
        fillCount: number;
        invalidFills: FillWithBlock[];
    };
    /**
     * Formulate a hash for a given deposit or fill
     * @param event The deposit or fill to formulate a hash for.
     * @returns The hash.
     * @note This hash is used to match deposits and fills together.
     * @note This hash takes the form of: `${depositId}-${originChainId}`.
     */
    getDepositHash(event: {
        depositId: BigNumber;
        originChainId: number;
    }): string;
    protected canResolveZeroAddressOutputToken(deposit: DepositWithBlock): boolean;
    /**
     * A wrapper over the `_update` method that handles errors and logs. This method additionally calls into the
     * HubPoolClient to update the state of this client with data from the HubPool contract.
     * @param eventsToQuery An optional list of events to query. If not provided, all events will be queried.
     * @returns A Promise that resolves to a SpokePoolUpdate object.
     * @note This method is the primary method for updating the state of this client externally.
     * @see _update
     */
    update(eventsToQuery?: string[]): Promise<void>;
    /**
     * Resolve a given timestamp to a block number on the HubPool chain via the HubPoolClient.
     * @param timestamp A single timestamp to be resolved via the HubPoolClient.
     * @returns The block number on the HubPool chain corresponding to the supplied timestamp.
     */
    protected getBlockNumber(timestamp: number): Promise<number>;
    /**
     * For an array of timestamps, resolve each timestamp to a block number on the HubPool chain via the HubPoolClient.
     * @param timestamps Array of timestamps to be resolved to a block number via the HubPoolClient.
     * @returns A mapping of quoteTimestamp -> HubPool block number.
     */
    protected getBlockNumbers(timestamps: number[]): Promise<{
        [quoteTimestamp: number]: number;
    }>;
    /**
     * Retrieves the destination token for a given deposit.
     * @param deposit The deposit to retrieve the destination token for.
     * @returns The destination token.
     */
    protected getDestinationTokenForDeposit(deposit: DepositWithBlock): Address;
    /**
     * Performs a log for a specific level, message and data.
     * @param level The log level.
     * @param message The log message.
     * @param data Optional data to log.
     */
    protected log(level: DefaultLogLevels, message: string, data?: AnyObject): void;
    /**
     * Retrieves the current time from the SpokePool contract.
     * @returns The current time, which will be 0 if there has been no update() yet.
     */
    getCurrentTime(): number;
    /**
     * Determines whether a deposit originates from a lite chain.
     * @param deposit The deposit to evaluate.
     * @returns True if the deposit originates from a lite chain, false otherwise. If the hub pool client is not defined,
     *          this method will return false.
     */
    protected isOriginLiteChain(deposit: DepositWithBlock): boolean;
    /**
     * Determines whether the deposit destination chain is a lite chain.
     * @param deposit The deposit to evaluate.
     * @returns True if the deposit is destined to a lite chain, false otherwise. If the hub pool client is not defined,
     *          this method will return false.
     */
    protected isDestinationLiteChain(deposit: DepositWithBlock): boolean;
    /**
     * Returns a list of event names that are queryable for the SpokePoolClient.
     * @returns A list of event names that are queryable for the SpokePoolClient.
     */
    abstract _queryableEventNames(): string[];
    /**
     * Performs an update to refresh the state of this client. This will query the SpokePool contract for new events
     * and store them in memory. This method is the primary method for updating the state of this client.
     * @param eventsToQuery An optional list of events to query. If not provided, all events will be queried.
     * @returns A Promise that resolves to a SpokePoolUpdate object.
     */
    protected abstract _update(eventsToQuery: string[]): Promise<SpokePoolUpdate>;
    /**
     * @notice Return maximum of fill deadline buffer at start and end of block range. This is a contract
     * immutable state variable so we can't query other events to find its updates.
     * @dev V3 deposits have a fill deadline which can be set to a maximum of fillDeadlineBuffer + deposit.block.timestamp.
     * Therefore, we cannot evaluate a block range for expired deposits if the spoke pool client doesn't return us
     * deposits whose block.timestamp is within fillDeadlineBuffer of the end block time. As a conservative check,
     * we verify that the time between the end block timestamp and the first timestamp queried by the
     * spoke pool client is greater than the maximum of the fill deadline buffers at the start and end of the block
     * range. We assume the fill deadline buffer wasn't changed more than once within a bundle.
     * @param startBlock start block
     * @param endBlock end block
     * @returns maximum of fill deadline buffer at start and end block
     */
    abstract getMaxFillDeadlineInRange(startBlock: number, endBlock: number): Promise<number>;
    /**
     * Retrieves the timestamp for a given block number.
     * @param blockTag The block number to retrieve the timestamp for.
     * @returns The timestamp for the given block number.
     */
    abstract getTimestampForBlock(blockTag: number): Promise<number>;
    /**
     * Retrieves the time from the SpokePool contract at a particular block.
     * @returns The time at the specified block tag.
     */
    abstract getTimeAt(blockNumber: number): Promise<number>;
    /**
     * For a given origin chain depositId, resolve the corresponding Deposit.
     * Note: This method can only be used for depositIds within the non-deterministic range (0 < depositId < 2^32 - 1).
     * @param depositId Deposit ID of the deposit to resolve.
     * @returns A DepositSearchResult instance.
     */
    abstract findDeposit(depositId: BigNumber): Promise<DepositSearchResult>;
    /**
     * Retrieves the fill status for a given relay data.
     * @param relayData The relay data to retrieve the fill status for.
     * @param atHeight The height at which to query the fill status.
     * @returns The fill status for the given relay data.
     */
    abstract relayFillStatus(relayData: RelayData, atHeight?: number): Promise<FillStatus>;
    /**
     * Retrieves the fill status for an array of given relay data.
     * @param relayData The array relay data to retrieve the fill status for.
     * @param atHeight The height at which to query the fill status.
     * @returns The fill status for each of the given relay data.
     */
    abstract fillStatusArray(relayData: RelayData[], atHeight?: number): Promise<(FillStatus | undefined)[]>;
}
//# sourceMappingURL=SpokePoolClient.d.ts.map