code.vegaprotocol.io/vega@v0.79.0/core/integration/features/spot/orders/0068-MATC-080.feature (about)

     1  Feature: Spot market matching engine
     2  
     3      Scenario: 001 0068-MATC-080-092, test the matching engine when in auction, moving into auction, and exiting autcion
     4  
     5          Given time is updated to "2023-07-20T00:00:00Z"
     6  
     7          Given the fees configuration named "fees-config-1":
     8              | maker fee | infrastructure fee |
     9              | 0         | 0                  |
    10          Given the log normal risk model named "lognormal-risk-model-1":
    11              | risk aversion | tau  | mu | r   | sigma |
    12              | 0.001         | 0.01 | 0  | 0.0 | 1.2   |
    13  
    14          And the price monitoring named "price-monitoring-1":
    15              | horizon | probability | auction extension |
    16              | 36000   | 0.999       | 3                 |
    17  
    18          And the liquidity sla params named "SLA-1":
    19              | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
    20              | 1           | 0.6                          | 2                             | 0.2                    |
    21  
    22          Given the following assets are registered:
    23              | id  | decimal places |
    24              | ETH | 1              |
    25              | BTC | 1              |
    26  
    27          And the following network parameters are set:
    28              | name                                                | value |
    29              | network.markPriceUpdateMaximumFrequency             | 2s    |
    30              | market.liquidity.earlyExitPenalty                   | 0.25  |
    31              | market.liquidity.bondPenaltyParameter               | 0.2   |
    32              | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0.7   |
    33              | market.liquidity.sla.nonPerformanceBondPenaltyMax   | 0.6   |
    34              | market.liquidity.maximumLiquidityFeeFactorLevel     | 0.4   |
    35              | validators.epoch.length                             | 2s    |
    36              | limits.markets.maxPeggedOrders                      | 10    |
    37  
    38          And the spot markets:
    39              | id      | name    | base asset | quote asset | risk model             | auction duration | fees          | price monitoring   | sla params |
    40              | BTC/ETH | BTC/ETH | BTC        | ETH         | lognormal-risk-model-1 | 1                | fees-config-1 | price-monitoring-1 | SLA-1      |
    41          And the following network parameters are set:
    42              | name                                             | value |
    43              | market.liquidity.providersFeeCalculationTimeStep | 1s    |
    44              | market.liquidity.stakeToCcyVolume                | 1     |
    45  
    46          Given the parties deposit on asset's general account the following amount:
    47              | party  | asset | amount |
    48              | party1 | ETH   | 10000  |
    49              | party2 | BTC   | 500    |
    50              | party3 | ETH   | 10000  |
    51              | party4 | BTC   | 500    |
    52              | lp1    | ETH   | 4000   |
    53              | lp1    | BTC   | 60     |
    54              | lp2    | ETH   | 4000   |
    55              | lp2    | BTC   | 60     |
    56  
    57          And the average block duration is "1"
    58  
    59          Given the liquidity monitoring parameters:
    60              | name               | triggering ratio | time window | scaling factor |
    61              | updated-lqm-params | 0.2              | 20s         | 0.8            |
    62  
    63          When the spot markets are updated:
    64              | id      | liquidity monitoring | linear slippage factor | quadratic slippage factor |
    65              | BTC/ETH | updated-lqm-params   | 0.5                    | 0.5                       |
    66  
    67          When the parties submit the following liquidity provision:
    68              | id  | party | market id | commitment amount | fee | lp type    |
    69              | lp1 | lp1   | BTC/ETH   | 3000              | 0.1 | submission |
    70  
    71          Then the network moves ahead "1" blocks
    72  
    73          Then the market data for the market "BTC/ETH" should be:
    74              | mark price | trading mode                 | auction trigger         | target stake | supplied stake | open interest |
    75              | 0          | TRADING_MODE_OPENING_AUCTION | AUCTION_TRIGGER_OPENING | 2400         | 3000           | 0             |
    76  
    77          #0068-MATC-084: GFN order rejected
    78          And the parties place the following orders:
    79              | party  | market id | side | volume | price | resulting trades | type       | tif     | reference    | expires in | error |
    80              | party1 | BTC/ETH   | buy  | 4      | 8     | 0                | TYPE_LIMIT | TIF_GTC | party-order5 |            |       |
    81              | party1 | BTC/ETH   | buy  | 1      | 15    | 0                | TYPE_LIMIT | TIF_GTC | party-order3 |            |       |
    82              | party2 | BTC/ETH   | sell | 1      | 15    | 0                | TYPE_LIMIT | TIF_GTC | party-order4 |            |       |
    83              | party2 | BTC/ETH   | sell | 6      | 24    | 0                | TYPE_LIMIT | TIF_GTC | party-order6 |            |       |
    84              | party4 | BTC/ETH   | sell | 1      | 19    | 0                | TYPE_LIMIT | TIF_GTC | p4-sell      |            |       |
    85  
    86          # 0068-MATC-089:Amend the price
    87          When the parties amend the following orders:
    88              | party  | reference | price | size delta | tif     |
    89              | party4 | p4-sell   | 20    | 0          | TIF_GTC |
    90          When the network moves ahead "2" blocks
    91  
    92          Then the order book should have the following volumes for market "BTC/ETH":
    93              | side | price | volume |
    94              | sell | 20    | 1      |
    95  
    96          Then the following trades should be executed:
    97              | buyer  | price | size | seller |
    98              | party1 | 15    | 1    | party2 |
    99  
   100          Then the market data for the market "BTC/ETH" should be:
   101              | mark price | trading mode            | auction trigger             | horizon | min bound | max bound |
   102              | 15         | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 36000   | 14        | 17        |
   103  
   104          And the parties place the following orders:
   105              | party  | market id | side | volume | price | resulting trades | type       | tif     | reference  | expires in | error |
   106              | party1 | BTC/ETH   | buy  | 1      | 8     | 0                | TYPE_LIMIT | TIF_GFN | party1-GFN |            |       |
   107              | party1 | BTC/ETH   | buy  | 1      | 8     | 0                | TYPE_LIMIT | TIF_GTT | party1-GTT | 1          |       |
   108  
   109          #trigger auction
   110          And the parties place the following orders:
   111              | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   112              | party3 | BTC/ETH   | buy  | 1      | 13    | 0                | TYPE_LIMIT | TIF_GTC | buy-13    |
   113              | party4 | BTC/ETH   | sell | 1      | 13    | 0                | TYPE_LIMIT | TIF_GTC | sell-13   |
   114  
   115          Then the market data for the market "BTC/ETH" should be:
   116              | mark price | trading mode                    | auction trigger       |
   117              | 15         | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE |
   118  
   119          #0068-MATC-084: GFN order rejected
   120          #0068-MATC-085: GTT order stays ACTIVE
   121          Then the orders should have the following status:
   122              | party  | reference  | status           |
   123              | party1 | party1-GFN | STATUS_CANCELLED |
   124              | party1 | party1-GTT | STATUS_ACTIVE    |
   125          Then the parties cancel the following orders:
   126              | party  | reference |
   127              | party3 | buy-13    |
   128              | party4 | sell-13   |
   129  
   130          #0068-MATC-080: orders are placed into the book and no matching takes place.
   131          #0068-MATC-081: post only orders are placed into the book and no matching takes place.
   132          And the parties place the following orders:
   133              | party  | market id | side | volume | price | resulting trades | type       | tif     | reference    | only |
   134              | party1 | BTC/ETH   | buy  | 1      | 14    | 0                | TYPE_LIMIT | TIF_GFA | party1-GFA   |      |
   135              | party1 | BTC/ETH   | buy  | 1      | 15    | 0                | TYPE_LIMIT | TIF_GTC | buy-15-self  |      |
   136              | party1 | BTC/ETH   | sell | 1      | 15    | 0                | TYPE_LIMIT | TIF_GTC | sell-15-self |      |
   137              | party1 | BTC/ETH   | buy  | 1      | 15    | 0                | TYPE_LIMIT | TIF_GTC | post-only-b  | post |
   138              | party2 | BTC/ETH   | sell | 1      | 15    | 0                | TYPE_LIMIT | TIF_GTC | post-only-s  | post |
   139              | party1 | BTC/ETH   | buy  | 1      | 15    | 0                | TYPE_LIMIT | TIF_GTC | buy-15       |      |
   140              | party2 | BTC/ETH   | sell | 1      | 15    | 0                | TYPE_LIMIT | TIF_GTC | sell-15      |      |
   141  
   142          And the parties place the following pegged orders:
   143              | party | market id | side | volume | pegged reference | offset | reference |
   144              | lp1   | BTC/ETH   | buy  | 2      | BID              | 3      | lp1-peg-b |
   145              | lp1   | BTC/ETH   | sell | 2      | ASK              | 3      | lp1-peg-s |
   146  
   147          # 0068-MATC-090:Amend the size
   148          When the parties amend the following orders:
   149              | party  | reference | price | size delta | tif     |
   150              | party4 | p4-sell   | 20    | 3          | TIF_GTC |
   151  
   152          #0068-MATC-083: pegged order is parked during auction
   153          Then the orders should have the following status:
   154              | party  | reference   | status        |
   155              | lp1    | lp1-peg-b   | STATUS_PARKED |
   156              | lp1    | lp1-peg-s   | STATUS_PARKED |
   157              | party1 | party1-GFA  | STATUS_ACTIVE |
   158              | party1 | post-only-b | STATUS_ACTIVE |
   159              | party2 | post-only-s | STATUS_ACTIVE |
   160  
   161          Then the parties cancel the following orders:
   162              | party  | reference   |
   163              | party1 | post-only-b |
   164              | party2 | post-only-s |
   165  
   166          Then the network moves ahead "5" blocks
   167          #0068-MATC-087: Self trading is allowed during uncrossing.
   168          Then the market data for the market "BTC/ETH" should be:
   169              | mark price | trading mode            | auction trigger             |
   170              | 15         | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED |
   171  
   172          Then the order book should have the following volumes for market "BTC/ETH":
   173              | side | price | volume |
   174              | sell | 20    | 4      |
   175  
   176          #0068-MATC-086: The book is uncrossed when exits an auction
   177          Then the following trades should be executed:
   178              | buyer  | price | size | seller |
   179              | party1 | 15    | 1    | party1 |
   180              | party1 | 15    | 1    | party2 |
   181  
   182          #0068-MATC-088: GFA orders are canceled when exiting auction
   183          Then the orders should have the following status:
   184              | party  | reference    | status           |
   185              | party1 | party1-GFA   | STATUS_CANCELLED |
   186              | party1 | buy-15-self  | STATUS_FILLED    |
   187              | party1 | sell-15-self | STATUS_FILLED    |
   188              | party1 | buy-15       | STATUS_FILLED    |
   189              | party2 | sell-15      | STATUS_FILLED    |
   190              | party1 | party1-GTT   | STATUS_EXPIRED   |
   191  
   192          #0068-MATC-091:An update to an order that is not [ACTIVE or PARKED](Stopped, Cancelled, Expired, Filled) will be rejected
   193          When the parties amend the following orders:
   194              | party  | reference   | price | size delta | tif     | error                        |
   195              | party1 | party1-GFA  | 14    | 1          | TIF_GFA | OrderError: Invalid Order ID |
   196              | party1 | buy-15-self | 15    | 1          | TIF_GFA | OrderError: Invalid Order ID |
   197              | party1 | party1-GTT  | 8     | 1          | TIF_GFA | OrderError: Invalid Order ID |
   198  
   199          #0068-MATC-092:The TIF of any persistent order can be updated to and from GTC and GTT only. Expiry time is required if amending to GTT and must not be given if amending to GTC.
   200          And the parties place the following orders:
   201              | party  | market id | side | volume | price | resulting trades | type       | tif     | reference    | expires in |
   202              | party1 | BTC/ETH   | buy  | 1      | 12    | 0                | TYPE_LIMIT | TIF_GTT | party1-GTT-1 | 2          |
   203              | party1 | BTC/ETH   | buy  | 1      | 12    | 0                | TYPE_LIMIT | TIF_GTC | party1-GTC-1 |            |
   204              | party1 | BTC/ETH   | buy  | 1      | 12    | 0                | TYPE_LIMIT | TIF_GFN | party1-GFN-1 |            |
   205  
   206          When the parties amend the following orders:
   207              | party  | reference    | price | size delta | tif     | error                                        |
   208              | party1 | party1-GTT-1 | 12    | 0          | TIF_GTC |                                              |
   209              | party1 | party1-GFN-1 | 12    | 0          | TIF_GTC | OrderError: Cannot amend TIF from GFA or GFN |
   210              | party1 | party1-GFN-1 | 12    | 0          | TIF_GFA | OrderError: Cannot amend TIF to GFA or GFN   |
   211          When the parties amend the following orders:
   212              | party  | reference    | price | size delta | tif     | expiration date      | error |
   213              | party1 | party1-GTC-1 | 12    | 0          | TIF_GTT | 2030-11-30T00:00:00Z |       |
   214  
   215          Then the network moves ahead "4" blocks
   216          Then the orders should have the following status:
   217              | party  | reference    | status        |
   218              | party1 | party1-GTT-1 | STATUS_ACTIVE |
   219              | party1 | party1-GTC-1 | STATUS_ACTIVE |
   220  
   221  
   222  
   223  
   224  
   225  
   226