bitshares / bitshares-core

BitShares Blockchain node and command-line wallet
https://bitshares.github.io/
Other
1.17k stars 643 forks source link

Implement Limit Order Modification Feature #2743

Closed abitmore closed 1 year ago

abitmore commented 1 year ago

PR for #1604.

Based on @nathanielhourt's work for #1604 (see https://github.com/nathanielhourt/bitshares-2/pull/1).

Changes:

NOTE 1: The base amount in the new price is limited by an estimation of the order's maximum amount to sell. This is to mitigate against inappropriate price manipulation, although not completely avoid it.

NOTE 2: When updating a limit order with a non-zero deferred fee, we charge the owner a small fee equal to order_cancel_fee * order_update_fee / order_create_fee (not higher than the deferred fee), and refund the remainder in the deferred fee, the deferred fee is then refreshed with the new operation fee paid. The small fee is to mitigate potential transaction spam issues. The deferred fee is used for all refund mechanisms.

Side effect: Assuming that order update fee will be lower than order creation fee, traders can create an order and then update it immediately to reduce costs, both for making and taking.

NOTE 3: Since the price can be modified, sell_price.base.amount is no longer always equal to the total amount allocated to the limit order. In the meanwhile, a new data field filled_amount is added to limit_order_object in PR #2776, this way users can still know the total amount.

NOTE 4: Please see https://github.com/bitshares/bitshares-core/pull/2749 for more info about automatic actions (Order-Sends-Order).

sonarcloud[bot] commented 1 year ago

Please retry analysis of this Pull-Request directly on SonarCloud.