Convert NO positions and conserve collateral across fixed negative-risk groups

This commit is contained in:
2026-12-03 04:41:35 +08:00
parent dd3e563a48
commit b2b7fc4610
12 changed files with 329 additions and 5 deletions
+12
View File
@@ -38,6 +38,17 @@ pub(crate) fn apply(tx: &Transaction, books: &Books, command: Command) -> Result
}
Ok(json!({"phase":"preopen"}))
}
Command::DefineNegRisk {
group,
event,
markets,
} => crate::neg_risk::define(tx, &group, &event, &markets),
Command::Convert {
group,
account,
no_markets,
qty,
} => crate::neg_risk::convert(tx, &group, &account, &no_markets, qty),
Command::Split {
market,
account,
@@ -286,6 +297,7 @@ fn finalize(tx: &Transaction, market: &str, winner: &str) -> Result<i64> {
phase(tx, market, &["closed"])?;
ensure!(matches!(winner, "YES" | "NO" | "VOID"), "invalid winner");
resolution::authorize_finalization(tx, market, winner)?;
crate::neg_risk::allocate_payout(tx, market, winner)?;
// Close releases all outstanding reservations before finality.
let changed=tx.execute(
"UPDATE markets SET phase='resolved',winner=?1