From f086fdfd373441266322467137052d6cd00060e8 Mon Sep 17 00:00:00 2001 From: abitmore Date: Sun, 18 Feb 2018 15:17:25 +0000 Subject: [PATCH 1/2] Add BSIP 34 --- bsip-0034.md | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 bsip-0034.md diff --git a/bsip-0034.md b/bsip-0034.md new file mode 100644 index 0000000..444a381 --- /dev/null +++ b/bsip-0034.md @@ -0,0 +1,97 @@ + BSIP: 0034 + Title: Always Trigger Margin Call When Call Price Above Or At Price Feed + Author: Abit More + Status: Draft + Type: Protocol + Created: 2018-02-18 + Discussion: https://github.com/bitshares/bitshares-core/issues/606 + Replaces: - + Worker: To be done + +# Abstract + +To avoid ambiguity, in this article, all prices are in terms of +`debt asset / collateral asset`, aka how much debt asset per collateral +asset. A bid is an order to buy collateral asset with debt asset. + +Generally, a short position may be margin called when its collateral ratio is +below or equal to maintenance collateral ratio (MCR). + +However, to calculate collateral ratio, a fair collateral price is needed. + +In BitShares, there are two data sources can be used to decide the fair +collateral price: +* the internal market +* the price feeds + +Currently, both data sources are used. Specifically, collateral price is decided +as the higher one between the highest bid price on the internal market and the +median price feed. That said, when a short position's collateral ratio has +fallen to below or equal to MCR according to median price feed (in this case, +call price of the short position is above or equal to median price feed), if +there is a bid on the market with high price, the short position won't be margin +called. + +This mechanism has led to certain confusion and anger among market participants. +* there are often orders with overlapping price on the book but didn't fill +* there are often short positions selling collaterals with low prices, but + traders are unable to buy at those prices +* it often causes borrowers to sell collaterals at a low price when have chances + to sell at higher price +* market manipulators / arbitrage traders have more chances to force borrowers + to sell collaterals at lower price + +This BSIP proposes a new behavior to improve the situation: derive the fair +collateral price only from price feeds. + +# Motivation + +Make the exchange system easier to understand and more user-friendly. + +# Rationale + +Since price feeds are provided by a set of chosen producers, the median price +feed is usually considered trustworthy. On the other hand, instant market +price is not as reliable, especially for the markets with poor depth, so it's +a rather limited supplement for calculating collateral price. Depth of internal +markets could be greatly improved in the future, however price feed producers +can always adjust their algorithm to include internal market data. + +At this moment, changing the rule to only use median price feed will clear away +the confusion the end users may have, while still keeping the derived collateral +price fair to an extent. + +After this change is done, placing a new limit order will no longer trigger a +margin call, cancelling a limit order or expiring a limit order will no longer +trigger a margin call as well, that means we don't need to check for new margin +calls nor black swan events in those scenarios, so we'll gain a side benefit on +performance. + +# Specifications + +In `check_call_orders(...)` function of `database` class, when matching a call +order with a limit order, there is a check: +`if( match_price > ~call_itr->call_price )`, when the result is `true`, +processing will be ended and `margin_called` will be returned. +Need to skip the check and the following `return` action. + +In `do_apply(...)` function of `limit_order_cancel_evaluator` class, and +similar code blocks after a limit order object is removed, no longer need to +call `check_call_orders(...)` function of `database` class. + +# Discussion + +[to be added if any] + +# Summary for Shareholders + +[to be added if any] + +# Copyright + +This document is placed in the public domain. + +# See Also + +* https://github.com/bitshares/bitshares-core/issues/606 +* https://bitsharestalk.org/index.php?topic=25926.0 From f22084690073f8631803be2d5c93ff30c9f5b71e Mon Sep 17 00:00:00 2001 From: abitmore Date: Sun, 18 Feb 2018 21:56:55 +0000 Subject: [PATCH 2/2] bsip34: wording change and text reorganization --- bsip-0034.md | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/bsip-0034.md b/bsip-0034.md index 444a381..1635b38 100644 --- a/bsip-0034.md +++ b/bsip-0034.md @@ -10,6 +10,19 @@ # Abstract +Currently, in BitShares, a short position may be margin called only when both +two requirements are met: +* call price is above or equal to median price feed +* no limit order on the book is buying collateral with price higher than the + short position's call price + +This behavior has led to certain confusion and anger among market participants. + +This BSIP proposes a new behavior to improve the situation: drop the second +requirement, trigger margin call when the first requirement is met. + +# Motivation + To avoid ambiguity, in this article, all prices are in terms of `debt asset / collateral asset`, aka how much debt asset per collateral asset. A bid is an order to buy collateral asset with debt asset. @@ -41,21 +54,15 @@ This mechanism has led to certain confusion and anger among market participants. * market manipulators / arbitrage traders have more chances to force borrowers to sell collaterals at lower price -This BSIP proposes a new behavior to improve the situation: derive the fair -collateral price only from price feeds. - -# Motivation - -Make the exchange system easier to understand and more user-friendly. +This BSIP effectively proposes a new behavior: derive the fair collateral price +only from price feeds. # Rationale Since price feeds are provided by a set of chosen producers, the median price feed is usually considered trustworthy. On the other hand, instant market price is not as reliable, especially for the markets with poor depth, so it's -a rather limited supplement for calculating collateral price. Depth of internal -markets could be greatly improved in the future, however price feed producers -can always adjust their algorithm to include internal market data. +a rather limited supplement for calculating collateral price. At this moment, changing the rule to only use median price feed will clear away the confusion the end users may have, while still keeping the derived collateral