/// /// /// /// /// import { paginatedEventQuery as umaPaginatedEventQuery } from "@uma/common"; import { createHttpClient } from "@uma/toolkit"; import { AxiosInstance } from "axios"; export declare const paginatedEventQuery: typeof umaPaginatedEventQuery; import type { Provider } from "@ethersproject/abstract-provider"; import { BigNumber, Contract, Event, EventFilter, ethers } from "ethers"; import { Logger } from "@uma/financial-templates-lib"; export { getContractInstanceWithProvider } from "../utils/contracts"; import * as s from "superstruct"; export { Logger }; export declare const ONE_SCALED: BigNumber; export declare const POLYGON_BLOCKS_PER_HOUR = 1800; export interface MonitoringParams { ctfExchangeAddress: string; ctfSportsOracleAddress: string; additionalRequesters: string[]; maxBlockLookBack: number; graphqlEndpoint: string; polymarketApiKey: string; apiEndpoint: string; provider: Provider; chainId: number; pollingDelay: number; unknownProposalNotificationInterval: number; retryAttempts: number; retryDelayMs: number; checkBeforeExpirationSeconds: number; fillEventsLookbackSeconds: number; httpClient: ReturnType; orderBookBatchSize: number; ooV2Addresses: string[]; ooV1Addresses: string[]; aiConfig?: AIConfig; } export interface PolymarketMarketGraphqlProcessed { volumeNum: number; outcomes: [string, string]; outcomePrices: [string, string]; clobTokenIds: [string, string]; question: string; questionID: string; } export interface PolymarketTradeInformation { price: number; type: "buy" | "sell"; amount: number; timestamp: number; } export interface PolymarketOrderBook { market: string; asset_id: string; bids: { price: string; size: string; }[]; asks: { price: string; size: string; }[]; hash: string; } export type Order = { price: number; size: number; }[]; export interface MarketOrderbook { bids: Order; asks: Order; } export interface OptimisticPriceRequest { requestHash: string; requestTimestamp: BigNumber; requestLogIndex: number; requester: string; proposer: string; identifier: string; ancillaryData: string; proposalBlockNumber: number; proposedPrice: BigNumber; proposalTimestamp: BigNumber; proposalHash: string; proposalExpirationTimestamp: BigNumber; proposalLogIndex: number; } interface StoredNotifiedProposal { proposalHash: string; } export declare enum MarketType { Winner = 0, Spreads = 1, Totals = 2 } export declare enum Ordering { HomeVsAway = 0, AwayVsHome = 1 } export declare enum Underdog { Home = 0, Away = 1 } export type Market = { marketType: MarketType; ordering: Ordering; underdog: Underdog; line: ethers.BigNumber; }; export declare const getPolymarketProposedPriceRequestsOO: (params: MonitoringParams, version: "v1" | "v2", requesterAddresses: string[], ooAddress: string) => Promise; export declare const extractInitializerFromAncillaryData: (ancillaryData: string) => string | null; export declare const getRewardForProposal: (params: MonitoringParams, proposal: OptimisticPriceRequest, version: "v1" | "v2") => Promise; export declare const shouldIgnoreThirdPartyProposal: (params: MonitoringParams, proposal: OptimisticPriceRequest, version: "v1" | "v2") => Promise; export declare const getPolymarketMarketInformation: (logger: typeof Logger, params: MonitoringParams, questionID: string) => Promise; export declare const getOrderFilledEvents: (params: MonitoringParams, clobTokenIds: [string, string], startBlockNumber: number) => Promise<[PolymarketTradeInformation[], PolymarketTradeInformation[]]>; export declare const calculatePolymarketQuestionID: (ancillaryData: string) => string; export declare function getOrFallback(client: AxiosInstance, url: string, fallback: T, opts?: { statusCode?: number; errorMessage?: string; }): Promise; export declare const getPolymarketOrderBook: (params: MonitoringParams, clobTokenIds: [string, string]) => Promise<[MarketOrderbook, MarketOrderbook]>; export interface BookParams { token_id: string; } export declare function getPolymarketOrderBooks(params: MonitoringParams, tokenIds: string[]): Promise>; export declare function getSportsMarketData(params: MonitoringParams, questionID: string): Promise; export declare function decodeMultipleQueryPriceAtIndex(encodedPrice: BigNumber, index: number): BigNumber; export declare function encodeMultipleQuery(values: string[]): BigNumber; export declare function isUnresolvable(price: BigNumber | string): boolean; export declare function decodeScores(ordering: Ordering, data: ethers.BigNumber): { home: ethers.BigNumber; away: ethers.BigNumber; }; export declare function getSportsPayouts(market: Market, proposedPrice: ethers.BigNumber): [number, number]; declare const MultipleValuesQuery: s.Struct<{ title: string; description: string; labels: string[]; }, { title: s.Struct; description: s.Struct; labels: s.Struct>; }>; export type MultipleValuesQuery = s.Infer; export declare function decodeMultipleValuesQuery(decodedAncillaryData: string): MultipleValuesQuery; export interface UMAAIRetry { id: string; question_id: string; data: { input: { timing?: { expiration_timestamp?: number; }; }; }; } export interface UMAAIRetriesLatestResponse { elements: UMAAIRetry[]; next_cursor: string | null; has_more: boolean; total_count: number; total_pages: number; } interface AIRetryLookupResult { deeplink?: string; } export declare function fetchLatestAIDeepLink(proposal: OptimisticPriceRequest, params: MonitoringParams, logger: typeof Logger): Promise; export declare const getProposalKeyToStore: (market: StoredNotifiedProposal | OptimisticPriceRequest) => string; export declare const isProposalNotified: (proposal: OptimisticPriceRequest) => Promise; export declare const getInitialConfirmationLoggedKey: (marketId: string) => string; export declare const isInitialConfirmationLogged: (marketId: string) => Promise; export declare const markInitialConfirmationLogged: (marketId: string) => Promise; export declare const storeNotifiedProposals: (notifiedContracts: OptimisticPriceRequest[]) => Promise; export declare const getNotifiedProposals: () => Promise<{ [key: string]: StoredNotifiedProposal; }>; export declare const parseEnvList: (env: NodeJS.ProcessEnv, key: string, defaultValue: string[]) => string[]; export declare const parseEnvJson: (env: NodeJS.ProcessEnv, key: string, defaultValue: T) => T; export interface AIConfig { projectId: string; apiUrl: string; resultsBaseUrl: string; apiKey: string; } export declare const initMonitoringParams: (env: NodeJS.ProcessEnv, logger: typeof Logger) => Promise; /** * Retries an async function if it errors up to N times with M delay between retries. * @param fn - The async function to retry. * @param retries - Number of times to retry the function. * @param delayMs - Delay between retries in milliseconds. * @returns A promise that resolves with the result of the async function. */ export declare function retryAsync(fn: () => Promise, retries: number, delayMs: number): Promise; /** * @dev This function is a wrapper around the queryFilter function that splits the query into smaller chunks if the query is too large. * @param contract - The contract to query. * @param filter - The filter to apply to the query. * @param fromBlock - The block number to start the query from. * @param toBlock - The block number to end the query at. * @returns The filtered events. */ export declare function queryFilterSafe(contract: Contract): (filter: EventFilter, fromBlock: number, toBlock: number) => Promise;