forked from townforge/townforge
rpc: fix orders matchable field not considering already matched amount
This commit is contained in:
parent
1e73157f9d
commit
ea43d90db1
@ -4196,7 +4196,8 @@ namespace cryptonote
|
||||
}
|
||||
const uint64_t balance = it->second;
|
||||
const uint64_t max_amount = balance / e.price;
|
||||
e.matchable = (uint32_t)std::min<uint64_t>(max_amount, e.amount);
|
||||
const uint32_t already_matched = db.get_cc_trade_used(e.nonce);
|
||||
e.matchable = (uint32_t)std::min<uint64_t>(max_amount, e.amount - std::min(already_matched, e.amount));
|
||||
it->second -= e.matchable * e.price;
|
||||
}
|
||||
|
||||
@ -4244,7 +4245,8 @@ namespace cryptonote
|
||||
it = running_item_balances.insert(std::make_pair(std::make_tuple(e.account, e.type, e.id), 0)).first;
|
||||
}
|
||||
const uint32_t item_balance = it->second;
|
||||
e.matchable = (uint32_t)std::min<uint32_t>(item_balance, e.amount);
|
||||
const uint32_t already_matched = db.get_cc_trade_used(e.nonce);
|
||||
e.matchable = (uint32_t)std::min<uint32_t>(item_balance, e.amount - std::min(already_matched, e.amount));
|
||||
it->second -= e.matchable;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user