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

     1  Feature: Simple example of successor markets
     2    Background:
     3      Given time is updated to "2019-11-30T00:00:00Z"
     4      And the following assets are registered:
     5        | id  | decimal places |
     6        | ETH | 0              |
     7        | USD | 0              |
     8      Given the log normal risk model named "lognormal-risk-model-fish":
     9        | risk aversion | tau  | mu | r   | sigma |
    10        | 0.001         | 0.01 | 0  | 0.0 | 1.2   |
    11      And the margin calculator named "margin-calculator-1":
    12        | search factor | initial factor | release factor |
    13        | 1.2           | 1.5            | 2              |
    14      Given time is updated to "2023-07-20T00:00:00Z"
    15      Given the average block duration is "1"
    16      # Create some oracles
    17      ## oracle for parent
    18      And the oracle spec for settlement data filtering data from "0xCAFECAFE1" named "ethDec19Oracle":
    19        | property         | type         | binding         |
    20        | prices.ETH.value | TYPE_INTEGER | settlement data |
    21      And the oracle spec for trading termination filtering data from "0xCAFECAFE1" named "ethDec19Oracle":
    22        | property           | type         | binding             |
    23        | trading.terminated | TYPE_BOOLEAN | trading termination |
    24      And the settlement data decimals for the oracle named "ethDec19Oracle" is given in "5" decimal places
    25      ## oracle for a successor
    26      And the oracle spec for settlement data filtering data from "0xCAFECAFE20" named "ethDec20Oracle":
    27        | property         | type         | binding         |
    28        | prices.ETH.value | TYPE_INTEGER | settlement data |
    29      And the oracle spec for trading termination filtering data from "0xCAFECAFE20" named "ethDec20Oracle":
    30        | property           | type         | binding             |
    31        | trading.terminated | TYPE_BOOLEAN | trading termination |
    32      And the settlement data decimals for the oracle named "ethDec20Oracle" is given in "5" decimal places
    33      And the liquidity monitoring parameters:
    34        | name               | triggering ratio | time window | scaling factor |
    35        | lqm-params         | 0.01             | 10s         | 10             |  
    36      
    37      And the following network parameters are set:
    38        | name                                                  | value |
    39        | network.markPriceUpdateMaximumFrequency               | 0s    |
    40        | market.auction.minimumDuration                        | 1     |
    41        | market.fee.factors.infrastructureFee                  | 0.001 |
    42        | market.fee.factors.makerFee                           | 0.004 |
    43        | market.value.windowLength                             | 60s   |
    44        | market.liquidity.bondPenaltyParameter               | 0.2   |
    45        | validators.epoch.length                               | 5s    |
    46        | market.liquidity.stakeToCcyVolume                   | 1     |
    47        | market.liquidity.successorLaunchWindowLength          | 1h    |
    48        | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0.19  |
    49        | market.liquidity.sla.nonPerformanceBondPenaltyMax   | 1     |
    50        | validators.epoch.length                               | 2s    |
    51        | market.liquidity.providersFeeCalculationTimeStep    | 2s   |
    52      And the liquidity sla params named "SLA":
    53        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
    54        | 1.0         | 0.5                          | 1                             | 1.0                    |
    55      And the oracle spec for settlement data filtering data from "0xCAFECAFE1" named "ethDec20Oracle":
    56        | property         | type         | binding         |
    57        | prices.ETH.value | TYPE_INTEGER | settlement data |
    58      And the oracle spec for trading termination filtering data from "0xCAFECAFE1" named "ethDec20Oracle":
    59        | property           | type         | binding             |
    60        | trading.terminated | TYPE_BOOLEAN | trading termination |
    61      # Add as many parties as needed here
    62      And the parties deposit on asset's general account the following amount:
    63        | party   | asset | amount      |
    64        | lpprov1 | USD   | 2000000000  |
    65        | lpprov2 | USD   | 20000000000 |
    66        | lpprov3 | USD   | 20000000000 |
    67        | lpprov4 | USD   | 20000000000 |
    68        | trader1 | USD   | 2000000     |
    69        | trader2 | USD   | 2000000     |
    70        | trader3 | USD   | 2000000     |
    71        | trader4 | USD   | 2000000     |
    72        | trader5 | USD   | 22000       |
    73  
    74    @SuccessorMarketActive @Liquidation
    75    Scenario: 001 Enact a successor market when the parent market is still active; Two proposals that name the same parent can be submitted; 0081-SUCM-005, 0081-SUCM-006, 0081-SUCM-020, 0081-SUCM-021, 0081-SUCM-022
    76      Given the markets:
    77        | 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 |
    78        | ETH/DEC19 | ETH        | USD   | lqm-params           | lognormal-risk-model-fish | margin-calculator-1       | 1                | default-none | default-none     | ethDec19Oracle         | 0.1                    | 0                         | 0              | 0                       |                  |                         |                   | SLA        |
    79        | ETH/DEC20 | ETH        | USD   | lqm-params           | default-st-risk-model     | default-margin-calculator | 1                | default-none | default-none     | ethDec20Oracle         | 0.1                    | 0                         | 0              | 0                       | ETH/DEC19        | 0.6                     | 10                | SLA        |
    80        | ETH/DEC21 | ETH        | USD   | lqm-params           | default-st-risk-model     | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 0.1                    | 0                         | 0              | 0                       | ETH/DEC19        | 0.6                     | 10                | SLA        |
    81      And the parties submit the following liquidity provision:
    82        | id  | party   | market id | commitment amount | fee | lp type    |
    83        | lp1 | lpprov1 | ETH/DEC19 | 9000              | 0.1 | submission |
    84        | lp1 | lpprov1 | ETH/DEC19 | 9000              | 0.1 | submission |
    85        | lp2 | lpprov2 | ETH/DEC19 | 1000              | 0.1 | submission |
    86        | lp2 | lpprov2 | ETH/DEC19 | 1000              | 0.1 | submission |
    87      And the parties place the following orders:
    88        | party   | market id | side | volume | price | resulting trades | type       | tif     |
    89        | trader1 | ETH/DEC19 | buy  | 10     | 1     | 0                | TYPE_LIMIT | TIF_GTC |
    90        | trader1 | ETH/DEC19 | sell | 10     | 2000  | 0                | TYPE_LIMIT | TIF_GTC |
    91        | trader1 | ETH/DEC19 | buy  | 1      | 150   | 0                | TYPE_LIMIT | TIF_GTC |
    92        | trader2 | ETH/DEC19 | sell | 1      | 150   | 0                | TYPE_LIMIT | TIF_GTC |
    93      When the opening auction period ends for market "ETH/DEC19"
    94      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
    95      Then the market data for the market "ETH/DEC19" should be:
    96        | mark price | trading mode            | auction trigger             | target stake | supplied stake | open interest |
    97        | 150        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 731          | 10000          | 1             |
    98      When the parties place the following orders:
    99        | party   | market id | side | volume | price | resulting trades | type       | tif     | reference       |
   100        | trader4 | ETH/DEC19 | sell | 290    | 150   | 0                | TYPE_LIMIT | TIF_GTC | sell-provider-1 |
   101        | trader3 | ETH/DEC19 | buy  | 1      | 140   | 0                | TYPE_LIMIT | TIF_GTC | buy-provider-1  |
   102      And the market data for the market "ETH/DEC19" should be:
   103        | mark price | trading mode            | target stake | supplied stake | open interest |
   104        | 150        | TRADING_MODE_CONTINUOUS | 731          | 10000          | 1             |
   105      When the parties place the following orders:
   106        | party   | market id | side | volume | price | resulting trades | type       | tif     | reference |
   107        | trader5 | ETH/DEC19 | buy  | 290    | 150   | 1                | TYPE_LIMIT | TIF_GTC | ref-1     |
   108      Then the parties should have the following account balances:
   109        | party   | asset | market id | margin | general |
   110        | trader5 | USD   | ETH/DEC19 | 17432  | 0       |
   111      Then the parties cancel the following orders:
   112        | party   | reference      |
   113        | trader3 | buy-provider-1 |
   114      When the parties place the following orders:
   115        | party   | market id | side | volume | price | resulting trades | type       | tif     | reference      |
   116        | trader3 | ETH/DEC19 | buy  | 290    | 120   | 0                | TYPE_LIMIT | TIF_GTC | buy-provider-2 |
   117      When the parties place the following orders:
   118        | party   | market id | side | volume | price | resulting trades | type       | tif     | reference |
   119        | trader4 | ETH/DEC19 | sell | 1      | 140   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   120        | trader3 | ETH/DEC19 | buy  | 1      | 140   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
   121      Then the network moves ahead "2" blocks
   122  
   123      And the insurance pool balance should be "6977" for the market "ETH/DEC19"
   124      And the global insurance pool balance should be "0" for the asset "USD"
   125  
   126  
   127  
   128      Then the parties should have the following account balances:
   129        | party   | asset | market id | margin | general     |
   130        | lpprov1 | USD   | ETH/DEC19 | 0      | 1999991000  |
   131        | lpprov2 | USD   | ETH/DEC19 | 0      | 19999999000 |
   132        | trader1 | USD   | ETH/DEC19 | 1088   | 1998902     |
   133        | trader2 | USD   | ETH/DEC19 | 121    | 1999889     |
   134        | trader3 | USD   | ETH/DEC19 | 27856  | 1978068     |
   135        | trader4 | USD   | ETH/DEC19 | 41369  | 1961706     |
   136        | trader5 | USD   | ETH/DEC19 | 0      | 0           |
   137  
   138      Then the parties should have the following profit and loss:
   139        | party   | volume | unrealised pnl | realised pnl |
   140        | trader1 | 1      | -10            | 0            |
   141        | trader2 | -1     | 10             | 0            |
   142        | trader3 | 291    | 5800           | 0            |
   143        | trader4 | -291   | 2900           | 0            |
   144        | trader5 | 0      | 0              | -17432       |
   145  
   146      And the liquidity provider fee shares for the market "ETH/DEC19" should be:
   147        | party   | equity like share  | average entry valuation |
   148        | lpprov1 | 0.9 | 9000  |
   149        | lpprov2 | 0.1 | 10000 |
   150  
   151      And then the network moves ahead "2" blocks
   152  
   153      And the insurance pool balance should be "6977" for the market "ETH/DEC19"
   154      And the global insurance pool balance should be "0" for the asset "USD"
   155  
   156      When the oracles broadcast data signed with "0xCAFECAFE1":
   157        | name               | value |
   158        | trading.terminated | true  |
   159  
   160      And time is updated to "2023-07-21T00:00:00Z"
   161      And the global insurance pool balance should be "0" for the asset "USD"
   162  
   163      Then the parties should have the following account balances:
   164        | party   | asset | market id | margin | general     |
   165        | lpprov1 | USD   | ETH/DEC19 | 0      | 1999991000  |
   166        | lpprov2 | USD   | ETH/DEC19 | 0      | 19999999000 |
   167        | trader1 | USD   | ETH/DEC19 | 1088   | 1998902     |
   168        | trader2 | USD   | ETH/DEC19 | 121    | 1999889     |
   169        | trader3 | USD   | ETH/DEC19 | 27856  | 1978068     |
   170        | trader4 | USD   | ETH/DEC19 | 41369  | 1961706     |
   171        | trader5 | USD   | ETH/DEC19 | 0      | 0           |
   172  
   173      Then the market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC19"
   174      And the insurance pool balance should be "6977" for the market "ETH/DEC19"
   175      When the oracles broadcast data signed with "0xCAFECAFE1":
   176        | name             | value    |
   177        | prices.ETH.value | 14000000 |
   178  
   179      And the insurance pool balance should be "16359" for the market "ETH/DEC19"
   180  
   181      And then the network moves ahead "10" blocks
   182      And the insurance pool balance should be "16359" for the market "ETH/DEC19"
   183      And the global insurance pool balance should be "0" for the asset "USD"
   184  
   185      Then the parties should have the following profit and loss:
   186        | party   | volume | unrealised pnl | realised pnl |
   187        | trader1 | 1      | 0              | -10          |
   188        | trader2 | -1     | 0              | 10           |
   189        | trader3 | 291    | 0              | 5800         |
   190        | trader4 | -291   | 0              | 2900         |
   191        | trader5 | 0      | 0              | -17432       |
   192  
   193      Then the parties should have the following account balances:
   194        | party   | asset | market id | margin | general     |
   195        | lpprov1 | USD   | ETH/DEC19 | 0      | 1999996905  |
   196        | lpprov2 | USD   | ETH/DEC19 | 0      | 19999999657 |
   197        | trader1 | USD   | ETH/DEC19 | 0      | 1999990     |
   198        | trader2 | USD   | ETH/DEC19 | 0      | 2000010     |
   199        | trader3 | USD   | ETH/DEC19 | 0      | 2005924     |
   200        | trader4 | USD   | ETH/DEC19 | 0      | 2003075     |
   201        | trader5 | USD   | ETH/DEC19 | 0      | 0           |
   202