bitshares / bsips

BitShares Improvement Proposals and Protocols. These technical documents describe the process of updating and improving the BitShares blockchain and technical ecosystem.
https://bitshares.github.io
63 stars 86 forks source link

BSIP71: Add "Prevent Global Settlement" Flag for Smartcoin #193

Closed MichelSantos closed 4 years ago

MichelSantos commented 5 years ago

Latest draft from #179

abitmore commented 5 years ago

For implementation, I think we can reuse the "disable_global_settlement" option. That option is now used to prevent the asset owner from manually doing a global settlement. I see no reason to allow a manual GS if don't allow GS caused by price feeds.

pmconrad commented 5 years ago

PMs need manual GS

abitmore commented 5 years ago

PM should not GS due to price feeds. Related discussions in #42 and https://github.com/bitshares/bitshares-core/issues/460.

pmconrad commented 5 years ago

A manual GS and the functionality described here are two different things. I think we should not mix them into one flag.

ryanRfox commented 5 years ago

I feel this BSIP should limit its scope to Smartcoin markets. I welcome designing a more robust PM model in #42

pmconrad commented 4 years ago

I'm OK with the specification, but after re-reading the whole document I noticed that the "Rationale" no longer matches the specification in two respects:

Perhaps add "Discussion" entries:


Discussion

settlement_price / feed_price

Some may perceive it as confusing or unfair that borrowing and force settlement may refer to different prices. However, in a period where the least collateralized short position has insufficient collateral in terms of FP_m, it would be dangerous to use the resulting settlement_price for borrowing as well, because that would allow creation of short positions that are undercollateralized from the start.

Least collateralized short

Once a short position's CR drops below MSSR, it will be sitting on the market with a price that is worse than the price of other margin calls. It is thus less likely to be bought up and filled. This means that the settlement_price is likely to continue dropping as the value of the collateral does.

  1. The settlement_price resulting from the least collateralized short position is the same as the price that would have resulted from global settlement. The difference here is that this price applies only to a fraction of the debt, whereas global settlement affects all debt.
  2. The least collateralized position can only pay as much collateral as it has. Price manipulation alone cannot solve that.
  3. Even if the other margin calls were queued behind the least collateralized short, the fill price would likely drift away from the usual market price, which would lead to no margin calls being filled. The proposed solution is seen as the lesser evil.
bitcrab commented 4 years ago

I went though all the discussion however am not sure I captured all the ideas from @pmconrad .

It's acceptable to use feed_price instead of settlement_price in borrowing.

I agree with @abitmore on below topic, I feel this method ensure both "having the least collateralized call_order filled" and "filling as much margin-called debt as possible ".

Another option is, when a big limit order buying into multiple margin calls, after each margin call got filled, recalculate settlement_price, this means the next call order will be bought at lower price (in favor of the buyer). I think this approach is better.

I still feel the "having the least collateralized call_order filled" principle is more important, leaving the least collateralized call_order there without being filled is just like leaving the biggest risk there without trying to remove it.

bitcrab commented 4 years ago
  • Rationale says "3. Ensure the debt positions be settled in the order from lower CR to higher CR." - after discussion we agreed that "filling as much margin-called debt as possible is more important" than "having the least collateralized call_order filled". (This only applies when the least collateralized order has CR < MSSR.)

Least collateralized short

Once a short position's CR drops below MSSR, it will be sitting on the market with a price that is worse than the price of other margin calls. It is thus less likely to be bought up and filled. This means that the settlement_price is likely to continue dropping as the value of the collateral does.

  1. The settlement_price resulting from the least collateralized short position is the same as the price that would have resulted from global settlement. The difference here is that this price applies only to a fraction of the debt, whereas global settlement affects all debt.
  2. The least collateralized position can only pay as much collateral as it has. Price manipulation alone cannot solve that.
  3. Even if the other margin calls were queued behind the least collateralized short, the fill price would likely drift away from the usual market price, which would lead to no margin calls being filled. The proposed solution is seen as the lesser evil.

I cannot agree that "filling as much margin-called debt as possible" is more important than "having the least collateralized call_order filled".

