code.vegaprotocol.io/vega@v0.79.0/core/integration/features/successor-markets-simple.feature (about)

     1  Feature: Simple example of successor markets
     2  
     3    Background:
     4      Given time is updated to "2019-11-30T00:00:00Z"
     5      And the following assets are registered:
     6        | id  | decimal places |
     7        | ETH | 18             |
     8        | USD | 0              |
     9  
    10      # Create some oracles
    11      ## oracle for parent
    12      And the oracle spec for settlement data filtering data from "0xCAFECAFE1" named "ethDec19Oracle":
    13        | property         | type         | binding         |
    14        | prices.ETH.value | TYPE_INTEGER | settlement data |
    15      And the oracle spec for trading termination filtering data from "0xCAFECAFE1" named "ethDec19Oracle":
    16        | property           | type         | binding             |
    17        | trading.terminated | TYPE_BOOLEAN | trading termination |
    18      And the settlement data decimals for the oracle named "ethDec19Oracle" is given in "5" decimal places
    19      ## oracle for a successor
    20      And the oracle spec for settlement data filtering data from "0xCAFECAFE" named "ethDec20Oracle":
    21        | property         | type         | binding         |
    22        | prices.ETH.value | TYPE_INTEGER | settlement data |
    23      And the oracle spec for trading termination filtering data from "0xCAFECAFE" named "ethDec20Oracle":
    24        | property           | type         | binding             |
    25        | trading.terminated | TYPE_BOOLEAN | trading termination |
    26      And the settlement data decimals for the oracle named "ethDec20Oracle" is given in "5" decimal places
    27      And the liquidity monitoring parameters:
    28        | name               | triggering ratio | time window | scaling factor |
    29        | lqm-params         | 0.01             | 10s         | 5              |  
    30      
    31      And the following network parameters are set:
    32        | name                                          | value |
    33        | network.markPriceUpdateMaximumFrequency       | 0s    |
    34        | market.auction.minimumDuration                | 1     |
    35        | market.fee.factors.infrastructureFee          | 0.001 |
    36        | market.fee.factors.makerFee                   | 0.004 |
    37        | market.value.windowLength                     | 60s   |
    38        | market.liquidity.bondPenaltyParameter       | 0.1   |
    39        | validators.epoch.length                       | 5s    |
    40        | market.liquidity.stakeToCcyVolume           | 0.2   |
    41        | market.liquidity.successorLaunchWindowLength  | 1h    |
    42      And the average block duration is "1"
    43  
    44  
    45  # All parties have 1,000,000.000,000,000,000,000,000
    46      # Add as many parties as needed here
    47      And the parties deposit on asset's general account the following amount:
    48        | party   | asset | amount                     |
    49        | lpprov  | ETH   | 10000000000000000000000000 |
    50        | trader1 | ETH   | 10000000000000000000000000 |
    51        | trader2 | ETH   | 10000000000000000000000000 |
    52        | trader3 | ETH   | 10000000000000000000000000 |
    53        | trader4 | ETH   | 10000000000000000000000000 |
    54        | trader5 | ETH   | 10000000000000000000000000 |
    55  
    56  
    57    @SuccessorMarketSimple
    58    Scenario: 001 Enact a successor market once the parent market is settled
    59      Given the markets:
    60        | id        | quote name | asset | liquidity monitoring | risk model            | margin calculator         | auction duration | fees         | price monitoring | data source config     | linear slippage factor | quadratic slippage factor | decimal places | position decimal places | parent market id | insurance pool fraction | successor auction | sla params      |
    61        | ETH/DEC19 | ETH        | ETH   | lqm-params           | default-st-risk-model | default-margin-calculator | 1                | default-none | default-none     | ethDec19Oracle         | 0.1                    | 0                         | 5              | 5                       |                  |                         |                   | default-futures |
    62        | ETH/DEC20 | ETH        | ETH   | lqm-params           | default-st-risk-model | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 0.1                    | 0                         | 5              | 5                       | ETH/DEC19        | 1                       | 10                | default-futures |
    63      And the parties submit the following liquidity provision:
    64        | id  | party  | market id | commitment amount | fee | lp type    |
    65        | lp1 | lpprov | ETH/DEC19 | 3905000000000000  | 0.3 | submission |
    66        | lp1 | lpprov | ETH/DEC19 | 3905000000000000  | 0.3 | submission |
    67      And the parties place the following orders:
    68        | party   | market id | side | volume | price  | resulting trades | type       | tif     | reference |
    69        | trader1 | ETH/DEC19 | buy  | 5      | 1001   | 0                | TYPE_LIMIT | TIF_GTC | t1-b-1    |
    70        | trader1 | ETH/DEC19 | buy  | 5      | 900    | 0                | TYPE_LIMIT | TIF_GTC | t1-b-2    |
    71        | trader1 | ETH/DEC19 | buy  | 1      | 100    | 0                | TYPE_LIMIT | TIF_GTC | t1-b-3    |
    72        | trader2 | ETH/DEC19 | sell | 5      | 1200   | 0                | TYPE_LIMIT | TIF_GTC | t2-s-1    |
    73        | trader2 | ETH/DEC19 | sell | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC | t2-s-2    |
    74        | trader2 | ETH/DEC19 | sell | 5      | 951    | 0                | TYPE_LIMIT | TIF_GTC | t2-s-3    |
    75      When the opening auction period ends for market "ETH/DEC19"
    76      Then the market data for the market "ETH/DEC19" should be:
    77        | mark price | trading mode            | auction trigger             | target stake | supplied stake   | open interest |
    78        | 976        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 134907600000 | 3905000000000000 | 5             |
    79      And the parties should have the following account balances:
    80        | party   | asset | market id | margin       | general                   |
    81        | trader1 | ETH   | ETH/DEC19 | 126362285504 | 9999999999999873637714496 |
    82      And the parties should have the following margin levels:
    83        | party   | market id | maintenance  |
    84        | trader1 | ETH/DEC19 | 105301904587 |
    85      When the parties submit the following liquidity provision:
    86        | id  | party  | market id | commitment amount | fee | lp type    |
    87        | lp1 | lpprov | ETH/DEC20 | 1905000000000000  | 0.1 | submission |
    88        | lp1 | lpprov | ETH/DEC20 | 1905000000000000  | 0.1 | submission |
    89      Then the oracles broadcast data signed with "0xCAFECAFE1":
    90        | name               | value |
    91        | trading.terminated | true  |
    92        | prices.ETH.value   | 975   |
    93  
    94      When the successor market "ETH/DEC20" is enacted
    95      Then the parties place the following orders:
    96        | party   | market id | side | volume | price  | resulting trades | type       | tif     | reference |
    97        | trader1 | ETH/DEC20 | buy  | 5      | 1001   | 0                | TYPE_LIMIT | TIF_GTC | t1-b-1    |
    98        | trader1 | ETH/DEC20 | buy  | 5      | 900    | 0                | TYPE_LIMIT | TIF_GTC | t1-b-2    |
    99        | trader1 | ETH/DEC20 | buy  | 1      | 100    | 0                | TYPE_LIMIT | TIF_GTC | t1-b-3    |
   100        | trader2 | ETH/DEC20 | sell | 5      | 1200   | 0                | TYPE_LIMIT | TIF_GTC | t2-s-1    |
   101        | trader2 | ETH/DEC20 | sell | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC | t2-s-2    |
   102        | trader2 | ETH/DEC20 | sell | 5      | 951    | 0                | TYPE_LIMIT | TIF_GTC | t2-s-3    |
   103      When the opening auction period ends for market "ETH/DEC20"
   104      Then the market data for the market "ETH/DEC20" should be:
   105        | mark price | trading mode            | auction trigger             | target stake | supplied stake   | open interest |
   106        | 976        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 134907600000 | 1905000000000000 | 5             |
   107  
   108    @SuccessorMarketSimple
   109    Scenario: 002 Enacting a successor market rejects any other pending successors
   110      ## parent market and 2 successors
   111      Given the markets:
   112        | id        | quote name | asset | risk model            | margin calculator         | auction duration | fees         | price monitoring | data source config     | linear slippage factor | quadratic slippage factor | decimal places | position decimal places | parent market id | insurance pool fraction | successor auction | sla params      | 
   113        | ETH/DEC19 | ETH        | ETH   | default-st-risk-model | default-margin-calculator | 1                | default-none | default-none     | ethDec19Oracle         | 0.1                    | 0                         | 5              | 5                       |                  |                         |                   | default-futures |
   114        | ETH/DEC20 | ETH        | ETH   | default-st-risk-model | default-margin-calculator | 1                | default-none | default-none     | ethDec20Oracle         | 0.1                    | 0                         | 5              | 5                       | ETH/DEC19        | 1                       | 10                | default-futures |
   115        | ETH/DEC21 | ETH        | ETH   | default-st-risk-model | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 0.1                    | 0                         | 5              | 5                       | ETH/DEC19        | 1                       | 10                | default-futures |
   116      And the parties submit the following liquidity provision:
   117        | id  | party  | market id | commitment amount | fee | lp type    |
   118        | lp1 | lpprov | ETH/DEC19 | 3905000000000000  | 0.3 | submission |
   119        | lp1 | lpprov | ETH/DEC19 | 3905000000000000  | 0.3 | submission |
   120      And the parties place the following orders:
   121        | party   | market id | side | volume | price  | resulting trades | type       | tif     | reference |
   122        | trader1 | ETH/DEC19 | buy  | 5      | 1001   | 0                | TYPE_LIMIT | TIF_GTC | t1-b-1    |
   123        | trader1 | ETH/DEC19 | buy  | 5      | 900    | 0                | TYPE_LIMIT | TIF_GTC | t1-b-2    |
   124        | trader1 | ETH/DEC19 | buy  | 1      | 100    | 0                | TYPE_LIMIT | TIF_GTC | t1-b-3    |
   125        | trader2 | ETH/DEC19 | sell | 5      | 1200   | 0                | TYPE_LIMIT | TIF_GTC | t2-s-1    |
   126        | trader2 | ETH/DEC19 | sell | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC | t2-s-2    |
   127        | trader2 | ETH/DEC19 | sell | 5      | 951    | 0                | TYPE_LIMIT | TIF_GTC | t2-s-3    |
   128      # Both successor markets should be pending
   129      Then the market state should be "STATE_PENDING" for the market "ETH/DEC20"
   130      And the market state should be "STATE_PENDING" for the market "ETH/DEC21"
   131      When the opening auction period ends for market "ETH/DEC19"
   132      Then the market data for the market "ETH/DEC19" should be:
   133        | mark price | trading mode            | auction trigger             | target stake | supplied stake   | open interest |
   134        | 976        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 269815200000 | 3905000000000000 | 5             |
   135      And the parties should have the following account balances:
   136        | party   | asset | market id | margin       | general                   |
   137        | trader1 | ETH   | ETH/DEC19 | 126362285504 | 9999999999999873637714496 |
   138      And the parties should have the following margin levels:
   139        | party   | market id | maintenance  |
   140        | trader1 | ETH/DEC19 | 105301904587 |
   141      # LP submissions are being made on both pending markets
   142      When the parties submit the following liquidity provision:
   143        | id  | party  | market id | commitment amount | fee | lp type    |
   144        | lp2 | lpprov | ETH/DEC20 | 1905000000000000  | 0.1 | submission |
   145        | lp2 | lpprov | ETH/DEC20 | 1905000000000000  | 0.1 | submission |
   146        | lp3 | lpprov | ETH/DEC21 | 1905000000000000  | 0.1 | submission |
   147        | lp3 | lpprov | ETH/DEC21 | 1905000000000000  | 0.1 | submission |
   148      Then the oracles broadcast data signed with "0xCAFECAFE1":
   149        | name               | value |
   150        | trading.terminated | true  |
   151      And the parties should have the following account balances:
   152        | party  | asset | market id | margin         | general                   | bond             |
   153        | lpprov | ETH | ETH/DEC19 | 0 | 9999999992285000000000000 | 3905000000000000 |
   154        | lpprov | ETH | ETH/DEC20 | 0 | 9999999992285000000000000 | 1905000000000000 |
   155        | lpprov | ETH | ETH/DEC21 | 0 | 9999999992285000000000000 | 1905000000000000 |
   156  
   157      When the successor market "ETH/DEC20" is enacted
   158      When the successor market "ETH/DEC21" is enacted
   159      Then the network moves ahead "1" blocks
   160  
   161      And the parties should have the following account balances:
   162        | party  | asset | market id | margin         | general                   | bond             |
   163        | lpprov | ETH | ETH/DEC19 | 0 | 9999999992285000000000000 | 3905000000000000 |
   164        | lpprov | ETH | ETH/DEC20 | 0 | 9999999992285000000000000 | 1905000000000000 |
   165        | lpprov | ETH | ETH/DEC21 | 0 | 9999999992285000000000000 | 1905000000000000 |
   166      Then the market state should be "STATE_PENDING" for the market "ETH/DEC20"
   167      Then the market state should be "STATE_PENDING" for the market "ETH/DEC21"
   168      Then the market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC19"
   169      When the oracles broadcast data signed with "0xCAFECAFE1":
   170        | name             | value |
   171        | prices.ETH.value | 975   |
   172      Then the market state should be "STATE_SETTLED" for the market "ETH/DEC19"
   173  
   174      Then the parties place the following orders:
   175        | party   | market id | side | volume | price  | resulting trades | type       | tif     | reference |
   176        | trader1 | ETH/DEC21 | buy  | 5      | 1001   | 0                | TYPE_LIMIT | TIF_GTC | t1-b-1    |
   177        | trader1 | ETH/DEC21 | buy  | 5      | 900    | 0                | TYPE_LIMIT | TIF_GTC | t1-b-2    |
   178        | trader1 | ETH/DEC21 | buy  | 1      | 100    | 0                | TYPE_LIMIT | TIF_GTC | t1-b-3    |
   179        | trader2 | ETH/DEC21 | sell | 5      | 1200   | 0                | TYPE_LIMIT | TIF_GTC | t2-s-1    |
   180        | trader2 | ETH/DEC21 | sell | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC | t2-s-2    |
   181        | trader2 | ETH/DEC21 | sell | 5      | 951    | 0                | TYPE_LIMIT | TIF_GTC | t2-s-3    |
   182      When the opening auction period ends for market "ETH/DEC21"
   183      Then the market data for the market "ETH/DEC21" should be:
   184        | mark price | trading mode            | auction trigger             | target stake | supplied stake   | open interest |
   185        | 976        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 269815200000 | 1905000000000000 | 5             |
   186  
   187      When the network moves ahead "1" blocks
   188  #The bond for market ETH/DEC20 should be released back to the general balance
   189      Then the parties should have the following account balances:
   190        | party  | asset | market id | margin         | general                   | bond             |
   191        | lpprov | ETH | ETH/DEC19 | 0 | 9999999998095000000000000 | 0                |
   192        | lpprov | ETH | ETH/DEC20 | 0 | 9999999998095000000000000 | 0                |
   193        | lpprov | ETH | ETH/DEC21 | 0 | 9999999998095000000000000 | 1905000000000000 |
   194  
   195      And the last market state should be "STATE_REJECTED" for the market "ETH/DEC20"
   196  
   197    @SuccessorMarketSimple
   198    Scenario: 003 Enact a successor market while the parent market is still in active state,
   199      Given the markets:
   200        | id        | quote name | asset | risk model            | margin calculator         | auction duration | fees         | price monitoring | data source config     | linear slippage factor | quadratic slippage factor | decimal places | position decimal places | parent market id | insurance pool fraction | successor auction | sla params      |
   201        | ETH/DEC19 | ETH        | ETH   | default-st-risk-model | default-margin-calculator | 1                | default-none | default-none     | ethDec19Oracle         | 0.1                    | 0                         | 5              | 5                       |                  |                         |                   | default-futures |
   202        | ETH/DEC20 | ETH        | ETH   | default-st-risk-model | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 0.1                    | 0                         | 5              | 5                       | ETH/DEC19        | 1                       | 10                | default-futures |
   203      And the parties submit the following liquidity provision:
   204        | id  | party  | market id | commitment amount | fee | lp type    |
   205        | lp1 | lpprov | ETH/DEC19 | 3905000000000000  | 0.3 | submission |
   206        | lp1 | lpprov | ETH/DEC19 | 3905000000000000  | 0.3 | submission |
   207      And the parties place the following orders:
   208        | party   | market id | side | volume | price  | resulting trades | type       | tif     | reference |
   209        | trader1 | ETH/DEC19 | buy  | 5      | 1001   | 0                | TYPE_LIMIT | TIF_GTC | t1-b-1    |
   210        | trader1 | ETH/DEC19 | buy  | 5      | 900    | 0                | TYPE_LIMIT | TIF_GTC | t1-b-2    |
   211        | trader1 | ETH/DEC19 | buy  | 1      | 100    | 0                | TYPE_LIMIT | TIF_GTC | t1-b-3    |
   212        | trader2 | ETH/DEC19 | sell | 5      | 1200   | 0                | TYPE_LIMIT | TIF_GTC | t2-s-1    |
   213        | trader2 | ETH/DEC19 | sell | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC | t2-s-2    |
   214        | trader2 | ETH/DEC19 | sell | 5      | 951    | 0                | TYPE_LIMIT | TIF_GTC | t2-s-3    |
   215      When the opening auction period ends for market "ETH/DEC19"
   216      Then the market data for the market "ETH/DEC19" should be:
   217        | mark price | trading mode            | auction trigger             | target stake | supplied stake   | open interest |
   218        | 976        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 269815200000 | 3905000000000000 | 5             |
   219      And the parties should have the following account balances:
   220        | party   | asset | market id | margin       | general                   |
   221        | trader1 | ETH   | ETH/DEC19 | 126362285504 | 9999999999999873637714496 |
   222      And the parties should have the following margin levels:
   223        | party   | market id | maintenance  |
   224        | trader1 | ETH/DEC19 | 105301904587 |
   225  
   226      # Parent market is still active at this point
   227      When the parties submit the following liquidity provision:
   228        | id  | party  | market id | commitment amount | fee | lp type    |
   229        | lp1 | lpprov | ETH/DEC20 | 1905000000000000  | 0.1 | submission |
   230        | lp1 | lpprov | ETH/DEC20 | 1905000000000000  | 0.1 | submission |
   231      Then the successor market "ETH/DEC20" is enacted
   232      # fill up the successor market orderbook
   233      And the parties place the following orders:
   234        | party   | market id | side | volume | price  | resulting trades | type       | tif     | reference |
   235        | trader1 | ETH/DEC20 | buy  | 5      | 1001   | 0                | TYPE_LIMIT | TIF_GTC | t1-b-1    |
   236        | trader1 | ETH/DEC20 | buy  | 5      | 900    | 0                | TYPE_LIMIT | TIF_GTC | t1-b-2    |
   237        | trader1 | ETH/DEC20 | buy  | 1      | 100    | 0                | TYPE_LIMIT | TIF_GTC | t1-b-3    |
   238        | trader2 | ETH/DEC20 | sell | 5      | 1200   | 0                | TYPE_LIMIT | TIF_GTC | t2-s-1    |
   239        | trader2 | ETH/DEC20 | sell | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC | t2-s-2    |
   240        | trader2 | ETH/DEC20 | sell | 5      | 951    | 0                | TYPE_LIMIT | TIF_GTC | t2-s-3    |
   241  # time progresses some more, and leave auction
   242      When the opening auction period ends for market "ETH/DEC20"
   243      # successor market is enacted without issue
   244      Then the market data for the market "ETH/DEC20" should be:
   245        | mark price | trading mode            | auction trigger             | target stake | supplied stake   | open interest |
   246        | 976        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 269815200000 | 1905000000000000 | 5             |
   247      # Now terminate the parent market
   248      When the oracles broadcast data signed with "0xCAFECAFE1":
   249        | name               | value |
   250        | trading.terminated | true  |
   251        | prices.ETH.value | 975 |
   252  # #   # ensure the parent market is settled, but the successor market is still going
   253      Then the last market state should be "STATE_SETTLED" for the market "ETH/DEC19"
   254      And the last market state should be "STATE_ACTIVE" for the market "ETH/DEC20"
   255      And the market data for the market "ETH/DEC20" should be:
   256        | mark price | trading mode            | auction trigger             | target stake | supplied stake   | open interest |
   257        | 976        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 269815200000 | 1905000000000000 | 5             |
   258  
   259    @SuccessorMarketSimple @NoPerp
   260    Scenario: 004 Enact a successor market while the parent market is still in pending state, 0081-SUCM-009, 0081-SUCM-010, 0081-SUCM-011
   261      Given the markets:
   262        | id        | quote name | asset | risk model            | margin calculator         | auction duration | fees         | price monitoring | data source config     | linear slippage factor | quadratic slippage factor | decimal places | position decimal places | parent market id | insurance pool fraction | successor auction | sla params      |
   263        | ETH/DEC19 | ETH        | ETH   | default-st-risk-model | default-margin-calculator | 1                | default-none | default-none     | ethDec19Oracle         | 0.1                    | 0                         | 5              | 5                       |                  |                         |                   | default-futures |
   264        | ETH/DEC20 | ETH        | ETH   | default-st-risk-model | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 0.1                    | 0                         | 5              | 5                       | ETH/DEC19        | 1                       | 10                | default-futures |
   265        | ETH/DEC21 | ETH        | ETH   | default-st-risk-model | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 0.1                    | 0                         | 5              | 5                       | ETH/DEC19        | 1                       | 10                | default-futures |
   266      And the parties submit the following liquidity provision:
   267        | id  | party  | market id | commitment amount | fee | lp type    |
   268        | lp1 | lpprov | ETH/DEC19 | 3905000000000000  | 0.3 | submission |
   269        | lp1 | lpprov | ETH/DEC19 | 3905000000000000  | 0.3 | submission |
   270      And the parties place the following orders:
   271        | party   | market id | side | volume | price  | resulting trades | type       | tif     | reference |
   272        | trader1 | ETH/DEC19 | buy  | 5      | 1001   | 0                | TYPE_LIMIT | TIF_GTC | t1-b-1    |
   273        | trader2 | ETH/DEC19 | sell | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC | t2-s-2    |
   274        | trader2 | ETH/DEC19 | sell | 5      | 9510   | 0                | TYPE_LIMIT | TIF_GTC | t2-s-3    |
   275  
   276      # When the opening auction period ends for market "ETH/DEC19"
   277      Then the market data for the market "ETH/DEC19" should be:
   278        | mark price | trading mode                 | auction trigger         |
   279        | 0          | TRADING_MODE_OPENING_AUCTION | AUCTION_TRIGGER_OPENING |
   280  
   281      # Parent market is still pending at this point
   282      When the parties submit the following liquidity provision:
   283        | id  | party  | market id | commitment amount | fee | lp type    |
   284        | lp1 | lpprov | ETH/DEC20 | 1905000000000000  | 0.1 | submission |
   285        | lp1 | lpprov | ETH/DEC20 | 1905000000000000  | 0.1 | submission |
   286        | lp2 | lpprov | ETH/DEC21 | 1905000000000000  | 0.1 | submission |
   287        | lp2 | lpprov | ETH/DEC21 | 1905000000000000  | 0.1 | submission |
   288  
   289      And the parties place the following orders:
   290        | party   | market id | side | volume | price | resulting trades | type       | tif     | reference |
   291        | trader1 | ETH/DEC20 | buy  | 10     | 10    | 0                | TYPE_LIMIT | TIF_GTC | t1-b-1    |
   292        | trader1 | ETH/DEC20 | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | t2-s-2    |
   293        | trader2 | ETH/DEC20 | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | t2-s-2    |
   294        | trader2 | ETH/DEC20 | sell | 10     | 2000  | 0                | TYPE_LIMIT | TIF_GTC | t2-s-3    |
   295  
   296      When the opening auction period ends for market "ETH/DEC20"
   297      Then the market data for the market "ETH/DEC20" should be:
   298        | mark price | trading mode            | auction trigger             | target stake | supplied stake   | open interest |
   299        | 1000       | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 552900000000 | 1905000000000000 | 10            |
   300      Then the successor market "ETH/DEC20" is enacted
   301      And the last market state should be "STATE_REJECTED" for the market "ETH/DEC21"
   302  
   303      #When a successor market is enacted (i.e. leaves the opening auction), all other related successor market proposals, in the state "pending" or "proposed", are automatically rejected. Any LP submissions associated with these proposals are cancelled, and the funds are released
   304      And the parties should have the following account balances:
   305        | party  | asset | market id | margin           | general                   | bond             |
   306        | lpprov | ETH | ETH/DEC20 | 0 | 9999999994190000000000000 | 1905000000000000 |
   307        | lpprov | ETH | ETH/DEC21 | 0 | 9999999994190000000000000 | 0                |
   308  
   309    @SuccessorMarketPanic @NoPerp
   310    Scenario: 005 Enacting a successor market rejects any other pending successors, same as scenario 2, but enact the older pending market
   311      ## parent market and 2 successors
   312      Given the markets:
   313        | id        | quote name | asset | risk model            | margin calculator         | auction duration | fees         | price monitoring | data source config     | linear slippage factor | quadratic slippage factor | decimal places | position decimal places | parent market id | insurance pool fraction | successor auction | sla params      |
   314        | ETH/DEC19 | ETH        | ETH   | default-st-risk-model | default-margin-calculator | 1                | default-none | default-none     | ethDec19Oracle         | 0.1                    | 0                         | 5              | 5                       |                  |                         |                   | default-futures |
   315        | ETH/DEC20 | ETH        | ETH   | default-st-risk-model | default-margin-calculator | 1                | default-none | default-none     | ethDec20Oracle         | 0.1                    | 0                         | 5              | 5                       | ETH/DEC19        | 1                       | 10                | default-futures |
   316        | ETH/DEC21 | ETH        | ETH   | default-st-risk-model | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 0.1                    | 0                         | 5              | 5                       | ETH/DEC19        | 1                       | 10                | default-futures |
   317        | ETH/DEC22 | ETH        | ETH   | default-st-risk-model | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 0.1                    | 0                         | 5              | 5                       |                  |                         |                   | default-futures |
   318      And the parties submit the following liquidity provision:
   319        | id  | party  | market id | commitment amount | fee | lp type    |
   320        | lp1 | lpprov | ETH/DEC19 | 3905000000000000  | 0.3 | submission |
   321        | lp1 | lpprov | ETH/DEC19 | 3905000000000000  | 0.3 | submission |
   322      And the parties place the following orders:
   323        | party   | market id | side | volume | price  | resulting trades | type       | tif     | reference |
   324        | trader1 | ETH/DEC19 | buy  | 5      | 1001   | 0                | TYPE_LIMIT | TIF_GTC | t1-b-1    |
   325        | trader1 | ETH/DEC19 | buy  | 5      | 900    | 0                | TYPE_LIMIT | TIF_GTC | t1-b-2    |
   326        | trader1 | ETH/DEC19 | buy  | 1      | 100    | 0                | TYPE_LIMIT | TIF_GTC | t1-b-3    |
   327        | trader2 | ETH/DEC19 | sell | 5      | 1200   | 0                | TYPE_LIMIT | TIF_GTC | t2-s-1    |
   328        | trader2 | ETH/DEC19 | sell | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC | t2-s-2    |
   329        | trader2 | ETH/DEC19 | sell | 5      | 951    | 0                | TYPE_LIMIT | TIF_GTC | t2-s-3    |
   330  # Both successor markets should be pending
   331      Then the market state should be "STATE_PENDING" for the market "ETH/DEC19"
   332      Then the market state should be "STATE_PENDING" for the market "ETH/DEC20"
   333      And the market state should be "STATE_PENDING" for the market "ETH/DEC21"
   334      When the opening auction period ends for market "ETH/DEC19"
   335      Then the market data for the market "ETH/DEC19" should be:
   336        | mark price | trading mode            | auction trigger             | target stake | supplied stake   | open interest |
   337        | 976        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 269815200000 | 3905000000000000 | 5             |
   338      And the parties should have the following account balances:
   339        | party   | asset | market id | margin       | general                   |
   340        | trader1 | ETH   | ETH/DEC19 | 126362285504 | 9999999999999873637714496 |
   341      And the parties should have the following margin levels:
   342        | party   | market id | maintenance  |
   343        | trader1 | ETH/DEC19 | 105301904587 |
   344      # LP submissions are being made on both pending markets
   345      When the parties submit the following liquidity provision:
   346        | id  | party  | market id | commitment amount | fee | lp type    |
   347        | lp2 | lpprov | ETH/DEC20 | 1905000000000000  | 0.1 | submission |
   348        | lp2 | lpprov | ETH/DEC20 | 1905000000000000  | 0.1 | submission |
   349        | lp3 | lpprov | ETH/DEC21 | 1905000000000000  | 0.1 | submission |
   350        | lp3 | lpprov | ETH/DEC21 | 1905000000000000  | 0.1 | submission |
   351      Then the oracles broadcast data signed with "0xCAFECAFE1":
   352        | name               | value |
   353        | trading.terminated | true  |
   354      And the parties should have the following account balances:
   355        | party  | asset | market id | margin         | general                   | bond             |
   356        | lpprov | ETH | ETH/DEC19 | 0 | 9999999992285000000000000 | 3905000000000000 |
   357        | lpprov | ETH | ETH/DEC20 | 0 | 9999999992285000000000000 | 1905000000000000 |
   358        | lpprov | ETH | ETH/DEC21 | 0 | 9999999992285000000000000 | 1905000000000000 |
   359  
   360      When the successor market "ETH/DEC20" is enacted
   361      Then the network moves ahead "1" blocks
   362      # The bond for market ETH/DEC20 should be released back to the general balance
   363      And the parties should have the following account balances:
   364        | party  | asset | market id | margin         | general                   | bond             |
   365        | lpprov | ETH | ETH/DEC19 | 0 | 9999999992285000000000000 | 3905000000000000 |
   366        | lpprov | ETH | ETH/DEC20 | 0 | 9999999992285000000000000 | 1905000000000000 |
   367        | lpprov | ETH | ETH/DEC21 | 0 | 9999999992285000000000000 | 1905000000000000 |
   368      Then the market state should be "STATE_PENDING" for the market "ETH/DEC20"
   369      Then the market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC19"
   370      When the oracles broadcast data signed with "0xCAFECAFE1":
   371        | name             | value |
   372        | prices.ETH.value | 975   |
   373      Then the market state should be "STATE_SETTLED" for the market "ETH/DEC19"
   374  
   375      Then the parties place the following orders:
   376        | party   | market id | side | volume | price  | resulting trades | type       | tif     | reference |
   377        | trader1 | ETH/DEC20 | buy  | 5      | 1001   | 0                | TYPE_LIMIT | TIF_GTC | t1-b-1    |
   378        | trader1 | ETH/DEC20 | buy  | 5      | 900    | 0                | TYPE_LIMIT | TIF_GTC | t1-b-2    |
   379        | trader1 | ETH/DEC20 | buy  | 1      | 100    | 0                | TYPE_LIMIT | TIF_GTC | t1-b-3    |
   380        | trader2 | ETH/DEC20 | sell | 5      | 1200   | 0                | TYPE_LIMIT | TIF_GTC | t2-s-1    |
   381        | trader2 | ETH/DEC20 | sell | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC | t2-s-2    |
   382        | trader2 | ETH/DEC20 | sell | 5      | 951    | 0                | TYPE_LIMIT | TIF_GTC | t2-s-3    |
   383      When the opening auction period ends for market "ETH/DEC20"
   384      Then the market data for the market "ETH/DEC20" should be:
   385        | mark price | trading mode            | auction trigger             | target stake | supplied stake   | open interest |
   386        | 976        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 269815200000 | 1905000000000000 | 5             |
   387  
   388      When the network moves ahead "1" blocks
   389      # The bond for market ETH/DEC20 should be released back to the general balance
   390      Then the parties should have the following account balances:
   391        | party  | asset | market id | margin         | general                   | bond             |
   392        | lpprov | ETH | ETH/DEC19 | 0 | 9999999998095000000000000 | 0                |
   393        | lpprov | ETH | ETH/DEC20 | 0 | 9999999998095000000000000 | 1905000000000000 |
   394        | lpprov | ETH | ETH/DEC21 | 0 | 9999999998095000000000000 | 0                |
   395  
   396      And the last market state should be "STATE_REJECTED" for the market "ETH/DEC21"
   397      And the parties should have the following account balances:
   398        | party  | asset | market id | margin         | general                   | bond             |
   399        | lpprov | ETH | ETH/DEC19 | 0 | 9999999998095000000000000 | 0                |
   400        | lpprov | ETH | ETH/DEC20 | 0 | 9999999998095000000000000 | 1905000000000000 |
   401        | lpprov | ETH | ETH/DEC21 | 0 | 9999999998095000000000000 | 0                |
   402  
   403