You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Update any orders that can no longer be filled with the account's balance.
.. does not take into consideration that there may exist multiple orders for a unique (src, dst).
The sum of SourceRemaining for the same (src, dst) should not exceed the available account balance.
The current implementation does not handle this case, but only deals with it on order creation:
// Ensure that the market is not showing "phantom liquidity" by rejecting multiple orders in an instrument based on the same balance.
How to reproduce
With an account balance of 10 eEUR.
Create 10 orders selling 1 eEUR for e.g. 1 eCHF (src: eEUR, dst: eCHF)
Send 7 eEUR from the account, reducing the balance to 3 eEUR.
10 orders will remain with unchanged sourceRemaining, as the 3 eEUR balance is still above 1 eEUR for each individual order.
Expected behavior Invariant: The sum of the sourceRemaining for identical (src, dst) orders should not exceed the spendable account balance.
Working through the orders in reverse distance from the best price, i.e. "orders the farthest away from the best price first", should have they sourceRemaining reduced and canceled until the above invariant holds.
The text was updated successfully, but these errors were encountered:
Describe the bug
Code at
em-ledger/x/market/keeper/keeper.go
Line 459 in 6a5582b
.. does not take into consideration that there may exist multiple orders for a unique (src, dst).
The sum of SourceRemaining for the same (src, dst) should not exceed the available account balance.
The current implementation does not handle this case, but only deals with it on order creation:
em-ledger/x/market/keeper/keeper.go
Line 183 in 6a5582b
How to reproduce
Expected behavior
Invariant: The sum of the sourceRemaining for identical (src, dst) orders should not exceed the spendable account balance.
Working through the orders in reverse distance from the best price, i.e. "orders the farthest away from the best price first", should have they sourceRemaining reduced and canceled until the above invariant holds.
The text was updated successfully, but these errors were encountered: