import { Contract, EventFilter } from "ethers"; import winston from "winston"; import { CachingMechanismInterface, CancelledRootBundle, CrossChainContractsSet, Deposit, DepositWithBlock, DestinationTokenWithBlock, DisputedRootBundle, ExecutedRootBundle, L1Token, Log, LpToken, PendingRootBundle, ProposedRootBundle, RealizedLpFee, TokenRunningBalance } from "../interfaces"; import { BigNumber, BlockFinder, EventSearchConfig, MakeOptional } from "../utils"; import { AcrossConfigStoreClient as ConfigStoreClient } from "./AcrossConfigStoreClient/AcrossConfigStoreClient"; import { BaseAbstractClient, UpdateFailureReason } from "./BaseAbstractClient"; type HubPoolUpdateSuccess = { success: true; currentTime: number; pendingRootBundleProposal: PendingRootBundle; events: Record; searchEndBlock: number; }; type HubPoolUpdateFailure = { success: false; reason: UpdateFailureReason; }; export type HubPoolUpdate = HubPoolUpdateSuccess | HubPoolUpdateFailure; type HubPoolEvent = "SetPoolRebalanceRoute" | "L1TokenEnabledForLiquidityProvision" | "ProposeRootBundle" | "RootBundleCanceled" | "RootBundleDisputed" | "RootBundleExecuted" | "CrossChainContractsSet"; type L1TokensToDestinationTokens = { [l1Token: string]: { [destinationChainId: number]: string; }; }; export type LpFeeRequest = Pick & { paymentChainId?: number; }; export declare class HubPoolClient extends BaseAbstractClient { readonly logger: winston.Logger; readonly hubPool: Contract; configStoreClient: ConfigStoreClient; deploymentBlock: number; readonly chainId: number; protected readonly configOverride: { ignoredHubExecutedBundles: number[]; ignoredHubProposedBundles: number[]; timeToCache?: number; }; protected l1TokensToDestinationTokens: L1TokensToDestinationTokens; protected l1Tokens: L1Token[]; protected lpTokens: { [token: string]: LpToken; }; protected proposedRootBundles: ProposedRootBundle[]; protected canceledRootBundles: CancelledRootBundle[]; protected disputedRootBundles: DisputedRootBundle[]; protected executedRootBundles: ExecutedRootBundle[]; protected crossChainContracts: { [l2ChainId: number]: CrossChainContractsSet[]; }; protected l1TokensToDestinationTokensWithBlock: { [l1Token: string]: { [destinationChainId: number]: DestinationTokenWithBlock[]; }; }; protected pendingRootBundle: PendingRootBundle | undefined; currentTime: number | undefined; readonly blockFinder: BlockFinder; constructor(logger: winston.Logger, hubPool: Contract, configStoreClient: ConfigStoreClient, deploymentBlock?: number, chainId?: number, eventSearchConfig?: MakeOptional, configOverride?: { ignoredHubExecutedBundles: number[]; ignoredHubProposedBundles: number[]; timeToCache?: number; }, cachingMechanism?: CachingMechanismInterface); protected hubPoolEventFilters(): Record; hasPendingProposal(): boolean; getPendingRootBundle(): PendingRootBundle | undefined; getProposedRootBundles(): ProposedRootBundle[]; getCancelledRootBundles(): CancelledRootBundle[]; getDisputedRootBundles(): DisputedRootBundle[]; getExecutedRootBundles(): ExecutedRootBundle[]; getSpokePoolForBlock(chain: number, block?: number): string; getSpokePoolActivationBlock(chain: number, spokePool: string): number | undefined; getL2TokenForL1TokenAtBlock(l1Token: string, destinationChainId: number, latestHubBlock?: number): string; getL1TokenForL2TokenAtBlock(l2Token: string, destinationChainId: number, latestHubBlock?: number): string; /** * Returns the L1 token that should be used for an L2 Bridge event. This function is * designed to be used by the caller to associate the L2 token with its mapped L1 token * at the HubPool equivalent block number of the L2 event. * @param deposit Deposit event * @param returns string L1 token counterpart for Deposit */ getL1TokenForDeposit(deposit: Pick): string; /** * Returns the L2 token that should be used as a counterpart to a deposit event. For example, the caller * might want to know what the refund token will be on l2ChainId for the deposit event. * @param l2ChainId Chain where caller wants to get L2 token counterpart for * @param event Deposit event * @returns string L2 token counterpart on l2ChainId */ getL2TokenForDeposit(deposit: Pick, l2ChainId?: number): string; l2TokenEnabledForL1Token(l1Token: string, destinationChainId: number): boolean; /** * @dev If tokenAddress + chain do not exist in TOKEN_SYMBOLS_MAP then this will throw. * @param tokenAddress Token address on `chain` * @param chain Chain where the `tokenAddress` exists in TOKEN_SYMBOLS_MAP. * @returns Token info for the given token address on the L2 chain including symbol and decimal. */ getTokenInfoForAddress(tokenAddress: string, chain: number): L1Token; /** * @dev If tokenAddress + chain do not exist in TOKEN_SYMBOLS_MAP then this will throw. * @dev if the token matched in TOKEN_SYMBOLS_MAP does not have an L1 token address then this will throw. * @param tokenAddress Token address on `chain` * @param chain Chain where the `tokenAddress` exists in TOKEN_SYMBOLS_MAP. * @returns Token info for the given token address on the Hub chain including symbol and decimal and L1 address. */ getL1TokenInfoForAddress(tokenAddress: string, chain: number): L1Token; /** * Resolve a given timestamp to a block number on the HubPool chain. * @param timestamp A single timestamp to be resolved to a block number on the HubPool chain. * @returns The block number corresponding to the supplied timestamp. */ getBlockNumber(timestamp: number): Promise; /** * For an array of timestamps, resolve each unique timestamp to a block number on the HubPool chain. * @dev Inputs are filtered for uniqueness and sorted to improve BlockFinder efficiency. * @dev Querying block numbers sequentially also improves BlockFinder efficiency. * @param timestamps Array of timestamps to be resolved to a block number on the HubPool chain. * @returns A mapping of quoteTimestamp -> HubPool block number. */ getBlockNumbers(timestamps: number[]): Promise<{ [quoteTimestamp: number]: number; }>; getCurrentPoolUtilization(l1Token: string): Promise; /** * For a HubPool token at a specific block number, compute the relevant utilization. * @param hubPoolToken HubPool token to query utilization for. * @param blocknumber Block number to query utilization at. * @param amount Amount to query. If set to 0, the closing utilization at blockNumber is returned. * @param amount timestamp Associated quoteTimestamp for query, used for caching evaluation. * @param timeToCache Age at which the response is able to be cached. * @returns HubPool utilization at `blockNumber` after optional `amount` increase in utilization. */ protected getUtilization(hubPoolToken: string, blockNumber: number, depositAmount: BigNumber, timestamp: number, timeToCache: number): Promise; computeRealizedLpFeePct(deposit: LpFeeRequest): Promise; batchComputeRealizedLpFeePct(deposits: LpFeeRequest[]): Promise; getL1Tokens(): L1Token[]; getTokenInfoForL1Token(l1Token: string): L1Token | undefined; getLpTokenInfoForL1Token(l1Token: string): LpToken | undefined; getL1TokenInfoForL2Token(l2Token: string, chainId: number): L1Token | undefined; getTokenInfoForDeposit(deposit: Deposit): L1Token | undefined; getTokenInfo(chainId: number | string, tokenAddress: string): L1Token | undefined; areTokensEquivalent(tokenA: string, chainIdA: number, tokenB: string, chainIdB: number, hubPoolBlock?: number): boolean; getSpokeActivationBlockForChain(chainId: number): number; isRootBundleValid(rootBundle: ProposedRootBundle, latestMainnetBlock: number): boolean; getRootBundleEvalBlockNumberContainingBlock(latestMainnetBlock: number, block: number, chain: number, chainIdListOverride?: number[]): number | undefined; getProposedRootBundlesInBlockRange(startingBlock: number, endingBlock: number): ProposedRootBundle[]; getCancelledRootBundlesInBlockRange(startingBlock: number, endingBlock: number): CancelledRootBundle[]; getDisputedRootBundlesInBlockRange(startingBlock: number, endingBlock: number): DisputedRootBundle[]; /** * Retrieves token mappings that were modified within a specified block range. * @param startingBlock - The starting block of the range (inclusive). * @param endingBlock - The ending block of the range (inclusive). * @returns An array of destination tokens, each containing the `l2ChainId`, that * were modified within the given block range. */ getTokenMappingsModifiedInBlockRange(startingBlock: number, endingBlock: number): (DestinationTokenWithBlock & { l2ChainId: number; })[]; getLatestProposedRootBundle(): ProposedRootBundle; getFollowingRootBundle(currentRootBundle: ProposedRootBundle): ProposedRootBundle | undefined; getExecutedLeavesForRootBundle(rootBundle: ProposedRootBundle, latestMainnetBlockToSearch: number): ExecutedRootBundle[]; getValidatedRootBundles(latestMainnetBlock?: number): ProposedRootBundle[]; getLatestFullyExecutedRootBundle(latestMainnetBlock: number): ProposedRootBundle | undefined; getEarliestFullyExecutedRootBundle(latestMainnetBlock: number, startBlock?: number): ProposedRootBundle | undefined; getNthFullyExecutedRootBundle(n: number, startBlock?: number): ProposedRootBundle | undefined; getLatestBundleEndBlockForChain(chainIdList: number[], latestMainnetBlock: number, chainId: number): number; getNextBundleStartBlockNumber(chainIdList: number[], latestMainnetBlock: number, chainId: number): number; getRunningBalanceBeforeBlockForChain(block: number, chain: number, l1Token: string): TokenRunningBalance; getRunningBalanceForToken(l1Token: string, executedRootBundle: ExecutedRootBundle): TokenRunningBalance; _update(eventNames: HubPoolEvent[]): Promise; update(eventsToQuery?: HubPoolEvent[]): Promise; protected getBundleEndBlockForChain(proposeRootBundleEvent: ProposedRootBundle, chainId: number, chainIdList: number[]): number; } export {}; //# sourceMappingURL=HubPoolClient.d.ts.map