code.vegaprotocol.io/vega@v0.79.0/core/integration/features/liquidity-provision/mid-price-issue-amend.feature (about)

     1  Feature: Replicate unexpected margin issues - no mid price pegs
     2  
     3    Background:
     4      Given the following assets are registered:
     5        | id  | decimal places |
     6        | DAI | 5              |
     7      Given the liquidity monitoring parameters:
     8        | name               | triggering ratio | time window | scaling factor |
     9        | lqm-params         | 1.0              | 20s         | 10.0           |  
    10      And the log normal risk model named "dai-lognormal-risk":
    11        | risk aversion | tau         | mu | r | sigma |
    12        | 0.00001       | 0.000114077 | 0  | 0 | 0.41  |
    13      And the markets:
    14        | id        | quote name | asset | liquidity monitoring | risk model         | margin calculator         | auction duration | fees         | price monitoring | data source config     | decimal places | linear slippage factor | quadratic slippage factor | sla params      |
    15        | DAI/DEC22 | DAI        | DAI   | lqm-params           | dai-lognormal-risk | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 5              | 0.25                   | 0                         | default-futures |
    16      And the following network parameters are set:
    17        | name                                    | value |
    18        | market.auction.minimumDuration          | 1     |
    19        | network.markPriceUpdateMaximumFrequency | 0s    |
    20        | limits.markets.maxPeggedOrders          | 2     |
    21   
    22    @MidPrice @LPAmend
    23    Scenario: Changing orders copying the script
    24      Given the parties deposit on asset's general account the following amount:
    25        | party  | asset | amount       |
    26        | party1 | DAI   | 110000000000 |
    27        | party2 | DAI   | 110000000000 |
    28  
    29      And the parties submit the following liquidity provision:
    30        | id  | party  | market id | commitment amount | fee  | reference | lp type    |
    31        | lp1 | party1 | DAI/DEC22 | 10000000000       | 0.01 | lp-1      | submission |
    32        | lp1 | party1 | DAI/DEC22 | 10000000000       | 0.01 | lp-1      | submission |
    33      And the parties place the following pegged iceberg orders:
    34        | party |  market id | peak size | minimum visible size | side | pegged reference | volume     | offset   |
    35        | party1 | DAI/DEC22 | 3         | 1                    | buy  | MID              | 3          | 10000000 |
    36        | party1 | DAI/DEC22 | 2         | 1                    | sell | MID              | 1          | 10000000 |
    37  
    38      When the parties place the following orders:
    39        | party  | market id | side | volume | price      | resulting trades | type       | tif     | reference |
    40        | party2 | DAI/DEC22 | buy  | 1      | 800000000  | 0                | TYPE_LIMIT | TIF_GTC | party2-1  |
    41        | party2 | DAI/DEC22 | buy  | 1      | 3500000000 | 0                | TYPE_LIMIT | TIF_GTC | party2-2  |
    42        | party1 | DAI/DEC22 | sell | 1      | 3500000000 | 0                | TYPE_LIMIT | TIF_GTC | party1-1  |
    43        | party1 | DAI/DEC22 | sell | 1      | 8200000000 | 0                | TYPE_LIMIT | TIF_GTC | party1-2  |
    44  
    45      And the opening auction period ends for market "DAI/DEC22"
    46      Then the following trades should be executed:
    47        | buyer  | price      | size | seller |
    48        | party2 | 3500000000 | 1    | party1 |
    49      And the market data for the market "DAI/DEC22" should be:
    50        | mark price | best static bid price | static mid price | best static offer price |
    51        | 3500000000 | 800000000             | 4500000000       | 8200000000              |
    52      And the order book should have the following volumes for market "DAI/DEC22":
    53        | side | price      | volume |
    54        | sell | 8200000000 | 1      |
    55        | sell | 4510000000 | 1      |
    56        | buy  | 4490000000 | 3      |
    57        | buy  | 800000000  | 1      |
    58  
    59      ## Now raise best bid price
    60      When the parties place the following orders with ticks:
    61        | party  | market id | side | volume | price     | resulting trades | type       | tif     | reference |
    62        | party2 | DAI/DEC22 | buy  | 1      | 810000000 | 0                | TYPE_LIMIT | TIF_GTC | party1-b  |
    63      Then the market data for the market "DAI/DEC22" should be:
    64        | mark price | best static bid price | static mid price | best static offer price |
    65        | 3500000000 | 810000000             | 4505000000       | 8200000000              |
    66      And the order book should have the following volumes for market "DAI/DEC22":
    67        | side | price      | volume |
    68        | sell | 8200000000 | 1      |
    69        | sell | 4515000000 | 1      |
    70        | sell | 4510000000 | 0      |
    71        | buy  | 4495000000 | 3      |
    72        | buy  | 4490000000 | 0      |
    73        | buy  | 810000000  | 1      |
    74        | buy  | 800000000  | 1      |
    75  
    76      # Expecting no change as LP amend had no changes compared to the submission and the market composition hasn't change too
    77      When the parties submit the following liquidity provision:
    78        | id  | party  | market id | commitment amount | fee  | reference | lp type   |
    79        | lp1 | party1 | DAI/DEC22 | 10000000000       | 0.01 | lp-1      | amendment |
    80        | lp1 | party1 | DAI/DEC22 | 10000000000       | 0.01 | lp-1      | amendment |
    81      Then the market data for the market "DAI/DEC22" should be:
    82        | mark price | best static bid price | static mid price | best static offer price |
    83        | 3500000000 | 810000000             | 4505000000       | 8200000000              |
    84      And the order book should have the following volumes for market "DAI/DEC22":
    85        | side | price      | volume |
    86        | sell | 8200000000 | 1      |
    87        | sell | 4515000000 | 1      |
    88        | sell | 4510000000 | 0      |
    89        | buy  | 4495000000 | 3      |
    90        | buy  | 4490000000 | 0      |
    91        | buy  | 810000000  | 1      |
    92        | buy  | 800000000  | 1      |
    93  
    94      When the parties cancel the following orders:
    95        | party  | reference |
    96        | party2 | party2-1  |
    97      Then the market data for the market "DAI/DEC22" should be:
    98        | mark price | best static bid price | static mid price | best static offer price |
    99        | 3500000000 | 810000000             | 4505000000       | 8200000000              |
   100      # expecting no change to LP orders as pegs haven't moved to do cancellation (order with reference part2-1 wasn't a best bid at that stage)
   101      And the order book should have the following volumes for market "DAI/DEC22":
   102        | side | price      | volume |
   103        | sell | 8200000000 | 1      |
   104        | sell | 4515000000 | 1      |
   105        | sell | 4510000000 | 0      |
   106        | buy  | 4495000000 | 3      |
   107        | buy  | 4490000000 | 0      |
   108        | buy  | 810000000  | 1      |
   109        | buy  | 800000000  | 0      |
   110  
   111      When the parties place the following orders with ticks:
   112        | party  | market id | side | volume | price      | resulting trades | type       | tif     | reference |
   113        | party2 | DAI/DEC22 | sell | 1      | 8190000000 | 0                | TYPE_LIMIT | TIF_GTC | party2-b  |
   114      Then the market data for the market "DAI/DEC22" should be:
   115        | mark price | best static bid price | static mid price | best static offer price |
   116        | 3500000000 | 810000000             | 4500000000       | 8190000000              |
   117      # LP orders change as the mid price changed
   118  
   119      And the order book should have the following volumes for market "DAI/DEC22":
   120        | side | price      | volume |
   121        | sell | 8200000000 | 1      |
   122        | sell | 4510000000 | 1      |
   123        | sell | 4515000000 | 0      |
   124        | buy  | 4495000000 | 0      |
   125        | buy  | 4490000000 | 3      |
   126        | buy  | 810000000  | 1      |
   127  
   128      # Null amend should not change anything
   129      When the parties submit the following liquidity provision:
   130        | id  | party  | market id | commitment amount | fee  | reference | lp type   |
   131        | lp1 | party1 | DAI/DEC22 | 10000000000       | 0.01 | lp-1      | amendment |
   132        | lp1 | party1 | DAI/DEC22 | 10000000000       | 0.01 | lp-1      | amendment |
   133      Then the market data for the market "DAI/DEC22" should be:
   134        | mark price | best static bid price | static mid price | best static offer price |
   135        | 3500000000 | 810000000             | 4500000000       | 8190000000              |
   136      And the order book should have the following volumes for market "DAI/DEC22":
   137        | side | price      | volume |
   138        | sell | 8200000000 | 1      |
   139        | sell | 8190000000 | 1      |
   140        | sell | 4510000000 | 1      |
   141        | sell | 4515000000 | 0      |
   142        | buy  | 4495000000 | 0      |
   143        | buy  | 4490000000 | 3      |
   144        | buy  | 810000000  | 1      |
   145  
   146      When the parties cancel the following orders:
   147        | party  | reference |
   148        | party1 | party1-2  |
   149      Then the market data for the market "DAI/DEC22" should be:
   150        | mark price | best static bid price | static mid price | best static offer price |
   151        | 3500000000 | 810000000             | 4500000000       | 8190000000              |
   152      # Pegged order prices unchanged as MID hasn't changed, volume unchanged as cancelling the limit order has no impact on pegged iceberg orders.
   153      And the order book should have the following volumes for market "DAI/DEC22":
   154        | side | price      | volume |
   155        | sell | 8200000000 | 0      |
   156        | sell | 8190000000 | 1      |
   157        | sell | 4510000000 | 1      |
   158        | sell | 4515000000 | 0      |
   159        | buy  | 4495000000 | 0      |
   160        | buy  | 4490000000 | 3      |
   161        | buy  | 810000000  | 1      |
   162  
   163    @MidPrice @LPAmend
   164    Scenario: Changing orders copying the script
   165      Given the parties deposit on asset's general account the following amount:
   166        | party  | asset | amount       |
   167        | party1 | DAI   | 110000000000 |
   168        | party2 | DAI   | 110000000000 |
   169  
   170      And the parties submit the following liquidity provision:
   171        | id  | party  | market id | commitment amount | fee  | reference | lp type    |
   172        | lp1 | party1 | DAI/DEC22 | 10000000000       | 0.01 | lp-1      | submission |
   173        | lp1 | party1 | DAI/DEC22 | 10000000000       | 0.01 | lp-1      | submission |
   174      And the parties place the following pegged iceberg orders:
   175        | party  | market id | peak size | minimum visible size | side | pegged reference | volume | offset   |
   176        | party1 | DAI/DEC22 | 3         | 1                    | buy  | MID              | 3      | 10000000 |
   177        | party1 | DAI/DEC22 | 2         | 1                    | sell | MID              | 1      | 10000000 |
   178  
   179      When the parties place the following orders:
   180        | party  | market id | side | volume | price      | resulting trades | type       | tif     | reference |
   181        | party2 | DAI/DEC22 | buy  | 1      | 800000000  | 0                | TYPE_LIMIT | TIF_GTC | party2-1  |
   182        | party2 | DAI/DEC22 | buy  | 1      | 3500000000 | 0                | TYPE_LIMIT | TIF_GTC | party2-2  |
   183        | party1 | DAI/DEC22 | sell | 1      | 3500000000 | 0                | TYPE_LIMIT | TIF_GTC | party1-1  |
   184        | party1 | DAI/DEC22 | sell | 1      | 8200000000 | 0                | TYPE_LIMIT | TIF_GTC | party1-2  |
   185  
   186      And the opening auction period ends for market "DAI/DEC22"
   187      Then the following trades should be executed:
   188        | buyer  | price      | size | seller |
   189        | party2 | 3500000000 | 1    | party1 |
   190      And the market data for the market "DAI/DEC22" should be:
   191        | mark price | best static bid price | static mid price | best static offer price |
   192        | 3500000000 | 800000000             | 4500000000       | 8200000000              |
   193      And the order book should have the following volumes for market "DAI/DEC22":
   194        | side | price      | volume |
   195        | sell | 8200000000 | 1      |
   196        | sell | 4510000000 | 1      |
   197        | buy  | 4490000000 | 3      |
   198        | buy  | 800000000  | 1      |
   199  
   200      When the parties amend the following orders:
   201        | party  | reference | price     | size delta | tif     |
   202        | party2 | party2-1  | 810000000 | 0          | TIF_GTC |
   203      Then the market data for the market "DAI/DEC22" should be:
   204        | mark price | best static bid price | static mid price | best static offer price |
   205        | 3500000000 | 810000000             | 4505000000       | 8200000000              |
   206      And the order book should have the following volumes for market "DAI/DEC22":
   207        | side | price      | volume |
   208        | sell | 8200000000 | 1      |
   209        | sell | 4515000000 | 1      |
   210        | sell | 4510000000 | 0      |
   211        | buy  | 4495000000 | 3      |
   212        | buy  | 4490000000 | 0      |
   213        | buy  | 810000000  | 1      |
   214        | buy  | 800000000  | 0      |
   215  
   216      When the parties amend the following orders:
   217        | party  | reference | price      | size delta | tif     |
   218        | party1 | party1-2  | 8190000000 | 0          | TIF_GTC |
   219      Then the market data for the market "DAI/DEC22" should be:
   220        | mark price | best static bid price | static mid price | best static offer price |
   221        | 3500000000 | 810000000             | 4500000000       | 8190000000              |
   222      And the order book should have the following volumes for market "DAI/DEC22":
   223        | side | price      | volume |
   224        | sell | 8200000000 | 0      |
   225        | sell | 8190000000 | 1      |
   226        | sell | 4515000000 | 0      |
   227        | sell | 4510000000 | 1      |
   228        | buy  | 4495000000 | 0      |
   229        | buy  | 4490000000 | 3      |
   230        | buy  | 810000000  | 1      |
   231        | buy  | 800000000  | 0      |