code.vegaprotocol.io/vega@v0.79.0/core/integration/features/system-test-default.feature (about)

     1  Feature: Basic feature-file matching the system-test setup like for like
     2  
     3    Background:
     4      Given the following assets are registered:
     5        | id  | decimal places |
     6        | ETH | 18             |
     7        | USD | 0              |
     8      And the liquidity monitoring parameters:
     9        | name               | triggering ratio | time window | scaling factor |
    10        | lqm-params         | 0.0              | 10s         | 5              |  
    11      
    12      And the markets:
    13        | 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 | sla params      |
    14        | ETH/DEC19 | 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                       | default-futures |
    15        | ETH/DEC20 | ETH        | ETH   | lqm-params           | closeout-st-risk-model | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 0.1                    | 0                         | 5              | 5                       | default-futures |
    16        | ETH/DEC21 | ETH        | USD   | lqm-params           | closeout-st-risk-model | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 0.1                    | 0                         | 0              | 0                       | default-futures |
    17        | ETH/DEC23 | ETH        | ETH   | lqm-params           | default-st-risk-model  | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 0.01                   | 0                         | 5              | 5                       | default-st      |
    18      And the following network parameters are set:
    19        | name                                          | value |
    20        | network.markPriceUpdateMaximumFrequency       | 0s    |
    21        | market.auction.minimumDuration                | 1     |
    22        | market.fee.factors.infrastructureFee          | 0.001 |
    23        | market.fee.factors.makerFee                   | 0.004 |
    24        | market.value.windowLength                     | 60s   |
    25        | market.liquidity.bondPenaltyParameter         | 0.1   |
    26        | validators.epoch.length                       | 5s    |
    27        #| limits.markets.maxPeggedOrders                | 2     |
    28      And the average block duration is "1"
    29  
    30      # All parties have 1,000,000.000,000,000,000,000,000 
    31      # Add as many parties as needed here
    32      And the parties deposit on asset's general account the following amount:
    33        | party   | asset | amount                     |
    34        | lpprov  | ETH   | 10000000000000000000000000 |
    35        | trader1 | ETH   | 10000000000000000000000000 |
    36        | trader2 | ETH   | 10000000000000000000000000 |
    37        | trader3 | ETH   | 10000000000000000000000000 |
    38        | trader4 | ETH   | 10000000000000000000000000 |
    39        | trader5 | ETH   | 10000000000000000000000000 |
    40  
    41  
    42    @SystemTestBase
    43    Scenario: 001 Create a new market and leave opening auction in the same way the system tests do
    44      # the amount ought to be 390,500.000,000,000,000,000,000
    45      Given the following network parameters are set:
    46        | name                                          | value |
    47        | limits.markets.maxPeggedOrders                | 2     |
    48      And the parties submit the following liquidity provision:
    49        | id  | party  | market id | commitment amount | fee | lp type    |
    50        | lp1 | lpprov | ETH/DEC19 | 3905000000000000  | 0.3 | submission |
    51        | lp1 | lpprov | ETH/DEC19 | 3905000000000000  | 0.3 | submission |
    52      And the parties place the following pegged iceberg orders:
    53        | party  | market id | side | volume | peak size | minimum visible size | pegged reference | offset |
    54        | lpprov | ETH/DEC19 | buy  | 20     | 2         | 1                    | BID              | 1      |
    55        | lpprov | ETH/DEC19 | sell | 130    | 2         | 1                    | ASK              | 1      |
    56    
    57      And the parties place the following orders:
    58        | party   | market id | side | volume | price  | resulting trades | type       | tif     | reference |
    59        | trader1 | ETH/DEC19 | buy  | 5      | 1001   | 0                | TYPE_LIMIT | TIF_GTC | t1-b-1    |
    60        | trader1 | ETH/DEC19 | buy  | 5      | 900    | 0                | TYPE_LIMIT | TIF_GTC | t1-b-2    |
    61        | trader1 | ETH/DEC19 | buy  | 1      | 100    | 0                | TYPE_LIMIT | TIF_GTC | t1-b-3    |
    62        | trader2 | ETH/DEC19 | sell | 5      | 1200   | 0                | TYPE_LIMIT | TIF_GTC | t2-s-1    |
    63        | trader2 | ETH/DEC19 | sell | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC | t2-s-2    |
    64        | trader2 | ETH/DEC19 | sell | 5      | 951    | 0                | TYPE_LIMIT | TIF_GTC | t2-s-3    |
    65      When the opening auction period ends for market "ETH/DEC19"
    66      Then the market data for the market "ETH/DEC19" should be:
    67        | mark price | trading mode            | auction trigger             | target stake | supplied stake   | open interest |
    68        | 976        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 134907600000 | 3905000000000000 | 5             |
    69      And the parties should have the following account balances:
    70        | party   | asset | market id | margin       | general                   |
    71        | trader1 | ETH   | ETH/DEC19 | 126362285504 | 9999999999999873637714496 |
    72      And the parties should have the following margin levels:
    73        | party   | market id | maintenance  |
    74        | trader1 | ETH/DEC19 | 105301904587 |
    75  
    76  
    77  
    78    @SystemTestBase
    79    Scenario: 002 Funding insurance pool balance by closing a trader out - note this scenario is a template. It does not actually close out the trader, it's just the first steps from the system test. With this scenario, we can check margin requirements before and after MTM settlement
    80      Given the parties deposit on asset's general account the following amount:
    81        | party           | asset | amount                     |
    82        | party1          | ETH   | 10000000000000000000000000 |
    83        | party2          | ETH   | 10000000000000000000000000 |
    84        | designatedloser | ETH   | 18000000000000000000000    |
    85      And the parties submit the following liquidity provision:
    86        | id  | party  | market id | commitment amount | fee | lp type    |
    87        | lp1 | lpprov | ETH/DEC20 | 3905000000000000  | 0.3 | submission |
    88        | lp1 | lpprov | ETH/DEC20 | 3905000000000000  | 0.3 | submission |
    89      And the parties place the following orders:
    90        | party   | market id | side | volume | price  | resulting trades | type       | tif     | reference |
    91        | trader1 | ETH/DEC20 | buy  | 5      | 1001   | 0                | TYPE_LIMIT | TIF_GTC | t1-b-1    |
    92        | trader1 | ETH/DEC20 | buy  | 5      | 900    | 0                | TYPE_LIMIT | TIF_GTC | t1-b-2    |
    93        | trader1 | ETH/DEC20 | buy  | 1      | 100    | 0                | TYPE_LIMIT | TIF_GTC | t1-b-3    |
    94        | trader2 | ETH/DEC20 | sell | 5      | 1200   | 0                | TYPE_LIMIT | TIF_GTC | t2-s-1    |
    95        | trader2 | ETH/DEC20 | sell | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC | t2-s-2    |
    96        | trader2 | ETH/DEC20 | sell | 5      | 951    | 0                | TYPE_LIMIT | TIF_GTC | t2-s-3    |
    97      When the opening auction period ends for market "ETH/DEC20"
    98      Then the market data for the market "ETH/DEC20" should be:
    99        | mark price | trading mode            | auction trigger             | target stake  | supplied stake   | open interest |
   100        | 976        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 1190402800000 | 3905000000000000 | 5             |
   101  
   102      # Now place orders to cause designatedloser party to be distressed
   103      When the parties place the following orders:
   104        | party           | market id | side | volume | price | resulting trades | type       | tif     | reference |
   105        | party1          | ETH/DEC20 | sell | 1      | 960   | 0                | TYPE_LIMIT | TIF_GTC | p1-s-1    |
   106        | party2          | ETH/DEC20 | buy  | 1      | 950   | 0                | TYPE_LIMIT | TIF_GTC | p1-b-1    |
   107        | designatedloser | ETH/DEC20 | buy  | 450    | 960   | 1                | TYPE_LIMIT | TIF_GTC | dl-b-1    |
   108      Then the parties should have the following account balances:
   109        | party           | asset | market id | margin         | general                 |
   110        | designatedloser | ETH   | ETH/DEC20 | 17753938373119 | 17999999982216781626881 |
   111      And the parties should have the following margin levels:
   112        | party           | market id | maintenance    | search         | initial        | release        |
   113        | designatedloser | ETH/DEC20 | 14794948644266 | 16274443508692 | 17753938373119 | 20712928101972 |
   114      When the network moves ahead "1" blocks
   115      Then the parties should have the following account balances:
   116        | party           | asset | market id | margin         | general                 |
   117        | designatedloser | ETH   | ETH/DEC20 | 17753938373119 | 17999999982216781626881 |
   118      And the parties should have the following margin levels:
   119        | party           | market id | maintenance    |
   120        | designatedloser | ETH/DEC20 | 14562008502557 |
   121  
   122  
   123  
   124  
   125  @SystemTestBase @NoPerp
   126    Scenario: 003 Funding insurance pool 
   127      Given the parties deposit on asset's general account the following amount:
   128        | party            | asset | amount       |
   129        | lpprov           | USD   | 10000000000  |
   130        | aux1             | USD   | 1000000      |
   131        | aux2             | USD   | 1000000      |
   132        | sellSideProvider | USD   | 200000000000 |
   133        | buySideProvider  | USD   | 200000000000 |
   134        | designatedloser  | USD   | 33000        |
   135      And the parties submit the following liquidity provision:
   136        | id  | party  | market id | commitment amount | fee | lp type    |
   137        | lp1 | lpprov | ETH/DEC21 | 390500            | 0.3 | submission |
   138        | lp1 | lpprov | ETH/DEC21 | 390500            | 0.3 | submission |
   139      Then the parties place the following orders:
   140        | party | market id | side | volume | price | resulting trades | type       | tif     |
   141        | aux1  | ETH/DEC21 | buy  | 400    | 1     | 0                | TYPE_LIMIT | TIF_GTC |
   142        | aux1  | ETH/DEC21 | sell | 300    | 2000  | 0                | TYPE_LIMIT | TIF_GTC |
   143        | aux1  | ETH/DEC21 | buy  | 1      | 150   | 0                | TYPE_LIMIT | TIF_GTC |
   144        | aux2  | ETH/DEC21 | sell | 1      | 150   | 0                | TYPE_LIMIT | TIF_GTC |
   145      When the opening auction period ends for market "ETH/DEC21"
   146      Then the market data for the market "ETH/DEC21" should be:
   147        | mark price | trading mode            | auction trigger             | target stake  | supplied stake   | open interest |
   148        | 150        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 365           | 390500 | 1             |
   149  
   150      # Now place orders to cause designatedloser party to be distressed
   151      When the parties place the following orders with ticks:
   152        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference       |
   153        | sellSideProvider | ETH/DEC21 | sell | 290    | 150   | 0                | TYPE_LIMIT | TIF_GTC | sell-provider-1 |
   154        | buySideProvider  | ETH/DEC21 | buy  | 1      | 140   | 0                | TYPE_LIMIT | TIF_GTC | buy-provider-1  |
   155  
   156      When the parties place the following orders with ticks:
   157        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference |
   158        | designatedloser  | ETH/DEC21 | buy  | 290    | 150   | 1                | TYPE_LIMIT | TIF_GTC | ref-loser-1     |
   159  
   160      Then the parties should have the following margin levels:
   161        | party            | market id | maintenance | search | initial | release |
   162        | designatedloser | ETH/DEC21 | 19004       | 20904  | 22804   | 26605   |
   163         Then the parties should have the following account balances:
   164        | party            | asset | market id | margin | general |
   165        | designatedloser | USD   | ETH/DEC21 | 19732  | 0       |
   166  
   167      Then the parties cancel the following orders:
   168        | party           | reference      |
   169        | buySideProvider | buy-provider-1 |
   170      When the parties place the following orders with ticks:
   171        | party           | market id | side | volume | price | resulting trades | type       | tif     | reference      |
   172        | buySideProvider | ETH/DEC21 | buy  | 290    | 120   | 0                | TYPE_LIMIT | TIF_GTC | buy-provider-2 |
   173  
   174      When the parties place the following orders with ticks:
   175        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference |
   176        | sellSideProvider | ETH/DEC21 | sell | 1      | 140   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   177        | buySideProvider  | ETH/DEC21 | buy  | 1      | 140   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
   178      And the network moves ahead "1" blocks
   179      And the insurance pool balance should be "417" for the market "ETH/DEC21"
   180  
   181    @AuctionDelay
   182    Scenario: Opening auction end is delayed for no apparent reason
   183      Given the parties deposit on asset's general account the following amount:
   184        | party | asset | amount                      |
   185        | aux1  | ETH   | 100000000000000000000000000 |
   186        | aux2  | ETH   | 100000000000000000000000000 |
   187      # block 425 -> creates proposal, 433 passes vote, 434 proposal is enacted, start opening auction
   188      # Pretend market ETH/DEC23 passed the vote here
   189      And the network moves ahead "12" blocks
   190  
   191      # Block 445, LP is submitted (433 + 12)
   192      When the parties submit the following liquidity provision:
   193        | id   | party  | market id | commitment amount        | fee | lp type    |
   194        | lp_1 | lpprov | ETH/DEC23 | 390500000000000000000000 | 0.3 | submission |
   195      And the network moves ahead "1" blocks
   196      Then the market data for the market "ETH/DEC23" should be:
   197        | mark price | trading mode                 | auction trigger         |
   198        | 0          | TRADING_MODE_OPENING_AUCTION | AUCTION_TRIGGER_OPENING |
   199  
   200      # LP orders are submitted at block 450 -> 445 + 5
   201      When the network moves ahead "4" blocks
   202      Then the parties place the following orders:
   203        | party  | market id | side | volume      | price      | resulting trades | type       | tif     | reference     |
   204        | lpprov | ETH/DEC23 | buy  | 39050000000 | 100000     | 0                | TYPE_LIMIT | TIF_GTC | lp-buy-order  |
   205        | lpprov | ETH/DEC23 | sell | 1           | 1000000000 | 0                | TYPE_LIMIT | TIF_GTC | lp-sell-order |
   206      And the network moves ahead "7" blocks
   207      Then the market data for the market "ETH/DEC23" should be:
   208        | mark price | trading mode                 | auction trigger         |
   209        | 0          | TRADING_MODE_OPENING_AUCTION | AUCTION_TRIGGER_OPENING |
   210  
   211      # First party submits a buy order at block 457
   212      When the parties place the following orders:
   213        | party   | market id | side | volume    | price  | resulting trades | type       | tif     | reference |
   214        | trader1 | ETH/DEC23 | buy  | 100100000 | 500000 | 0                | TYPE_LIMIT | TIF_GTC | buy-457   |
   215      Then the network moves ahead "1" blocks
   216      And the market data for the market "ETH/DEC23" should be:
   217        | mark price | trading mode                 | auction trigger         |
   218        | 0          | TRADING_MODE_OPENING_AUCTION | AUCTION_TRIGGER_OPENING |
   219  
   220      # More orders are submitted in block 458
   221      When the parties place the following orders:
   222        | party   | market id | side | volume      | price  | resulting trades | type       | tif     | reference  |
   223        | trader2 | ETH/DEC23 | sell | 95100000    | 500000 | 0                | TYPE_LIMIT | TIF_GTC | sell-458-1 |
   224        | trader1 | ETH/DEC23 | buy  | 90000000    | 500000 | 0                | TYPE_LIMIT | TIF_GTC | buy-458-1  |
   225        | trader2 | ETH/DEC23 | sell | 120000000   | 500000 | 0                | TYPE_LIMIT | TIF_GTC | sell-458-2 |
   226        | trader1 | ETH/DEC23 | buy  | 10000000    | 100000 | 0                | TYPE_LIMIT | TIF_GTC | buy-458-2  |
   227        | trader2 | ETH/DEC23 | sell | 10000000000 | 100000 | 0                | TYPE_LIMIT | TIF_GTC | sell-458-3 |
   228      # For some reason, even though we have orders that can uncross, we remain in auction
   229      Then the network moves ahead "1" blocks
   230      And the market data for the market "ETH/DEC23" should be:
   231        | mark price | trading mode            | auction trigger             | target stake            | supplied stake           | open interest |
   232        | 100000     | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 27645000000000000000000 | 390500000000000000000000 | 10000000000   |
   233