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

     1  Feature: Test settlement at expiry time from internal oracle
     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 "vegaprotocol.builtin" named "ethDec20Oracle":
    12        | property                       | type           | binding             | condition                      | value                |
    13        | vegaprotocol.builtin.timestamp | TYPE_TIMESTAMP | trading termination | OPERATOR_GREATER_THAN_OR_EQUAL | 2019-12-31T23:59:59Z |
    14  
    15      And the oracle spec for settlement data filtering data from "0xCAFECAFE1" named "ethDec21Oracle":
    16        | property         | type         | binding         |
    17        | prices.ETH.value | TYPE_INTEGER | settlement data |
    18  
    19      And the oracle spec for trading termination filtering data from "0xCAFECAFE1" named "ethDec21Oracle":
    20        | property           | type         | binding             |
    21        | trading.terminated | TYPE_BOOLEAN | trading termination |
    22  
    23      And the settlement data decimals for the oracle named "ethDec20Oracle" is given in "0" decimal places
    24      And the settlement data decimals for the oracle named "ethDec21Oracle" is given in "0" decimal places
    25  
    26      And the following network parameters are set:
    27        | name                                    | value |
    28        | market.auction.minimumDuration          | 1     |
    29        | network.markPriceUpdateMaximumFrequency | 0s    |
    30        | limits.markets.maxPeggedOrders          | 2     |
    31  
    32      And the fees configuration named "fees-config-1":
    33        | maker fee | infrastructure fee |
    34        | 0.005     | 0.02               |
    35      And the price monitoring named "price-monitoring-1":
    36        | horizon | probability | auction extension |
    37        | 1       | 0.99        | 300               |
    38      And the simple risk model named "simple-risk-model-1":
    39        | long | short | max move up | min move down | probability of trading |
    40        | 0.2  | 0.1   | 100         | -100          | 0.1                    |
    41  
    42      And the markets:
    43        | id        | quote name | asset | risk model                  | margin calculator         | auction duration | fees          | price monitoring   | data source config | linear slippage factor | quadratic slippage factor | sla params      |
    44        | ETH/DEC19 | ETH        | ETH   | default-simple-risk-model-3 | default-margin-calculator | 1                | default-none  | default-none       | ethDec20Oracle     | 0.25                   | 0                         | default-futures |
    45        | ETH/DEC21 | ETH        | ETH   | simple-risk-model-1         | default-margin-calculator | 1                | fees-config-1 | price-monitoring-1 | ethDec21Oracle     | 0.25                   | 0                         | default-futures |
    46  
    47    @STest
    48    Scenario: Order cannot be placed once the market is expired
    49      Given the parties deposit on asset's general account the following amount:
    50        | party  | asset | amount |
    51        | party1 | ETH   | 10000  |
    52        | aux1   | ETH   | 100000 |
    53        | aux2   | ETH   | 100000 |
    54        | lpprov | ETH   | 100000 |
    55      And the following network parameters are set:
    56        | name                                    | value |
    57        | network.markPriceUpdateMaximumFrequency | 5s    |
    58        | limits.markets.maxPeggedOrders          | 2     |
    59  
    60      When the parties submit the following liquidity provision:
    61        | id  | party  | market id | commitment amount | fee   | lp type    |
    62        | lp1 | lpprov | ETH/DEC19 | 10000             | 0.001 | submission |
    63        | lp1 | lpprov | ETH/DEC19 | 10000             | 0.001 | submission |
    64      And the parties place the following pegged iceberg orders:
    65        | party  | market id | peak size | minimum visible size | side | pegged reference | volume | offset |
    66        | lpprov | ETH/DEC19 | 2         | 1                    | buy  | BID              | 50     | 1      |
    67        | lpprov | ETH/DEC19 | 2         | 1                    | sell | ASK              | 50     | 1      |
    68    
    69      And the parties place the following orders:
    70        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
    71        | aux1  | ETH/DEC19 | buy  | 1      | 999   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    72        | aux2  | ETH/DEC19 | sell | 1      | 1010  | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
    73        | aux1  | ETH/DEC19 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | ref-3     |
    74        | aux2  | ETH/DEC19 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | ref-4     |
    75      Then the opening auction period ends for market "ETH/DEC19"
    76      And the mark price should be "1000" for the market "ETH/DEC19"
    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  
    82      # The oracle terminates trading at this time
    83      # vegaprotocol.builtin.timestamp | TYPE_TIMESTAMP | trading termination | OPERATOR_GREATER_THAN_OR_EQUAL | 2019-12-31T23:59:59Z |
    84      # So let's make some trades happen Before final settlement
    85  
    86      When time is updated to "2019-12-31T23:59:57Z"
    87      And the parties place the following orders with ticks:
    88        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    89        | party1 | ETH/DEC19 | sell | 1      | 1005  | 0                | TYPE_LIMIT | TIF_GTC | ref-5     |
    90        | aux1   | ETH/DEC19 | buy  | 1      | 1005  | 1                | TYPE_LIMIT | TIF_GTC | ref-6     |
    91      Then the parties should have the following account balances:
    92        | party  | asset | market id | margin | general |
    93        | party1 | ETH   | ETH/DEC19 | 120    | 9880    |
    94        | aux1   | ETH   | ETH/DEC19 | 696    | 99302   |
    95        | aux2   | ETH   | ETH/DEC19 | 540    | 99460   |
    96  
    97      When time is updated to "2020-01-01T01:01:01Z"
    98      Then the market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC19"
    99      When the oracles broadcast data signed with "0xCAFECAFE":
   100        | name             | value |
   101        | prices.ETH.value | 42    |
   102      And time is updated to "2020-01-01T01:01:02Z"
   103      Then the parties should have the following account balances:
   104        | party  | asset | market id | margin | general |
   105        | party1 | ETH   | ETH/DEC19 | 0      | 10963   |
   106        | aux1   | ETH   | ETH/DEC19 | 0      | 98077   |
   107        | aux2   | ETH   | ETH/DEC19 | 0      | 100958  |
   108  
   109      When the parties place the following orders with ticks:
   110        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference | error                         |
   111        | party1 | ETH/DEC19 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | ref-7     | OrderError: Invalid Market ID |