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

     1  
     2  Feature: Pegged orders do not cross
     3  
     4      Aiming for full coverage of edge-cases, check the following for both
     5    derivative and spot markets:
     6  
     7    - Market decimals > asset decimals
     8    - Market decimals < asset decimals
     9  
    10    - For each of the above
    11    - tick size cannot be expressed in asset decimals
    12    - tick size can just be expressed in asset decimals
    13    - tick size can be expressed in asset decimals
    14  
    15    - For each of the above
    16    - offset cannot be expressed in asset decimals
    17    - offset can just be expressed in asset decimals
    18    - offset can be expressed in asset decimals
    19  
    20    Background:
    21  
    22      Given the average block duration is "1"
    23      And the following assets are registered:
    24        | id       | decimal places | quantum |
    25        | ETH.1.10 | 1              | 1       |
    26        | BTC.1.10 | 1              | 1       |
    27  
    28      And the following network parameters are set:
    29        | name                           | value |
    30        | limits.markets.maxPeggedOrders | 6     |
    31  
    32      And the parties deposit on asset's general account the following amount:
    33        | party  | asset    | amount           |
    34        | aux1   | ETH.1.10 | 1000000000000000 |
    35        | aux2   | ETH.1.10 | 1000000000000000 |
    36        | party1 | ETH.1.10 | 1000000000000000 |
    37        | party2 | ETH.1.10 | 1000000000000000 |
    38        | aux1   | BTC.1.10 | 1000000000000000 |
    39        | aux2   | BTC.1.10 | 1000000000000000 |
    40        | party1 | BTC.1.10 | 1000000000000000 |
    41        | party2 | BTC.1.10 | 1000000000000000 |
    42  
    43    Scenario Outline: Derivative markets - market decimals > asset decimals
    44  
    45      Given the markets:
    46        | 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    | decimal places | tick size   |
    47        | ETH.1.10/DEC21 | ETH.1.10   | ETH.1.10 | default-parameters   | default-simple-risk-model | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 0.5                    | 0                         | default-basic | 2              | <tick size> |
    48      Given the parties place the following pegged orders:
    49        | party  | market id      | side | pegged reference | volume | offset   | reference | error   |
    50        | party1 | ETH.1.10/DEC21 | buy  | MID              | 10     | <offset> | peg-buy   | <error> |
    51        | party2 | ETH.1.10/DEC21 | sell | MID              | 10     | <offset> | peg-sell  | <error> |
    52      And the parties place the following orders:
    53        | party | market id      | side | volume | price | resulting trades | type       | tif     | reference |
    54        | aux1  | ETH.1.10/DEC21 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | p3b1-1    |
    55        | aux1  | ETH.1.10/DEC21 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | p3b1-1    |
    56        | aux2  | ETH.1.10/DEC21 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | p3b2-1    |
    57        | aux2  | ETH.1.10/DEC21 | sell | 1      | <bo>  | 0                | TYPE_LIMIT | TIF_GTC | p3b2-1    |
    58      When the opening auction period ends for market "ETH.1.10/DEC21"
    59      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH.1.10/DEC21"
    60  
    61    Examples:
    62        | bo   | tick size | offset | error                                  |
    63        | 1010 | 1         | 1      | invalid offset - pegged mid will cross |
    64        | 1010 | 1         | 10     |                                        |
    65        | 1010 | 1         | 100    |                                        |
    66        | 1010 | 10        | 1      | OrderError: price not in tick size     |
    67        | 1010 | 10        | 10     |                                        |
    68        | 1010 | 10        | 100    |                                        |
    69        | 1100 | 100       | 1      | OrderError: price not in tick size     |
    70        | 1100 | 100       | 10     | OrderError: price not in tick size     |
    71        | 1100 | 100       | 100    |                                        |
    72  
    73  
    74    Scenario Outline: Derivative markets - market decimals < asset decimals
    75  
    76      Given the markets:
    77        | 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    | decimal places | tick size   |
    78        | ETH.1.10/DEC21 | ETH.1.10   | ETH.1.10 | default-parameters   | default-simple-risk-model | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 0.5                    | 0                         | default-basic | 0              | <tick size> |
    79      Given the parties place the following pegged orders:
    80        | party  | market id      | side | pegged reference | volume | offset   | reference | error   |
    81        | party1 | ETH.1.10/DEC21 | buy  | MID              | 10     | <offset> | peg-buy   | <error> |
    82        | party2 | ETH.1.10/DEC21 | sell | MID              | 10     | <offset> | peg-sell  | <error> |
    83      And the parties place the following orders:
    84        | party | market id      | side | volume | price | resulting trades | type       | tif     | reference |
    85        | aux1  | ETH.1.10/DEC21 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | p3b1-1    |
    86        | aux1  | ETH.1.10/DEC21 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | p3b1-1    |
    87        | aux2  | ETH.1.10/DEC21 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | p3b2-1    |
    88        | aux2  | ETH.1.10/DEC21 | sell | 1      | <bo>  | 0                | TYPE_LIMIT | TIF_GTC | p3b2-1    |
    89      When the opening auction period ends for market "ETH.1.10/DEC21"
    90      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH.1.10/DEC21"
    91  
    92    Examples:
    93        | bo   | tick size | offset | error                              |
    94        | 1001 | 1         | 1      |                                    |
    95        | 1001 | 1         | 10     |                                    |
    96        | 1001 | 1         | 100    |                                    |
    97        | 1010 | 10        | 1      | OrderError: price not in tick size |
    98        | 1010 | 10        | 10     |                                    |
    99        | 1010 | 10        | 100    |                                    |
   100        | 1100 | 100       | 1      | OrderError: price not in tick size |
   101        | 1100 | 100       | 10     | OrderError: price not in tick size |
   102        | 1100 | 100       | 100    |                                    |
   103  
   104  
   105    Scenario Outline: Spot market - market decimals > asset decimals
   106  
   107      Given the spot markets:
   108        | id      | name    | base asset | quote asset | liquidity monitoring | risk model                | auction duration | fees         | price monitoring | sla params    | decimal places | tick size   |
   109        | BTC/ETH | BTC/ETH | BTC.1.10   | ETH.1.10    | default-parameters   | default-simple-risk-model | 1                | default-none | default-none     | default-basic | 2              | <tick size> |
   110      Given the parties place the following pegged orders:
   111        | party  | market id | side | pegged reference | volume | offset   | reference | error   |
   112        | party1 | BTC/ETH   | buy  | MID              | 10     | <offset> | peg-buy   | <error> |
   113        | party2 | BTC/ETH   | sell | MID              | 10     | <offset> | peg-sell  | <error> |
   114      And the parties place the following orders:
   115        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
   116        | aux1  | BTC/ETH   | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | p3b1-1    |
   117        | aux1  | BTC/ETH   | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | p3b1-1    |
   118        | aux2  | BTC/ETH   | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | p3b2-1    |
   119        | aux2  | BTC/ETH   | sell | 1      | <bo>  | 0                | TYPE_LIMIT | TIF_GTC | p3b2-1    |
   120      When the opening auction period ends for market "BTC/ETH"
   121      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH"
   122  
   123    Examples:
   124        | bo   | tick size | offset | error                                  |
   125        | 1010 | 1         | 1      | invalid offset - pegged mid will cross |
   126        | 1010 | 1         | 10     |                                        |
   127        | 1010 | 1         | 100    |                                        |
   128        | 1010 | 10        | 1      | OrderError: price not in tick size     |
   129        | 1010 | 10        | 10     |                                        |
   130        | 1010 | 10        | 100    |                                        |
   131        | 1100 | 100       | 1      | OrderError: price not in tick size     |
   132        | 1100 | 100       | 10     | OrderError: price not in tick size     |
   133        | 1100 | 100       | 100    |                                        |
   134  
   135  
   136    Scenario Outline: Spot market - market decimals < asset decimals
   137  
   138      Given the spot markets:
   139        | id      | name    | base asset | quote asset | liquidity monitoring | risk model                | auction duration | fees         | price monitoring | sla params    | decimal places | tick size   |
   140        | BTC/ETH | BTC/ETH | BTC.1.10   | ETH.1.10    | default-parameters   | default-simple-risk-model | 1                | default-none | default-none     | default-basic | 0              | <tick size> |
   141      Given the parties place the following pegged orders:
   142        | party  | market id | side | pegged reference | volume | offset   | reference | error   |
   143        | party1 | BTC/ETH   | buy  | MID              | 10     | <offset> | peg-buy   | <error> |
   144        | party2 | BTC/ETH   | sell | MID              | 10     | <offset> | peg-sell  | <error> |
   145      And the parties place the following orders:
   146        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
   147        | aux1  | BTC/ETH   | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | p3b1-1    |
   148        | aux1  | BTC/ETH   | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | p3b1-1    |
   149        | aux2  | BTC/ETH   | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | p3b2-1    |
   150        | aux2  | BTC/ETH   | sell | 1      | <bo>  | 0                | TYPE_LIMIT | TIF_GTC | p3b2-1    |
   151      When the opening auction period ends for market "BTC/ETH"
   152      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/ETH"
   153  
   154    Examples:
   155        | bo   | tick size | offset | error                              |
   156        | 1001 | 1         | 1      |                                    |
   157        | 1001 | 1         | 10     |                                    |
   158        | 1001 | 1         | 100    |                                    |
   159        | 1010 | 10        | 1      | OrderError: price not in tick size |
   160        | 1010 | 10        | 10     |                                    |
   161        | 1010 | 10        | 100    |                                    |
   162        | 1100 | 100       | 1      | OrderError: price not in tick size |
   163        | 1100 | 100       | 10     | OrderError: price not in tick size |
   164        | 1100 | 100       | 100    |                                    |
   165