Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BSIP62: Close Margin Position #211

Merged
merged 10 commits into from
Sep 30, 2019
Merged
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions bsip-0062.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
```
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.
sschiessl-bcp marked this conversation as resolved.
Show resolved Hide resolved

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.

# References
https://bitsharestalk.org/index.php?topic=28211.msg328509

User custom price for his margin call order #129
abitmore marked this conversation as resolved.
Show resolved Hide resolved

# 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.

https://bitsharestalk.org/index.php?topic=28211.0

https://github.com/bitshares/bsips/issues/156

# Copyright
This document is placed in the public domain.