Skip to content

Conversation

@litepresence
Copy link
Contributor

Closes #3746

Use median_feed instead of current_feed in the case of a BSRM 2 individual settlement

Code Preparation

Please review all your changes one last time before committing

  • Check for unused code
  • No unrelated changes are included
  • None of the changed files are reformatting only
  • Code is self explanatory or documented
  • All written text is properly translated (english language)

Testing

The branch has been tested on the following browsers (desktop and mobile view)

  • Chrome
  • Opera
  • Firefox
  • Safari
  • Brave (Chrome derived)

Copy link
Contributor

@sschiessl-bcp sschiessl-bcp left a 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")) {
Copy link
Contributor

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?

Copy link
Member

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.

  1. We should always use median_feeds.settlement_price when borrowing, to calculate CR and etc.
  2. Use current_feed.settlement_price when 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 is 0 and a black swan event had happened), etc.
  3. When BSRM is 1 or 2, median_feeds.settlement_price and current_feed.settlement_price can 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");
Copy link
Contributor

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

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Smartcoin borrow modal doesn't use median_price during individual settlement

4 participants