Reconcile precise collateral funding, fee debits and available cash
This commit is contained in:
@@ -143,7 +143,9 @@ pub(crate) fn submit(tx: &Transaction, books: &Books, order: NewOrder) -> Result
|
||||
release(tx, seq, &account, CancelReason::Cancelled)?;
|
||||
status = "cancelled".into();
|
||||
}
|
||||
crate::fees::debit(tx, &account, fee_micros)?;
|
||||
if fee_micros > 0 {
|
||||
ledger::cash_micros(tx, &account, -fee_micros)?;
|
||||
}
|
||||
Ok(ShareExecution {
|
||||
fee_micros,
|
||||
seq,
|
||||
@@ -219,8 +221,7 @@ pub(crate) fn market_buy(tx: &Transaction, books: &Books, order: BudgetBuy) -> R
|
||||
params![seq, amount_cents, spent],
|
||||
)?;
|
||||
let fee = settle(tx, &market, &outcome, fills, Some(Taker::Budget(seq)))?;
|
||||
ledger::cash(tx, &account, gross_remainder)?;
|
||||
crate::fees::debit(tx, &account, fee)?;
|
||||
ledger::cash_micros(tx, &account, gross_remainder * 10000 - fee)?;
|
||||
let status = if unspent_micros == 0 {
|
||||
"filled"
|
||||
} else {
|
||||
@@ -357,7 +358,7 @@ pub(crate) fn settle(
|
||||
params![execution, taker.map(Taker::seq)],
|
||||
)?;
|
||||
if let Some(taker) = taker {
|
||||
let fee = crate::fees::micros(rate, f.price, f.quantity);
|
||||
let fee = crate::fees::micros(rate, f.price * 10000, f.quantity);
|
||||
if fee > 0 {
|
||||
tx.execute(
|
||||
"INSERT INTO execution_fees VALUES(?,?,?)",
|
||||
|
||||
Reference in New Issue
Block a user