code.vegaprotocol.io/vega@v0.79.0/core/integration/features/mark-price/0009-MRKP-130.feature (about)

     1  Feature: Test setting of mark price from 2 oracles with one getting stale (AC 0009-MRKP-130)
     2      Background:
     3          Given the following network parameters are set:
     4              | name                                    | value |
     5              | network.markPriceUpdateMaximumFrequency | 1s    |
     6          And the liquidity monitoring parameters:
     7              | name       | triggering ratio | time window | scaling factor |
     8              | lqm-params | 0.00             | 24h         | 1e-9           |
     9          And the simple risk model named "simple-risk-model":
    10              | long | short | max move up | min move down | probability of trading |
    11              | 0.1  | 0.1   | 100         | -100          | 0.2                    |
    12  
    13          # this is just an example of setting up oracles
    14          And the composite price oracles from "0xCAFECAFE1":
    15              | name    | price property   | price type   | price decimals |
    16              | oracle1 | price1.USD.value | TYPE_INTEGER | 0              |
    17              | oracle2 | price2.USD.value | TYPE_INTEGER | 0              |
    18  
    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 | oracle2 |
    21              | ETH/FEB23 | ETH        | USD   | lqm-params           | simple-risk-model | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 0.25                   | 0                         | default-futures | weight     | 1            | 1           | 0           | 0,0,1,3,0      | 0s,0s,10s,20s,0s           | oracle1 | oracle2 |
    22  
    23      Scenario: 001 check mark price using weight average
    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              | party            | USD   | 48050        |
    29          And the parties place the following orders:
    30              | party            | market id | side | volume | price  | resulting trades | type       | tif     | reference |
    31              | buySideProvider  | ETH/FEB23 | buy  | 10     | 14900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    32              | buySideProvider  | ETH/FEB23 | buy  | 1      | 15000  | 0                | TYPE_LIMIT | TIF_GTC |           |
    33              | buySideProvider  | ETH/FEB23 | buy  | 3      | 15900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    34              | party            | ETH/FEB23 | sell | 3      | 15900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    35              | sellSideProvider | ETH/FEB23 | sell | 2      | 15920  | 0                | TYPE_LIMIT | TIF_GTC | sell-2    |
    36              | sellSideProvider | ETH/FEB23 | sell | 1      | 15940  | 0                | TYPE_LIMIT | TIF_GTC | sell-3    |
    37              | sellSideProvider | ETH/FEB23 | sell | 3      | 15960  | 0                | TYPE_LIMIT | TIF_GTC | sell-4    |
    38              | sellSideProvider | ETH/FEB23 | sell | 5      | 15990  | 0                | TYPE_LIMIT | TIF_GTC | sell-5    |
    39              | sellSideProvider | ETH/FEB23 | sell | 2      | 16000  | 0                | TYPE_LIMIT | TIF_GTC | sell-7    |
    40              | sellSideProvider | ETH/FEB23 | sell | 4      | 16020  | 0                | TYPE_LIMIT | TIF_GTC | sell-8    |
    41              | sellSideProvider | ETH/FEB23 | sell | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC |           |
    42  
    43          # AC 0009-MRKP-012
    44          When the network moves ahead "2" blocks
    45          Then the mark price should be "15900" for the market "ETH/FEB23"
    46  
    47          And the parties place the following orders:
    48              | party           | market id | side | volume | price | resulting trades | type       | tif     | reference |
    49              | buySideProvider | ETH/FEB23 | buy  | 2      | 15920 | 1                | TYPE_LIMIT | TIF_GTC |           |
    50  
    51          When the network moves ahead "1" blocks
    52          Then the mark price should be "15900" for the market "ETH/FEB23"
    53  
    54          And the parties place the following orders:
    55              | party           | market id | side | volume | price | resulting trades | type       | tif     | reference |
    56              | buySideProvider | ETH/FEB23 | buy  | 1      | 15940 | 1                | TYPE_LIMIT | TIF_GTC |           |
    57  
    58          When the network moves ahead "1" blocks
    59          Then the mark price should be "15900" for the market "ETH/FEB23"
    60  
    61          When the network moves ahead "2" blocks
    62          Then the mark price should be "15900" for the market "ETH/FEB23"
    63  
    64          # example of pushing oracle prices
    65          Then the oracles broadcast data with block time signed with "0xCAFECAFE1":
    66              | name             | value | time offset |
    67              | price1.USD.value | 16000 | -1s         |
    68  
    69          When the network moves ahead "1" blocks
    70          # only the first oracle has ticked so mark price is set fully from oracle1
    71          Then the mark price should be "16000" for the market "ETH/FEB23"
    72  
    73          When the network moves ahead "2" blocks
    74          Then the oracles broadcast data with block time signed with "0xCAFECAFE1":
    75              | name             | value | time offset |
    76              | price2.USD.value | 15900 | -1s         |
    77  
    78          When the network moves ahead "1" blocks
    79          # 0.25 * 16000 + 0.75 * 15900 = 15925
    80          Then the mark price should be "15925" for the market "ETH/FEB23"
    81  
    82          # lets get the first oracle price out of scope (it has 10s tolerance)
    83          When the network moves ahead "10" blocks
    84          # 0 * 16000 + 1 * 15900 = 15900
    85           Then the mark price should be "15900" for the market "ETH/FEB23"