import { Wallet } from "@ethersproject/wallet";
import { JsonRpcProvider, JsonRpcSigner } from "@ethersproject/providers";
import { ClobClient, OpenOrder, OrderType } from '@polymarket/clob-client';
import { SignedOrder } from "@polymarket/order-utils";
import { PredictionProvider, Market, MarketDiscussion, OrderBookSummary, TradeRecord, Exchange, SearchFilter, Trader, TraderPosition, ExecuteOrderParams, TradeUpdateHandlers, TradeSubscription, MarketMatchResult, PolynanceClientOptions, Candle } from './types';
/**
 * The main client class for interacting with the Polynance API.
 * Provides methods to fetch prediction market data and subscribe to real-time events.
 */
export declare class PolynanceSDK {
    private apiClient;
    private sseBaseUrl;
    polymarketClob: ClobClient;
    private wallet?;
    private walletAddress?;
    private pendingOrderIds;
    /**
     * Creates an instance of the PolynanceClient.
     * @param options - Optional configuration for the client, such as API URLs and timeout.
     */
    constructor(options?: PolynanceClientOptions);
    initCreds(wallet: JsonRpcSigner | Wallet): Promise<void>;
    buildOrder(params: ExecuteOrderParams, wallet?: JsonRpcSigner | Wallet): Promise<SignedOrder>;
    executeOrder(order: SignedOrder, orderType?: OrderType, rpcProvider?: JsonRpcProvider, wallet?: JsonRpcSigner | Wallet): Promise<OpenOrder | any>;
    getPendingOrdersIds(): string[];
    waitOrderMatched(orderId: string): Promise<boolean>;
    private approveAllowanceBalance;
    getConditionalTokensBalance(tokenId: string, walletAddress?: string): Promise<number>;
    getUSDCBalance(walletAddress?: string): Promise<number>;
    proposePrice(order: SignedOrder): Promise<import("axios").AxiosResponse<any, any> | null>;
    verifyPrice(): Promise<null | undefined>;
    scanPendingPriceData(): Promise<boolean>;
    private toPolyOrder;
    /**
     * Handles errors, logs them, and wraps them in a PolynanceApiError.
     * @param error - The error object caught.
     * @param methodName - The name of the method where the error originated.
     * @param context - Additional context about the operation (e.g., parameters).
     * @returns A PolynanceApiError instance.
     * @private
     */
    private handleError;
    asContext<T>(data: T, prompt?: string): string;
    /**
     * Retrieves detailed information for a specific market by its ID and prediction provider.
     * @param protocol - The prediction provider identifier (e.g., 'polymarket').
     * @param marketId - The unique identifier of the market.
     * @returns A Promise resolving to the `Market` object.
     * @throws {PolynanceApiError} If parameters are invalid or the API request fails.
     */
    getMarket(protocol: PredictionProvider, marketId: string): Promise<Market>;
    /**
     * Retrieves detailed information for a specific exchange by its ID and prediction provider.
     * @param protocol - The prediction provider identifier (e.g., 'polymarket').
     * @param exchangeId - The unique identifier of the exchange.
     * @returns A Promise resolving to the `Exchange` object.
     * @throws {PolynanceApiError} If parameters are invalid or the API request fails.
     */
    getExchange(protocol: PredictionProvider, exchangeId: string): Promise<Exchange>;
    /**
     * Retrieves a list of currently active markets for a specific prediction provider.
     * Supports pagination.
     * @param protocol - The prediction provider identifier (e.g., 'polymarket').
     * @param page - The page number to retrieve (1-based). Defaults to 1.
     * @param limit - The maximum number of markets per page. Defaults to 50.
     * @returns A Promise resolving to an array of `Market` objects.
     * @throws {PolynanceApiError} If parameters are invalid or the API request fails.
     */
    getActiveMarkets(protocol: PredictionProvider, page?: number, limit?: number): Promise<Market[]>;
    /**
     * Retrieves a list of discussions associated with a specific market.
     * @param protocol - The prediction provider identifier (e.g., 'polymarket').
     * @param marketId - The unique identifier of the market.
     * @returns A Promise resolving to an array of `MarketDiscussion` objects.
     * @throws {PolynanceApiError} If parameters are invalid or the API request fails.
     */
    getMarketDiscussions(protocol: PredictionProvider, marketId: string): Promise<MarketDiscussion[]>;
    /**
     * Retrieves the current order book summary for a specific exchange.
     * @param protocol - The prediction provider identifier (e.g., 'polymarket').
     * @param exchangeId - The unique identifier of the exchange.
     * @returns A Promise resolving to a Record mapping asset IDs to `OrderBookSummary` objects.
     * @throws {PolynanceApiError} If parameters are invalid or the API request fails.
     */
    getOrderbook(protocol: PredictionProvider, exchangeId: string): Promise<Record<string, OrderBookSummary>>;
    /**
     * Retrieves the historical price history for all position tokens in a specific exchange.
     * @param protocol - The prediction provider identifier (e.g., 'polymarket').
     * @param exchangeId - The unique identifier of the exchange.
     * @returns A Promise resolving to a 2D array of `TradeRecord`, organized by position token index.
     * @throws {PolynanceApiError} If parameters are invalid or the API request fails.
     */
    getPriceHistory(protocol: PredictionProvider, exchangeId: string): Promise<TradeRecord[][]>;
    getTrader(protocol: PredictionProvider, traderAddress: string): Promise<Trader>;
    traderPositions(protocol: PredictionProvider, traderAddress: string): Promise<TraderPosition[]>;
    /**
     * Retrieves a list of all available market slugs across all prediction providers.
     * Supports pagination. Slugs are URL-friendly identifiers for markets.
     * @param page - The page number to retrieve (1-based). Defaults to 1.
     * @param limit - The maximum number of slugs per page. Defaults to 100.
     * @returns A Promise resolving to an array of market slug strings.
     * @throws {PolynanceApiError} If the API request fails.
     */
    getSlugs(page?: number, limit?: number): Promise<string[]>;
    /**
     * Retrieves market information using its unique slug.
     * A single slug might resolve to multiple markets if the same market exists on different prediction providers.
     * @param slug - The URL-friendly identifier of the market.
     * @returns A Promise resolving to an array of `Market` objects matching the slug.
     * @throws {PolynanceApiError} If the slug is missing or the API request fails.
     */
    getMarketBySlug(slug: string): Promise<Market[]>;
    getExchangeBySlug(slug: string): Promise<Exchange[]>;
    /**
     * Searches for prediction markets using a natural language query.
     * Allows filtering by prediction provider, comment inclusion, result count, and similarity threshold.
     * @param query - The search query string (e.g., "Who will win the next US election?").
     * @param filter - Optional filtering parameters (`SearchFilter`).
     * @returns A Promise resolving to an array of `MarketMatchResult` objects, sorted by relevance.
     * @throws {PolynanceApiError} If the query is missing or the API request fails.
     */
    search(query: string, filter?: Partial<SearchFilter>): Promise<MarketMatchResult[]>;
    /**
     * Subscribes to real-time trade updates for a specific exchange or identifier via Server-Sent Events (SSE).
     *
     * **Note:** This requires a browser environment or a Node.js environment with an `EventSource` polyfill.
     *
     * @param protocol - The prediction provider identifier (e.g., 'polymarket').
     * @param id - The identifier for the event stream, typically the exchange ID.
     * @param handlers - Optional callback functions for handling SSE lifecycle events (`onOpen`, `onMessage`, `onError`).
     * @returns A `TradeSubscription` object containing the `EventSource` instance and methods to control the subscription.
     * @throws {PolynanceApiError} If `EventSource` is unavailable or parameters are invalid.
     */
    subscribeToTrades(protocol: PredictionProvider, id: string, handlers?: TradeUpdateHandlers): TradeSubscription;
}
/**
 * Generates price chart data (OHLCV) from a list of trade records.
 *
 * @param tradeRecords - An array of `TradeRecord` objects representing trades. Assumes timestamps are in **seconds**.
 * @param intervalMillis - The desired candlestick interval duration in **milliseconds**.
 * @param fromTimeMillis - The start timestamp (Unix milliseconds) for the desired data range (inclusive).
 * @param toTimeMillis - The end timestamp (Unix milliseconds) for the desired data range (exclusive).
 * @returns An array of `Candle` objects, sorted by time. Returns an empty array if no valid events fall within the range.
 * @throws {PolynanceApiError} if intervalMillis is not positive.
 */
export declare function generatePriceChart(tradeRecords: TradeRecord[], intervalMillis: number, fromTimeMillis: number, toTimeMillis: number): Candle[];
