Apply per-market taker fees to cash budgets, fills and account activity

This commit is contained in:
2026-12-03 05:52:39 +08:00
parent f72d0fe602
commit d01ab8f15c
17 changed files with 312 additions and 36 deletions
+8
View File
@@ -28,6 +28,7 @@ pub(crate) fn apply(
rules,
listing,
resolution,
taker_fee_rate_ppm,
} => {
identifier(&market)?;
ensure!(!rules.trim().is_empty(), "rules required");
@@ -35,6 +36,9 @@ pub(crate) fn apply(
"INSERT INTO markets(id,rules,phase) VALUES(?,?,'preopen')",
params![market, rules],
)?;
if let Some(rate) = taker_fee_rate_ppm {
crate::fees::configure(tx, &market, rate)?;
}
if let Some(policy) = resolution {
policy.save(tx, &market)?;
}
@@ -176,6 +180,10 @@ pub(crate) fn apply(
let mut receipt = result.receipt();
receipt["proceeds_cents"] = json!(result.gross_cents);
receipt["unsold_shares"] = json!(qty - result.filled);
if result.fee_micros > 0 {
receipt["net_proceeds_micros"] =
json!(result.gross_cents * 10000 - result.fee_micros);
}
Ok(receipt)
}
Command::MarketBuy {