-
Notifications
You must be signed in to change notification settings - Fork 573
Fix BSRM 2 Borrowing; Issue #3746 #3748
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
base: develop
Are you sure you want to change the base?
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.
Since we have multiple black swan strategies, I think we need to detail out how each of them is used and which variables are set or not set and fix this method to work for all.
| } | ||
| if (!!asset.get("settlement_price")) { | ||
| return asset.getIn(["settlement_price"]); | ||
| if (!!asset.get("individual_settlement_debt")) { |
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.
@abitmore since we have different black swan handling strategies, which variables are set in which case?
Is settlement_price and individual_settlement_debt both set at the same time, or either or?
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.
IMO, since the extractRawFeedPrice() function is used in different places for different purposes, we should be careful when updating code here to avoid introducing new bugs.
- We should always use
median_feeds.settlement_pricewhen borrowing, to calculate CR and etc. - Use
current_feed.settlement_pricewhen displaying the "yellow" orders (margin calls) on the order book, placing limit order to buy into the margin calls, or requesting forced-settlements (note that it's not for the scenario when BSRM is0and a black swan event had happened), etc. - When
BSRMis1or2,median_feeds.settlement_priceandcurrent_feed.settlement_pricecan be different when there was a black swan event.
settlement_price is set when BSRM is 0 and a black swan event happens. It is used in this case for forced-settlements. Check the USD asset on chain.
individual_settlement_debt is set when BSRM is (2 or 3) and a black swan event happens. Check the CNY and SGD assets on chain.
| if (!!asset.get("settlement_price")) { | ||
| return asset.getIn(["settlement_price"]); | ||
| if (!!asset.get("individual_settlement_debt")) { | ||
| ret = asset.get("median_feed").get("settlement_price"); |
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.
Please add a comment how it relates, and why
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.
If it has a positive individual_settlement_debt, then the current feed freezes, you need to switch to using the median feed to continue borrowing new individual settlement positions.
Closes #3746
Use
median_feedinstead ofcurrent_feedin the case of a BSRM 2 individual settlementCode Preparation
Please review all your changes one last time before committing
Testing
The branch has been tested on the following browsers (desktop and mobile view)