import { type Static } from "@sinclair/typebox"; import type { ClearinghouseState as StrategyClearingHouseState, OpenPosition as StrategyOpenPosition } from "../../types/strategy.js"; declare const watchdogConfigSchema: import("@sinclair/typebox").TObject<{ /** Margin buffer % below which a WARNING alert is emitted. */ bufferWarningPct: import("@sinclair/typebox").TOptional; /** Margin buffer % below which a CRITICAL alert + WATCHDOG_CLOSE signal are emitted. */ bufferCriticalPct: import("@sinclair/typebox").TOptional; /** Per-position liquidation distance (%) warning threshold. */ liqDistanceWarningPct: import("@sinclair/typebox").TOptional; /** ROE (%) below which a position is flagged as dangerous. */ roeDangerPct: import("@sinclair/typebox").TOptional; }>; export type WatchdogConfig = Static; export type ResolvedWatchdogConfig = Required; export interface WatchdogState { lastCheckTimestamp: number; lastAlerts: WatchdogAlert[]; consecutiveCleanChecks: number; } export type AlertLevel = "WARNING" | "CRITICAL"; export interface WatchdogAlert { level: AlertLevel; message: string; asset?: string; value?: number; threshold?: number; } export type ClearingHouseState = StrategyClearingHouseState; export type ClearingHousePosition = StrategyOpenPosition; interface WatchdogPositionView { asset: string; direction: "LONG" | "SHORT"; size: number; entryPrice: number; markPrice: number; liquidationPrice: number | null; unrealizedPnl: number; roe: number; leverage: number; } /** * Computes margin buffer as a percentage of account value. * buffer = withdrawable / accountValue * 100 */ export declare function computeMarginBuffer(accountValue: number, withdrawable: number): number; /** * Computes liquidation distance as a percentage of mark price. * For LONG: (markPrice - liqPrice) / markPrice * 100 * For SHORT: (liqPrice - markPrice) / liqPrice * 100 (or markPrice based) */ export declare function computeLiqDistance(markPrice: number, liqPrice: number | null, direction: "LONG" | "SHORT"): number | null; /** * Analyzes clearinghouse state and produces alerts based on thresholds. */ export declare function analyzeMarginHealth(chState: ClearingHouseState, cfg: ResolvedWatchdogConfig, dslFloors?: Map): { alerts: WatchdogAlert[]; lowestRoePosition: WatchdogPositionView | null; }; export declare function liquidationWatchdogScanner(): import("../index.js").Scanner<{ bufferWarningPct?: number | undefined; bufferCriticalPct?: number | undefined; liqDistanceWarningPct?: number | undefined; roeDangerPct?: number | undefined; }, WatchdogState>; export {}; //# sourceMappingURL=liquidation-watchdog.d.ts.map