import { HubPoolClient } from "../HubPoolClient";
import UBAFeeConfig from "../../UBAFeeCalculator/UBAFeeConfig";
import { SpokePoolClients } from "../../utils/TypeUtils";
import { ModifiedUBAFlow, RequestValidReturnType, SpokePoolFillFilter, UBAClientState } from "./UBAClientTypes";
import { DepositWithBlock, Fill, FillWithBlock, RefundRequestWithBlock, TokenRunningBalance, UBAParsedConfigType, UbaFlow } from "../../interfaces";
/**
 * Parses a UBAParsedConfigType into a UBAFeeConfig
 * @param chainId The chain ID to parse the UBA config for
 * @param tokenSymbol The token symbol to parse the UBA config for
 * @param ubaConfig The UBAParsedConfigType to parse
 * @returns The parsed UBAFeeConfig
 */
export declare function parseUBAFeeConfig(chainId: number, tokenSymbol: string, ubaConfig?: UBAParsedConfigType): UBAFeeConfig | undefined;
/**
 * Returns the UBA config for a given chainId and tokenSymbol at a given block height.
 * @param hubPoolClient The hub pool client to use for fetching the UBA config. This client's config store client must be updated.
 * @param chainId The chainId to fetch the UBA config for.
 * @param tokenSymbol The token symbol to fetch the UBA config for.
 * @param blockNumber The block height to fetch the UBA config for.
 * @returns The UBA config for the given chainId and tokenSymbol at the given block height.
 * @throws If the config store client has not been updated at least once.
 * @throws If the L1 token address cannot be found for the given token symbol.
 * @throws If the UBA config for the given block height cannot be found.
 */
export declare function getUBAFeeConfig(hubPoolClient: HubPoolClient, chainId: number, tokenSymbol: string, blockNumber?: number): UBAFeeConfig;
/**
 * Returns most recent `maxBundleStates` bundle ranges for a given chain, in chronological ascending order.
 * Will only returns bundle ranges that are subject to UBA rules, which is based on the bundle's start block.
 * Additionally, includes potential next bundle block ranges which extend until the latest spoke pool client search
 * windows, so that the caller can call this function to cover all UBA events.
 * @param chainId
 * @param maxBundleStates If this is larger than available validated bundles in the HubPoolClient, will throw an error.
 * @param hubPoolClient The hub pool client to use for fetching the bundle ranges.
 * @param spokePoolClients The spoke pool clients to use for fetching the bundle ranges.
 * @returns The most recent `maxBundleStates` bundle ranges for a given chain, in chronological ascending order.
 */
export declare function getMostRecentBundleBlockRanges(chainId: number, maxBundleStates: number, hubPoolClient: HubPoolClient, spokePoolClients: SpokePoolClients): {
    start: number;
    end: number;
}[];
/**
 * Return the latest validated running balance for the given token.
 * @param eventBlock Block number on SpokePool chain.
 * @param eventChain SpokePool chain ID.
 * @param l1Token Address of token on the HubPool chain.
 * @param hubPoolLatestBlock Most recent block to query from. Queries progress backwards in reverse chronology.
 * @returns Token running balance as at eventBlock.
 **/
export declare function getOpeningRunningBalanceForEvent(hubPoolClient: HubPoolClient, eventBlock: number, eventChain: number, l1Token: string, hubPoolLatestBlock: number): TokenRunningBalance;
export declare function getMatchedDeposit(spokePoolClients: SpokePoolClients, fill: Fill, fillFieldsToIgnore?: string[]): Promise<DepositWithBlock | undefined>;
export declare function isUBAActivatedAtBlock(hubPoolClient: HubPoolClient, block: number, chain: number): boolean;
/**
 * Returns bundle range start blocks for first bundle that UBA was activated
 * @param chainIds Chains to return start blocks for.
 * */
export declare function getUbaActivationBundleStartBlocks(hubPoolClient: HubPoolClient): number[];
/**
 * Return chain where flow occurred.
 * @param flow
 */
export declare function getFlowChain(flow: UbaFlow): number;
/**
 * Retrieves the flows for a given chainId. This is designed only to work with UBA start and end blocks as
 * the realizedLpFeePct for deposits is not compared against fills. Retrieving any "Pre UBA" deposits with
 * defined realizedLpFeePct will cause this function to throw.
 * * @param tokenSymbol Symbol of token to retrieve flows for.
 * @param chainId The chainId to retrieve flows for
 * @param spokePoolClients A mapping of chainIds to spoke pool clients
 * @param hubPoolClient A hub pool client instance to query the hub pool
 * @param fromBlock The block number to start retrieving flows from
 * @param toBlock The block number to stop retrieving flows from
 * @returns The flows for the given chainId
 */
