code.vegaprotocol.io/vega@v0.79.0/core/integration/features/price_monitoring/post-auction-reference-price-with-oracle.feature (about)

     1  Feature: Test price monitoring engine with oracle based mark price
     2    Background:
     3      Given the following network parameters are set:
     4        | name                                    | value |
     5        | network.markPriceUpdateMaximumFrequency | 4s    |
     6        | limits.markets.maxPeggedOrders          | 2     |
     7      And the liquidity monitoring parameters:
     8        | name       | triggering ratio | time window | scaling factor |
     9        | lqm-params | 0.00             | 24h         | 1e-9           |
    10      And the simple risk model named "simple-risk-model":
    11        | long | short | max move up | min move down | probability of trading |
    12        | 0.1  | 0.1   | 100         | -100          | 0.2                    |
    13      And the price monitoring named "price-monitoring":
    14        | horizon | probability | auction extension |
    15        | 5       | 0.99        | 3                 |
    16      And the composite price oracles from "0xCAFECAFE1":
    17        | name    | price property   | price type   | price decimals |
    18        | oracle1 | prices.ETH.value | TYPE_INTEGER | 0              |
    19      And the markets:
    20        | id        | quote name | asset | liquidity monitoring | risk model        | margin calculator         | auction duration | fees         | price monitoring | data source config     | linear slippage factor | quadratic slippage factor | sla params      | price type | decay weight | decay power | cash amount | source weights | source staleness tolerance | oracle1 | market type |
    21        | ETH/FEB23 | ETH        | USD   | lqm-params           | simple-risk-model | default-margin-calculator | 5                | default-none | price-monitoring | default-eth-for-future | 0.25                   | 0                         | default-futures | weight     | 0.1          | 0.5         | 500000      | 0,0,1,0        | 0s,0s,10s,0s           | oracle1 | future      |
    22  
    23    Scenario: reference price after uncrossing the auction is the weighted average of traded volume and mark price (with a weight of 1)
    24      Given the parties deposit on asset's general account the following amount:
    25        | party             | asset | amount       |
    26        | buySideProvider   | USD   | 100000000000 |
    27        | sellSideProvider  | USD   | 100000000000 |
    28        | lp1               | USD   | 100000000000 |
    29      And the parties submit the following liquidity provision:
    30        | id  | party  | market id | commitment amount | fee   | lp type    |
    31        | lp1 | lp1    | ETH/FEB23 | 50000             | 0.001 | submission |
    32        | lp1 | lp1    | ETH/FEB23 | 50000             | 0.001 | amendment  |
    33      And the parties place the following pegged iceberg orders:
    34        | party | market id | peak size | minimum visible size | side | pegged reference | volume  | offset |
    35        | lp1   | ETH/FEB23 | 49        | 1                    | sell | ASK              | 49      | 20     |
    36        | lp1   | ETH/FEB23 | 52        | 1                    | buy  | BID              | 52      | 20     |
    37      And the parties place the following orders:
    38        | party             | market id | side | volume | price  | resulting trades | type       | tif     | reference    |
    39        | lp1               | ETH/FEB23 | buy  | 1      | 15899  | 0                | TYPE_LIMIT | TIF_GTC |              |
    40        | lp1               | ETH/FEB23 | sell | 1      | 15901  | 0                | TYPE_LIMIT | TIF_GTC |              |
    41        | buySideProvider   | ETH/FEB23 | buy  | 1      | 1      | 0                | TYPE_LIMIT | TIF_GTC |              |
    42        | buySideProvider   | ETH/FEB23 | buy  | 1      | 15900  | 0                | TYPE_LIMIT | TIF_GTC |              |
    43        | sellSideProvider  | ETH/FEB23 | sell | 1      | 15900  | 0                | TYPE_LIMIT | TIF_GTC |              |
    44        | sellSideProvider  | ETH/FEB23 | sell | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC |              |
    45  
    46      When the network moves ahead "1" blocks
    47      Then the mark price should be "0" for the market "ETH/FEB23"
    48      And the trading mode should be "TRADING_MODE_OPENING_AUCTION" for the market "ETH/FEB23"
    49  
    50      Then the oracles broadcast data with block time signed with "0xCAFECAFE1":
    51        | name             | value | time offset |
    52        | prices.ETH.value | 16000 | -1s         |
    53      And the market data for the market "ETH/FEB23" should be:
    54        | mark price | trading mode                 | horizon | min bound | max bound |
    55        | 0          | TRADING_MODE_OPENING_AUCTION | 5       | 15801     | 15999     |
    56  
    57  
    58      When the network moves ahead "5" blocks
    59      Then the market data for the market "ETH/FEB23" should be:
    60        | mark price | trading mode                    | auction trigger             | horizon | min bound | max bound |
    61        | 16000      | TRADING_MODE_CONTINUOUS         | AUCTION_TRIGGER_UNSPECIFIED | 5       | 15900     | 16100     |
    62      
    63      When the parties place the following orders with ticks:
    64        | party             | market id | side | volume | price  | resulting trades | type       | tif     | reference    |
    65        | buySideProvider   | ETH/FEB23 | buy  | 10     | 14000  | 0                | TYPE_LIMIT | TIF_GTC |              |
    66        | sellSideProvider  | ETH/FEB23 | sell | 10     | 14000  | 0                | TYPE_LIMIT | TIF_GTC |              |
    67      Then the market data for the market "ETH/FEB23" should be:
    68        | mark price | trading mode                    | auction trigger       |
    69        | 16000      | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE |
    70  
    71      When the oracles broadcast data with block time signed with "0xCAFECAFE1":
    72        | name             | value | time offset |
    73        | prices.ETH.value | 14050 | -1s         |
    74      And the network moves ahead "5" blocks
    75      Then the market data for the market "ETH/FEB23" should be:
    76        | mark price | trading mode                    | auction trigger             | ref price | horizon | min bound | max bound |
    77        | 14050      | TRADING_MODE_CONTINUOUS         | AUCTION_TRIGGER_UNSPECIFIED | 14025     | 5       | 13925     | 14125     |
    78  
    79  Scenario: when previous mark price is outside the bounds implied by the auction uncrossing trade the market will only return to continuous trading once the last oracle feed became stale
    80      Given the parties deposit on asset's general account the following amount:
    81        | party             | asset | amount       |
    82        | buySideProvider   | USD   | 100000000000 |
    83        | sellSideProvider  | USD   | 100000000000 |
    84        | lp1               | USD   | 100000000000 |
    85      And the parties submit the following liquidity provision:
    86        | id  | party  | market id | commitment amount | fee   | lp type    |
    87        | lp1 | lp1    | ETH/FEB23 | 50000             | 0.001 | submission |
    88        | lp1 | lp1    | ETH/FEB23 | 50000             | 0.001 | amendment  |
    89      And the parties place the following pegged iceberg orders:
    90        | party | market id | peak size | minimum visible size | side | pegged reference | volume  | offset |
    91        | lp1   | ETH/FEB23 | 49        | 1                    | sell | ASK              | 49      | 20     |
    92        | lp1   | ETH/FEB23 | 52        | 1                    | buy  | BID              | 52      | 20     |
    93      And the parties place the following orders:
    94        | party             | market id | side | volume | price  | resulting trades | type       | tif     | reference    |
    95        | lp1               | ETH/FEB23 | buy  | 1      | 15899  | 0                | TYPE_LIMIT | TIF_GTC |              |
    96        | lp1               | ETH/FEB23 | sell | 1      | 15901  | 0                | TYPE_LIMIT | TIF_GTC |              |
    97        | buySideProvider   | ETH/FEB23 | buy  | 1      | 1      | 0                | TYPE_LIMIT | TIF_GTC |              |
    98        | buySideProvider   | ETH/FEB23 | buy  | 1      | 15900  | 0                | TYPE_LIMIT | TIF_GTC |              |
    99        | sellSideProvider  | ETH/FEB23 | sell | 1      | 15900  | 0                | TYPE_LIMIT | TIF_GTC |              |
   100        | sellSideProvider  | ETH/FEB23 | sell | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC |              |
   101  
   102      When the network moves ahead "1" blocks
   103      Then the mark price should be "0" for the market "ETH/FEB23"
   104      And the trading mode should be "TRADING_MODE_OPENING_AUCTION" for the market "ETH/FEB23"
   105  
   106      Then the oracles broadcast data with block time signed with "0xCAFECAFE1":
   107        | name             | value | time offset |
   108        | prices.ETH.value | 16000 | -1s         |
   109      And the market data for the market "ETH/FEB23" should be:
   110        | mark price | trading mode                 | horizon | min bound | max bound |
   111        | 0          | TRADING_MODE_OPENING_AUCTION | 5       | 15801     | 15999     |
   112  
   113  
   114      When the network moves ahead "5" blocks
   115      Then the market data for the market "ETH/FEB23" should be:
   116        | mark price | trading mode                    | auction trigger             | horizon | min bound | max bound |
   117        | 16000      | TRADING_MODE_CONTINUOUS         | AUCTION_TRIGGER_UNSPECIFIED | 5       | 15900     | 16100     |
   118      
   119      When the parties place the following orders with ticks:
   120        | party             | market id | side | volume | price  | resulting trades | type       | tif     | reference    |
   121        | buySideProvider   | ETH/FEB23 | buy  | 10     | 14000  | 0                | TYPE_LIMIT | TIF_GTC |              |
   122        | sellSideProvider  | ETH/FEB23 | sell | 10     | 14000  | 0                | TYPE_LIMIT | TIF_GTC |              |
   123      Then the market data for the market "ETH/FEB23" should be:
   124        | mark price | trading mode                    | auction trigger       |
   125        | 16000      | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE |
   126  
   127      When the network moves ahead "5" blocks
   128      Then the market data for the market "ETH/FEB23" should be:
   129        | mark price | trading mode                    | auction trigger       |
   130        | 16000      | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE |
   131  
   132      When the network moves ahead "3" blocks
   133      Then the market data for the market "ETH/FEB23" should be:
   134        | mark price | trading mode                    | auction trigger             | ref price | horizon | min bound | max bound |
   135        | 16000      | TRADING_MODE_CONTINUOUS         | AUCTION_TRIGGER_UNSPECIFIED | 14000     | 5       | 13901     | 14099     |
   136