import BN from "bn.js"; import { PoolType, AffectedIndices } from "../types.js"; /** * LMSR (Logarithmic Market Scoring Rule) Module * * CRITICAL: resolveLmsrIndices must match programs/pit/src/math/lmsr.rs exactly */ /** * Resolve LMSR indices - maps token type to affected q_vector indices * Must match on-chain implementation in programs/pit/src/math/lmsr.rs EXACTLY * * High Pool (strikes ascending: [150, 160, 170]): * - HIT strike_index 0: [1,2,3] (S1,S2,S3) * - HIT strike_index 1: [2,3] (S2,S3) * - HIT strike_index 2: [3] (S3) * - MISS strike_index 0: [0] (S0) * - MISS strike_index 1: [0,1] (S0,S1) * - MISS strike_index 2: [0,1,2] (S0,S1,S2) * * Low Pool (strikes descending: [160, 150, 140]): * - HIT strike_index 0: [1,2,3] (S1,S2,S3) * - HIT strike_index 1: [2,3] (S2,S3) * - HIT strike_index 2: [3] (S3) * - MISS strike_index 0: [0] (S0) * - MISS strike_index 1: [0,1] (S0,S1) * - MISS strike_index 2: [0,1,2] (S0,S1,S2) */ export declare function resolveLmsrIndices(poolType: PoolType, strikeIndex: number, isHit: boolean): AffectedIndices; /** * Calculate LMSR cost: C(q) = b * ln(Σ exp(qi/b)) * Uses Log-Sum-Exp trick for numerical stability */ export declare function lmsrCost(qVector: BN[], b: BN): BN; /** * Simulate a trade and return cost/refund */ export declare function simulateTrade(qVector: BN[], b: BN, affectedIndices: AffectedIndices, amount: BN, isBuy: boolean): { cost: BN; newQVector: BN[]; }; /** * Calculate token price (marginal cost for 1 token) */ export declare function tokenPrice(qVector: BN[], b: BN, poolType: PoolType, strikeIndex: number, isHit: boolean): BN; /** * Calculate liquidity parameter b from total subsidy * Formula: b = (subsidy / 2) / ln(4) */ export declare function calculateLiquidityParameter(totalSubsidy: BN): BN; //# sourceMappingURL=lmsr.d.ts.map