Clarify reserved negative-risk outcomes without reissuing positions
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user