Skip to content

Commit

Permalink
Merge pull request #211 from bitcrab/patch-6
Browse files Browse the repository at this point in the history
BSIP62: Close Margin Position
  • Loading branch information
ryanRfox authored Sep 30, 2019
2 parents 4506cfd + 468b33b commit d5169b7
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions bsip-0062.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
```
BSIP: 0062
Title: Close margin position
Authors:
Stefan Schießl [email protected]
Jerry Liu [email protected]
Status: Draft
Type: Protocol
Created: 2019-09-14
Worker: TBD
```

# Abstract
Closing a short position comes with a risk of getting margin called if no spare funds are available to buy the long and reduce the debt to zero. This BSIP introduces a way to put the short position directly on the market.

# Rationale
Closing a short position with a healthy CR should come with no risk of getting margin called. Currently a user, who has no spare funds, has to take out collateral from the short position in order to put it on the market. Reducing the collateral increases the risk of margin call. This is especially cumbersome and risky if you want to close a position that has CR close to MCR (in that case you can only take out a small amount of collateral, sell it, reduce debt, repeat until position closed).

# Specification
Introduce a way that user can directly place orders to sell collateral in a margin position, and the received SmartCoins will be used to reduce the debt automatically.

We introduce a direct collateral sell order and a manual margin call. Recommendation to the core team is to implement one of them for the upcoming hard fork, and the other one for the following one.

## Direct collateral sell order

User needs to define the amount to sell and the amount to receive while placing the order. The amount to receive must be equal or less than the debt amount, and the price must be less than the current collateral ration times feed price
(ensurance that the margin positions collatearl ratio will not be reduced after the filling of the sell orders).

Remarks:
1. No creation fee refund when the order is cancelled.

2. The order should be cancelled automatically if the asset is globally settled.

3. The order should be cancelled automatically if the position is manually closed.

4. If the order wants to sell more collateral than it has left (due to margin called, force settled or debt position updated), only allow to fill this order up to the actually available collateral (this may be realized by shrinking the actual values in the limit_order object, or through calculation logic when trying to match).

5. If the order is asking for more than its debt (due to margin called, force settled or debt position updated), only allow to fill this order up to the actually needed debt (this may be realized by shrinking the actual values in the limit_order object, or through calculation logic when trying to match).

6. `fill_or_kill` can be set just like for a normal limit order

7. `expiration` must be defined

## Manual margin call
User needs to specify the manual margin call price ratio (value must be positive, and a value of 1 represents the feedprice) that will be used to calculate the sell price depending the feed price, and a manual margin call will be created that follows the logic of a margin call, except that the price is calculated from the user-defined percent instead of MSSR.


# Discussion
Another process logic is also possible when a debt position is margin called or margin call orders change with close short orders,system check whether the margin call conflict with the close short orders via a defined logic, if yes than delete all the close short orders and place margin call orders, if not just place margin call orders without deleting the close short orders.

This logic bring better user experience but also complexity. it is also a good choice if the complexity is acceptable from developer's perspective.

# References
* https://bitsharestalk.org/index.php?topic=28211.0
* https://github.com/bitshares/bsips/issues/129
* https://github.com/bitshares/bsips/issues/156

# Copyright
This document is placed in the public domain.

0 comments on commit d5169b7

Please sign in to comment.