code.vegaprotocol.io/vega@v0.79.0/core/integration/features/margin/testnet_crash.feature (about)

     1  Feature: Test order amendment such that the full order is matched but the party doesn't have sufficient cover and their orders should be cancelled and funds released. This is testing the fix for https://github.com/vegaprotocol/vega/issues/10493
     2  
     3      Background:
     4          Given the following network parameters are set:
     5              | name                                    | value |
     6              | network.markPriceUpdateMaximumFrequency | 0s    |
     7          And the liquidity monitoring parameters:
     8              | name       | triggering ratio | time window | scaling factor |
     9              | lqm-params | 0.00             | 24h         | 1e-9           |
    10          And the fees configuration named "fees-config-1":
    11              | maker fee | infrastructure fee |
    12              | 0.0004    | 0.001              |
    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      |
    18              | ETH/FEB23 | ETH        | USD   | lqm-params           | simple-risk-model | default-margin-calculator | 1                | fees-config-1 | default-none     | default-eth-for-future | 0.09                   | 0                         | default-futures |
    19  
    20      Scenario: 001 The party tried to amend an order which is fully matched after the price change but they don't have sufficient cover.
    21          Given the parties deposit on asset's general account the following amount:
    22              | party            | asset | amount       |
    23              | buySideProvider  | USD   | 100000000000 |
    24              | sellSideProvider | USD   | 100000000000 |
    25              | party1           | USD   | 320000       |
    26  
    27          And the parties place the following orders:
    28              | party            | market id | side | volume | price | resulting trades | type       | tif     | reference |
    29              | buySideProvider  | ETH/FEB23 | buy  | 10     | 14900 | 0                | TYPE_LIMIT | TIF_GTC |           |
    30              | buySideProvider  | ETH/FEB23 | buy  | 6      | 15800 | 0                | TYPE_LIMIT | TIF_GTC |           |
    31              | buySideProvider  | ETH/FEB23 | buy  | 10     | 15900 | 0                | TYPE_LIMIT | TIF_GTC |           |
    32              | party1           | ETH/FEB23 | buy  | 100    | 15850 | 0                | TYPE_LIMIT | TIF_GTC | buy-1     |
    33              | sellSideProvider | ETH/FEB23 | sell | 10     | 15900 | 0                | TYPE_LIMIT | TIF_GTC |           |
    34              | sellSideProvider | ETH/FEB23 | sell | 100    | 20100 | 0                | TYPE_LIMIT | TIF_GTC |           |
    35  
    36          When the network moves ahead "2" blocks
    37          Then the mark price should be "15900" for the market "ETH/FEB23"
    38  
    39          And the parties should have the following margin levels:
    40              | party  | market id | maintenance | initial |
    41              | party1 | ETH/FEB23 | 159000      | 190800  |
    42  
    43          Then the parties should have the following account balances:
    44              | party  | asset | market id | margin | general |
    45              | party1 | USD   | ETH/FEB23 | 190200 | 129800  |
    46  
    47          And the parties submit update margin mode:
    48              | party  | market    | margin_mode     | margin_factor |error|
    49              | party1 | ETH/FEB23 | isolated margin | 0.2           ||
    50  
    51          And the parties should have the following margin levels:
    52              | party  | market id | maintenance | search | initial | release | margin mode     | margin factor | order  |
    53              | party1 | ETH/FEB23 | 0           | 0      | 0       | 0       | isolated margin | 0.2           | 317000 |
    54  
    55          When the parties amend the following orders:
    56              | party  | reference | price | size delta | tif     | error               |
    57              | party1 | buy-1     | 20100 | 0          | TIF_GTC | margin check failed |
    58  
    59          And the orders should have the following status:
    60              | party  | reference | status         |
    61              | party1 | buy-1     | STATUS_STOPPED |
    62  
    63          Then the parties should have the following account balances:
    64              | party  | asset | market id | margin | general |
    65              | party1 | USD   | ETH/FEB23 | 0      | 320000  |
    66  
    67      @Fail
    68      Scenario: 002 The party tried to amend an order which is partially matched after the price change but they don't have sufficient cover.
    69          Given the parties deposit on asset's general account the following amount:
    70              | party            | asset | amount       |
    71              | buySideProvider  | USD   | 100000000000 |
    72              | sellSideProvider | USD   | 100000000000 |
    73              | party1           | USD   | 320000       |
    74  
    75          And the parties place the following orders:
    76              | party            | market id | side | volume | price | resulting trades | type       | tif     | reference |
    77              | buySideProvider  | ETH/FEB23 | buy  | 10     | 14900 | 0                | TYPE_LIMIT | TIF_GTC |           |
    78              | buySideProvider  | ETH/FEB23 | buy  | 6      | 15800 | 0                | TYPE_LIMIT | TIF_GTC |           |
    79              | buySideProvider  | ETH/FEB23 | buy  | 10     | 15900 | 0                | TYPE_LIMIT | TIF_GTC |           |
    80              | party1           | ETH/FEB23 | buy  | 100    | 15850 | 0                | TYPE_LIMIT | TIF_GTC | buy-1     |
    81              | sellSideProvider | ETH/FEB23 | sell | 10     | 15900 | 0                | TYPE_LIMIT | TIF_GTC |           |
    82              | sellSideProvider | ETH/FEB23 | sell | 10     | 20100 | 0                | TYPE_LIMIT | TIF_GTC |           |
    83  
    84          When the network moves ahead "2" blocks
    85          Then the mark price should be "15900" for the market "ETH/FEB23"
    86  
    87          And the parties should have the following margin levels:
    88              | party  | market id | maintenance | initial |
    89              | party1 | ETH/FEB23 | 159000      | 190800  |
    90  
    91          Then the parties should have the following account balances:
    92              | party  | asset | market id | margin | general |
    93              | party1 | USD   | ETH/FEB23 | 190200 | 129800  |
    94  
    95          And the parties submit update margin mode:
    96              | party  | market    | margin_mode     | margin_factor |
    97              | party1 | ETH/FEB23 | isolated margin | 0.2           |
    98  
    99          And the parties should have the following margin levels:
   100              | party  | market id | maintenance | search | initial | release | margin mode     | margin factor | order  |
   101              | party1 | ETH/FEB23 | 0           | 0      | 0       | 0       | isolated margin | 0.2           | 317000 |
   102  
   103          And the average fill price is:
   104              | market     | volume | side | ref price | mark price | equivalent linear slippage factor |
   105              | ETH/FEB23  | 100    | buy  | 15900     | 15900      | 0                                 |
   106          # update linear slippage factor in line with what book-based slippage used to be
   107          And the markets are updated:
   108              | id          | linear slippage factor |
   109              | ETH/FEB23   | 0                      |
   110  
   111          When the parties amend the following orders:
   112              | party  | reference | price | size delta | tif     | error               |
   113              | party1 | buy-1     | 20100 | 0          | TIF_GTC | margin check failed |
   114  
   115          And the orders should have the following status:
   116              | party  | reference | status         |
   117              | party1 | buy-1     | STATUS_STOPPED |
   118  
   119          Then the parties should have the following account balances:
   120              | party  | asset | market id | margin | general | order margin |
   121              | party1 | USD   | ETH/FEB23 | 40200  | 279518  | 0            |
   122