From 37ca45b475163bed8b632a4c296886002737f8a1 Mon Sep 17 00:00:00 2001 From: abitmore Date: Tue, 10 Apr 2018 13:56:55 -0400 Subject: [PATCH] bsip38: rewording; add max_debt_to_cover formula --- bsip-0038.md | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/bsip-0038.md b/bsip-0038.md index e615ecb..764203c 100644 --- a/bsip-0038.md +++ b/bsip-0038.md @@ -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. +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 @@ -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 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 call order has `target_collateral_ratio` set and is receiving the + maximum debt amount calculated with `target_collateral_ratio`, see the call + order as smaller, try to round up its paying amount;** + * **for edge cases, if the call order's 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 its `target_collateral_ratio` + as "not set" for this time, re-apply the filling rules for this match.** + * otherwise, the call order is larger, 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