import type { Market, MarketStatus, MarketType, Odds } from "@prisma/client"; import type { Redis } from "ioredis"; import type { LevrChain, LevrGameMarketId, MarketWithOddsGameLeague, MarketWithRelations } from "../../../core"; export interface SearchQuery { marketType?: MarketType | MarketType[]; levrGameObjectId?: string | string[]; marketObjectId?: string | string[]; gameMarketId?: string | string[]; status?: MarketStatus | MarketStatus[]; chainId?: LevrChain | LevrChain[]; gameId?: number | number[]; levrMarketContract?: string | string[]; limit?: number; offset?: number; } export interface SearchResult { total: number; results: T[]; duration: number; } export interface UpdateMarketCacheResult { success: number; failed: number; total: number; } /** * Create market index with proper schema and versioning * Validates existing index schema and recreates if mismatched. * Uses the Redis client's keyPrefix to construct the correct index name and data prefix. */ export declare const createMarketIndex: (redis: Redis) => Promise; /** * Drop market search index * @param redis - Redis client instance */ export declare const dropMarketIndex: (redis: Redis) => Promise; /** * Add markets to cache with RediSearch indexing * @param redis - Redis client instance * @param markets - Array of Market objects to cache * @returns Result object with success/failed counts */ export declare const updateMarketCache: (redis: Redis, markets: Market[]) => Promise; /** * Interface for partial Market updates. * Only objectId and levrGameObjectId + marketType are required (for key generation). * All other fields are optional and only provided fields will be updated. */ export interface MarketPatch { objectId: string; levrGameObjectId: string; marketType: MarketType; chainId?: number; gameId?: number; levrMarketId?: string; levrMarketContract?: string; gameMarketId?: string; txHash?: string; maturedAt?: Date | null; leveraged?: boolean; isMatured?: boolean; normalizationFactor?: number; marketDetails?: unknown; marketRiskAllocation?: unknown; providers?: unknown; activeProvider?: unknown; status?: MarketStatus; winner?: string | null; createdAt?: Date; updatedAt?: Date; } /** * Patches markets in the Redis cache by updating only the provided fields. * Unlike updateMarketCache which overwrites all fields, this function only updates * the fields that are explicitly provided in each market object. * * @param redis - The Redis client instance used for cache operations * @param markets - An array of partial Market objects (objectId, levrGameObjectId, marketType required) * @returns A Promise resolving to UpdateMarketCacheResult with success/failure counts */ export declare const patchMarketCache: (redis: Redis, markets: MarketPatch[]) => Promise; export interface MarketSearchResult { markets: Market[]; total: number; } /** * Searches for markets in the Redis cache using RediSearch. * All filter params support single values or arrays (OR matching). * Limit auto-calculates to max(100, largestArraySize) if not specified. */ export declare const getGameMarkets: (redis: Redis, params: SearchQuery) => Promise; /** * Get markets with their associated odds * @param redis - Redis client instance * @param query - Search query parameters * @returns Results with markets and their odds */ export declare const getGameMarketsWithOdds: (redis: Redis, query: SearchQuery) => Promise>; /** * Get multiple markets with their associated odds using multiple queries * @param redis - Redis client instance * @param queries - Array of search query parameters * @returns Combined results with markets and their odds */ export declare const getMultipleMarketsWithOdds: (redis: Redis, queries: SearchQuery[]) => Promise<{ total: number; results: Record; duration: number; }>; /** * Get market data with associated odds for multiple games and market types * @param redis - Redis client instance * @param query - Array of query objects with gameUniqueIdentifier and marketType * @returns Map of game IDs to their markets with odds */ export declare const getMarketDataCacheWithOdds: (redis: Redis, query: Array<{ gameUniqueIdentifier: string; marketType: MarketType[]; }>) => Promise>; /** * Get odds for a specific gameMarketId with pagination using Redis LIST * @param redis - Redis client instance * @param gameMarketId - The game market identifier (key suffix) * @param limit - Number of latest odds to return (from the end). Use -1 for all. * @returns Array of Odds objects (most recent last) */ export declare const getOddsList: (redis: Redis, gameMarketId: string, limit?: number) => Promise; /** * Add odds to cache using Redis LIST (RPUSH) * @param redis - Redis client instance * @param gameMarketId - The game market identifier (used as key suffix) * @param odds - Array of Odds objects to append to the list * @param opts - Optional settings, e.g. ttlSeconds for postgame/backfill (2h) */ export declare const addOddsToOddsCache: (redis: Redis, gameMarketId: string, odds: Odds[], opts?: { ttlSeconds?: number; }) => Promise; export declare const getMarketsWithOddsAndGameLeague: (redis: Redis, gameMarketIds: string[]) => Promise; /** * Get the latest odds for a specific gameMarketId * @param redis - Redis client instance * @param gameMarketId - The game market identifier * @returns Latest Odds object or null if not found */ export declare const getLatestOdds: (redis: Redis, gameMarketId: string) => Promise; export declare const saveLatestQueuedOdds: (redis: Redis, gameMarketId: LevrGameMarketId, oddsData: Odds) => Promise; export declare const getLatestQueuedOdds: (redis: Redis, gameMarketId: LevrGameMarketId) => Promise;