Validate market tick sizes and encode precise limit order amounts
This commit is contained in:
@@ -51,6 +51,7 @@ pub(crate) fn apply(
|
||||
resolution,
|
||||
taker_fee_rate_ppm,
|
||||
min_order_size,
|
||||
tick_size,
|
||||
} => {
|
||||
identifier(&market)?;
|
||||
ensure!(!rules.trim().is_empty(), "rules required");
|
||||
@@ -58,6 +59,9 @@ pub(crate) fn apply(
|
||||
"INSERT INTO markets(id,rules,phase) VALUES(?,?,'preopen')",
|
||||
params![market, rules],
|
||||
)?;
|
||||
if let Some(tick) = tick_size {
|
||||
crate::tick_size::TickSize::configure(tx, &market, &tick)?;
|
||||
}
|
||||
if let Some(size) = min_order_size {
|
||||
crate::minimum_size::MinimumSize::configure(tx, &market, &size)?;
|
||||
}
|
||||
@@ -261,7 +265,9 @@ pub(crate) fn apply(
|
||||
let book = books
|
||||
.get(&market, &outcome)
|
||||
.ok_or_else(|| anyhow::anyhow!("missing auction book"))?;
|
||||
book::settle(tx, &market, &outcome, book.opening(), None)?;
|
||||
let step = crate::tick_size::TickSize::load(tx, &market)?
|
||||
.map_or(std::num::NonZeroU32::MIN, |tick| tick.local_step());
|
||||
book::settle(tx, &market, &outcome, book.opening_with_step(step), None)?;
|
||||
}
|
||||
tx.execute("UPDATE markets SET phase='continuous' WHERE id=?", [market])?;
|
||||
Ok(json!({"phase":"continuous"}))
|
||||
|
||||
Reference in New Issue
Block a user