From e22fe0e2d3db90a7a2027c093f344ee83703f82e Mon Sep 17 00:00:00 2001 From: abitmore Date: Sun, 25 Feb 2018 22:07:57 +0000 Subject: [PATCH] bsip35: rounding rules when call bigger than limit --- bsip-0035.md | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/bsip-0035.md b/bsip-0035.md index d0a6e21..3174f87 100644 --- a/bsip-0035.md +++ b/bsip-0035.md @@ -262,14 +262,19 @@ The detailed rules proposed by this BSIP with new rules highlighted: * When matching a limit order with a call order, * **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.** - * **In the latter case, if the limit order would receive nothing, cancel it - (it's smaller, so safe to cancel).** + paying amount; otherwise,** round down its paying amount. + * **In the latter case,** + * **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.** * When matching a settle order with a call order, * **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.** + paying amount; otherwise,** round down its paying amount. * **In the latter case,** * **if the settle order would receive nothing,** * **if the settle order would be completely filled, cancel it;** @@ -280,6 +285,7 @@ The detailed rules proposed by this BSIP with new rules highlighted: * **otherwise (if the settle order would not receive nothing), calculate the amount that the settle order would pay as `round_up(receiving_amount * match_price)`. After filled both orders, + if the settle order still exists, match the settle order with the call order again. In the new match, either the settle order will be cancelled due to too small, or we will stop matching due to hitting `maximum_force_settlement_volume`.** @@ -349,6 +355,7 @@ Process: for example `$27`, then Alice would get * `round_up(27 * 3 / 8) = round_up(10.125) = 11 CORE` as a maker, or * `round_up(27 * 19 / 50) = round_up(10.26) = 11 CORE` as a taker. + However, since the collateral is only `10 CORE`, this match will fail and trigger a black swan event. @@ -401,8 +408,11 @@ In `check_call_orders(...)` function of `database` class, if the call order is smaller, round up `order_receives`, otherwise round down `order_receives`. -In the latter case, if `order_receives` is zero, skip filling and cancel the -limit order. +In the latter case, +* if `order_receives` is zero, skip filling and cancel the limit order. +* otherwise, calculate `order_pays` as + `round_up(order_receives * match_price)`, then the limit order will be + either completely filled, or culled due to too small after partially filled. ## When Matching A Settle Order With A Call Order