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 8 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
55 changes: 55 additions & 0 deletions bsip-0062.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
```
BSIP: 0062
Title: Close short position
abitmore marked this conversation as resolved.
Show resolved Hide resolved
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

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 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 logic when trying to match).

6. `fill_or_kill` does not apply

7. The order has an `expiration`

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