-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BSIP 74 Specification Clarification #273
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for bringing this up.
|
||
**Case 2:** In the case of the call order being the taker, | ||
|
||
`Margin call match price = settlement price/MSSR`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The match price here should be the limit order's price. The limit order's price (which is buying the collateral asset with debt asset) should not be lower than settlement_price / (MSSR-MCFR)
, otherwise the match doesn't happen.
Note: the order matching engine requires 1 <= MSSR < MCR
and 1 <= MSSR-MCFR < MCR
. This ensures that CR of the call order will increase after being matched with a limit order, and the limit order is not buying above feed price when being a taker. If for some reason the parameters became inconsistent and broke the limitations above, cap MCFR
at MSSR - 1
. The capping applies to case 1 too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: the order matching engine requires
1 <= MSSR < MCR
and1 <= MSSR-MCFR < MCR
. This ensures that CR of the call order will increase after being matched with a limit order, and the limit order is not buying above feed price when being a taker.
If for some reason the parameters became inconsistent and broke the limitations above, cap
MCFR
atMSSR - 1
. The capping applies to case 1 too.
I'm wondering about how to perform these checks efficiently. If these values should be honored during order matching, does that require "normalizing" all the limit orders during the start of the order matching process? Or once whenever violating limitations are set?
What about, as an alternative, preventing the setting of invalid MSSR and MCFR when they are set in their operation evaluator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are plenty of numbers floating around here, so please let me make sure I understand what you are saying.
MSSR is defaulted at 1500 (GRAPHENE_DEFAULT_MAX_SHORT_SQUEEZE_RATIO
), which I read as 150%. I assume that when you say 1 <= MSSR
you mean 1 <= ( ( MSSR-1000) / 1000 )
, i.e. the default case is 1 <= 0.5
Also, when you say cap MCFR
at MSSR - 1
, am I correct in believing (assuming MSSR
is GRAPHENE_DEFAULT_MAX_SHORT_SQUEEZE_RATIO
) 1499 a.k.a. 149.9%?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about, as an alternative, preventing the setting of invalid MSSR and MCFR when they are set in their operation evaluator?
See bitshares/bitshares-core#2130 (comment)
In short:
However, mssr is updated by price feed producers and an internal timer, mcfr is updated by asset owner, so likely we can't validate when one of them is updated. So we need to cap the value of mcfr when use it in calculation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 <= MSSR < MCR
Default value of MSSR
is 1500
aka 1.5
, default value of MCR
is 1750
aka 1.75
.
1 <= 1.5 < 1.75
, it's perfect.
Current data on chain:
- bitCNY MCR 1600 MSSR 1010, so 1 <= 1.01 < 1.6
- bitRUBLE MCR 1750 MSSR 1100, so 1 <= 1.1 < 1.75
1 <= MSSR-MCFR < MCR
- for bitCNY, I'd assume the valid MCFR would be between 0 and 0.01,
[0, 0.01]
- for bitCNY, I'd assume the valid MCFR would be between 0 and 0.1,
[0, 0.1]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: the order matching engine requires
1 <= MSSR < MCR
and1 <= MSSR-MCFR < MCR
.
Is it safe to only consider the second part? Or do we allow a negative MCFR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we allow a negative MCFR.
|
||
Note that MCFR does not come into play for order matching in this case, but it is involved in the calculation of collateral that is returned to the call order owner. | ||
|
||
When margin call trading happens with the call order as the taker, the buyer sells smartcoin with quantity X and receives collateral in quantity `X/limit order price`, the margin call order owner sells collateral in quantity `X/limit order price*(1+MCFR)` and gets smartcoin in quantity X, the delta in paid and received collaterals (quantity `X*MCFR/limit order price`) will be paid to the owner of the smartcoin as the margin call fee. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a fair approach, although perhaps not the best.
Also please be aware that X
is affected by the TCR
parameter as well as the filling price (but not only the matching price), when the filling price got shifted due to MCFR
, X
could be different. This applies to case 1 too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a fair approach, although perhaps not the best.
Would this be better by not reducing the CR of a margin call order that is partially filled?
"When margin call trading happens with the call order as the taker, the buyer sells smartcoin with quantity X and receives collateral in quantity X*(1-MCFR)/limit order price
, the margin call order owner sells collateral in quantity X/limit order price
and gets smartcoin in quantity X, the delta in paid and received collaterals (quantity X*MCFR/limit order price
) will be paid to the owner of the smartcoin as the margin call fee."
Is there something else that would be better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When there is a limit order bidding high, and a call order takes it, it's perhaps "better" (or not) that the call order pays more fees than X*MCFR/limit_order_price
, e.g. pays X*MCFR/feed_price
.
The status is you do not have enough collateral so you are margin called. Your debt is placed up for sale so your collateral can be extracted to pay your due. The amount of collateral you get back (per unit of debt) is less than feed price because you're being squeezed. You're liquidated at up to the margin call limit price; the realized call price. Now the system will tax you and pay the issuer as an added penalty/indignity of being margin called. It would seem a legitimate tax is on the collateral ACTUALLY recovered; as opposed to collateral that "could have been" recovered. As a metaphor, in real life, we're often faced with theoretical prices and executed market prices when we shop. The "list price" of some item for sale at the store might be $200; but the actual price you pay after a 50% discount is $100. In such circumstance, the State charges tax on the discounted rate of execution; not the theoretical list price. This is the case regardless of whether its an advertised discount, haggled discount, or any other reduction of execution price. Likewise; feed price is theoretical. Whereas, realized call price is the price of execution. It seems in keeping with norms of society to charge taxation on the executed market prices. If the State tax rate is 10%, your liability on $100 executed sale (realized call) is $10; not $20 on the listed (feed) price. |
@abitmore This is a follow-up to a related discussion There are three ideas that I am having difficulty with reconciling. Idea 1: The original BSIP74 specifications as being approximately true Idea 2: Our discussion where we confirmed that "the buyer's/limit order owner's expectation of the "real price" is settlement_price/(MSSR-MCFR)." and that the this "real price" is the match price. Idea 3: The statement "IMO, when MCFR is zero, all existing test cases should pass." which includes two BSIP77 tests (1 and 2) which, under the current values of the hardfork activation times, operate under BSIP74 rules. My current reconciliation is to conclude that BSIP74 does not apply when the call order is taker but does apply when the call order is maker. I conclude this based on the test line 1 which is operating under BSIP74 rules because (a) it is invoked from this BSIP77 test, and (b) the currently defined activation times. [1] specifically states that Bob, the margin call owner, paid 105 CORE in collateral which (c) is the amount asked for by the limit order, and (d) does not equal 110 CORE which is what should be paid by the call order according to BSIP74 when there is a 10% MSSR. Is there some other way to interpret or reconcile these three ideas? Alternatively, if these three ideas are compatible with each other, and if this BSIP77 test is an example of how BSIP74 should operate under BSIP74 rules when the call order is a taker, it would help greatly and save time to have the following additional numerical examples (a) more_call_order_update_test_after_hardfork_bsip77_when_icr_not_set when MCFR is 5% which describe
With these numerical examples, we can finally resolve the specifications. |
Offering some of my own thoughts here. No guarantee they're fully baked. It seems to me the maker/taker issue boils down to the fact that one party to the trade (the taker) has the potential to get a "better deal" than they are asking for, by virtue of being able to pick an existing order off the book. If the taker is the limit order, the logic in BSIP74 as written is reasonably clear. The trade price will be The other scenario: If the taker is the call order, then the trade price will be collateral amount In this case, it's a little unclear what amount of collateral the call order should relinquish. On the one hand, it could relinquish the very same On the other hand, when the call order is taker, we could "fix" the delta at I favor the latter option, as it seems more fair to me. Further commentary:
can't be correct (or I'm not understanding it) — as there ARE cases where the match price is DIFFERENT from settlement_price/(MSSR-MCFR) — specifically the case where the call order is taker. The difference is in favor of the call order (allows it to retain a bit more collateral). A possible reconciliation of this is that "real price" is not supposed to refer to the "match price" but only to the price at which the call order is offered. The match price may differ in the case where the call takes an existing advantageous offer. |
@MichelSantos wrote:
There was a misunderstanding or miscommunication. I replied "yes" there because I thought your question implied the limit order was the taker, in this case, the (maker) price the call order offers is As @christophersanborn pointed out, the logic is clear when the limit order is the taker. When the limit order is the maker, I've commented earlier (#273 (comment)):
Actually it is the same idea as @christophersanborn's : "fix" the delta at a price. @christophersanborn wrote:
This assumption is correct. |
@christophersanborn @abitmore Do we have agreement of the following for Case 2/call order is taker/limit order is maker? Case 2: In the case of the call order being the taker, When margin call trading happens with the call order as the taker: The match price is X/limit_order_price During filling
Therefore the call order pays a total collateral with quantity X/limit_order_price + X*MCFR/settlement_price |
When the call order is the taker, it pays the fee in collateral asset with quantity |
Which is better depends on the objective. The objective described in the Motivation is "add to the system's income". Both
One might argue that another advantage is that it is a larger fee which is in closer agreement to the motivation of adding to the system's income. However this ignores that the owners of call orders might adjust their behavior if and when BSIP74 is activated to reduce the frequency or likelihood being margin called. This could be achieved either by reducing the creation of call orders and/or increasing their collateral ratios to reduce margin calls. (Updated by @abitmore for better format) |
This is an interesting question. Here the I propose we check which fee calculation is better and give the call order the better result. This check is only needed when call is taker. In particular, I propose this matrix: Call is Maker (Just for review): In this case we do:
Call is Taker: In this case we do:
|
Thank you @christophersanborn for pointing out the error. |
I'm sorry but I don't understand how Your statement seems to be that the fee as taker should not be more than the fee as maker. A min function, as described by Christopher, would address that concern. |
It comes from the fact that the call order offers a price of
which, when plugged in to the formula for fee gives: (inequality switches direction because the price is in inverse)
So we get the result that the fee matches the spec price in the extremum match condition where we take an order at the same price as the offer price, but goes down if we happen to match at a more favorable price. |
@MichelSantos wrote:
The 2 orders match, which means
|
Thanks for both of those explanations @christophersanborn @abitmore I also now understand that because the limit_order_price is constrained between Although I still think that this margin call fee is more complicated to explain than a |
I have not thought through your detailed explanation, it looks fine at glance and does not alter the intent of this bsip. @jmjatlanta can you resolve all reviews and comment when you see this done? |
I think it can be explained in a consistent manner as
which to be deducted from remainder of collateral in the debt position. |
@sschiessl-bcp I would expect that @MichelSantos will create a new pull request to resolve the reviews. |
@sschiessl-bcp For whatever it's worth, I agree that the updates do not change the intent, and that it addresses an ambiguity when the margin call order was a taker. The ambiguity is well summarized by @abitmore , after much development and discussions, as what is amount of collateral that is paid to the buyer. |
Closing in favor of #278. |
Note 1: It is not the intent of this PR to change the mechanics, only to clarify the specifications of BSIP 74. Please review these changes carefully to assure the integrity of the original BSIP, and the accuracy of the specifications.
Note 2: Implementing BSIP74 reduces the "window" of matching limit orders by the MCFR in Case 1. It is assumed the reader understands that, and that issuers will be judicious with their selection of MCFR values. Is it appropriate (or desired) to add this note to this BSIP?
Note 3: These specifications do not dictate what should happen if the collateral is insufficient to pay the margin trading fee. Perhaps (a) the fee takes what it can, or (b) the match fails. If (b), what happens next? Perhaps there is a (c) that I have not thought of.