code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/0002-STTL-settlement_future_example_paths.feature (about)

     1  Feature: Test settlement future example paths (0002-STTL-011), (0002-STTL-012), (0002-STTL-013)
     2  
     3    Background:
     4      Given time is updated to "2019-11-30T00:00:00Z"
     5      And the average block duration is "1"
     6  
     7      And the oracle spec for settlement data filtering data from "0xCAFECAFE" named "ethDec20Oracle":
     8        | property         | type         | binding         |
     9        | prices.ETH.value | TYPE_INTEGER | settlement data |
    10  
    11      And the oracle spec for trading termination filtering data from "0xCAFECAFE" named "ethDec20Oracle":
    12        | property           | type         | binding             |
    13        | trading.terminated | TYPE_BOOLEAN | trading termination |
    14  
    15      And the settlement data decimals for the oracle named "ethDec20Oracle" is given in "0" decimal places
    16  
    17      And the following network parameters are set:
    18        | name                                         | value |
    19        | market.auction.minimumDuration               | 1     |
    20        | network.markPriceUpdateMaximumFrequency      | 0s    |
    21        | market.liquidity.successorLaunchWindowLength | 1s    |
    22        | limits.markets.maxPeggedOrders               | 4     |
    23  
    24      And the markets:
    25        | id        | quote name | asset | risk model                  | margin calculator         | auction duration | fees          | price monitoring   | data source config | linear slippage factor | quadratic slippage factor | sla params      |
    26        | ETH/DEC19 | ETH        | ETH   | default-simple-risk-model-3 | default-margin-calculator | 1                | default-none  | default-basic      | ethDec20Oracle     | 0.25                   | 0                         | default-futures |
    27      And the initial insurance pool balance is "1000" for all the markets
    28  
    29    Scenario: A typical path of a cash settled futures market nearing expiry when market is trading in continuous session (0002-STTL-011)
    30      Given the parties deposit on asset's general account the following amount:
    31        | party  | asset | amount |
    32        | aux1   | ETH   | 100000 |
    33        | aux2   | ETH   | 100000 |
    34        | lpprov | ETH   | 100000 |
    35  
    36      When the parties submit the following liquidity provision:
    37        | id  | party  | market id | commitment amount | fee | lp type    |
    38        | lp1 | lpprov | ETH/DEC19 | 90000             | 0.1 | submission |
    39        | lp1 | lpprov | ETH/DEC19 | 90000             | 0.1 | submission |
    40      And the parties place the following pegged iceberg orders:
    41        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
    42        | lpprov | ETH/DEC19 | 2         | 1                    | buy  | BID              | 50         | 10     |
    43        | lpprov | ETH/DEC19 | 2         | 1                    | sell | ASK              | 50         | 10     |
    44  
    45      When the parties place the following orders:
    46        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
    47        | aux1  | ETH/DEC19 | buy  | 1      | 999   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    48        | aux2  | ETH/DEC19 | sell | 1      | 1001  | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
    49        | aux1  | ETH/DEC19 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | ref-3     |
    50        | aux2  | ETH/DEC19 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | ref-4     |
    51      Then the opening auction period ends for market "ETH/DEC19"
    52      And the mark price should be "1000" for the market "ETH/DEC19"
    53      And the market state should be "STATE_ACTIVE" for the market "ETH/DEC19"
    54      And the insurance pool balance should be "1000" for the market "ETH/DEC19"
    55  
    56      # check bond
    57      And the parties should have the following account balances:
    58        | party | asset | market id   | margin | general | bond  |
    59        | lpprov  | ETH   | ETH/DEC19 | 6600   | 3400    | 90000 |
    60      # check margin
    61      And the parties should have the following account balances:
    62        | party | asset | market id | margin | general |
    63        | aux1  | ETH   | ETH/DEC19 | 564    | 99436   |
    64        | aux2  | ETH   | ETH/DEC19 | 540    | 99460   |
    65      # check positions
    66      Then the parties should have the following profit and loss:
    67        | party  | volume | unrealised pnl | realised pnl |
    68        | aux1   | 1      | 0              | 0            |
    69        | aux2   | -1     | 0              | 0            |
    70  
    71      When the oracles broadcast data signed with "0xCAFECAFE":
    72        | name               | value |
    73        | trading.terminated | true  |
    74      And time is updated to "2020-01-01T01:01:01Z"
    75      Then the market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC19"
    76      # check margin
    77      And the parties should have the following account balances:
    78        | party | asset | market id | margin | general |
    79        | aux1  | ETH   | ETH/DEC19 | 564    | 99436   |
    80        | aux2  | ETH   | ETH/DEC19 | 540    | 99460   |
    81      # check positions
    82      Then the parties should have the following profit and loss:
    83        | party  | volume | unrealised pnl | realised pnl |
    84        | aux1   | 1      | 0              | 0            |
    85        | aux2   | -1     | 0              | 0            |
    86  
    87      When the oracles broadcast data signed with "0xCAFECAFE":
    88        | name             | value |
    89        | prices.ETH.value | 42    |
    90      Then time is updated to "2020-01-01T01:01:02Z"
    91  
    92      # check margin
    93      And the parties should have the following account balances:
    94        | party | asset | market id | margin | general |
    95        | aux1  | ETH   | ETH/DEC19 | 0      | 99042   |
    96        | aux2  | ETH   | ETH/DEC19 | 0      | 100958  |
    97      
    98      # check bond
    99      And the parties should have the following account balances:
   100        | party   | asset | market id | margin | general | bond   |
   101        | lpprov  | ETH   | ETH/DEC19 | 0      | 100000  | 0      |
   102      
   103      # check positions
   104      And the parties should have the following profit and loss:
   105        | party  | volume | unrealised pnl | realised pnl |
   106        | aux1   | 1      | 0              | -958         |
   107        | aux2   | -1     | 0              | 958          |
   108  
   109      And the network moves ahead "2" blocks
   110      And the insurance pool balance should be "0" for the market "ETH/DEC19"
   111      And the global insurance pool balance should be "1000" for the asset "ETH"
   112    
   113    Scenario: A less typical path of such a futures market nearing expiry when market is suspended (0002-STTL-012)
   114      Given the parties deposit on asset's general account the following amount:
   115        | party  | asset | amount |
   116        | party1 | ETH   | 10000  |
   117        | party2 | ETH   | 1000   |
   118        | aux1   | ETH   | 100000 |
   119        | aux2   | ETH   | 100000 |
   120        | lpprov | ETH   | 100000 |
   121  
   122      When the parties submit the following liquidity provision:
   123        | id  | party  | market id | commitment amount | fee | lp type    |
   124        | lp1 | lpprov | ETH/DEC19 | 90000             | 0.1 | submission |
   125        | lp1 | lpprov | ETH/DEC19 | 90000             | 0.1 | submission |
   126      And the parties place the following pegged iceberg orders:
   127        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
   128        | lpprov | ETH/DEC19 | 2         | 1                    | buy  | BID              | 50         | 10     |
   129        | lpprov | ETH/DEC19 | 2         | 1                    | sell | ASK              | 50         | 10     |
   130  
   131      When the parties place the following orders:
   132        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
   133        | aux1  | ETH/DEC19 | buy  | 1      | 999   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   134        | aux2  | ETH/DEC19 | sell | 1      | 1001  | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
   135        | aux1  | ETH/DEC19 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | ref-3     |
   136        | aux2  | ETH/DEC19 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | ref-4     |
   137      Then the opening auction period ends for market "ETH/DEC19"
   138      And the mark price should be "1000" for the market "ETH/DEC19"
   139      And the insurance pool balance should be "1000" for the market "ETH/DEC19"
   140      And the market state should be "STATE_ACTIVE" for the market "ETH/DEC19"
   141  
   142      When the parties place the following orders with ticks:
   143        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   144        | party1 | ETH/DEC19 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | ref-5     |
   145        | party2 | ETH/DEC19 | buy  | 1      | 1000  | 1                | TYPE_LIMIT | TIF_GTC | ref-6     |
   146  
   147      And the mark price should be "1000" for the market "ETH/DEC19"
   148  
   149      Then the parties should have the following profit and loss:
   150        | party  | volume | unrealised pnl | realised pnl |
   151        | party1 | -1     | 0              | 0            |
   152        | party2 | 1      | 0              | 0            |
   153  
   154      And the parties should have the following account balances:
   155        | party  | asset | market id | margin | general |
   156        | party1 | ETH   | ETH/DEC19 | 420    | 9580    |
   157        | party2 | ETH   | ETH/DEC19 | 432    | 468     |
   158  
   159      And then the network moves ahead "10" blocks
   160  
   161      When the parties place the following orders with ticks:
   162        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   163        | party1 | ETH/DEC19 | sell | 1      | 1101  | 0                | TYPE_LIMIT | TIF_GTC | ref-7     |
   164        | party2 | ETH/DEC19 | buy  | 1      | 1101  | 0                | TYPE_LIMIT | TIF_GTC | ref-8     |
   165  
   166      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC19"
   167      And the market state should be "STATE_SUSPENDED" for the market "ETH/DEC19"
   168  
   169      # check bond
   170      And the parties should have the following account balances:
   171        | party  | asset | market id | margin | general | bond  |
   172        | lpprov | ETH   | ETH/DEC19 | 0      | 10100   | 90000 |
   173      # check margin
   174      And the parties should have the following account balances:
   175        | party | asset | market id | margin | general |
   176        | aux1  | ETH   | ETH/DEC19 | 564    | 99436   |
   177        | aux2  | ETH   | ETH/DEC19 | 540    | 99460   |
   178      # check positions
   179      Then the parties should have the following profit and loss:
   180        | party  | volume | unrealised pnl | realised pnl |
   181        | aux1   | 1      | 0              | 0            |
   182        | aux2   | -1     | 0              | 0            |
   183  
   184      When the oracles broadcast data signed with "0xCAFECAFE":
   185        | name               | value |
   186        | trading.terminated | true  |
   187      And time is updated to "2020-01-01T01:01:01Z"
   188      Then the market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC19"
   189      # check margin
   190      And the parties should have the following account balances:
   191        | party | asset | market id | margin | general |
   192        | aux1  | ETH   | ETH/DEC19 | 564    | 99436   |
   193        | aux2  | ETH   | ETH/DEC19 | 540    | 99460   |
   194      # check positions
   195      Then the parties should have the following profit and loss:
   196        | party  | volume | unrealised pnl | realised pnl |
   197        | aux1   | 1      | 0              | 0            |
   198        | aux2   | -1     | 0              | 0            |
   199  
   200      When the oracles broadcast data signed with "0xCAFECAFE":
   201        | name             | value |
   202        | prices.ETH.value | 42    |
   203      Then time is updated to "2020-01-01T01:01:02Z"
   204  
   205      # check margin
   206      And the parties should have the following account balances:
   207        | party | asset | market id | margin | general |
   208        | aux1  | ETH   | ETH/DEC19 | 0      | 99042   |
   209        | aux2  | ETH   | ETH/DEC19 | 0      | 100958  |
   210      
   211      # check bond
   212      And the parties should have the following account balances:
   213        | party   | asset | market id | margin | general | bond   |
   214        | lpprov  | ETH   | ETH/DEC19 | 0      | 100100  | 0      |
   215      
   216      # check positions
   217      And the parties should have the following profit and loss:
   218        | party  | volume | unrealised pnl | realised pnl |
   219        | aux1   | 1      | 0              | -958         |
   220        | aux2   | -1     | 0              | 958          |
   221  
   222      Then the network moves ahead "2" blocks
   223      And the insurance pool balance should be "0" for the market "ETH/DEC19"
   224      And the global insurance pool balance should be "942" for the asset "ETH"
   225  
   226      Scenario: Settlement data to cash settled future is submitted before trading is terminated (0002-STTL-013)
   227      Given the parties deposit on asset's general account the following amount:
   228        | party  | asset | amount |
   229        | aux1   | ETH   | 1000000 |
   230        | aux2   | ETH   | 1000000 |
   231        | lpprov | ETH   | 100000  |
   232  
   233      When the parties submit the following liquidity provision:
   234        | id  | party  | market id | commitment amount | fee | lp type    |
   235        | lp1 | lpprov | ETH/DEC19 | 90000             | 0.1 | submission |
   236        | lp1 | lpprov | ETH/DEC19 | 90000             | 0.1 | submission |
   237      And the parties place the following pegged iceberg orders:
   238        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
   239        | lpprov | ETH/DEC19 | 2         | 1                    | buy  | BID              | 50         | 10     |
   240        | lpprov | ETH/DEC19 | 2         | 1                    | sell | ASK              | 50         | 10     |
   241  
   242      When the parties place the following orders:
   243        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
   244        | aux1  | ETH/DEC19 | buy  | 1      | 999   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
   245        | aux2  | ETH/DEC19 | sell | 1      | 1001  | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
   246        | aux1  | ETH/DEC19 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | ref-3     |
   247        | aux2  | ETH/DEC19 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | ref-4     |
   248      Then the opening auction period ends for market "ETH/DEC19"
   249      And the mark price should be "1000" for the market "ETH/DEC19"
   250      And the market state should be "STATE_ACTIVE" for the market "ETH/DEC19"
   251      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
   252      And the insurance pool balance should be "1000" for the market "ETH/DEC19"
   253      
   254      # check bond
   255      And the parties should have the following account balances:
   256        | party | asset | market id   | margin | general | bond  |
   257        | lpprov  | ETH   | ETH/DEC19 | 6600   | 3400    | 90000 |
   258      # check margin
   259      And the parties should have the following account balances:
   260        | party | asset | market id | margin | general |
   261        | aux1  | ETH   | ETH/DEC19 | 564    | 999436   |
   262        | aux2  | ETH   | ETH/DEC19 | 540    | 999460   |
   263      # check positions
   264      Then the parties should have the following profit and loss:
   265        | party  | volume | unrealised pnl | realised pnl |
   266        | aux1   | 1      | 0              | 0            |
   267        | aux2   | -1     | 0              | 0            |
   268  
   269      When the oracles broadcast data signed with "0xCAFECAFE":
   270        | name             | value |
   271        | prices.ETH.value | 42    |
   272      Then time is updated to "2020-01-01T01:01:02Z"
   273      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
   274  
   275      When the parties place the following orders:
   276        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
   277        | aux1  | ETH/DEC19 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | ref-5     |
   278        | aux2  | ETH/DEC19 | sell | 1      | 1000  | 1                | TYPE_LIMIT | TIF_GTC | ref-6     |
   279  
   280      And the following trades should be executed:
   281        | buyer  | price | size | seller |
   282        | aux1   | 1000  | 1    | aux2   |
   283  
   284      When the oracles broadcast data signed with "0xCAFECAFE":
   285        | name             | value |
   286        | prices.ETH.value | 45    |
   287      Then time is updated to "2020-01-01T01:01:02Z"
   288      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
   289  
   290      When the parties place the following orders:
   291        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
   292        | aux1  | ETH/DEC19 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | ref-7     |
   293        | aux2  | ETH/DEC19 | sell | 1      | 1000  | 1                | TYPE_LIMIT | TIF_GTC | ref-8     |
   294  
   295      And the following trades should be executed:
   296        | buyer  | price | size | seller |
   297        | aux1   | 1000  | 1    | aux2   |
   298    
   299      When the oracles broadcast data signed with "0xCAFECAFE":
   300        | name               | value |
   301        | trading.terminated | true  |
   302      And time is updated to "2020-01-01T01:01:01Z"
   303      
   304      # check margin
   305      And the parties should have the following account balances:
   306        | party | asset | market id | margin | general |
   307        | aux1  | ETH   | ETH/DEC19 | 0      | 997135  |
   308        | aux2  | ETH   | ETH/DEC19 | 0      | 1002665 |
   309      # check positions
   310      Then the parties should have the following profit and loss:
   311        | party  | volume | unrealised pnl | realised pnl |
   312        | aux1   | 3      | 0              | -2865        |
   313        | aux2   | -3     | 0              | 2865         |
   314  
   315      # check bond
   316      And the parties should have the following account balances:
   317        | party   | asset | market id | margin | general | bond   |
   318        | lpprov  | ETH   | ETH/DEC19 | 0      | 100200  | 0      |
   319    
   320      And the network moves ahead "2" blocks
   321      And the insurance pool balance should be "0" for the market "ETH/DEC19"
   322      And the global insurance pool balance should be "1000" for the asset "ETH"