code.vegaprotocol.io/vega@v0.79.0/core/integration/features/spot/orders/0032-PRIM-033.feature (about)

     1  Feature: Spot market
     2  
     3    Background:
     4      Given time is updated to "2024-01-01T00:00:00Z"
     5  
     6      Given the following network parameters are set:
     7        | name                                                | value |
     8        | network.markPriceUpdateMaximumFrequency             | 0s    |
     9        | market.value.windowLength                           | 1h    |
    10      
    11      Given the following assets are registered:
    12        | id  | decimal places |
    13        | ETH | 2              |
    14        | BTC | 2              |
    15  
    16      Given the fees configuration named "fees-config-1":
    17        | maker fee | infrastructure fee |
    18        | 0.01      | 0.03               |
    19      Given the log normal risk model named "lognormal-risk-model-1":
    20        | risk aversion | tau  | mu | r   | sigma |
    21        | 0.001         | 0.01 | 0  | 0.0 | 1.2   |
    22  
    23      Given the log normal risk model named "lognormal-risk-model-2":
    24        | risk aversion | tau  | mu | r   | sigma |
    25        | 0.002         | 0.02 | 0  | 0.1 | 1.3   |
    26  
    27      And the price monitoring named "price-monitoring-1":
    28        | horizon | probability | auction extension |
    29        | 30      | 0.999       | 10                |
    30        | 60      | 0.999       | 20                |
    31        | 90      | 0.999       | 40                |
    32        | 120     | 0.999       | 80                |
    33  
    34      And the spot markets:
    35        | id      | name    | base asset | quote asset | risk model             | auction duration | fees          | price monitoring   | decimal places | position decimal places | sla params    |
    36        | BTC/ETH | BTC/ETH | BTC        | ETH         | lognormal-risk-model-1 | 1                | fees-config-1 | price-monitoring-1 | 2              | 2                       | default-basic |
    37  
    38      # setup accounts
    39      Given the parties deposit on asset's general account the following amount:
    40        | party  | asset | amount |
    41        | party1 | ETH   | 10000  |
    42        | party1 | BTC   | 1000   |
    43        | party2 | ETH   | 10000  |
    44        | party4 | BTC   | 1000   |
    45        | party5 | BTC   | 1000   |
    46      And the average block duration is "1"
    47  
    48      # Place some orders to get out of auction
    49      And the parties place the following orders:
    50        | party  | market id | side | volume | price | resulting trades | type       | tif     |
    51        | party1 | BTC/ETH   | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GFA |
    52        | party5 | BTC/ETH   | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    53  
    54      And the opening auction period ends for market "BTC/ETH"
    55      When the network moves ahead "1" blocks
    56      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH"
    57      And the mark price should be "1000" for the market "BTC/ETH"
    58  
    59    Scenario: When market is in price monitoring auction, change of a risk model or any of its parameters doesn't affect the previously
    60              calculated auction end time, any remaining price monitoring bounds cannot extend the auction further. Upon uncrossing
    61              price monitoring bounds get reset using the updated parameter values. (0032-PRIM-033)
    62  
    63      # Check that the market price bounds are set 
    64      And the market data for the market "BTC/ETH" should be:
    65        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest | auction start | auction end |
    66        | 1000       | TRADING_MODE_CONTINUOUS | 30      | 997       | 1003      | 0            | 0              | 0             | 0             | 0           |
    67        | 1000       | TRADING_MODE_CONTINUOUS | 60      | 995       | 1005      | 0            | 0              | 0             | 0             | 0           |
    68        | 1000       | TRADING_MODE_CONTINUOUS | 90      | 994       | 1006      | 0            | 0              | 0             | 0             | 0           |
    69        | 1000       | TRADING_MODE_CONTINUOUS | 120     | 993       | 1007      | 0            | 0              | 0             | 0             | 0           |
    70  
    71      # Place 2 persistent orders that are outside all of the price bounds
    72      And the parties place the following orders:
    73        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    74        | party1 | BTC/ETH   | buy  | 1      | 1008  | 0                | TYPE_LIMIT | TIF_GTC | buy1      |
    75        | party5 | BTC/ETH   | sell | 1      | 1008  | 0                | TYPE_LIMIT | TIF_GTC | sell1     |
    76      When the network moves ahead "1" blocks
    77  
    78      # Check we have been placed in auction
    79      Then the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "BTC/ETH"
    80  
    81      # Check we know the auction time
    82      And the market data for the market "BTC/ETH" should be:
    83        | mark price | trading mode                    | horizon | min bound | max bound | target stake | supplied stake | open interest | auction start       | auction end         |
    84        | 1000       | TRADING_MODE_MONITORING_AUCTION | 60      | 995       | 1005      | 0            | 0              | 0             | 1704067203000000000 | 1704067213000000000 |
    85        | 1000       | TRADING_MODE_MONITORING_AUCTION | 90      | 994       | 1006      | 0            | 0              | 0             | 1704067203000000000 | 1704067213000000000 |
    86        | 1000       | TRADING_MODE_MONITORING_AUCTION | 120     | 993       | 1007      | 0            | 0              | 0             | 1704067203000000000 | 1704067213000000000 |
    87  
    88      # Now update the risk model to deactivate all pending price bounds
    89      Then the spot markets are updated:
    90        | id      | risk model             |
    91        | BTC/ETH | lognormal-risk-model-2 |
    92  
    93      # If we move ahead 25 blocks we should come out of auction instead of it being extended
    94      When the network moves ahead "25" blocks
    95  
    96      And the market data for the market "BTC/ETH" should be:
    97        | mark price | trading mode                    | horizon | min bound | max bound | target stake | supplied stake | open interest | auction start       | auction end         |
    98        | 1008       | TRADING_MODE_CONTINUOUS         | 30      | 1004      | 1012      | 0            | 0              | 0             | 0 | 0 |
    99        | 1008       | TRADING_MODE_CONTINUOUS         | 60      | 1003      | 1013      | 0            | 0              | 0             | 0 | 0 |
   100        | 1008       | TRADING_MODE_CONTINUOUS         | 90      | 1001      | 1015      | 0            | 0              | 0             | 0 | 0 |
   101        | 1008       | TRADING_MODE_CONTINUOUS         | 120     | 1000      | 1016      | 0            | 0              | 0             | 0 | 0 |
   102  
   103      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH"
   104  
   105      # The mark price should show the orders have traded
   106      And the mark price should be "1008" for the market "BTC/ETH"
   107  
   108     And the orders should have the following states:
   109      | party  | market id | reference | side | volume | remaining | price | status         |
   110      | party1 | BTC/ETH   | buy1      | buy  | 1      | 0         | 1008  | STATUS_FILLED  |
   111      | party5 | BTC/ETH   | sell1     | sell | 1      | 0         | 1008  | STATUS_FILLED  |
   112