code.vegaprotocol.io/vega@v0.79.0/core/integration/features/mark-price/0009-MRKP-028.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  
     7      And the perpetual oracles from "0xCAFECAFE1":
     8        | 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 |
     9        | perp-oracle | USD   | perp.ETH.value      | TYPE_INTEGER    | perp.funding.cue  | TYPE_TIMESTAMP | 0.5                   | 0.05          | 0.1               | 0.9               | ETH        | 18                  |
    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      And the markets:
    17        | 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 | market type |
    18        | 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           | 50000000    | 1,1,0,0        | 8s,5s,24h0m0s,1h25m0s      | future      |
    19        | 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           | 50000000    | 1,1,0,0        | 8s,5s,24h0m0s,1h25m0s      | perp        |
    20  
    21    Scenario: 001 check mark price using weight average
    22      Given the parties deposit on asset's general account the following amount:
    23        | party             | asset | amount       |
    24        | buySideProvider   | USD   | 100000000000 |
    25        | sellSideProvider  | USD   | 100000000000 |
    26        | party             | USD   | 48050        |
    27        | buySideProvider1  | USD   | 100000000000 |
    28        | sellSideProvider1 | USD   | 100000000000 |
    29        | party1            | USD   | 48050        |
    30      And the parties place the following orders:
    31        | party             | market id | side | volume | price  | resulting trades | type       | tif     | reference |
    32        | buySideProvider   | ETH/FEB23 | buy  | 5      | 14900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    33        | buySideProvider   | ETH/FEB23 | buy  | 1      | 15000  | 0                | TYPE_LIMIT | TIF_GTC |           |
    34        | buySideProvider   | ETH/FEB23 | buy  | 3      | 15900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    35        | party             | ETH/FEB23 | sell | 3      | 15900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    36        | sellSideProvider  | ETH/FEB23 | sell | 2      | 15920  | 0                | TYPE_LIMIT | TIF_GTC | sell-2    |
    37        | sellSideProvider  | ETH/FEB23 | sell | 1      | 15940  | 0                | TYPE_LIMIT | TIF_GTC | sell-3    |
    38        | sellSideProvider  | ETH/FEB23 | sell | 3      | 15960  | 0                | TYPE_LIMIT | TIF_GTC | sell-4    |
    39        | sellSideProvider  | ETH/FEB23 | sell | 5      | 15990  | 0                | TYPE_LIMIT | TIF_GTC | sell-5    |
    40        | sellSideProvider  | ETH/FEB23 | sell | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC |           |
    41        | buySideProvider1  | ETH/FEB22 | buy  | 5      | 14900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    42        | buySideProvider1  | ETH/FEB22 | buy  | 1      | 15000  | 0                | TYPE_LIMIT | TIF_GTC |           |
    43        | buySideProvider1  | ETH/FEB22 | buy  | 3      | 15900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    44        | party1            | ETH/FEB22 | sell | 3      | 15900  | 0                | TYPE_LIMIT | TIF_GTC |           |
    45        | sellSideProvider1 | ETH/FEB22 | sell | 2      | 15920  | 0                | TYPE_LIMIT | TIF_GTC | sell-2    |
    46        | sellSideProvider1 | ETH/FEB22 | sell | 1      | 15940  | 0                | TYPE_LIMIT | TIF_GTC | sell-3    |
    47        | sellSideProvider1 | ETH/FEB22 | sell | 3      | 15960  | 0                | TYPE_LIMIT | TIF_GTC | sell-4    |
    48        | sellSideProvider1 | ETH/FEB22 | sell | 5      | 15990  | 0                | TYPE_LIMIT | TIF_GTC | sell-5    |
    49        | sellSideProvider1 | ETH/FEB22 | sell | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC |           |
    50  
    51      # AC 0009-MRKP-028,0009-MRKP-029
    52      When the network moves ahead "2" blocks
    53      Then the mark price should be "15900" for the market "ETH/FEB23"
    54      Then the mark price should be "15900" for the market "ETH/FEB22"
    55  
    56      And the parties place the following orders:
    57        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference |
    58        | buySideProvider  | ETH/FEB23 | buy  | 2      | 15920 | 1                | TYPE_LIMIT | TIF_GTC |           |
    59        | buySideProvider1 | ETH/FEB22 | buy  | 2      | 15920 | 1                | TYPE_LIMIT | TIF_GTC |           |
    60      When the network moves ahead "1" blocks
    61      Then the mark price should be "15900" for the market "ETH/FEB23"
    62      Then the mark price should be "15900" for the market "ETH/FEB22"
    63  
    64      And the parties place the following orders:
    65        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference |
    66        | buySideProvider  | ETH/FEB23 | buy  | 1      | 15940 | 1                | TYPE_LIMIT | TIF_GTC |           |
    67        | buySideProvider1 | ETH/FEB22 | buy  | 1      | 15940 | 1                | TYPE_LIMIT | TIF_GTC |           |
    68      When the network moves ahead "1" blocks
    69      Then the mark price should be "15900" for the market "ETH/FEB23"
    70      Then the mark price should be "15900" for the market "ETH/FEB22"
    71  
    72      And the parties place the following orders:
    73        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference |
    74        | buySideProvider  | ETH/FEB23 | buy  | 3      | 15960 | 1                | TYPE_LIMIT | TIF_GTC |           |
    75        | buySideProvider1 | ETH/FEB22 | buy  | 3      | 15960 | 1                | TYPE_LIMIT | TIF_GTC |           |
    76      When the network moves ahead "1" blocks
    77      Then the mark price should be "15900" for the market "ETH/FEB23"
    78      Then the mark price should be "15900" for the market "ETH/FEB22"
    79  
    80      And the parties place the following orders:
    81        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference |
    82        | buySideProvider  | ETH/FEB23 | buy  | 5      | 15990 | 1                | TYPE_LIMIT | TIF_GTC |           |
    83        | buySideProvider1 | ETH/FEB22 | buy  | 5      | 15990 | 1                | TYPE_LIMIT | TIF_GTC |           |
    84      When the network moves ahead "1" blocks
    85      Then the mark price should be "15900" for the market "ETH/FEB23"
    86      Then the mark price should be "15900" for the market "ETH/FEB22"
    87  
    88      #decay weight is 1, so with time weight, mark price is: (15920*2*0+15940*1*0.25+15960*3*0.5+15990*5*0.75)/11=15979
    89      #median of (15900, 15979)=15939
    90      When the network moves ahead "1" blocks
    91      Then the mark price should be "15939" for the market "ETH/FEB23"
    92      Then the mark price should be "15939" for the market "ETH/FEB22"
    93  
    94      #AC 0009-MRKP-020,0009-MRKP-021
    95      #book mark price is stale, and we only have trade mark price available
    96      When the network moves ahead "4" blocks
    97      Then the mark price should be "15979" for the market "ETH/FEB23"
    98      Then the mark price should be "15979" for the market "ETH/FEB22"
    99  
   100  
   101  
   102  
   103  
   104  
   105