import type { EthAddress, Promisable } from '@ariestools/sdk';
import { type IAddressStakingEvents } from '@xyo-network/typechain';
import { type StakeEvent, type StakeEventFilter, type StakeEventName, type StakeEventsViewer } from '@xyo-network/xl1-protocol/protocol-lib';
import type { EvmViewerParams } from './AbstractEvmViewer.js';
import { AbstractEvmViewer } from './AbstractEvmViewer.js';
/**
 * Starting max blocks per eth_getLogs / queryFilter call. Providers that cap
 * the range reject with an explicit error and the fetcher adapts downward,
 * jumping straight to an advertised limit when the error states one.
 */
export declare const DEFAULT_EVENT_QUERY_START_CHUNK_SIZE = 100000;
/** Floor for adaptive chunk shrinking — a range error below this is rethrown. */
export declare const MIN_EVENT_QUERY_BLOCK_CHUNK_SIZE = 1000;
/** Default attempts (including first) when eth_getLogs hits provider rate limits. */
export declare const DEFAULT_EVENT_QUERY_MAX_ATTEMPTS = 8;
/** Initial backoff after a rate-limit response before retrying eth_getLogs. */
export declare const DEFAULT_EVENT_QUERY_INITIAL_DELAY_MS = 1000;
/**
 * Structural view of a parsed stake event log — satisfied by both ethers
 * `EventLog` (address-only sweep) and typechain `TypedEventLog` (live
 * listeners). Full shape validation happens via `EvmStakeEventZod`.
 */
interface StakeEventLogLike {
    blockNumber: number;
    eventName: string;
}
export interface EvmStakeEventsParams extends EvmViewerParams {
    /**
     * Fixed max blocks per eth_getLogs / queryFilter call when loading
     * historical stake events. When omitted the fetcher starts at
     * {@link DEFAULT_EVENT_QUERY_START_CHUNK_SIZE} and adapts down to the
     * provider's actual range limit.
     */
    eventQueryBlockChunkSize?: number;
    /**
     * Initial delay (ms) after a rate-limit response before retrying eth_getLogs.
     * Defaults to {@link DEFAULT_EVENT_QUERY_INITIAL_DELAY_MS}.
     */
    eventQueryInitialDelayMs?: number;
    /**
     * Total eth_getLogs attempts per chunk (including the first) when rate limited.
     * Defaults to {@link DEFAULT_EVENT_QUERY_MAX_ATTEMPTS}.
     */
    eventQueryMaxAttempts?: number;
}
export declare class EvmStakeEventsViewer extends AbstractEvmViewer<EvmStakeEventsParams, IAddressStakingEvents> implements StakeEventsViewer {
    static readonly connectionTypes: readonly ["evm-rpc"];
    static readonly defaultMoniker: "StakeEventsViewer";
    static readonly dependencies: "EvmChainViewer"[];
    static readonly monikers: "StakeEventsViewer"[];
    static readonly surface: "node";
    moniker: "StakeEventsViewer";
    /**
     * Current adaptive chunk size — shrinks when the provider rejects a range
     * and persists across loads so the tail catch-up reuses the learned limit.
     */
    private adaptiveChunkSize?;
    /** Set at start when `params.deploymentBlock` is omitted (getCode binary search, date-estimate fallback). */
    private defaultDeploymentBlock;
    private eventCache;
    get deploymentBlock(): number;
    get eventQueryBlockChunkSize(): number;
    get eventQueryInitialDelayMs(): number;
    get eventQueryMaxAttempts(): number;
    /**
     * Fixed eth_getLogs range: explicit param (deprecated), else the bound evm-rpc
     * connection profile's `eventQueryBlockChunkSize`. Undefined → adaptive sizing.
     */
    protected get fixedEventQueryBlockChunkSize(): number | undefined;
    positionCount(range: [number, number | 'latest']): Promise<number>;
    stakeEvents<TName extends StakeEventName>(range?: [number, number | 'latest'], filter?: StakeEventFilter<TName>): Promisable<StakeEvent<TName>[]>;
    protected connectContract(address: EthAddress): IAddressStakingEvents;
    protected onEventHandler(staked: string, staker: string, id: bigint, amount: bigint, event: StakeEventLogLike, throwOnInvalid?: boolean): StakeEvent | undefined;
    protected startHandler(): Promise<void>;
    private attachLiveListeners;
    /**
     * Loads all stake events for the range with a single address-only sweep —
     * one eth_getLogs pass per chunk covers all three event types (demuxed by
     * event name client-side) instead of three filtered sweeps over the same
     * blocks. Chunk size adapts to the provider: on a range/result-limit error
     * the chunk shrinks (to the advertised limit when the error states one,
     * halving otherwise) and the window is retried; rate limits retry at the
     * same size with backoff.
     */
    private loadHistoricalEvents;
}
export {};
//# sourceMappingURL=EvmStakeEventsViewer.d.ts.map