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

     1  Feature: Test setting of mark price
     2    Background:
     3      Given the following network parameters are set:
     4        | name                                    | value |
     5        | network.markPriceUpdateMaximumFrequency | 4s    |
     6      And the perpetual oracles from "0xCAFECAFE1":
     7        | name        | asset | settlement property | settlement type | schedule property | schedule type  | margin funding factor | interest rate | clamp lower bound | clamp upper bound | quote name | settlement decimals |
     8        | perp-oracle | USD   | perp.ETH.value      | TYPE_INTEGER    | perp.funding.cue  | TYPE_TIMESTAMP | 0.5                   | 0.05          | 0.1               | 0.9               | ETH        | 18                  |
     9  
    10      And the liquidity monitoring parameters:
    11        | name       | triggering ratio | time window | scaling factor |
    12        | lqm-params | 0.00             | 24h         | 1e-9           |
    13      And the simple risk model named "simple-risk-model":
    14        | long | short | max move up | min move down | probability of trading |
    15        | 0.1  | 0.1   | 100         | -100          | 0.2                    |
    16  
    17      # this is just an example of setting up oracles
    18      And the composite price oracles from "0xCAFECAFE1":
    19        | name    | price property   | price type   | price decimals |
    20        | oracle1 | price1.USD.value | TYPE_INTEGER | 0              |
    21        | oracle2 | price2.USD.value | TYPE_INTEGER | 0              |
    22        | oracle3 | price3.USD.value | TYPE_INTEGER | 0              |
    23        | oracle4 | price4.USD.value | TYPE_INTEGER | 0              |
    24        | oracle5 | price4.USD.value | TYPE_INTEGER | 0              |
    25  
    26      And the markets:
    27        | 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 | oracle3 | oracle4 | oracle5 | market type |
    28        | 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           | 1,0,0,0,0,0,0,0 | 3h0m0s,2s,24h0m0s,24h0m0s,24h0m0s,24h0m0s,24h0m0s,1h25m0s | oracle1 | oracle2 | oracle3 | oracle4 | oracle5 | future      |
    29        | ETH/FEB22 | ETH        | USD   | lqm-params           | simple-risk-model | default-margin-calculator | 1                | default-none | default-none     | perp-oracle            | 0.25                   | 0                         | default-futures | weight     | 1            | 1           | 0           | 1,0,0,0,0,0,0,0 | 3h0m0s,2s,24h0m0s,24h0m0s,24h0m0s,24h0m0s,24h0m0s,1h25m0s | oracle1 | oracle2 | oracle3 | oracle4 | oracle5 | perp        |
    30    Scenario: 001 check mark price using weight average
    31      Given the parties deposit on asset's general account the following amount:
    32        | party             | asset | amount       |
    33        | buySideProvider   | USD   | 100000000000 |
    34        | sellSideProvider  | USD   | 100000000000 |
    35        | party             | USD   | 48050        |
    36        | buySideProvider1  | USD   | 100000000000 |
    37        | sellSideProvider1 | USD   | 100000000000 |
    38        | party1            | USD   | 48050        |
    39      And the parties place the following orders:
    40        | party             | market id | side | volume | price  | resulting trades | type       | tif     | reference |
    41        | buySideProvider   | ETH/FEB23 | buy  | 10     | 14900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    42        | buySideProvider   | ETH/FEB23 | buy  | 1      | 15000  | 0                | TYPE_LIMIT | TIF_GTC |           |
    43        | buySideProvider   | ETH/FEB23 | buy  | 3      | 15900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    44        | party             | ETH/FEB23 | sell | 3      | 15900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    45        | sellSideProvider  | ETH/FEB23 | sell | 2      | 15920  | 0                | TYPE_LIMIT | TIF_GTC | sell-2    |
    46        | sellSideProvider  | ETH/FEB23 | sell | 1      | 15940  | 0                | TYPE_LIMIT | TIF_GTC | sell-3    |
    47        | sellSideProvider  | ETH/FEB23 | sell | 3      | 15960  | 0                | TYPE_LIMIT | TIF_GTC | sell-4    |
    48        | sellSideProvider  | ETH/FEB23 | sell | 5      | 15990  | 0                | TYPE_LIMIT | TIF_GTC | sell-5    |
    49        | sellSideProvider  | ETH/FEB23 | sell | 2      | 16000  | 0                | TYPE_LIMIT | TIF_GTC | sell-7    |
    50        | sellSideProvider  | ETH/FEB23 | sell | 4      | 16020  | 0                | TYPE_LIMIT | TIF_GTC | sell-8    |
    51        | sellSideProvider  | ETH/FEB23 | sell | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC |           |
    52        | buySideProvider1  | ETH/FEB22 | buy  | 10     | 14900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    53        | buySideProvider1  | ETH/FEB22 | buy  | 1      | 15000  | 0                | TYPE_LIMIT | TIF_GTC |           |
    54        | buySideProvider1  | ETH/FEB22 | buy  | 3      | 15900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    55        | party1            | ETH/FEB22 | sell | 3      | 15900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    56        | sellSideProvider1 | ETH/FEB22 | sell | 2      | 15920  | 0                | TYPE_LIMIT | TIF_GTC | sell-21   |
    57        | sellSideProvider1 | ETH/FEB22 | sell | 1      | 15940  | 0                | TYPE_LIMIT | TIF_GTC | sell-31   |
    58        | sellSideProvider1 | ETH/FEB22 | sell | 3      | 15960  | 0                | TYPE_LIMIT | TIF_GTC | sell-41   |
    59        | sellSideProvider1 | ETH/FEB22 | sell | 5      | 15990  | 0                | TYPE_LIMIT | TIF_GTC | sell-51   |
    60        | sellSideProvider1 | ETH/FEB22 | sell | 2      | 16000  | 0                | TYPE_LIMIT | TIF_GTC | sell-71   |
    61        | sellSideProvider1 | ETH/FEB22 | sell | 4      | 16020  | 0                | TYPE_LIMIT | TIF_GTC | sell-81   |
    62        | sellSideProvider1 | ETH/FEB22 | sell | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC |           |
    63  
    64      # AC 0009-MRKP-012,0009-MRKP-013
    65      When the network moves ahead "2" blocks
    66      Then the mark price should be "15900" for the market "ETH/FEB23"
    67      Then the mark price should be "15900" for the market "ETH/FEB22"
    68  
    69      And the parties place the following orders:
    70        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference |
    71        | buySideProvider  | ETH/FEB23 | buy  | 2      | 15920 | 1                | TYPE_LIMIT | TIF_GTC |           |
    72        | buySideProvider1 | ETH/FEB22 | buy  | 2      | 15920 | 1                | TYPE_LIMIT | TIF_GTC |           |
    73  
    74      When the network moves ahead "1" blocks
    75      Then the mark price should be "15900" for the market "ETH/FEB23"
    76      Then the mark price should be "15900" for the market "ETH/FEB22"
    77  
    78      And the parties place the following orders:
    79        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference |
    80        | buySideProvider  | ETH/FEB23 | buy  | 1      | 15940 | 1                | TYPE_LIMIT | TIF_GTC |           |
    81        | buySideProvider1 | ETH/FEB22 | buy  | 1      | 15940 | 1                | TYPE_LIMIT | TIF_GTC |           |
    82  
    83      When the network moves ahead "1" blocks
    84      Then the mark price should be "15900" for the market "ETH/FEB23"
    85  
    86      When the network moves ahead "2" blocks
    87      Then the mark price should be "15900" for the market "ETH/FEB23"
    88      Then the mark price should be "15900" for the market "ETH/FEB22"
    89  
    90      # example of pushing oracle prices
    91      Then the oracles broadcast data with block time signed with "0xCAFECAFE1":
    92        | name             | value | time offset |
    93        | price1.USD.value | 16000 | -1s         |
    94        | price2.USD.value | 15900 | -1s         |
    95        | price3.USD.value | 15940 | -1s         |
    96        | price4.USD.value | 16001 | -1s         |
    97        | price5.USD.value | 16002 | -1s         |
    98  
    99      When the network moves ahead "1" blocks
   100      Then the mark price should be "15940" for the market "ETH/FEB23"
   101      Then the mark price should be "15940" for the market "ETH/FEB22"
   102  
   103      When the markets are updated:
   104        | id        | decay weight | decay power | linear slippage factor | quadratic slippage factor |
   105        | ETH/FEB23 | 0            | 1           | 0.25                   | 0                         |
   106        | ETH/FEB22 | 0            | 1           | 0.25                   | 0                         |
   107  
   108      Then the mark price should be "15940" for the market "ETH/FEB23"
   109      Then the mark price should be "15940" for the market "ETH/FEB22"
   110  
   111      And the parties place the following orders:
   112        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference |
   113        | buySideProvider  | ETH/FEB23 | buy  | 3      | 15960 | 1                | TYPE_LIMIT | TIF_GTC |           |
   114        | buySideProvider1 | ETH/FEB22 | buy  | 3      | 15960 | 1                | TYPE_LIMIT | TIF_GTC |           |
   115  
   116      When the network moves ahead "1" blocks
   117      Then the mark price should be "15940" for the market "ETH/FEB23"
   118      Then the mark price should be "15940" for the market "ETH/FEB22"
   119  
   120      And the parties place the following orders:
   121        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference |
   122        | buySideProvider  | ETH/FEB23 | buy  | 5      | 15990 | 1                | TYPE_LIMIT | TIF_GTC |           |
   123        | buySideProvider1 | ETH/FEB22 | buy  | 5      | 15990 | 1                | TYPE_LIMIT | TIF_GTC |           |
   124  
   125      When the network moves ahead "2" blocks
   126      Then the mark price should be "15940" for the market "ETH/FEB23"
   127      Then the mark price should be "15940" for the market "ETH/FEB22"
   128  
   129      When the network moves ahead "1" blocks
   130      Then the mark price should be "15990" for the market "ETH/FEB23"
   131      Then the mark price should be "15990" for the market "ETH/FEB22"
   132  
   133