Clarify reserved negative-risk outcomes without reissuing positions

This commit is contained in:
2026-12-03 04:46:11 +08:00
parent b2b7fc4610
commit 99028f9073
14 changed files with 292 additions and 13 deletions
+6
View File
@@ -111,6 +111,12 @@ pub(crate) fn allocate_payout(tx: &Transaction, market: &str, outcome: &str) ->
let Some((group, winner, reserve)) = group else {
return Ok(());
};
let valid: bool = tx.query_row(
"SELECT NOT EXISTS (SELECT 1 FROM augmented_outcomes a
LEFT JOIN augmented_results r ON r.group_id=a.group_id
WHERE a.market=?1 AND (r.winner IS NULL OR ?2<>CASE WHEN r.winner=?1 THEN 'YES' ELSE 'NO' END))",
params![market,outcome], |r|r.get(0))?;
ensure!(valid, "resolve the observed winner with finalize_augmented");
match outcome {
"YES" => {
ensure!(winner.is_none(), "group already has a winner");