Expose integer base fees alongside execution fee curves

This commit is contained in:
2026-12-03 12:48:10 +08:00
parent 2a62f1812a
commit f7946d2277
15 changed files with 207 additions and 26 deletions
+33
View File
@@ -2000,6 +2000,19 @@ fn fees_follow_taker_cash_budget_and_net_sale_proceeds() {
_ => {}
}
}
for token in ["eb:YES:cup", "eb:NO:cup"] {
assert_eq!(e.base_fee_bps(token).unwrap(), Some(30));
}
let clob = e.clob_market_info("cup").unwrap().unwrap();
assert_eq!(clob["mbf"], 0);
assert_eq!(clob["tbf"], 30);
assert_eq!(clob["fd"]["r"], json!(0.05));
let gamma = e
.gamma_market(exchange::DirectoryKey::Slug("cup"))
.unwrap()
.unwrap();
assert_eq!(gamma["makerBaseFee"], 0);
assert_eq!(gamma["takerBaseFee"], 30);
let s = state(&mut e);
assert_eq!(s["accounts"][1]["cash"], 903);
assert_eq!(s["cash_remainders"][0]["micros"], 9500);
@@ -3145,6 +3158,13 @@ fn clob_parameters_follow_the_market_across_both_tokens_and_restart() {
assert_eq!(info["mts"], json!(0.005));
assert_eq!(info["mos"], json!(2.5));
assert_eq!(info["fd"], json!({"r":0.025,"e":1,"to":true}));
assert_eq!(info["tbf"], 250);
assert_eq!(
reader
.base_fee_bps(pair["secondary_token_id"].as_str().unwrap())
.unwrap(),
Some(250)
);
assert_eq!(info["gst"], "2027-01-15T08:00:00.000Z");
writer
.execute(
@@ -3692,3 +3712,16 @@ fn public_interest_filters_archived_and_inactive_without_affecting_redemption()
db.execute(visibility("relist", true, false)).unwrap();
assert_eq!(read(&db, query)[0]["value"], 0);
}
#[test]
fn fractional_basis_point_curve_keeps_its_precision_without_inventing_a_base_fee() {
let mut e = Exchange::open(":memory:").unwrap();
e.execute(json!({"op":"list","id":"list","market":"precise","rules":"example","taker_fee_rate_ppm":125})).unwrap();
assert_eq!(e.base_fee_bps("eb:YES:precise").unwrap(), None);
let info = e.clob_market_info("precise").unwrap().unwrap();
assert!(info.get("tbf").is_none());
assert_eq!(info["fd"]["r"], json!(0.000125));
let bad = json!({"op":"list","id":"bad","market":"invalid","rules":"example","base_fees":{"maker_bps":0,"taker_bps":-3}});
assert!(e.execute(bad).is_err());
assert!(e.clob_market_info("invalid").unwrap().is_none());
}