Skip to content

MllBreachRegistry

Global Durable Object for tracking MLL (Maximum Loss Limit) breach events with admin filtering and statistics.

Purpose

Provides admin visibility into challenge failures caused by MLL breaches. When a user's account value drops to or below the minimum balance threshold during a challenge, UserPaperTradePortfolio records the breach event here. This DO is a simple append-only event store with query and aggregation capabilities.

  • Single global instance (id: "global")
  • All methods are synchronous (simple record store)
  • Append-only -- no updates or deletes

Edge Cases

  • Monetary values stored as strings (account_value_at_breach, mll_threshold, capital) to preserve BigNumber precision.
  • No deduplication -- the same breach event could theoretically be recorded twice if the caller retries. The auto-increment ID differentiates them.
  • Dynamic WHERE clause is built with parameterized queries to prevent SQL injection.
  • Limit clamping -- limit is clamped to 1-100 regardless of input.