Validate market tick sizes and encode precise limit order amounts

This commit is contained in:
2026-12-03 06:34:52 +08:00
parent 00660d890c
commit 2269752b9e
14 changed files with 246 additions and 20 deletions
+8 -16
View File
@@ -39,29 +39,18 @@ impl Request {
amount_cents,
max_price,
tif,
} => (
market,
outcome,
Side::Buy,
amount_cents,
max_price.unwrap_or(100),
tif,
),
} => (market, outcome, Side::Buy, amount_cents, max_price, tif),
Self::Sell {
market,
outcome,
qty,
min_price,
tif,
} => (
market,
outcome,
Side::Sell,
qty,
min_price.unwrap_or(0),
tif,
),
} => (market, outcome, Side::Sell, qty, min_price, tif),
};
let tick = crate::tick_size::TickSize::load(tx, &market)?;
let edge = tick.as_ref().map_or(0, |t| i64::from(t.local_step().get()));
let limit = limit.unwrap_or(if side == Side::Buy { 100 - edge } else { edge });
let tif = tif.unwrap_or(TimeInForce::Fak);
amount(requested)?;
ensure!(
@@ -72,6 +61,9 @@ impl Request {
matches!(outcome.as_str(), "YES" | "NO") && (0..=100).contains(&limit),
"invalid outcome or price"
);
if let Some(tick) = tick {
tick.check(limit * 10000)?;
}
phase(tx, &market, &["continuous"])?;
let rate = crate::fees::rate(tx, &market)?;
if let Some(minimum) = crate::minimum_size::MinimumSize::load(tx, &market)? {