import { env } from "../../config/env.js";
import { settlePendingSignals } from "../signals/signals.service.js";

export function startSettlementWorker() {
  const run = async () => {
    try {
      await settlePendingSignals();
    } catch (error) {
      console.error("Settlement worker error", error);
    }
  };

  void run();
  return setInterval(run, env.SETTLEMENT_INTERVAL_MS);
}