export declare function getUBAFlows(tokenSymbol: string, chainId: number, spokePoolClients: SpokePoolClients, hubPoolClient: HubPoolClient, fromBlock?: number, toBlock?: number): Promise<UbaFlow[]>;
export declare function getBundleKeyForBlockRanges(blockRanges: number[][]): string;
/**
 * The return value should be a number whose sign indicates the relative order of the two elements:
 * negative if a is less than b, positive if a is greater than b, and zero if they are equal.
 * @param fx
 * @param fy
 * @returns
 */
export declare function flowComparisonFunction(a: UbaFlow, b: UbaFlow): number;
export declare function sortFlowsAscendingInPlace(flows: UbaFlow[]): UbaFlow[];
export declare function sortFlowsAscending(flows: UbaFlow[]): UbaFlow[];
/**
 * Validate a refund request.
 * @param chainId The chainId of the spoke pool
 * @param chainIdIndices The chainIds of the spoke pools that align with the spoke pool clients
 * @param spokePoolClients A mapping of chainIds to spoke pool clients
 * @param hubPoolClient The hub pool client
 * @param refundRequest The refund request to validate
 * @returns Whether or not the refund request is valid
 */
export declare function refundRequestIsValid(spokePoolClients: SpokePoolClients, hubPoolClient: HubPoolClient, refundRequest: RefundRequestWithBlock, ignoredDepositValidationParams?: string[]): Promise<RequestValidReturnType>;
/**
 * @notice Get the matching flow in a stream of already validated flows. Useful for seeing if an outflow's
 * matched inflow `targetFlow` is in the `allValidatedFlows` list.
 * @dev Assumes `allValidatedFlows` are all validated UBA flows so there should be no duplicate
 * origin chain and deposit id combinations.
 * @param allFlows
 * @param targetFlow
 * @returns
 */
export declare function getMatchingFlow(allValidatedFlows: ModifiedUBAFlow[], targetFlow: UbaFlow): ModifiedUBAFlow | undefined;
/**
 * @description Search for fills recorded by a specific SpokePool. These fills are matched against deposits
 * on all fields except for `realizedLpFeePct` which isn't filled yet.
 * @param chainId Chain ID of the relevant SpokePoolClient instance.
 * @param spokePoolClients Set of SpokePoolClient instances, mapped by chain ID.
 * @param filter  Optional filtering criteria.
 * @param ignoredDepositValidationParams Event fields to ignore when matching a Fill to a Deposit.
 * @returns Array of FillWithBlock events matching the chain ID and optional filtering criteria.
 */
export declare function getValidFillCandidates(chainId: number, spokePoolClients: SpokePoolClients, filter?: SpokePoolFillFilter, ignoredDepositValidationParams?: string[]): Promise<(FillWithBlock & {
    matchedDeposit: DepositWithBlock;
})[]>;
/**
 * Search for refund requests recorded by a specific SpokePool.
 * @param chainId Chain ID of the relevant SpokePoolClient instance.
 * @param chainIdIndices Complete set of ordered chain IDs.
 * @param hubPoolClient HubPoolClient instance.
 * @param spokePoolClients Set of SpokePoolClient instances, mapped by chain ID.
 * @param filter  Optional filtering criteria.
 * @returns Array of RefundRequestWithBlock events matching the chain ID and optional filtering criteria.
 */
export declare function getValidRefundCandidates(chainId: number, hubPoolClient: HubPoolClient, spokePoolClients: SpokePoolClients, filter?: Pick<SpokePoolFillFilter, "fromBlock" | "toBlock">, ignoredDepositValidationParams?: string[]): Promise<(RefundRequestWithBlock & {
    matchedDeposit: DepositWithBlock;
})[]>;
/**
 * Serializes a `UBAClientState` object.
 * @param ubaClientState `UBAClientState` object to serialize.
 * @returns Serialized `UBAClientState` object as a string.
 * @note The resulting string can be deserialized using `deserializeUBAClientState`.
 */
export declare function serializeUBAClientState(ubaClientState: UBAClientState): string;
/**
 * @todo Improve type safety and reduce `any`s.
 * Deserializes a serialized `UBAClientState` object.
 * @param serializedUBAClientState Serialized `UBAClientState` object that for example gets returned when calling `updateUBAClient` and serializing the result.
 * @returns Deserialized `UBAClientState` object. Specifically with `{ type: "BigNumber", value: "0x0" } converted to `BigNumber` instances. And a correct `UBAFeeConfig` instance.
 */
export declare function deserializeUBAClientState(serializedUBAClientState: object): UBAClientState;
