Add BSIP 34

This commit is contained in:
abitmore 2018-02-18 15:17:25 +00:00
parent 3a526a4109
commit f086fdfd37

97
bsip-0034.md Normal file
View file

@ -0,0 +1,97 @@
BSIP: 0034
Title: Always Trigger Margin Call When Call Price Above Or At Price Feed
Author: Abit More <https://github.com/abitmore>
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