Publish settlement clarifications and atomically clear affected orders

This commit is contained in:
2026-12-03 10:42:35 +08:00
parent fe69e31929
commit 3495e8de3c
12 changed files with 319 additions and 3 deletions
+7
View File
@@ -5,6 +5,13 @@ CREATE TABLE IF NOT EXISTS markets (
id TEXT PRIMARY KEY, rules TEXT NOT NULL, phase TEXT NOT NULL,
collateral INTEGER NOT NULL DEFAULT 0 CHECK(collateral >= 0), winner TEXT
);
CREATE TABLE IF NOT EXISTS market_clarifications (
id INTEGER PRIMARY KEY, market TEXT NOT NULL REFERENCES markets(id),
content TEXT NOT NULL CHECK(length(trim(content))>0),
clear_book INTEGER NOT NULL CHECK(clear_book IN (0,1)),
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now'))
);
CREATE INDEX IF NOT EXISTS clarifications_by_market ON market_clarifications(market,id);
CREATE TABLE IF NOT EXISTS positions (
account TEXT REFERENCES accounts, market TEXT REFERENCES markets, outcome TEXT,
quantity INTEGER NOT NULL CHECK(quantity >= 0), PRIMARY KEY(account,market,outcome)