Maybe they are the most complex parts of BitShares. We don't want to see global settlement happen on popular bitAssets, but we should know how it exactly works. In this post I will try to explain the whole process of these two events.
<p dir="auto"><span>Many thanks to <a href="/@abit">@abit for some of the details I was also missing before. <p dir="auto">This post reflects the mechanisms of current network consensus (version <code>2.0.171105a), and some of them may change in future hardforks. <h1>1. Triggering Global Settlement <h3>a. How is it triggered? <p dir="auto">Currently there are 3 ways to trigger global settlement on bitAssets. <h4>1. <code>asset_global_settle_operation <p dir="auto">This operation is for asset issuers to trigger the global settlement manually. I'll skip the details about it here. <h4>2. Margin position having collateral ratio below 1 <sup>[1] <p dir="auto">This is the most known black swan condition. When settlement price of the asset drops, collateral ratio of open margin positions will also decrease. If the collateral ratio of least collateralized margin position drops below 1, and <strong>there are no bid orders having price above <code>debt / collateral of that position, global settlement will be triggered. In this situation, the global settlement price will be <code>debt / collateral of the triggering least collateralized margin position. <p dir="auto">For example, we have a margin position with debt of 100 bitUSD and collateral of 200 BTS. If the settlement price of bitUSD drop below 0.5 bitUSD/BTS, and the highest bid of the exchange market is also below 0.5 bitUSD/BTS, global settlement will be triggered on bitUSD asset, with global settlement price of 0.5 bitUSD/BTS. <h4>3. Margin call order matched at market price below collateral ratio of 1 <sup>[2] <p dir="auto">The margin-called positions (those having collateral ratio below maintenance collateral ratio(MCR, usually 1.75)) will be sold on market with the price of <code>settlement price / maximum short squeeze ratio(MSSR, usually 1.1). Because of this, the call order could be executed below settlement price.<br /> The margin call order will only execute below call price <code>debt / collateral * MCR and above the limit <code>settlement price / MSSR. More details about margin call executions could be found in documents<sup>[7]. <p dir="auto">There could be a situation in which the call order has lowest execute price below 1 collateral ratio (<code>debt / collateral). If there are any matching bid order which could lead to the call order execute below 1 collateral ratio, global settlement will be triggered. In this situation, the global settlement price will be current settlement price of the asset. <p dir="auto">For example, with most common MCR(1.75) and MSSR(1.1), we have a margin position with debt of 100 bitUSD and collateral of 200 BTS. The settlement price of bitUSD is 0.528 bitUSD/BTS, below the position's call price <code>100 / 200 * 1.75 = 0.875 bitUSD/BTS, so the call order is put on the market with lowest possible execution price of <code>0.528 / 1.1 = 0.48 bitUSD/BTS, which is in turn below the collateral ratio 1 price of the position <code>100 / 200 = 0.5 bitUSD/BTS. As the margin positions cannot trade below that price (or the peg is lost), so if there are any buy orders with price between 0.48 and 0.5, global settlement will be triggered, with global settlement price of 0.528 bitUSD/BTS. <h3>b. What will happen?<sup>[3] <h4>1. All margin positions will be closed at global settlement price <p dir="auto">For all positions, use the collateral to buy the debt at global settlement price. The bought debt is returned to the blockchain and destroyed, effectively closing the position; the paid collateral will be put into settlement fund; the remaining collateral will be returned to the owner of the position<sup>[4]. <h4>2. Global instant settle will be enabled <p dir="auto">All of the existing asset will not be affected. Instead, the owner could choose to settle the asset at the global settlement price instantly without 24h delay, returning the asset to the blockchain and destroying them, and get the corresponding value from the settlement fund. <strong>This is not a forced operation. <p dir="auto">For example, when bitUSD enter global settlement state with global settlement price and current feed price of 0.5 bitUSD/BTS, there are 2 margin positions: <div class="table-responsive"><table> <thead> <tr><th>Account<th>Collateral<th>Debt<th>Call price<th>Collateral ratio <tbody> <tr><td><code>bob<td>200 BTS<td>100 bitUSD<td>0.5 bitUSD/BTS<td>1.0 <tr><td><code>alice<td>150 BTS<td>50 bitUSD<td>0.3333 bitUSD/BTS<td>1.5 <p dir="auto">During the process of entering global settlement, <code>alice will use 100 BTS of the collateral to buy 50 bitUSD at 0.5 bitUSD/BTS, and the remaining 50 BTS will be returned to <code>alice, while <code>bob will use all of the collateral to buy his debt, getting nothing back. The settlement fund will receive 300 BTS and will be used to settle the circulating 150 bitUSD. <h4>3. Normal bitAsset functions will be disabled <p dir="auto">The asset could still be freely traded at the exchange or send to others, but borrowing will be disabled. The asset is not pegged anymore at this state. Witnesses could still provide price feeds. <h1>2. Reviving from Global Settlement <p dir="auto">After the last hardfork, BSIP18 is activated and bitAssets in global settlement could be revived to restore it's complete function. This works by converting the current supply to new margin positions while satisfying all bitAsset requirements. <h3>a. How to revive bitAsset? <p dir="auto">There are 3 ways to revive a bitAsset. <h4>1. All existing bitAsset is settled <sup>[5] <p dir="auto">When the settlement price is changed on feed update, if the bitAsset has valid feed and current supply of the asset is 0, the asset will be revived. <h4>2. Settlement fund could satisfy collateral ratio requirement <sup>[5] <p dir="auto">When the settlement price is changed on feed update, if the bitAsset has valid feed and the new settlement price is above global settlement price * MCR (actual calculation: <code>settlement price > current supply / settlement fund * MCR), the asset will be revived. The blockchain will create a new margin position with the issuer of the bitAsset as the owner, current supply as the debt and settlement fund as the collateral. <p dir="auto">For example, bitUSD is in global settlement state, having global settlement price of 0.5 bitUSD/BTS, with current supply of 100 USD and 200 BTS in settlement fund. If the settlement price from price feed goes above <code>100 / 200 * 1.75 = 0.875 bitUSD/BTS, bitUSD will be revived, and committee_account will have a new margin position with 100 bitUSD debt and 200 BTS collateral. <h4>3. Collateral bids could cover the supply of the asset <sup>[6] <p dir="auto">BSIP-0018 introduced a new operation <code>bid_collateral_operation. As reviving requires creating new margin positions, this operation allows everyone to "bid" additional collateral to create new margin positions. <p dir="auto">To bid additional collateral, the bidder will indicate how much debt he is willing to take, and how much additional collateral he will add to the margin position. This operation is not present in GUI wallet right now, but can be done by using <code>bid_collateral command in CLI wallet or constructing the operation manually. <p dir="auto">On every blockchain maintenance (currently every hour), the blockchain will check if the sum of debt of all bids would cover the current asset supply. If it's true, the blockchain will sort the bids with higher <code>additional collateral / debt price in top, then create new margin positions for the bids until all current supply is covered. Each margin position will have debt as in the bid and collateral equals <code>debt of the bid * global settlement price + additional collateral of the bid. During the creation process, if any of the new margin position have collateral ratio below MCR, the revive process is failed. <p dir="auto">Here is an example of how it actually works. <p dir="auto">bitUSD is in the global settlement state with current supply of 100 bitUSD and 200 BTS in settlement fund. The global settlement price is 0.5 bitUSD/BTS, and settlement from price feed is 0.75 bitUSD/BTS.<br /> The bids before the maintenance are: <div class="table-responsive"><table> <thead> <tr><th>Account<th>Debt to take<th>Additional collateral<th>Additional collateral / debt <tbody> <tr><td><code>alice<td>25 bitUSD<td>100 BTS<td>4 <tr><td><code>bob<td>50 bitUSD<td>25 BTS<td>0.5 <tr><td><code>charlie<td>50 bitUSD<td>50 BTS<td>1 <tr><td><code>dave<td>100 bitUSD<td>1 BTS<td>0.01 <p dir="auto">On the blockchain maintenance, the sum of debt from all bids are over the current supply (125 > 100). The blockchain will sort the bids with order <code>alice - charlie - bob - dave. <ol> <li><code>alice will be assigned a new margin position with 25 bitUSD as debt and <code>25 / 0.5 + 100 = 150 BTS as collateral, in which <code>25 / 0.5 = 50 BTS is taken from the settlement fund, leaving 150 BTS behind, and 75 bitUSD remaining to be covered. <li><code>charlie will be assigned a new margin position with 50 bitUSD as debt and <code>50 / 0.5 + 50 = 150 BTS as collateral, in which <code>50 / 0.5 = 100 BTS is taken from the settlement fund, leaving 50 BTS behind, and 25 bitUSD remaining to be covered. <li><code>bob will be assigned a new margin position with remaining 25 bitUSD as debt and <code>25 / 0.5 + 25 = 75 BTS as collateral, in which <code>25 / 0.5 = 50 BTS is taken from the remaining settlement fund. <p dir="auto">The whole supply is converted to margin positions at this point, so <code>dave's bid is automatically cancelled.<br /> The resulting margin positions are: <div class="table-responsive"><table> <thead> <tr><th>Account<th>Collateral<th>Debt<th>Call price<th>Collateral ratio <tbody> <tr><td><code>bob<td>75 BTS<td>25 bitUSD<td>0.5833 bitUSD/BTS<td>2.25 <tr><td><code>charlie<td>150 BTS<td>50 bitUSD<td>0.5833 bitUSD/BTS<td>2.25 <tr><td><code>alice<td>150 BTS<td>25 bitUSD<td>0.2917 bitUSD/BTS<td>4.5 <p dir="auto">All of the margin positions have collateral ratio above 1.75, so the bitUSD is successfully revived. <h3>b. What will happen after the bitAsset revives? <p dir="auto">After the revive, all functions of the bitAsset will restore to normal - Anyone can borrow new assets into existence, settlement will have 24 hours delay, and most importantly, the asset will be pegged again. And everyone will be happy. <h2>References <p dir="auto">For those who want to take a look at the bitshares-core source code, here are the corresponding locations:<br /><br /><br /><br /><br /><br /><span> [1]: <a href="https://github.com/bitshares/bitshares-core/blob/master/libraries/chain/db_update.cpp#L200-L255" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://github.com/bitshares/bitshares-core/blob/master/libraries/chain/db_update.cpp#L200-L255<span> [2]: <a href="https://github.com/bitshares/bitshares-core/blob/master/libraries/chain/db_market.cpp#L522-L609" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://github.com/bitshares/bitshares-core/blob/master/libraries/chain/db_market.cpp#L522-L609<span> [3]: <a href="https://github.com/bitshares/bitshares-core/blob/master/libraries/chain/db_market.cpp#L43-L93" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://github.com/bitshares/bitshares-core/blob/master/libraries/chain/db_market.cpp#L43-L93<span> [4]: <a href="https://github.com/bitshares/bitshares-core/blob/master/libraries/chain/db_market.cpp#L427-L480" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://github.com/bitshares/bitshares-core/blob/master/libraries/chain/db_market.cpp#L427-L480<span> [5]: <a href="https://github.com/bitshares/bitshares-core/blob/master/libraries/chain/asset_evaluator.cpp#L558-L589" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://github.com/bitshares/bitshares-core/blob/master/libraries/chain/asset_evaluator.cpp#L558-L589<span> [6]: <a href="https://github.com/bitshares/bitshares-core/blob/master/libraries/chain/db_maint.cpp#L719-L767" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">https://github.com/bitshares/bitshares-core/blob/master/libraries/chain/db_maint.cpp#L719-L767 <p dir="auto">The margin call mechanics page article on bitshares docs site is a good read if you want to know more about how margin call is handled.<br /><span> [7]: <a href="http://docs.bitshares.org/user/dex-margin-mechanics.html" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">http://docs.bitshares.org/user/dex-margin-mechanics.html <h2>Feedback <p dir="auto">There could still be some details I'm not getting right or missing, or not expressed clearly, especially the reviving part. Please let me know in the comments, and I'll try to update this post or answer if possible. <p dir="auto">Hope this post clears up some points about the global settlement and reviving mechanism of BitShares platform. And many thanks for reading my first steemit post!
Uf, its complicated ((
But thanks for info!
Thanks for taking the time to write this up!
This post helped a lot!
Congratulations @haruka! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
<p dir="auto"><a href="http://steemitboard.com/@haruka" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/firstpayout.png" srcset="https://images.hive.blog/768x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/firstpayout.png 1x, https://images.hive.blog/1536x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/firstpayout.png 2x" /> You got your First payout <p dir="auto">Click on any badge to view your own Board of Honor on SteemitBoard.<br /> For more information about SteemitBoard, click <a href="https://steemit.com/@steemitboard" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">here <p dir="auto">If you no longer want to receive notifications, reply to this comment with the word <code>STOP <blockquote> <p dir="auto">Upvote this notification to help all Steemit users. Learn why <a href="https://steemit.com/steemitboard/@steemitboard/http-i-cubeupload-com-7ciqeo-png" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">here!Congratulations @haruka! You have completed the following achievement on Steemit and have been rewarded with new badge(s) :
<p dir="auto"><a href="http://steemitboard.com/@haruka" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://steemitimages.com/70x70/http://steemitboard.com/notifications/firstpayout.png" srcset="https://images.hive.blog/768x0/https://steemitimages.com/70x70/http://steemitboard.com/notifications/firstpayout.png 1x, https://images.hive.blog/1536x0/https://steemitimages.com/70x70/http://steemitboard.com/notifications/firstpayout.png 2x" /> You got your First payout <p dir="auto"><sub><em>Click on the badge to view your Board of Honor.<br /> <sub><em>If you no longer want to receive notifications, reply to this comment with the word <code>STOP <p dir="auto"><strong><span>Do not miss the last post from <a href="/@steemitboard">@steemitboard:<br /> <a href="https://steemit.com/steemitboard/@steemitboard/steemitboard-world-cup-contest-the-results-and-prizes" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">SteemitBoard World Cup Contest - The results, the winners and the prizes <blockquote> <p dir="auto">Do you like <a href="https://steemit.com/@steemitboard" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">SteemitBoard's project? Then <strong><a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Vote for its witness and <strong>get one more award!Looks like it happened. bitUSD has been called.
Congratulations @haruka! You received a personal award!
Click here to view your Board
Congratulations @haruka! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Do not miss the last post from @steemitboard:
Vote for @Steemitboard as a witness to get one more award and increased upvotes!