From 956d1c539821a20a6893fe01f7ecfcb1466a4aad Mon Sep 17 00:00:00 2001 From: bitcrab Date: Sat, 14 Sep 2019 23:35:30 +0800 Subject: [PATCH 01/10] Create bsip-0062.md --- bsip-0062.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 bsip-0062.md diff --git a/bsip-0062.md b/bsip-0062.md new file mode 100644 index 0000000..9af92ff --- /dev/null +++ b/bsip-0062.md @@ -0,0 +1,37 @@ + ``` + BSIP: 0062 + Title: Close short position + Authors: + Stefan Schießl stefan.schiessl@blockchainprojectsbv.com + Jerry Liu bitcrab@qq.com + Status: Draft + Type: Protocol + Created: 2019-09-14 + Discussion: https://bitsharestalk.org/index.php?topic=28211.0 + 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. + +# Specification +Introduce a way that user can directly place orders to sell collaterals in a debt position, and the got smartcoins will be used to reduce debt automatically. + +User need to define the amount and price while placing the sell orders, and the price should be greater or equal to margin call price/MCR, to ensure the deposit position CR will not be reduced after the filling of the sell orders. + +When a debt position is margin called with close short orders, 2 ways are possible to handle this: +1.system delete all the close short orders and place margin call orders. +2.system define a logic to check whether the margin call conflict with the close short orders, if yes than delete all the close short orders and place margin call orders, if not just place margin call orders. + +When user adjust the debt position, system will check whether the target debt position conflict with the close short orders, if yes than reject to adjust. + +# References +https://bitsharestalk.org/index.php?topic=28211.msg328509 + +User custom price for his margin call order #129 + +# Copyright +This document is placed in the public domain. From 45cf77eee05396a4b0e5bc9f92198936a8f8f46a Mon Sep 17 00:00:00 2001 From: bitcrab Date: Sun, 15 Sep 2019 23:52:20 +0800 Subject: [PATCH 02/10] Update bsip-0062.md --- bsip-0062.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bsip-0062.md b/bsip-0062.md index 9af92ff..2eed0f3 100644 --- a/bsip-0062.md +++ b/bsip-0062.md @@ -7,7 +7,6 @@ Status: Draft Type: Protocol Created: 2019-09-14 - Discussion: https://bitsharestalk.org/index.php?topic=28211.0 Worker: TBD ``` @@ -33,5 +32,10 @@ https://bitsharestalk.org/index.php?topic=28211.msg328509 User custom price for his margin call order #129 +# Discussion +https://bitsharestalk.org/index.php?topic=28211.0 + +https://github.com/bitshares/bsips/issues/156 + # Copyright This document is placed in the public domain. From 679301f8d19568a2fcbf557c86812d20d522fbb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Schie=C3=9Fl?= Date: Mon, 16 Sep 2019 09:35:34 +0200 Subject: [PATCH 03/10] Update bsip-0062.md --- bsip-0062.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bsip-0062.md b/bsip-0062.md index 2eed0f3..03466c3 100644 --- a/bsip-0062.md +++ b/bsip-0062.md @@ -17,15 +17,17 @@ Closing a short position comes with a risk of getting margin called if no spare Closing a short position with a healthy CR should come with no risk of getting margin called. # Specification -Introduce a way that user can directly place orders to sell collaterals in a debt position, and the got smartcoins will be used to reduce debt automatically. +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. -User need to define the amount and price while placing the sell orders, and the price should be greater or equal to margin call price/MCR, to ensure the deposit position CR will not be reduced after the filling of the sell orders. +User needs to define the amount to sell and amount to receive while placing the sell orders, and the +price should be greater or equal to margin call price/MCR, to ensure the deposit position CR will not be reduced after the filling of the sell orders. When a debt position is margin called with close short orders, 2 ways are possible to handle this: -1.system delete all the close short orders and place margin call orders. -2.system define a logic to check whether the margin call conflict with the close short orders, if yes than delete all the close short orders and place margin call orders, if not just place margin call orders. -When user adjust the debt position, system will check whether the target debt position conflict with the close short orders, if yes than reject to adjust. +1. System delete all the Close short position orders and place margin call orders. +2. System define a logic to check whether the margin call conflict with the close short orders, if yes than delete all the close short orders and place margin call orders, if not just place margin call orders. + +When user adjust the debt position, system will check whether the target debt position conflicts with the close short orders, if yes than reject to adjust. # References https://bitsharestalk.org/index.php?topic=28211.msg328509 From 283f786b18802dda74cd861cce7bf7da03ccaa60 Mon Sep 17 00:00:00 2001 From: bitcrab Date: Wed, 18 Sep 2019 01:11:07 +0800 Subject: [PATCH 04/10] Update bsip-0062.md --- bsip-0062.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bsip-0062.md b/bsip-0062.md index 03466c3..e217ea3 100644 --- a/bsip-0062.md +++ b/bsip-0062.md @@ -20,12 +20,9 @@ Closing a short position with a healthy CR should come with no risk of getting m 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. User needs to define the amount to sell and amount to receive while placing the sell orders, and the -price should be greater or equal to margin call price/MCR, to ensure the deposit position CR will not be reduced after the filling of the sell orders. +price should be greater or equal to debt/collateral, to ensure the deposit position CR will not be reduced after the filling of the sell orders. -When a debt position is margin called with close short orders, 2 ways are possible to handle this: - -1. System delete all the Close short position orders and place margin call orders. -2. System define a logic to check whether the margin call conflict with the close short orders, if yes than delete all the close short orders and place margin call orders, if not just place margin call orders. +When a debt position is margin called with close short orders,system delete all the close short orders and place margin call orders. When user adjust the debt position, system will check whether the target debt position conflicts with the close short orders, if yes than reject to adjust. @@ -35,6 +32,8 @@ https://bitsharestalk.org/index.php?topic=28211.msg328509 User custom price for his margin call order #129 # 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. + https://bitsharestalk.org/index.php?topic=28211.0 https://github.com/bitshares/bsips/issues/156 From 275a8f2ce9949bfe88d38a72e0b2be3cbd502c1a Mon Sep 17 00:00:00 2001 From: bitcrab Date: Wed, 18 Sep 2019 01:20:12 +0800 Subject: [PATCH 05/10] Update bsip-0062.md --- bsip-0062.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bsip-0062.md b/bsip-0062.md index e217ea3..0b5c297 100644 --- a/bsip-0062.md +++ b/bsip-0062.md @@ -34,6 +34,8 @@ User custom price for his margin call order #129 # 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 From 86b0132f394930d9c63c48284d5b22c4d81b8121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Schie=C3=9Fl?= Date: Thu, 19 Sep 2019 09:05:22 +0200 Subject: [PATCH 06/10] add more details on the risk when closing --- bsip-0062.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsip-0062.md b/bsip-0062.md index 0b5c297..ae88cd0 100644 --- a/bsip-0062.md +++ b/bsip-0062.md @@ -14,7 +14,7 @@ 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. +Closing a short position with a healthy CR should come with no risk of getting margin called. Currently the user 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. From d1a7f5ddcaf22809cc8b37a61f6a7cdf83808d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Schie=C3=9Fl?= Date: Fri, 20 Sep 2019 12:06:30 +0200 Subject: [PATCH 07/10] implement remarks --- bsip-0062.md | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/bsip-0062.md b/bsip-0062.md index ae88cd0..1b78f90 100644 --- a/bsip-0062.md +++ b/bsip-0062.md @@ -14,17 +14,28 @@ 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 the user 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). +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. -User needs to define the amount to sell and amount to receive while placing the sell orders, and the -price should be greater or equal to debt/collateral, to ensure the deposit position CR will not be reduced after the filling of the sell orders. +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). -When a debt position is margin called with close short orders,system delete all the close short orders and place margin call orders. +Remarks: +1. No creation fee refund when the order is cancelled. -When user adjust the debt position, system will check whether the target debt position conflicts with the close short orders, if yes than reject to adjust. +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), shrink the order accordingly. + +5. If the order is asking for more than its debt (due to margin called, force settled or debt position updated), shrink the order accordingly + +6. `fill_or_kill` does not apply + +7. The order has an `expiration` # References https://bitsharestalk.org/index.php?topic=28211.msg328509 From b372d456ac4588fa593e28b5c6fef88b1adacd73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Schie=C3=9Fl?= Date: Fri, 20 Sep 2019 12:10:13 +0200 Subject: [PATCH 08/10] refine wording for shrinking --- bsip-0062.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bsip-0062.md b/bsip-0062.md index 1b78f90..b8ea39a 100644 --- a/bsip-0062.md +++ b/bsip-0062.md @@ -29,9 +29,9 @@ Remarks: 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), shrink the order accordingly. +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), shrink the order accordingly +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 From 6b88494cfb27b0d228e17627e84183e6f1926c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Schie=C3=9Fl?= Date: Thu, 26 Sep 2019 08:46:00 +0200 Subject: [PATCH 09/10] add Direct collateral sell order and Manual margin call --- bsip-0062.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/bsip-0062.md b/bsip-0062.md index b8ea39a..5372bbd 100644 --- a/bsip-0062.md +++ b/bsip-0062.md @@ -1,6 +1,6 @@ ``` BSIP: 0062 - Title: Close short position + Title: Close margin position Authors: Stefan Schießl stefan.schiessl@blockchainprojectsbv.com Jerry Liu bitcrab@qq.com @@ -19,6 +19,10 @@ Closing a short position with a healthy CR should come with no risk of getting m # 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). @@ -29,13 +33,17 @@ Remarks: 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). +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 -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). +7. `expiration` must be defined -6. `fill_or_kill` does not apply +## Manual margin call -7. The order has an `expiration` +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 From 468b33bc1ea10bd698f4b8fc5930e5f2388a0904 Mon Sep 17 00:00:00 2001 From: Abit Date: Mon, 30 Sep 2019 21:10:01 +0200 Subject: [PATCH 10/10] Update links --- bsip-0062.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/bsip-0062.md b/bsip-0062.md index 5372bbd..d23ad92 100644 --- a/bsip-0062.md +++ b/bsip-0062.md @@ -42,22 +42,18 @@ Remarks: 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 # 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 +# 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.