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

     1  Feature: Test setting of mark price from 2 oracles - check mark price is updating on schedule (AC 0009-MRKP-131)
     2      Background:
     3          Given the following network parameters are set:
     4              | name                                    | value |
     5              | network.markPriceUpdateMaximumFrequency | 5s    |
     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          # 1s into the mark price period
    55          Then the oracles broadcast data with block time signed with "0xCAFECAFE1":
    56              | name             | value | time offset |
    57              | price1.USD.value | 16000 | -1s         |
    58          Then the mark price should be "15900" for the market "ETH/FEB23"
    59  
    60          # 2s into the mark price period
    61          When the network moves ahead "1" blocks
    62          Then the oracles broadcast data with block time signed with "0xCAFECAFE1":
    63              | name             | value | time offset |
    64              | price2.USD.value | 15000 | -1s         |
    65          Then the mark price should be "15900" for the market "ETH/FEB23"
    66  
    67          # 3s into the mark price period
    68          When the network moves ahead "1" blocks
    69          Then the mark price should be "15900" for the market "ETH/FEB23"
    70  
    71          # 4s into the mark price period
    72          When the network moves ahead "1" blocks
    73          Then the mark price should be "15900" for the market "ETH/FEB23"
    74  
    75          # 5s into the mark price period
    76          When the network moves ahead "1" blocks
    77          Then the mark price should be "15900" for the market "ETH/FEB23"
    78  
    79          # now mtm has happened
    80          When the network moves ahead "1" blocks
    81          Then the mark price should be "15250" for the market "ETH/FEB23"
    82  
    83          Then the oracles broadcast data with block time signed with "0xCAFECAFE1":
    84              | name             | value | time offset |
    85              | price2.USD.value | 20000 | -1s         |
    86          When the network moves ahead "3" blocks
    87  
    88          Then the oracles broadcast data with block time signed with "0xCAFECAFE1":
    89              | name             | value | time offset |
    90              | price1.USD.value | 10000 | -1s         |
    91          When the network moves ahead "2" blocks
    92          # 10000*0.25+20000*0.75 = 17500
    93          Then the mark price should be "17500" for the market "ETH/FEB23"
    94  
    95          
    96  
    97  
    98  
    99