From 716a1ddb0c0d49386dc80dd08c9e0927dd85a450 Mon Sep 17 00:00:00 2001 From: ze97286 Date: Mon, 18 Dec 2023 15:22:12 +0000 Subject: [PATCH] feat: empty insurance pool into global insurance pool --- CHANGELOG.md | 1 + core/collateral/engine.go | 17 +- ...-STTL-settlement_at_expiry_with_dp.feature | 15 +- .../insurance-pools-at-settlement.feature | 62 +++--- ...xpiry_by_time_from_internal_oracle.feature | 11 +- .../features/successor-markets-ELS.feature | 24 +-- .../successor-markets-expiration.feature | 8 +- .../successor-markets-insurance.feature | 192 +++++++++--------- .../0002-STTL-settlement_at_expiry.feature | 14 +- 9 files changed, 165 insertions(+), 179 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51c281acc2..120b83a409 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ - [10218](https://github.com/vegaprotocol/vega/issues/10218) - Volume discount stats shows volumes even if party doesn't qualify for a discount tier. - [9880](https://github.com/vegaprotocol/vega/issues/9880) - Add support for batch proposals. - [10159](https://github.com/vegaprotocol/vega/issues/10159) - Add additional funding period data to market data API to allow streaming funding period data. +-[10154](https://github.com/vegaprotocol/vega/issues/10154) - Move remaining insurance pool balance into the network treasury rather than splitting between other markets and global insurance. ### 🐛 Fixes diff --git a/core/collateral/engine.go b/core/collateral/engine.go index 301e864725..5b72404ae4 100644 --- a/core/collateral/engine.go +++ b/core/collateral/engine.go @@ -3294,24 +3294,10 @@ func (e *Engine) ClearInsurancepool(ctx context.Context, mktID, asset string, cl return nil, nil } - // get all other market insurance accounts for the same asset - sortedAccKeys := maps.Keys(e.accs) - sort.Strings(sortedAccKeys) - - var insuranceAccounts []*types.Account - for _, accKey := range sortedAccKeys { - acc := e.accs[accKey] - if acc.ID != marketInsuranceID && acc.Asset == asset && acc.Type == types.AccountTypeInsurance { - insuranceAccounts = append(insuranceAccounts, acc.Clone()) - } - } - - // add the global insurance account globalIns, _ := e.GetGlobalInsuranceAccount(asset) - insuranceAccounts = append(insuranceAccounts, globalIns) // redistribute market insurance funds between the global and other markets equally req.FromAccount[0] = marketInsuranceAcc - req.ToAccount = insuranceAccounts + req.ToAccount[0] = globalIns req.Amount = marketInsuranceAcc.Balance.Clone() insuranceLedgerEntries, err := e.getLedgerEntries(ctx, req) if err != nil { @@ -3327,7 +3313,6 @@ func (e *Engine) ClearInsurancepool(ctx context.Context, mktID, asset string, cl } resp = append(resp, insuranceLedgerEntries) e.removeAccount(marketInsuranceID) - return resp, nil } diff --git a/core/integration/features/settlement/0002-STTL-settlement_at_expiry_with_dp.feature b/core/integration/features/settlement/0002-STTL-settlement_at_expiry_with_dp.feature index 4816fcbf07..531964e1e6 100644 --- a/core/integration/features/settlement/0002-STTL-settlement_at_expiry_with_dp.feature +++ b/core/integration/features/settlement/0002-STTL-settlement_at_expiry_with_dp.feature @@ -244,6 +244,7 @@ Feature: Test settlement at expiry with decimal places for asset and market (dif And the global insurance pool balance should be "2000000000" for the asset "ETH" And the insurance pool balance should be "0" for the market "ETH/DEC21" + Scenario: Same as above, but the other market already terminated before the end of scenario, expecting 0 balances in per market insurance pools - all should go to per asset insurance pool (0002-STTL-additional-tests, 0005-COLL-002, 0015-INSR-002, 0032-PRIM-018) Given the initial insurance pool balance is "1000000000" for all the markets @@ -335,8 +336,8 @@ Feature: Test settlement at expiry with decimal places for asset and market (dif Then the market state should be "STATE_SETTLED" for the market "ETH/DEC21" And the network moves ahead "6" blocks And the insurance pool balance should be "0" for the market "ETH/DEC21" - And the insurance pool balance should be "1500000000" for the market "ETH/DEC19" - And the global insurance pool balance should be "500000000" for the asset "ETH" + And the insurance pool balance should be "1000000000" for the market "ETH/DEC19" + And the global insurance pool balance should be "1000000000" for the asset "ETH" Then the market state should be "STATE_ACTIVE" for the market "ETH/DEC19" @@ -466,9 +467,9 @@ Feature: Test settlement at expiry with decimal places for asset and market (dif When the network moves ahead "2" blocks And the cumulated balance for all accounts should be worth "10021300000000" And the insurance pool balance should be "0" for the market "ETH/DEC19" - # 916 were taken from the insurance pool to cover the losses of party 2, the remaining is split between global and the other market - And the global insurance pool balance should be "4200000" for the asset "ETH" - And the insurance pool balance should be "104200000" for the market "ETH/DEC21" + # 916 were taken from the insurance pool to cover the losses of party 2, the remaining is moved to the global insurance account + And the global insurance pool balance should be "8400000" for the asset "ETH" + And the insurance pool balance should be "100000000" for the market "ETH/DEC21" @SLABug Scenario: Settlement happened when market is being closed - loss socialisation in action - insurance doesn't cover all losses (0002-STTL-009) @@ -649,8 +650,8 @@ Feature: Test settlement at expiry with decimal places for asset and market (dif And the cumulated balance for all accounts should be worth "10201200000000" And the insurance pool balance should be "0" for the market "ETH/DEC21" - And the global insurance pool balance should be "25000000" for the asset "ETH" - And the insurance pool balance should be "75000000" for the market "ETH/DEC19" + And the global insurance pool balance should be "50000000" for the asset "ETH" + And the insurance pool balance should be "50000000" for the market "ETH/DEC19" diff --git a/core/integration/features/settlement/insurance-pools-at-settlement.feature b/core/integration/features/settlement/insurance-pools-at-settlement.feature index 9e67760338..a00d31087a 100644 --- a/core/integration/features/settlement/insurance-pools-at-settlement.feature +++ b/core/integration/features/settlement/insurance-pools-at-settlement.feature @@ -177,12 +177,12 @@ Feature: Test the transfers to and from the insurance pools when markets termina And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC21" And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC22" And the trading mode should be "TRADING_MODE_NO_TRADING" for the market "ETH/DEC23" - And the insurance pool balance should be "1200000" for the market "ETH/DEC19" - And the insurance pool balance should be "1200000" for the market "ETH/DEC20" - And the insurance pool balance should be "1200000" for the market "ETH/DEC21" - And the insurance pool balance should be "1200000" for the market "ETH/DEC22" + And the insurance pool balance should be "1000000" for the market "ETH/DEC19" + And the insurance pool balance should be "1000000" for the market "ETH/DEC20" + And the insurance pool balance should be "1000000" for the market "ETH/DEC21" + And the insurance pool balance should be "1000000" for the market "ETH/DEC22" And the insurance pool balance should be "0" for the market "ETH/DEC23" - And the global insurance pool balance should be "200000" for the asset "ETH" + And the global insurance pool balance should be "1000000" for the asset "ETH" # OK, let's terminate a market via governance that is in continuous trading # The successor time window now comes in to play @@ -195,12 +195,12 @@ Feature: Test the transfers to and from the insurance pools when markets termina And the trading mode should be "TRADING_MODE_NO_TRADING" for the market "ETH/DEC22" And the trading mode should be "TRADING_MODE_NO_TRADING" for the market "ETH/DEC23" # insurance pool is not yet distributed - And the insurance pool balance should be "1200000" for the market "ETH/DEC19" - And the insurance pool balance should be "1200000" for the market "ETH/DEC20" - And the insurance pool balance should be "1200000" for the market "ETH/DEC21" - And the insurance pool balance should be "1200000" for the market "ETH/DEC22" + And the insurance pool balance should be "1000000" for the market "ETH/DEC19" + And the insurance pool balance should be "1000000" for the market "ETH/DEC20" + And the insurance pool balance should be "1000000" for the market "ETH/DEC21" + And the insurance pool balance should be "1000000" for the market "ETH/DEC22" And the insurance pool balance should be "0" for the market "ETH/DEC23" - And the global insurance pool balance should be "200000" for the asset "ETH" + And the global insurance pool balance should be "1000000" for the asset "ETH" # pass the successor time window When the network moves ahead "10" blocks Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20" @@ -209,13 +209,13 @@ Feature: Test the transfers to and from the insurance pools when markets termina #And the trading mode should be "TRADING_MODE_NO_TRADING" for the market "ETH/DEC22" #And the trading mode should be "TRADING_MODE_NO_TRADING" for the market "ETH/DEC23" ## now we should see the update - And the insurance pool balance should be "1500000" for the market "ETH/DEC19" - And the insurance pool balance should be "1500000" for the market "ETH/DEC20" - And the insurance pool balance should be "1500000" for the market "ETH/DEC21" + And the insurance pool balance should be "1000000" for the market "ETH/DEC19" + And the insurance pool balance should be "1000000" for the market "ETH/DEC20" + And the insurance pool balance should be "1000000" for the market "ETH/DEC21" ## Nothing in the drained pool, nothing goes to the insurance pool of the old market And the insurance pool balance should be "0" for the market "ETH/DEC22" And the insurance pool balance should be "0" for the market "ETH/DEC23" - And the global insurance pool balance should be "500000" for the asset "ETH" + And the global insurance pool balance should be "2000000" for the asset "ETH" ## Now settle a market via the oracle When the oracles broadcast data signed with "0xCAFECAFE2": @@ -223,36 +223,36 @@ Feature: Test the transfers to and from the insurance pools when markets termina | trading.terminated | true | And the network moves ahead "1" blocks Then the trading mode should be "TRADING_MODE_NO_TRADING" for the market "ETH/DEC21" - And the insurance pool balance should be "1500000" for the market "ETH/DEC19" - And the insurance pool balance should be "1500000" for the market "ETH/DEC20" - And the insurance pool balance should be "1500000" for the market "ETH/DEC21" + And the insurance pool balance should be "1000000" for the market "ETH/DEC19" + And the insurance pool balance should be "1000000" for the market "ETH/DEC20" + And the insurance pool balance should be "1000000" for the market "ETH/DEC21" ## Nothing in the drained pool, nothing goes to the insurance pool of the old market And the insurance pool balance should be "0" for the market "ETH/DEC22" And the insurance pool balance should be "0" for the market "ETH/DEC23" - And the global insurance pool balance should be "500000" for the asset "ETH" + And the global insurance pool balance should be "2000000" for the asset "ETH" # Moving past the successor window means nothing here, market is not settled When the network moves ahead "10" blocks Then the trading mode should be "TRADING_MODE_NO_TRADING" for the market "ETH/DEC21" - And the insurance pool balance should be "1500000" for the market "ETH/DEC19" - And the insurance pool balance should be "1500000" for the market "ETH/DEC20" - And the insurance pool balance should be "1500000" for the market "ETH/DEC21" + And the insurance pool balance should be "1000000" for the market "ETH/DEC19" + And the insurance pool balance should be "1000000" for the market "ETH/DEC20" + And the insurance pool balance should be "1000000" for the market "ETH/DEC21" ## Nothing in the drained pool, nothing goes to the insurance pool of the old market And the insurance pool balance should be "0" for the market "ETH/DEC22" And the insurance pool balance should be "0" for the market "ETH/DEC23" - And the global insurance pool balance should be "500000" for the asset "ETH" + And the global insurance pool balance should be "2000000" for the asset "ETH" ## Now settle the terminated market When the oracles broadcast data signed with "0xCAFECAFE2": | name | value | | prices.ETH.value | 150 | And the network moves ahead "10" blocks - Then the insurance pool balance should be "2000000" for the market "ETH/DEC19" - And the insurance pool balance should be "2000000" for the market "ETH/DEC20" + Then the insurance pool balance should be "1000000" for the market "ETH/DEC19" + And the insurance pool balance should be "1000000" for the market "ETH/DEC20" And the insurance pool balance should be "0" for the market "ETH/DEC21" ## Nothing in the drained pool, nothing goes to the insurance pool of the old market And the insurance pool balance should be "0" for the market "ETH/DEC22" And the insurance pool balance should be "0" for the market "ETH/DEC23" - And the global insurance pool balance should be "1000000" for the asset "ETH" + And the global insurance pool balance should be "3000000" for the asset "ETH" ## Now terminate both of the other markets When the oracles broadcast data signed with "0xCAFECAFE1": @@ -263,17 +263,17 @@ Feature: Test the transfers to and from the insurance pools when markets termina | trading.terminated | true | Then the trading mode should be "TRADING_MODE_NO_TRADING" for the market "ETH/DEC20" And the trading mode should be "TRADING_MODE_NO_TRADING" for the market "ETH/DEC19" - And the insurance pool balance should be "2000000" for the market "ETH/DEC19" - And the insurance pool balance should be "2000000" for the market "ETH/DEC20" - And the global insurance pool balance should be "1000000" for the asset "ETH" + And the insurance pool balance should be "1000000" for the market "ETH/DEC19" + And the insurance pool balance should be "1000000" for the market "ETH/DEC20" + And the global insurance pool balance should be "3000000" for the asset "ETH" ## Now settle one market, pass the successor window and ensure the insurance pool is divided between the global insurance pool and the terminated market When the oracles broadcast data signed with "0xCAFECAFE1": | name | value | | prices.ETH.value | 150 | And the network moves ahead "10" blocks - Then the insurance pool balance should be "3000000" for the market "ETH/DEC19" - And the global insurance pool balance should be "2000000" for the asset "ETH" + Then the insurance pool balance should be "1000000" for the market "ETH/DEC19" + And the global insurance pool balance should be "4000000" for the asset "ETH" ## the insurance pools from the settled/cancelled markets are all drained And the insurance pool balance should be "0" for the market "ETH/DEC20" And the insurance pool balance should be "0" for the market "ETH/DEC21" @@ -285,7 +285,7 @@ Feature: Test the transfers to and from the insurance pools when markets termina | name | value | | prices.ETH.value | 150 | And the network moves ahead "10" blocks - And the global insurance pool balance should be "5000000" for the asset "ETH" + And the global insurance pool balance should be "5000000" for the asset "ETH" ## the insurance pools from the settled/cancelled markets are all drained Then the insurance pool balance should be "0" for the market "ETH/DEC19" And the insurance pool balance should be "0" for the market "ETH/DEC20" diff --git a/core/integration/features/settlement/settlement_at_expiry_by_time_from_internal_oracle.feature b/core/integration/features/settlement/settlement_at_expiry_by_time_from_internal_oracle.feature index 5ac58b9552..c964d605e2 100644 --- a/core/integration/features/settlement/settlement_at_expiry_by_time_from_internal_oracle.feature +++ b/core/integration/features/settlement/settlement_at_expiry_by_time_from_internal_oracle.feature @@ -300,8 +300,7 @@ Feature: Test settlement at expiry time from internal oracle And the network moves ahead "3" blocks And the insurance pool balance should be "0" for the market "ETH/DEC21" - And the insurance pool balance should be "15000" for the market "ETH/DEC19" - + And the insurance pool balance should be "10000" for the market "ETH/DEC19" Then the market state should be "STATE_ACTIVE" for the market "ETH/DEC19" When the parties place the following orders with ticks: @@ -421,8 +420,9 @@ Feature: Test settlement at expiry time from internal oracle When the network moves ahead "2" blocks Then the cumulated balance for all accounts should be worth "100213000" And the insurance pool balance should be "0" for the market "ETH/DEC19" - # 916 were taken from the insurance pool to cover the losses of party 2, the remaining is split between global and the other market - And the insurance pool balance should be "1042" for the market "ETH/DEC21" + # 916 were taken from the insurance pool to cover the losses of party 2, the remaining is moved to the global insurance pool + And the insurance pool balance should be "1000" for the market "ETH/DEC21" + And the global insurance pool balance should be "84" for the asset "ETH" @SLABug Scenario: Settlement happened when market is being closed - loss socialisation in action - insurance doesn't cover all losses @@ -598,7 +598,8 @@ Feature: Test settlement at expiry time from internal oracle And the cumulated balance for all accounts should be worth "102012000" And the insurance pool balance should be "0" for the market "ETH/DEC21" - And the insurance pool balance should be "750" for the market "ETH/DEC19" + And the insurance pool balance should be "500" for the market "ETH/DEC19" + And the global insurance pool balance should be "500" for the asset "ETH" @Oracle Scenario: Orders can still be placed if the order expiry was sent with the wrong pub key diff --git a/core/integration/features/successor-markets-ELS.feature b/core/integration/features/successor-markets-ELS.feature index f46e2169c1..36b91d23e9 100644 --- a/core/integration/features/successor-markets-ELS.feature +++ b/core/integration/features/successor-markets-ELS.feature @@ -221,8 +221,8 @@ Feature: Simple example of successor markets | lpprov2 | 0.7272727272727273 | 10000 | When the network moves ahead "1" blocks Then the insurance pool balance should be "0" for the market "ETH/DEC19" - And the insurance pool balance should be "7085" for the market "ETH/DEC20" - And the global insurance pool balance should be "4669" for the asset "USD" + And the insurance pool balance should be "2416" for the market "ETH/DEC20" + And the global insurance pool balance should be "9338" for the asset "USD" @SuccessorMarketSimple @Liquidation Scenario: 002 Successor market enacted with parent market still active, ELS is copied over and both states can change independently. 0042-LIQF-031, 0042-LIQF-048, 0042-LIQF-033 @@ -318,8 +318,8 @@ Feature: Simple example of successor markets | 150 | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 82 | 10000 | 1 | And the insurance pool balance should be "0" for the market "ETH/DEC19" - And the insurance pool balance should be "9403" for the market "ETH/DEC20" - And the global insurance pool balance should be "2351" for the asset "USD" + And the insurance pool balance should be "7052" for the market "ETH/DEC20" + And the global insurance pool balance should be "4702" for the asset "USD" #this is from ETH/DEC19 market And the liquidity provider fee shares for the market "ETH/DEC20" should be: @@ -472,8 +472,8 @@ Feature: Simple example of successor markets | lpprov2 | 0.8 | 10000 | When the network moves ahead "1" blocks Then the insurance pool balance should be "0" for the market "ETH/DEC19" - And the insurance pool balance should be "7085" for the market "ETH/DEC20" - And the global insurance pool balance should be "4669" for the asset "USD" + And the insurance pool balance should be "2416" for the market "ETH/DEC20" + And the global insurance pool balance should be "9338" for the asset "USD" @SuccessorMarketExpires2 @Liquidation @@ -549,8 +549,8 @@ Feature: Simple example of successor markets And the successor market "ETH/DEC20" is enacted When the network moves ahead "5" blocks Then the insurance pool balance should be "0" for the market "ETH/DEC19" - Then the insurance pool balance should be "5877" for the market "ETH/DEC20" - And the global insurance pool balance should be "5877" for the asset "USD" + Then the insurance pool balance should be "0" for the market "ETH/DEC20" + And the global insurance pool balance should be "11754" for the asset "USD" # make LP commitment while market is still pending Then the parties submit the following liquidity provision: @@ -571,8 +571,8 @@ Feature: Simple example of successor markets | mark price | trading mode | auction trigger | target stake | supplied stake | open interest | | 150 | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 82 | 10000 | 1 | And the insurance pool balance should be "0" for the market "ETH/DEC19" - And the insurance pool balance should be "5877" for the market "ETH/DEC20" - And the global insurance pool balance should be "5877" for the asset "USD" + And the insurance pool balance should be "0" for the market "ETH/DEC20" + And the global insurance pool balance should be "11754" for the asset "USD" # this is from ETH/DEC19 market And the liquidity provider fee shares for the market "ETH/DEC20" should be: @@ -594,5 +594,5 @@ Feature: Simple example of successor markets | lpprov2 | 0.7272727272727273 | 10000 | When the network moves ahead "1" blocks Then the insurance pool balance should be "0" for the market "ETH/DEC19" - And the insurance pool balance should be "5877" for the market "ETH/DEC20" - And the global insurance pool balance should be "5877" for the asset "USD" + And the insurance pool balance should be "0" for the market "ETH/DEC20" + And the global insurance pool balance should be "11754" for the asset "USD" diff --git a/core/integration/features/successor-markets-expiration.feature b/core/integration/features/successor-markets-expiration.feature index 7fb62124cb..6bc89df09b 100644 --- a/core/integration/features/successor-markets-expiration.feature +++ b/core/integration/features/successor-markets-expiration.feature @@ -116,8 +116,8 @@ Feature: Simple example of successor markets And the last market state should be "STATE_SETTLED" for the market "ETH/DEC19" And the last market state should be "STATE_PENDING" for the market "ETH/DEC20" And the insurance pool balance should be "0" for the market "ETH/DEC19" - And the insurance pool balance should be "1500" for the market "ETH/DEC20" - And the global insurance pool balance should be "500" for the asset "ETH" + And the insurance pool balance should be "1000" for the market "ETH/DEC20" + And the global insurance pool balance should be "1000" for the asset "ETH" And the parties submit the following liquidity provision: | id | party | market id | commitment amount | fee | lp type | @@ -146,6 +146,6 @@ Feature: Simple example of successor markets And the last market state should be "STATE_SETTLED" for the market "ETH/DEC19" And the last market state should be "STATE_ACTIVE" for the market "ETH/DEC20" And the insurance pool balance should be "0" for the market "ETH/DEC19" - And the insurance pool balance should be "1500" for the market "ETH/DEC20" - And the global insurance pool balance should be "500" for the asset "ETH" + And the insurance pool balance should be "1000" for the market "ETH/DEC20" + And the global insurance pool balance should be "1000" for the asset "ETH" diff --git a/core/integration/features/successor-markets-insurance.feature b/core/integration/features/successor-markets-insurance.feature index c3435e9cc7..1cc1520d92 100644 --- a/core/integration/features/successor-markets-insurance.feature +++ b/core/integration/features/successor-markets-insurance.feature @@ -144,13 +144,13 @@ Feature: Successor markets: Global insurance pool account collects all outstandi And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20" ## Insurance pool for closed market is distributed - And the insurance pool balance should be "1500" for the market "ETH/DEC19" - And the insurance pool balance should be "2500" for the market "ETH/DEC20" + And the insurance pool balance should be "500" for the market "ETH/DEC19" + And the insurance pool balance should be "1500" for the market "ETH/DEC20" And the insurance pool balance should be "0" for the market "ETH/DEC21" And the insurance pool balance should be "0" for the market "ETH/DEC22" And the insurance pool balance should be "0" for the market "ETH/DEC23" - And the global insurance pool balance should be "1000" for the asset "USD" + And the global insurance pool balance should be "3000" for the asset "USD" ## Cancel ETH/DEC19 When the market states are updated through governance: @@ -160,9 +160,9 @@ Feature: Successor markets: Global insurance pool account collects all outstandi ## Insurance pool for closed market is distributed as two equal parts to the remaining successor ## and the global insurance pool And the insurance pool balance should be "0" for the market "ETH/DEC19" - And the insurance pool balance should be "3250" for the market "ETH/DEC20" + And the insurance pool balance should be "1500" for the market "ETH/DEC20" - And the global insurance pool balance should be "1750" for the asset "USD" + And the global insurance pool balance should be "3500" for the asset "USD" And the network moves ahead "1" blocks @@ -181,8 +181,8 @@ Feature: Successor markets: Global insurance pool account collects all outstandi Then the market state should be "STATE_SETTLED" for the market "ETH/DEC20" And then the network moves ahead "1" blocks - And the insurance pool balance should be "3250" for the market "ETH/DEC20" - And the global insurance pool balance should be "1750" for the asset "USD" + And the insurance pool balance should be "1500" for the market "ETH/DEC20" + And the global insurance pool balance should be "3500" for the asset "USD" And the network moves ahead "10" blocks @@ -257,12 +257,12 @@ Feature: Successor markets: Global insurance pool account collects all outstandi ## The balance from the settled parent market gets distributed equally among the remaining ## 4 successor markets in TRADING_MODE_OPENING_AUCTION and the global insurance pool And the insurance pool balance should be "0" for the market "ETH/DEC19" - And the insurance pool balance should be "1200" for the market "ETH/DEC20" - And the insurance pool balance should be "1200" for the market "ETH/DEC21" - And the insurance pool balance should be "1200" for the market "ETH/DEC22" - And the insurance pool balance should be "1200" for the market "ETH/DEC23" + And the insurance pool balance should be "1000" for the market "ETH/DEC20" + And the insurance pool balance should be "1000" for the market "ETH/DEC21" + And the insurance pool balance should be "1000" for the market "ETH/DEC22" + And the insurance pool balance should be "1000" for the market "ETH/DEC23" - And the global insurance pool balance should be "200" for the asset "USD" + And the global insurance pool balance should be "1000" for the asset "USD" ## Get one of the successors into continous mode And the parties place the following orders: @@ -283,31 +283,32 @@ Feature: Successor markets: Global insurance pool account collects all outstandi And the trading mode should be "TRADING_MODE_OPENING_AUCTION" for the market "ETH/DEC23" ## Insurance pool balances are not changed at this point - And the insurance pool balance should be "1200" for the market "ETH/DEC20" - And the insurance pool balance should be "1200" for the market "ETH/DEC21" - And the insurance pool balance should be "1200" for the market "ETH/DEC22" - And the insurance pool balance should be "1200" for the market "ETH/DEC23" + And the insurance pool balance should be "1000" for the market "ETH/DEC20" + And the insurance pool balance should be "1000" for the market "ETH/DEC21" + And the insurance pool balance should be "1000" for the market "ETH/DEC22" + And the insurance pool balance should be "1000" for the market "ETH/DEC23" + And the global insurance pool balance should be "1000" for the asset "USD" ## Cancel ETH/DEC20 When the market states are updated through governance: | market id | state | settlement price | | ETH/DEC20 | MARKET_STATE_UPDATE_TYPE_TERMINATE | 150 | - And the insurance pool balance should be "1200" for the market "ETH/DEC20" - And the insurance pool balance should be "1200" for the market "ETH/DEC21" - And the insurance pool balance should be "1200" for the market "ETH/DEC22" - And the insurance pool balance should be "1200" for the market "ETH/DEC23" + And the insurance pool balance should be "1000" for the market "ETH/DEC20" + And the insurance pool balance should be "1000" for the market "ETH/DEC21" + And the insurance pool balance should be "1000" for the market "ETH/DEC22" + And the insurance pool balance should be "1000" for the market "ETH/DEC23" And the network moves ahead "10" blocks - ## Insurance balance from ETH/DEC20 is distributed amond existing successor markets + ## Insurance balance from ETH/DEC20 is moved to global insurance account ## and the global insurance pool And the insurance pool balance should be "0" for the market "ETH/DEC20" - And the insurance pool balance should be "1500" for the market "ETH/DEC21" - And the insurance pool balance should be "1500" for the market "ETH/DEC22" - And the insurance pool balance should be "1500" for the market "ETH/DEC23" + And the insurance pool balance should be "1000" for the market "ETH/DEC21" + And the insurance pool balance should be "1000" for the market "ETH/DEC22" + And the insurance pool balance should be "1000" for the market "ETH/DEC23" - And the global insurance pool balance should be "500" for the asset "USD" + And the global insurance pool balance should be "2000" for the asset "USD" ## Now we need to cancel the remaining successor markets one by one. ## Cancel ETH/DEC21 @@ -318,10 +319,10 @@ Feature: Successor markets: Global insurance pool account collects all outstandi And the network moves ahead "10" blocks And the insurance pool balance should be "0" for the market "ETH/DEC20" And the insurance pool balance should be "0" for the market "ETH/DEC21" - And the insurance pool balance should be "2000" for the market "ETH/DEC22" - And the insurance pool balance should be "2000" for the market "ETH/DEC23" + And the insurance pool balance should be "1000" for the market "ETH/DEC22" + And the insurance pool balance should be "1000" for the market "ETH/DEC23" - And the global insurance pool balance should be "1000" for the asset "USD" + And the global insurance pool balance should be "3000" for the asset "USD" ## Cancel ETH/DEC22 When the market states are updated through governance: @@ -332,9 +333,9 @@ Feature: Successor markets: Global insurance pool account collects all outstandi And the insurance pool balance should be "0" for the market "ETH/DEC20" And the insurance pool balance should be "0" for the market "ETH/DEC21" And the insurance pool balance should be "0" for the market "ETH/DEC22" - And the insurance pool balance should be "3000" for the market "ETH/DEC23" + And the insurance pool balance should be "1000" for the market "ETH/DEC23" - And the global insurance pool balance should be "2000" for the asset "USD" + And the global insurance pool balance should be "4000" for the asset "USD" ## Cancel ETH/DEC23 When the market states are updated through governance: @@ -431,12 +432,12 @@ Feature: Successor markets: Global insurance pool account collects all outstandi ## Insurance pool balances for canceled successors got distributed as: ## 50% to the enacted successor, remaining amount in two parts 1:2 to the parent and global insurance pool - And the insurance pool balance should be "1500" for the market "ETH/DEC19" + And the insurance pool balance should be "500" for the market "ETH/DEC19" And the insurance pool balance should be "0" for the market "ETH/DEC20" - And the insurance pool balance should be "2500" for the market "ETH/DEC21" + And the insurance pool balance should be "1500" for the market "ETH/DEC21" And the insurance pool balance should be "0" for the market "ETH/DEC22" And the insurance pool balance should be "0" for the market "ETH/DEC23" - And the global insurance pool balance should be "1000" for the asset "USD" + And the global insurance pool balance should be "3000" for the asset "USD" And the network moves ahead "10" blocks @@ -456,26 +457,25 @@ Feature: Successor markets: Global insurance pool account collects all outstandi And the network moves ahead "1" blocks And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" - And the insurance pool balance should be "1500" for the market "ETH/DEC19" - And the insurance pool balance should be "2500" for the market "ETH/DEC21" + And the insurance pool balance should be "500" for the market "ETH/DEC19" + And the insurance pool balance should be "1500" for the market "ETH/DEC21" And the insurance pool balance should be "0" for the market "ETH/DEC20" And the insurance pool balance should be "0" for the market "ETH/DEC22" And the insurance pool balance should be "0" for the market "ETH/DEC23" - And the global insurance pool balance should be "1000" for the asset "USD" + And the global insurance pool balance should be "3000" for the asset "USD" And the network moves ahead "10" blocks And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" - ## After ETH/DEC21 was canceled it distributed its insurance pool balance as - ## 1250 to parent and 1250 to the global insurance pool - And the insurance pool balance should be "2750" for the market "ETH/DEC19" + ## After ETH/DEC21 was canceled its insurance pool balance is moved into the global insurance account + And the insurance pool balance should be "500" for the market "ETH/DEC19" And the insurance pool balance should be "0" for the market "ETH/DEC21" And the insurance pool balance should be "0" for the market "ETH/DEC20" And the insurance pool balance should be "0" for the market "ETH/DEC22" And the insurance pool balance should be "0" for the market "ETH/DEC23" - And the global insurance pool balance should be "2250" for the asset "USD" + And the global insurance pool balance should be "4500" for the asset "USD" ## Cancel ETH/DEC19 When the market states are updated through governance: @@ -571,13 +571,13 @@ Feature: Successor markets: Global insurance pool account collects all outstandi And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC21" ## Insurance pool balances for canceled successors got distributed as: - ## 50% to the enacted successor, remaining amount in two parts 1:2 to the parent and global insurance pool - And the insurance pool balance should be "1500" for the market "ETH/DEC19" + ## 50% to the enacted successor, remaining amount in two parts 1:2 to the parent and global insurance account + And the insurance pool balance should be "500" for the market "ETH/DEC19" And the insurance pool balance should be "0" for the market "ETH/DEC20" - And the insurance pool balance should be "2500" for the market "ETH/DEC21" + And the insurance pool balance should be "1500" for the market "ETH/DEC21" And the insurance pool balance should be "0" for the market "ETH/DEC22" And the insurance pool balance should be "0" for the market "ETH/DEC23" - And the global insurance pool balance should be "1000" for the asset "USD" + And the global insurance pool balance should be "3000" for the asset "USD" And the network moves ahead "10" blocks @@ -605,26 +605,25 @@ Feature: Successor markets: Global insurance pool account collects all outstandi And the network moves ahead "1" blocks And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" - And the insurance pool balance should be "1500" for the market "ETH/DEC19" - And the insurance pool balance should be "2500" for the market "ETH/DEC21" + And the insurance pool balance should be "500" for the market "ETH/DEC19" + And the insurance pool balance should be "1500" for the market "ETH/DEC21" And the insurance pool balance should be "0" for the market "ETH/DEC20" And the insurance pool balance should be "0" for the market "ETH/DEC22" And the insurance pool balance should be "0" for the market "ETH/DEC23" - And the global insurance pool balance should be "1000" for the asset "USD" + And the global insurance pool balance should be "3000" for the asset "USD" And the network moves ahead "10" blocks And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" - ## After ETH/DEC21 was canceled it distributed its insurance pool balance as - ## 1250 to parent and 1250 to the global insurance pool - And the insurance pool balance should be "2750" for the market "ETH/DEC19" + ## After ETH/DEC21 was canceled - its insurance pool balance is moved into the global insruance account + And the insurance pool balance should be "500" for the market "ETH/DEC19" And the insurance pool balance should be "0" for the market "ETH/DEC21" And the insurance pool balance should be "0" for the market "ETH/DEC20" And the insurance pool balance should be "0" for the market "ETH/DEC22" And the insurance pool balance should be "0" for the market "ETH/DEC23" - And the global insurance pool balance should be "2250" for the asset "USD" + And the global insurance pool balance should be "4500" for the asset "USD" ## Cancel ETH/DEC19 When the market states are updated through governance: @@ -767,14 +766,14 @@ Feature: Successor markets: Global insurance pool account collects all outstandi And the trading mode should be "TRADING_MODE_OPENING_AUCTION" for the market "ETH/DEC22" And the trading mode should be "TRADING_MODE_OPENING_AUCTION" for the market "ETH/DEC23" - ## Settled successor distributed its insurance pool balance across in 5 equal parts. - And the insurance pool balance should be "1200" for the market "ETH/DEC19" + ## Settled successor moved into global insurnace account + And the insurance pool balance should be "1000" for the market "ETH/DEC19" And the insurance pool balance should be "0" for the market "ETH/DEC21" - And the insurance pool balance should be "1200" for the market "ETH/DEC20" - And the insurance pool balance should be "1200" for the market "ETH/DEC22" - And the insurance pool balance should be "1200" for the market "ETH/DEC23" + And the insurance pool balance should be "1000" for the market "ETH/DEC20" + And the insurance pool balance should be "1000" for the market "ETH/DEC22" + And the insurance pool balance should be "1000" for the market "ETH/DEC23" - And the global insurance pool balance should be "200" for the asset "USD" + And the global insurance pool balance should be "1000" for the asset "USD" ## Settle another of the successors that initially had orders Then the oracles broadcast data signed with "0xCAFECACC": @@ -792,13 +791,13 @@ Feature: Successor markets: Global insurance pool account collects all outstandi And the trading mode should be "TRADING_MODE_OPENING_AUCTION" for the market "ETH/DEC20" And the trading mode should be "TRADING_MODE_OPENING_AUCTION" for the market "ETH/DEC23" - ## Settled successor distributed its insurance pool balance across in 4 equal parts. - And the insurance pool balance should be "1500" for the market "ETH/DEC19" + ## Settled successor moved into the global insurance account. + And the insurance pool balance should be "1000" for the market "ETH/DEC19" And the insurance pool balance should be "0" for the market "ETH/DEC21" - And the insurance pool balance should be "1500" for the market "ETH/DEC20" - And the insurance pool balance should be "1500" for the market "ETH/DEC23" + And the insurance pool balance should be "1000" for the market "ETH/DEC20" + And the insurance pool balance should be "1000" for the market "ETH/DEC23" - And the global insurance pool balance should be "500" for the asset "USD" + And the global insurance pool balance should be "2000" for the asset "USD" And the network moves ahead "10" blocks And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" @@ -818,23 +817,23 @@ Feature: Successor markets: Global insurance pool account collects all outstandi And the network moves ahead "1" blocks Then the trading mode should be "TRADING_MODE_OPENING_AUCTION" for the market "ETH/DEC23" - And the insurance pool balance should be "1500" for the market "ETH/DEC19" + And the insurance pool balance should be "1000" for the market "ETH/DEC19" And the insurance pool balance should be "0" for the market "ETH/DEC21" - And the insurance pool balance should be "1500" for the market "ETH/DEC20" + And the insurance pool balance should be "1000" for the market "ETH/DEC20" And the insurance pool balance should be "0" for the market "ETH/DEC22" - And the insurance pool balance should be "1500" for the market "ETH/DEC23" + And the insurance pool balance should be "1000" for the market "ETH/DEC23" - And the global insurance pool balance should be "500" for the asset "USD" + And the global insurance pool balance should be "2000" for the asset "USD" ## wait until successor window expires When the network moves ahead "9" blocks Then the trading mode should be "TRADING_MODE_OPENING_AUCTION" for the market "ETH/DEC23" And the insurance pool balance should be "0" for the market "ETH/DEC19" And the insurance pool balance should be "0" for the market "ETH/DEC21" - And the insurance pool balance should be "2000" for the market "ETH/DEC20" + And the insurance pool balance should be "1000" for the market "ETH/DEC20" And the insurance pool balance should be "0" for the market "ETH/DEC22" - And the insurance pool balance should be "2000" for the market "ETH/DEC23" - And the global insurance pool balance should be "1000" for the asset "USD" + And the insurance pool balance should be "1000" for the market "ETH/DEC23" + And the global insurance pool balance should be "3000" for the asset "USD" ## Cancel the last successor When the market states are updated through governance: @@ -843,11 +842,11 @@ Feature: Successor markets: Global insurance pool account collects all outstandi And the insurance pool balance should be "0" for the market "ETH/DEC19" And the insurance pool balance should be "0" for the market "ETH/DEC21" - And the insurance pool balance should be "3000" for the market "ETH/DEC20" + And the insurance pool balance should be "1000" for the market "ETH/DEC20" And the insurance pool balance should be "0" for the market "ETH/DEC22" And the insurance pool balance should be "0" for the market "ETH/DEC23" - And the global insurance pool balance should be "2000" for the asset "USD" + And the global insurance pool balance should be "4000" for the asset "USD" ## Cancel the ETH/DEC20 successor When the market states are updated through governance: @@ -969,14 +968,14 @@ Feature: Successor markets: Global insurance pool account collects all outstandi And the trading mode should be "TRADING_MODE_OPENING_AUCTION" for the market "ETH/DEC22" And the trading mode should be "TRADING_MODE_OPENING_AUCTION" for the market "ETH/DEC23" - ## Settled successor distributed its insurance pool balance across in 5 equal parts. - And the insurance pool balance should be "1200" for the market "ETH/DEC19" + ## Settled successor moved into global insurance account + And the insurance pool balance should be "1000" for the market "ETH/DEC19" And the insurance pool balance should be "0" for the market "ETH/DEC21" - And the insurance pool balance should be "1200" for the market "ETH/DEC20" - And the insurance pool balance should be "1200" for the market "ETH/DEC22" - And the insurance pool balance should be "1200" for the market "ETH/DEC23" + And the insurance pool balance should be "1000" for the market "ETH/DEC20" + And the insurance pool balance should be "1000" for the market "ETH/DEC22" + And the insurance pool balance should be "1000" for the market "ETH/DEC23" - And the global insurance pool balance should be "200" for the asset "USD" + And the global insurance pool balance should be "1000" for the asset "USD" ## Settle the other of the successors that had orders - ETH/DEC23 Then the oracles broadcast data signed with "0xCAFECADD": @@ -993,14 +992,14 @@ Feature: Successor markets: Global insurance pool account collects all outstandi And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" And the trading mode should be "TRADING_MODE_OPENING_AUCTION" for the market "ETH/DEC20" - ## Settled successor distributed its insurance pool balance across in 3 equal parts. - And the insurance pool balance should be "1500" for the market "ETH/DEC19" + ## Settled successor remaining insurance pool balance is moved into the global insurance account. + And the insurance pool balance should be "1000" for the market "ETH/DEC19" And the insurance pool balance should be "0" for the market "ETH/DEC21" - And the insurance pool balance should be "1500" for the market "ETH/DEC22" - And the insurance pool balance should be "1500" for the market "ETH/DEC20" + And the insurance pool balance should be "1000" for the market "ETH/DEC22" + And the insurance pool balance should be "1000" for the market "ETH/DEC20" And the insurance pool balance should be "0" for the market "ETH/DEC23" - And the global insurance pool balance should be "500" for the asset "USD" + And the global insurance pool balance should be "2000" for the asset "USD" And the network moves ahead "10" blocks And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" @@ -1020,22 +1019,22 @@ Feature: Successor markets: Global insurance pool account collects all outstandi And the network moves ahead "1" blocks And the trading mode should be "TRADING_MODE_OPENING_AUCTION" for the market "ETH/DEC20" - And the insurance pool balance should be "1500" for the market "ETH/DEC19" + And the insurance pool balance should be "1000" for the market "ETH/DEC19" And the insurance pool balance should be "0" for the market "ETH/DEC21" - And the insurance pool balance should be "1500" for the market "ETH/DEC20" - And the insurance pool balance should be "1500" for the market "ETH/DEC22" + And the insurance pool balance should be "1000" for the market "ETH/DEC20" + And the insurance pool balance should be "1000" for the market "ETH/DEC22" And the insurance pool balance should be "0" for the market "ETH/DEC23" - And the global insurance pool balance should be "500" for the asset "USD" + And the global insurance pool balance should be "2000" for the asset "USD" And the network moves ahead "10" blocks And the insurance pool balance should be "0" for the market "ETH/DEC19" And the insurance pool balance should be "0" for the market "ETH/DEC21" - And the insurance pool balance should be "2000" for the market "ETH/DEC20" - And the insurance pool balance should be "2000" for the market "ETH/DEC22" + And the insurance pool balance should be "1000" for the market "ETH/DEC20" + And the insurance pool balance should be "1000" for the market "ETH/DEC22" And the insurance pool balance should be "0" for the market "ETH/DEC23" - And the global insurance pool balance should be "1000" for the asset "USD" + And the global insurance pool balance should be "3000" for the asset "USD" ## Cancel the ETH/DEC20 successor When the market states are updated through governance: @@ -1045,10 +1044,10 @@ Feature: Successor markets: Global insurance pool account collects all outstandi And the insurance pool balance should be "0" for the market "ETH/DEC19" And the insurance pool balance should be "0" for the market "ETH/DEC21" And the insurance pool balance should be "0" for the market "ETH/DEC20" - And the insurance pool balance should be "3000" for the market "ETH/DEC22" + And the insurance pool balance should be "1000" for the market "ETH/DEC22" And the insurance pool balance should be "0" for the market "ETH/DEC23" - And the global insurance pool balance should be "2000" for the asset "USD" + And the global insurance pool balance should be "4000" for the asset "USD" ## Cancel the ETH/DEC22 successor When the market states are updated through governance: @@ -1151,14 +1150,13 @@ Feature: Successor markets: Global insurance pool account collects all outstandi And the network moves ahead "10" blocks - ## Remaining successor markets redistributed their insurance pool balances as: - ## 3 x 500 to ETH/DEC23, 500 to ETH/DEC19 and 1000 to the global insurance pool - And the insurance pool balance should be "1500" for the market "ETH/DEC19" + ## Remaining successor markets moved into the global insurance account + And the insurance pool balance should be "500" for the market "ETH/DEC19" And the insurance pool balance should be "0" for the market "ETH/DEC20" And the insurance pool balance should be "0" for the market "ETH/DEC21" And the insurance pool balance should be "0" for the market "ETH/DEC22" - And the insurance pool balance should be "2500" for the market "ETH/DEC23" - And the global insurance pool balance should be "1000" for the asset "USD" + And the insurance pool balance should be "1500" for the market "ETH/DEC23" + And the global insurance pool balance should be "3000" for the asset "USD" ## Settle ETH/DEC23 Then the oracles broadcast data signed with "0xCAFECADD": @@ -1178,7 +1176,7 @@ Feature: Successor markets: Global insurance pool account collects all outstandi And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" ## Settled successor distributed its insurance pool balance across in 2 equal parts. - And the insurance pool balance should be "2750" for the market "ETH/DEC19" + And the insurance pool balance should be "500" for the market "ETH/DEC19" And the insurance pool balance should be "0" for the market "ETH/DEC21" And the insurance pool balance should be "0" for the market "ETH/DEC20" And the insurance pool balance should be "0" for the market "ETH/DEC22" diff --git a/core/integration/features/verified/0002-STTL-settlement_at_expiry.feature b/core/integration/features/verified/0002-STTL-settlement_at_expiry.feature index 7fb0644da0..77bad1acab 100644 --- a/core/integration/features/verified/0002-STTL-settlement_at_expiry.feature +++ b/core/integration/features/verified/0002-STTL-settlement_at_expiry.feature @@ -309,8 +309,8 @@ Feature: Test settlement at expiry (0016-PFUT-012) And the network moves ahead "3" blocks And the insurance pool balance should be "0" for the market "ETH/DEC21" - And the insurance pool balance should be "15000" for the market "ETH/DEC19" - And the global insurance pool balance should be "5000" for the asset "ETH" + And the insurance pool balance should be "10000" for the market "ETH/DEC19" + And the global insurance pool balance should be "10000" for the asset "ETH" Then the market state should be "STATE_ACTIVE" for the market "ETH/DEC19" @@ -423,9 +423,9 @@ Feature: Test settlement at expiry (0016-PFUT-012) When the network moves ahead "2" blocks Then the cumulated balance for all accounts should be worth "100213000" And the insurance pool balance should be "0" for the market "ETH/DEC19" - # 916 were taken from the insurance pool to cover the losses of party 2, the remaining is split between global and the other market - And the global insurance pool balance should be "42" for the asset "ETH" - And the insurance pool balance should be "1042" for the market "ETH/DEC21" + # 916 were taken from the insurance pool to cover the losses of party 2, the remaining is moved into the global insurance pool + And the global insurance pool balance should be "84" for the asset "ETH" + And the insurance pool balance should be "1000" for the market "ETH/DEC21" Scenario: Settlement happened when market is being closed - loss socialisation in action - insurance doesn't cover all losses (0002-STTL-009) Given the initial insurance pool balance is "500" for all the markets @@ -587,5 +587,5 @@ Feature: Test settlement at expiry (0016-PFUT-012) And the cumulated balance for all accounts should be worth "102012000" And the insurance pool balance should be "0" for the market "ETH/DEC21" - And the global insurance pool balance should be "250" for the asset "ETH" - And the insurance pool balance should be "750" for the market "ETH/DEC19" + And the global insurance pool balance should be "500" for the asset "ETH" + And the insurance pool balance should be "500" for the market "ETH/DEC19"