bsip38: rewording; add max_debt_to_cover formula

This commit is contained in:
abitmore 2018-04-10 13:56:55 -04:00
parent 3006bc8022
commit 37ca45b475

View file

@ -82,6 +82,14 @@ max_amount_to_sell = (debt * target_CR - collateral * feed_price)
The result is a rational number, need to be rounded up to an integer. The result is a rational number, need to be rounded up to an integer.
Then, the maximum debt it wants to cover can be calculated as:
```
max_debt_to_cover = max_amount_to_sell * match_price
```
It need to be rounded up to an integer as well.
# Specifications # Specifications
@ -143,14 +151,14 @@ The rule for matching a limit order with a call order need to be revised as
smaller and the short position will be closed after the match, round up its smaller and the short position will be closed after the match, round up its
paying amount; paying amount;
* **otherwise,** * **otherwise,**
* **if `target_collateral_ratio` is set and it's receiving the maximum debt * **if the call order has `target_collateral_ratio` set and is receiving the
amount calculated with `target_collateral_ratio`, see this order is smaller, maximum debt amount calculated with `target_collateral_ratio`, see the call
try to round up its paying amount;** order as smaller, try to round up its paying amount;**
* **for edge cases, if its collateral ratio would not increase after being * **for edge cases, if the call order's collateral ratio would not increase
partially filled due to the round-up (which may even cause a black swan after being partially filled due to the round-up (which may even cause a
event in an extreme scenario), see `target_collateral_ratio` as not set for black swan event in an extreme scenario), see its `target_collateral_ratio`
this time, re-apply the filling rules for this match.** as "not set" for this time, re-apply the filling rules for this match.**
* otherwise, round down its paying amount. * otherwise, the call order is larger, round down its paying amount.
* if the limit order would receive nothing, cancel it (it's smaller, * if the limit order would receive nothing, cancel it (it's smaller,
so safe to cancel); so safe to cancel);
* otherwise, calculate the amount that the limit order would pay as * otherwise, calculate the amount that the limit order would pay as