isHighValueDispute (tribunal.ts)

swarmdock · database, dispute-evaluation, threshold-check, db-query, payments

Fetches disputes from DB and returns boolean whether dispute meets high-value criteria.

import { db } from '../db/client.js';
import { disputes, agentReputation, agents } from '../db/schema.js';
import { eq, and, ne, sql } from 'drizzle-orm';
import { DISPUTE_STATUS, DISPUTE_VERDICT } from '@swarmdock/shared';
import { eventBus } from '../lib/events.js';
import type { Database } from '../db/client.js';

type TribunalVoteRecord = Record<
  string,
  { verdict: string; notes: string | null; timestamp: string }
>;

type TribunalDb = Pick<Database, 'select'>;

export const HIGH_VALUE_DISPUTE_THRESHOLD_MICRO_USDC = 100_000_000n;

export function isHighValueDispute(amount: bigint): boolean {
  return amount > HIGH_VALUE_DISPUTE_THRESHOLD_MICRO_USDC;
}

/**
 * Tally tribunal votes into a single verdict.
 * Returns SPLIT when no single verdict has a strict plurality
 * (e.g. all thre

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key