Expose negative-risk membership and convert fractional outcome balances

This commit is contained in:
2026-12-03 12:56:07 +08:00
parent f7946d2277
commit 351de6187e
13 changed files with 233 additions and 45 deletions
+6
View File
@@ -196,6 +196,12 @@ CREATE TABLE IF NOT EXISTS neg_risk_groups (
id TEXT PRIMARY KEY, reserve_cents INTEGER NOT NULL DEFAULT 0 CHECK(reserve_cents>=0),
winner TEXT REFERENCES markets
);
CREATE TABLE IF NOT EXISTS neg_risk_reserve_remainders (
group_id TEXT PRIMARY KEY REFERENCES neg_risk_groups(id), micros INTEGER NOT NULL CHECK(micros BETWEEN 0 AND 9999)
);
CREATE VIEW IF NOT EXISTS neg_risk_reserves AS
SELECT g.id,g.winner,g.reserve_cents*10000+COALESCE(r.micros,0) AS micros
FROM neg_risk_groups g LEFT JOIN neg_risk_reserve_remainders r ON r.group_id=g.id;
CREATE TABLE IF NOT EXISTS neg_risk_members (
market TEXT PRIMARY KEY REFERENCES markets, group_id TEXT NOT NULL REFERENCES neg_risk_groups,
ordinal INTEGER NOT NULL, UNIQUE(group_id,ordinal)