consider one edge case:

there are only 2 debt positions in USD markets, both become bad in one price downtrend, A has a settlement price 0.03USD, B has a settlement price 0.02USD, and the market price is 0.015USD.

if we make B be filled/settled first, bitUSD will be more devalued in the process, as the value behind 1bitUSD become lower after B is solved. OTOH, if we make A be filled/settled first, bitUSD will be less devalued after A is solved.

so "higher CR first" will lead to "let's buy the best with our USD, who care the left USD", it will maximize the devalue of bitUSD and delay the process to revive.

"lower CR first" will lead to "let's solve the difficult problem first, then the left will be easy", it will minimize the devalue of bitUSD and speed up the process to revive.

even more, as "higher CR first" allow the different bad call_order to sell in different price, it may be more friendly to shorting attack, as shorter can press price to create more bad debt call_order with lower sell price and make profit by filling.

the least collatearlized call_order is the biggest threaten to the smartcoin system, it make little sense to process higher collateralized call_order and ignore the least collateralized call_order.

pmconrad commented 4 years ago

there are only 2 debt positions in USD markets, both become bad in one price downtrend, A has a settlement price 0.03USD, B has a settlement price 0.02USD, and the market price is 0.015USD. "lower CR first" will lead to "let's solve the difficult problem first, then the left will be easy", it will minimize the devalue of bitUSD and speed up the process to revive.

The "lower CR first" rule is important as long as both debt positions are able to pay the market price. In your example though, neither A nor B have sufficient collateral to pay the market price, therefore neither position will be improved. But consider the way leading there: perhaps there has been a situation where the market price was 0.025 USD. At that point, B could have paid back some of his debt, while A still couldn't. In my opinion in this situation it is better if B improves the CR of his position, because A can't do anything anyway.

abitmore commented 4 years ago

@pmconrad in your example A was a bad debt but B was not. If we fill B but not A, the asset will be stuck in GS protection status unless price raises, if it's in a down trend, new bad debt may appear and unable to be bought which will make the situation worse. It's discussed in early stage of #179. One important purpose of this BSIP is to get the asset out of GS protection status as fast as possible, nevertheless, at the cost of collateral buyers. So in that case I would recommend that we fill A first even A can't fully pay her debt. Then, when the price falls and both A and B become bad debt, we still fill A first, because once the price raises, it's more possible that the asset will get out of GS protection status.

pmconrad commented 4 years ago

I would recommend that we fill A first even A can't fully pay her debt.

But that makes things even worse. If A's collateral/debt < market price then selling at market price means collateral'/debt' < collateral/debt and in the extreme case collateral == 0 while debt > 0.

abitmore commented 4 years ago

selling at market price

Why did you get this idea? The idea was always to sell at no lower than collateral/debt.

pmconrad commented 4 years ago

Apparently we're talking past each other.

In my example the market price was between A and B. A has worse collateral/debt ratio, B has better collateral/debt ratio. You said "we still fill A first" while I say that we can't fill A but we can fill B, and it's better to fill B now instead of waiting for A to be filled first.

With "market price" I mean the best offer on the market, not feed price nor settlement price.

abitmore commented 4 years ago

So the idea is to always "hide" B behind A, because A's CR is lower.

bitcrab commented 4 years ago

The "lower CR first" rule is important as long as both debt positions are able to pay the market price. In your example though, neither A nor B have sufficient collateral to pay the market price, therefore neither position will be improved. But consider the way leading there: perhaps there has been a situation where the market price was 0.025 USD. At that point, B could have paid back some of his debt, while A still couldn't. In my opinion in this situation it is better if B improves the CR of his position, because A can't do anything anyway.

as @abitmore commented, One important purpose of this BSIP is to get the asset out of GS protection status as fast as possible, nevertheless, at the cost of collateral buyers. comparatively, "filling as much margin-called debt as possible" is not what we should try to seek.

if we allow buyers to buy from B when A is still there, it will give buyers expectation that there will always be cheaper collaterals, the result may be finally the bad debts with higher CR were bought first and what left at the end is the bad debts with lower CR, this conflict with the purpose "get the asset out of GS protection ASAP".

