Add rounding rule for bsip 38

bsip53
abitmore 2018-04-10 05:18:11 -04:00
parent 98d712ece6
commit 17dd78b6c7
2 changed files with 31 additions and 4 deletions

View File

@ -7,7 +7,7 @@
Discussion: https://github.com/bitshares/bitshares-core/issues/132,
https://github.com/bitshares/bitshares-core/issues/184,
https://github.com/bitshares/bitshares-core/issues/342
Replaces: -
Superseded-By: 0038 (partly)
Worker: 1.14.96
# Abstract
@ -261,7 +261,8 @@ The detailed rules proposed by this BSIP with new rules highlighted:
amount remaining), check the remaining amount, if the amount is too small
so the order would receive nothing on next match, cancel the order.**
* When matching a limit order with a call order,
* When matching a limit order with a call order (**note: this rule has changed
in [BSIP 38](bsip-0038.md)**),
* **if the call order is receiving the whole debt amount, which means it's
smaller and the short position will be closed after the match, round up its
paying amount; otherwise,** round down its paying amount.

View File

@ -6,7 +6,7 @@
Created: 2018-03-05
Discussion: https://bitsharestalk.org/index.php?topic=25924.0,
https://github.com/bitshares/bsips/issues/51
Replaces: -
Replaces: 0035 (partly)
Worker: To be done
# Abstract
@ -30,7 +30,7 @@ black swan, thus hurts the BTS ecosystem. Many participants in the discussion
agree that usually it's not really required to cover all debt (thus selling more
collateral) when being margin called.
After [BSIP 31](https://github.com/bitshares/bsips/blob/master/bsip-0031.md) is
After [BSIP 31](bsip-0031.md) is
in place, shorters will have more chance to not cover all debt on margin call,
but it's not 100% guaranteed, and they can only accept the result passively.
@ -131,6 +131,32 @@ After a call order get matched with a limit order and about to fill,
* if `target_collateral_ratio` is set, calculate maximum amount of collateral
for sale according to the equation described above, then process as before.
### Rounding
Rules about rounding are defined in [BSIP 35](bsip-0035.md).
The rule for matching a limit order with a call order need to be revised as
(new rules **in bold**):
* if the call order is receiving the whole debt amount, which means it's
smaller and the short position will be closed after the match, round up its
paying amount;
* **otherwise,**
* **if `target_collateral_ratio` is set and it's receiving the maximum debt
amount calculated with `target_collateral_ratio`, see this order is smaller,
try to round up its paying amount;**
* **for edge cases, if its collateral ratio would not increase after being
partially filled due to the round-up (which may even cause a black swan
event in an extreme scenario), see `target_collateral_ratio` as not set for
this time, re-apply the filling rules for this match.**
* otherwise, round down its paying amount.
* if the limit order would receive nothing, cancel it (it's smaller,
so safe to cancel);
* otherwise, calculate the amount that the limit order would pay as
`round_up(receiving_amount * match_price)`. After filled both orders,
if the limit order still exists, the remaining amount might be too small,
so cancel it.
## UI/UX
The new option need to be presented and can be used in UI after the hard fork.