import {
  gridCurrentDelta,
  gridFillsPerMinute,
  gridPendingHedges,
  gridSelfTradeRatio,
  gridStepBps,
  gridVolatilityBps,
  makerRatio
} from "./metrics";

export interface GridMetricSnapshot {
  stepBps: number;
  pendingHedges: number;
  currentDelta: number;
  hourlyVolatilityBps?: number;
}

export interface FillRateSnapshot {
  fillsPerMinute: number;
  makerRatio: number;
  selfTradeRatio: number;
}

export function observeGridMetrics(
  symbol: string,
  snapshot: GridMetricSnapshot
): void {
  if (!symbol) return;
  gridStepBps.set({ symbol }, snapshot.stepBps);
  gridPendingHedges.set({ symbol }, snapshot.pendingHedges);
  gridCurrentDelta.set({ symbol }, snapshot.currentDelta);
  if (snapshot.hourlyVolatilityBps !== undefined) {
    gridVolatilityBps.set({ symbol }, snapshot.hourlyVolatilityBps);
  }
}

export function observeFillRateMetrics(
  symbol: string,
  snapshot: FillRateSnapshot
): void {
  if (!symbol) return;
  gridFillsPerMinute.set({ symbol }, snapshot.fillsPerMinute);
  makerRatio.set({ symbol }, snapshot.makerRatio);
  gridSelfTradeRatio.set({ symbol }, snapshot.selfTradeRatio);
}
