UNPKG

@0xsplits/splits-sdk

Version:

SDK for the 0xSplits protocol

66 lines (65 loc) 4.16 kB
import { Address, GetLogsReturnType } from 'viem'; import { SplitsPublicClient } from '../types'; import { splitV2FactoryABI } from '../constants/abi/splitV2Factory'; import { splitMainPolygonAbi, splitV2ABI } from '../constants/abi'; import { SplitV2Versions } from '../subgraph/types'; import { splitV2o2FactoryAbi } from '../constants/abi/splitV2o2Factory'; /** * Retries a function n number of times with exponential backoff before giving up */ export declare function retryExponentialBackoff<T extends (...arg0: any[]) => any>(fn: T, args: Parameters<T>, maxTry: number, retryCount?: number): Promise<ReturnType<T>>; export declare const isLogsPublicClient: (publicClient: SplitsPublicClient) => boolean; export declare const isAlchemyPublicClient: (arg0: SplitsPublicClient) => boolean; export declare const isInfuraPublicClient: (arg0: SplitsPublicClient) => boolean; export declare const getLargestValidBlockRange: ({ maxBlockRange, publicClient, }: { maxBlockRange?: bigint; publicClient: SplitsPublicClient; }) => Promise<bigint>; type SplitCreatedEventType = (typeof splitV2FactoryABI)[8] | (typeof splitMainPolygonAbi)[14] | (typeof splitV2o2FactoryAbi)[1] | (typeof splitV2o2FactoryAbi)[2]; type SplitUpdatedEventType = (typeof splitV2ABI)[28] | (typeof splitMainPolygonAbi)[18]; export declare const getSplitCreateAndUpdateLogs: <SplitCreatedEventName extends SplitCreatedEventType["name"], SplitUpdatedEventName extends SplitUpdatedEventType["name"], SplitCreatedLogType extends GetLogsReturnType<SplitCreatedEventType, [SplitCreatedEventType], true, bigint, bigint, SplitCreatedEventName>[0] = GetLogsReturnType<SplitCreatedEventType, [SplitCreatedEventType], true, bigint, bigint, SplitCreatedEventName>[0], SplitUpdatedLogType extends GetLogsReturnType<SplitUpdatedEventType, [SplitUpdatedEventType], true, bigint, bigint, SplitUpdatedEventName>[0] = GetLogsReturnType<SplitUpdatedEventType, [SplitUpdatedEventType], true, bigint, bigint, SplitUpdatedEventName>[0]>({ splitAddress, publicClient, splitCreatedEvent, splitUpdatedEvent, addresses, startBlockNumber, defaultBlockRange, currentUpdateLog, currentEndBlockNumber, maxBlockRange, cachedBlocks, splitV2Version, }: { splitAddress: Address; publicClient: SplitsPublicClient; splitCreatedEvent: SplitCreatedEventType; splitUpdatedEvent: SplitUpdatedEventType; addresses: Address[]; startBlockNumber: bigint; defaultBlockRange?: bigint; currentUpdateLog?: SplitUpdatedLogType; currentEndBlockNumber?: bigint; maxBlockRange?: bigint; cachedBlocks?: { createBlock?: bigint; updateBlock?: bigint; latestScannedBlock: bigint; }; splitV2Version?: SplitV2Versions; }) => Promise<{ blockRange: bigint; createLog?: SplitCreatedLogType; updateLog?: SplitUpdatedLogType; }>; export declare const LOGS_SEARCH_BATCH_SIZE = 10; export declare const searchLogs: <SplitCreatedEventName extends SplitCreatedEventType["name"], SplitUpdatedEventName extends SplitUpdatedEventType["name"], SplitCreatedLogType extends GetLogsReturnType<SplitCreatedEventType, [SplitCreatedEventType], true, bigint, bigint, SplitCreatedEventName>[0], SplitUpdatedLogType extends GetLogsReturnType<SplitUpdatedEventType, [SplitUpdatedEventType], true, bigint, bigint, SplitUpdatedEventName>[0]>({ formattedSplitAddress, publicClient, addresses, splitCreatedEvent, splitUpdatedEvent, startBlock, endBlock, defaultBlockRange, maxBlockRange, currentUpdateLog, cachedBlocks, splitV2Version, }: { formattedSplitAddress: Address; publicClient: SplitsPublicClient; splitCreatedEvent: SplitCreatedEventType; splitUpdatedEvent: SplitUpdatedEventType; addresses: Address[]; startBlock: bigint; endBlock: bigint; defaultBlockRange?: bigint; currentUpdateLog?: SplitUpdatedLogType; maxBlockRange?: bigint; cachedBlocks?: { createBlock: bigint; updateBlock?: bigint; latestScannedBlock: bigint; }; splitV2Version?: SplitV2Versions; }) => Promise<{ blockRange: bigint; createLog?: SplitCreatedLogType; updateLog?: SplitUpdatedLogType; }>; export {};