bad debts can be solved by 1. buying call_order 2. CR adjust 3. price recovery. buying call_order is the most valuable way and we need to lead them to focus on the least collateralized debt first.

this is not price manipulation, this is just special way at special scenarios.

frankly speaking, if the "having the least collateralized call_order filled first" principle can not be guaranteed, I prefer to not implement this BSIP and just keep the current status - let the witnesses ensure the feed price higher than GS price, although this depend on witnesses' work but it guarantee this "lower CR first" principle.

pmconrad commented 4 years ago

What I fear is that once the market price has moved past the least collateralized short no margin calls are bought up anymore. I think that would be dramatically worse than the current situation, because that way we pile up more and more bad debt as the price goes down instead of resolving at least some of it through the margin calls.

It would also be extremely bad for those debt positions that would normally improve their CR via margin calls. I imagine it would also lead to the much-cited "confusion and anger" from the owners of those debt positions. :-)

Again, I agree that the "least collateralized first" rule is important. But here we're discussing the situation where the least collateralized position cannot pay the market price. I think it does not make sense to keep up the rule even in such an extreme situation.

bitcrab commented 4 years ago

when bad debts pile up, BTS market is always very weak and the price is at the lowest level, at this time it is not good to try to sell cheap collaterals, "least collateralized first" rule is telling all, you can buy the cheap collaterals, but please buy the expensive one first. this is to force the smartcoin holders to guarantee the value of the smartcoin.

we have observed that bitCNY and bitUSD both have experienced GS protection, actually the status do not keep long and the price recover soon, Why? because GS protection stop the feed price to go down and let every shorter know he cannot buy cheaper BTS. if we tell the shorters that they can buy cheaper BTS without solving the least collateralized first, they will just wait the cheaper collateral to come.

the BTS price trend depend highly on the smartcoin rule. as rule designer we should try to avoid providing convenience to shorting attack.

pmconrad commented 4 years ago

you can buy the cheap collaterals, but please buy the expensive one first.

Hm, we're looking at this from very different perspectives.

If I understand you correctly you mean that trading on the market essentially happens because traders want to buy up the margin calls, and that therefore the market price adjusts toward the margin call execution price.

OTOH I assume that the market price centers more or less around the feed price and is otherwise independent from the margin call execution price. (Admittedly this is only true in one direction. As long as there are margin calls open they will keep the market price at or above MSSR.) In the presence of bad debt, traders who want to buy up the collateral from the bad debt would have to pay more than the fair price. Why would they want to do that? They didn't want it even when the price was better. I think in a BTS downtrend traders would rather pay more BTS than the fair price to get into the safety of the SmartCoin. I think it is therefore unlikely that the bad debt will be filled via market trades.

the status do not keep long and the price recover soon, Why? because GS protection stop the feed price to go down and let every shorter know he cannot buy cheaper BTS

I don't think so. The BTS price is driven by many more factors than the margin calls on the DEX. This may be a little different on the bitCNY market, for reasons we have often discussed. But we're talking about a general mechnism here, not just about bitCNY.

abitmore commented 4 years ago

Yes you're looking from different perspectives.

Game theory plays a role in the scenario. When bad debt is piling up,

the market price centers more or less around the feed price

I'd expect that the debt asset would devalue in this scenario, thus the market price of debt:collateral (but not the_pegging_taget:collateral) would be between the feed price and the settlement price, and perhaps closer to the settlement price. By the way we can take a look at what's current market price of GSed bitBTC.

pmconrad commented 4 years ago

we can take a look at what's current market price of GSed bitBTC

I think this is not quite applicable. The situation is a bit different there.

Anyway, I'm unsure what's best. I see valid arguments for either side. I cannot predict how the market will behave (nor do I think that anyone else can :-) ). Any other opinions? @MichelSantos perhaps?

bitcrab commented 4 years ago

