code.vegaprotocol.io/vega@v0.79.0/core/integration/features/spot/orders/0032-PRIM-037.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      And the price monitoring named "price-monitoring-1":
    23        | horizon | probability | auction extension |
    24        | 30      | 0.999       | 10                |
    25        | 60      | 0.999       | 10                |
    26  
    27      And the spot markets:
    28        | id      | name    | base asset | quote asset | risk model             | auction duration | fees          | price monitoring   | decimal places | position decimal places | sla params    |
    29        | BTC/ETH | BTC/ETH | BTC        | ETH         | lognormal-risk-model-1 | 1                | fees-config-1 | price-monitoring-1 | 2              | 2                       | default-basic |
    30  
    31      # setup accounts
    32      Given the parties deposit on asset's general account the following amount:
    33        | party  | asset | amount |
    34        | party1 | ETH   | 10000  |
    35        | party1 | BTC   | 1000   |
    36        | party2 | ETH   | 10000  |
    37        | party4 | BTC   | 1000   |
    38        | party5 | BTC   | 1000   |
    39      And the average block duration is "1"
    40  
    41      # Place some orders to get out of auction
    42      And the parties place the following orders:
    43        | party  | market id | side | volume | price | resulting trades | type       | tif     |
    44        | party1 | BTC/ETH   | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GFA |
    45        | party5 | BTC/ETH   | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    46  
    47      And the opening auction period ends for market "BTC/ETH"
    48      When the network moves ahead "1" blocks
    49      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH"
    50      And the mark price should be "1000" for the market "BTC/ETH"
    51  
    52    Scenario: 2 persistent orders with prices outside both trigger price bands triggers an auction. Initial auction duration is equal
    53              to the extension period of the first trigger. Once the initial period ends the auction gets extended by the extension
    54              period of the second trigger. No other orders placed during auction, auction terminates with a trade from order that
    55              originally triggered the auction. (0032-PRIM-037)
    56  
    57      # Check that the market price bounds are set 
    58      And the market data for the market "BTC/ETH" should be:
    59        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
    60        | 1000       | TRADING_MODE_CONTINUOUS | 30      | 997       | 1003      | 0            | 0              | 0             |
    61        | 1000       | TRADING_MODE_CONTINUOUS | 60      | 995       | 1005      | 0            | 0              | 0             |
    62  
    63      # Place 2 persistent orders that are outside both price bounds
    64      And the parties place the following orders:
    65        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    66        | party1 | BTC/ETH   | buy  | 1      | 1006  | 0                | TYPE_LIMIT | TIF_GTC | buy1      |
    67        | party5 | BTC/ETH   | sell | 1      | 1006  | 0                | TYPE_LIMIT | TIF_GTC | sell1     |
    68      When the network moves ahead "1" blocks
    69  
    70      # Check we have been placed in auction
    71      Then the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "BTC/ETH"
    72  
    73      # If we move forward 10 blocks we should still be in auction due to the second extension
    74      When the network moves ahead "10" blocks
    75      Then the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "BTC/ETH"
    76  
    77      # If we move forward 10 more blocks we should leave the auction
    78      When the network moves ahead "10" blocks
    79      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH"
    80  
    81      # The mark price should show the orders have traded
    82      And the mark price should be "1006" for the market "BTC/ETH"
    83  
    84     And the orders should have the following states:
    85      | party  | market id | reference | side | volume | remaining | price | status         |
    86      | party1 | BTC/ETH   | buy1      | buy  | 1      | 0         | 1006  | STATUS_FILLED  |
    87      | party5 | BTC/ETH   | sell1     | sell | 1      | 0         | 1006  | STATUS_FILLED  |
    88