ExchangeUnion / xud

Exchange Union Daemon 🔁 ⚡️
https://exchangeunion.com
GNU Affero General Public License v3.0
115 stars 44 forks source link

No maxsell/maxbuy recalculation for order replacement case #1999

Closed raladev closed 4 years ago

raladev commented 4 years ago

Screenshot from 2020-11-20 00-07-56

Case:

  1. Placed order blocks part of max sell/ max buy amount.
  2. But when user tries to replace this orders, xud uses reserved amount of order that should be replaced in tradinglimits calculation.
  3. As a resultm user cant place order

Example:

  1. max sell ETH = 1 ETH, max buy BTC = 0.1 BTC
  2. placeorder sell 0.95 ETH/BTC 0.1 my-id-> order placed
  3. max sell ETH = 1 - 0,95 = 0.05, max buy BTC = 0.1 - 0,095 = 0.005 BTC
  4. placeorder sell 0.948 ETH/BTC 0.1 -r my-id -> err because of max sell and max buy

Expected behavior: On step 4 (on trading limits check) we should increase maxsell/maxbuy values by 0.95 ETH/ 0.095 BTC (amount that were used in old order).

kilrau commented 4 years ago

Related (but different): https://github.com/ExchangeUnion/xud/issues/1991

kilrau commented 4 years ago

@sangaman the problem in simple words seems to be: when replacing an order we currently do not remove reserved order amounts of the old order from tradinglimits, which is when the channel capacity is not large enough to cover the second new order, replacing fails.

Fix should be as simple as removing reserved quantity from tradinglimits as intermediate step in the replace process.