one key point is, when bad debt appear, smartcoin begin to devalue. consider the extreme case mentioned above, at one time there are only 2 debt positions and both are bad. debt position A: debt 30K bitUSD, collateral 1MBTS, settlement price 0.03bitUSD. debt position B: debt 20K bitUSD, collateral 1MBTS, settlement price 0.02bitUSD. at this time, market price/feed price = 0.015USD.

at this time, what's the value of bitUSD?

it can be calculated by the value of the backed assets: sum(debt)/sum(collateral) = 50KbitUSD/2MBTS = 0.025bitUSD/BTS.

as market price is 0.015USD, so ATM 1bitUSD = 0.6USD(fiat)

if you allow buyer to settle B first ATM, means you allow buyer to buy collateral in B with price 0.02bitUSD, or 0.012USD. cheaper than market price 0.015USD, which is not acceptable.

pmconrad commented 4 years ago

at this time, what's the value of bitUSD?

There is no single "true" answer.

The combination of all these creates the market price. I cannot tell where that will be.

bitcrab commented 4 years ago

at this time, what's the value of bitUSD?

There is no single "true" answer.

  • a well-informed holder who has only 3 bitUSD knows that if he settles now he'll receive 100 BTS which are worth 1.5 USD, so 1 bitUSD = 0.5 USD.
  • a well-informed holder who has 50K bitUSD will, as you did, conclude that 1 bitUSD = 0.6 USD.
  • a badly informed holder might think that 1 bitUSD = 1 USD
  • a shorter will have to put FP*MCR as collateral and hopes to sell his new bitUSD for more than 1 USD (minus settlement_offset)
  • an extremely well informed holder who can look into the future (or maybe he's just an optimist) and sees BTS rising will buy bitUSD at 0.9 USD for a 10% profit.

The combination of all these creates the market price. I cannot tell where that will be.

only the first 2 logic make sense, the other 3 do not. we are talking the essential value in one bitUSD ATM, not the "market price". the value depend on how much you can directly get by paying 1USD ATM, what's the cost of 1 bitUSD, what's the value of bitUSD in one's wrong idea, what's the value of 1USD in future is not relevant here.

pmconrad commented 4 years ago

we are talking the essential value in one bitUSD ATM, not the "market price". the value depend on how much you can directly get by paying 1USD ATM, what's the cost of 1 bitUSD, what's the value of bitUSD in one's wrong idea, what's the value of 1USD in future is not relevant here.

I'm arguing that if the market price moves away from the margin call execution price no margin calls will be filled anymore, even those that could afford the market price. That's why we are discussing the market price. The market price depends on how people trade. Markets are not only used by well-informed, logical traders. (Quite the opposite IMO.) Therefore, what people think about the future price determines the market price, and therefore it is relevant.

bitcrab commented 4 years ago

I'm arguing that if the market price moves away from the margin call execution price no margin calls will be filled anymore, even those that could afford the market price. That's why we are discussing the market price. The market price depends on how people trade. Markets are not only used by well-informed, logical traders. (Quite the opposite IMO.) Therefore, what people think about the future price determines the market price, and therefore it is relevant.

market price depend on market, however, system logic should not be "if any bad debt position can be settled by market price, let the settlement happen", NO!

actually currently the GS protection is running well, although there is uncertainty inside as it depend on witnesses' work, the intention of this BSIP is to remove the uncertainty by replacing the withesses' work with core code, without big logic change.

if we cannot reach consensus soon, I suggest to stop the work on this BSIP and pay more time and effort on other important BSIPs like BSIP74 and BSIP62, I believe the "filling as much margin-called debt as possible" principle will introduce new risk which may be even worse than current uncertainty.

pmconrad commented 4 years ago

Ok, like I said I'm not sure what's best. Changed the wording accordingly and added to "Discussion".

Wrt the other point (borrowing price vs. settlement price) I have modified the rationale and also added a "Discussion" section. Please review.

bitcrab commented 4 years ago

it's OK, in my view we can go ahead with this version.

pmconrad commented 4 years ago

Thanks. @abitmore ?

abitmore commented 4 years ago

I have modified the rationale and also added a "Discussion" section.

Looks good to me.