code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/0035-LIQM-liquidity_monitoring.feature (about)

     1  Feature: Test liquidity monitoring
     2  
     3    Background:
     4      Given the following network parameters are set:
     5        | name                                    | value |
     6        | network.floatingPointUpdates.delay      | 10s   |
     7        | market.auction.minimumDuration          | 1     |
     8        | network.markPriceUpdateMaximumFrequency | 0s    |
     9        | limits.markets.maxPeggedOrders          | 4     |
    10      Given the liquidity monitoring parameters:
    11        | name       | triggering ratio | time window | scaling factor |
    12        | lqm-params | 1.0              | 1s          | 1.0            |
    13      And the average block duration is "1"
    14      And the margin calculator named "margin-calculator-1":
    15        | search factor | initial factor | release factor |
    16        | 1.0           | 1.0            | 2              |
    17      And the simple risk model named "simple-risk-model-1":
    18        | long | short | max move up | min move down | probability of trading |
    19        | 0.1  | 0.1   | 10          | 10            | 0.1                    |
    20      And the log normal risk model named "log-normal-risk-model-1":
    21        | risk aversion | tau | mu | r | sigma |
    22        | 0.000001      | 0.1 | 0  | 0 | 1.0   |
    23      And the fees configuration named "fees-config-1":
    24        | maker fee | infrastructure fee |
    25        | 0.004     | 0.001              |
    26      And the price monitoring named "price-monitoring-1":
    27        | horizon | probability | auction extension |
    28        | 100     | 0.99        | 300               |
    29      And the price monitoring named "price-monitoring-2":
    30        | horizon | probability | auction extension |
    31        | 1       | 0.99        | 300               |
    32      And the markets:
    33        | 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      |
    34        | ETH/DEC21 | ETH        | ETH   | lqm-params           | simple-risk-model-1     | margin-calculator-1       | 1                | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.5                    | 0                         | default-futures |
    35        | ETH/MAR22 | ETH        | USD   | lqm-params           | log-normal-risk-model-1 | default-margin-calculator | 1                | fees-config-1 | price-monitoring-2 | default-eth-for-future | 0.5                    | 0                         | default-futures |
    36      And the parties deposit on asset's general account the following amount:
    37        | party  | asset | amount     |
    38        | party1 | ETH   | 100000000  |
    39        | party2 | ETH   | 100000000  |
    40        | party3 | ETH   | 100000000  |
    41        | party4 | ETH   | 100000000  |
    42        | lprov1 | ETH   | 1000000000 |
    43        | lprov2 | ETH   | 1000000000 |
    44      And the parties deposit on asset's general account the following amount:
    45        | party  | asset | amount    |
    46        | party1 | USD   | 100000000 |
    47        | party2 | USD   | 100000000 |
    48        | party3 | USD   | 100000000 |
    49        | party4 | USD   | 100000000 |
    50        | party3 | USD   | 100000000 |
    51        | lprov1 | USD   | 500000    |
    52        | lprov2 | USD   | 500000    |
    53  
    54    Scenario: 001: A market which enters a state requiring liquidity auction through increased open interest during a block but then leaves state again prior to block completion never enters liquidity auction. (0035-LIQM-005)
    55      Given the parties submit the following liquidity provision:
    56        | id  | party  | market id | commitment amount | fee   | lp type    |
    57        | lp1 | lprov1 | ETH/DEC21 | 1000              | 0.001 | submission |
    58        | lp1 | lprov1 | ETH/DEC21 | 1000              | 0.001 | submission |
    59      And the parties place the following pegged iceberg orders:
    60        | party  | market id | peak size | minimum visible size | side | pegged reference | volume | offset |
    61        | lprov1 | ETH/DEC21 | 2         | 1                    | buy  | BID              | 1      | 2      |
    62        | lprov1 | ETH/DEC21 | 2         | 1                    | sell | ASK              | 1      | 2      |
    63      And the parties place the following orders:
    64        | party  | market id | side | volume | price | resulting trades | type       | tif     |
    65        | party1 | ETH/DEC21 | buy  | 1      | 990   | 0                | TYPE_LIMIT | TIF_GTC |
    66        | party1 | ETH/DEC21 | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    67        | party3 | ETH/DEC21 | buy  | 20     | 900   | 0                | TYPE_LIMIT | TIF_GTC |
    68        | party4 | ETH/DEC21 | sell | 20     | 1050  | 0                | TYPE_LIMIT | TIF_GTC |
    69        | party2 | ETH/DEC21 | sell | 1      | 1010  | 0                | TYPE_LIMIT | TIF_GTC |
    70        | party2 | ETH/DEC21 | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    71  
    72      When the opening auction period ends for market "ETH/DEC21"
    73      Then the auction ends with a traded volume of "10" at a price of "1000"
    74      And the market data for the market "ETH/DEC21" should be:
    75        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
    76        | 1000       | TRADING_MODE_CONTINUOUS | 100     | 990       | 1010      | 1000         | 1000           | 10            |
    77  
    78      Then clear all events
    79  
    80      When the parties place the following orders:
    81        | party  | market id | side | volume | price | resulting trades | type       | tif     |
    82        | party2 | ETH/DEC21 | sell | 20     | 1010  | 0                | TYPE_LIMIT | TIF_GTC |
    83        | party1 | ETH/DEC21 | buy  | 20     | 1010  | 2                | TYPE_LIMIT | TIF_GTC |
    84  
    85      # verify that we don't enter liquidity auction immediately despite liquidity being undersuplied
    86      And the market data for the market "ETH/DEC21" should be:
    87        | trading mode            | auction trigger             | target stake | supplied stake | open interest |
    88        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 3000         | 1000           | 30            |
    89  
    90      Then the parties submit the following liquidity provision:
    91        | id  | party  | market id | commitment amount | fee   | lp type   |
    92        | lp1 | lprov1 | ETH/DEC21 | 10000             | 0.001 | amendment |
    93        | lp1 | lprov1 | ETH/DEC21 | 10000             | 0.001 | amendment |
    94      And the parties place the following pegged iceberg orders:
    95        | party  | market id | peak size | minimum visible size | side | pegged reference | volume | offset |
    96        | lprov1 | ETH/DEC21 | 2         | 1                    | buy  | BID              | 1      | 2      |
    97        | lprov1 | ETH/DEC21 | 2         | 1                    | sell | ASK              | 1      | 2      |
    98      # move to the next block to perform liquidity check, we should still be in continuous trading
    99      Then the network moves ahead "1" blocks
   100  
   101      And the market data for the market "ETH/DEC21" should be:
   102        | trading mode            | auction trigger             | target stake | supplied stake | open interest |
   103        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 3030         | 10000          | 30            |
   104  
   105      # verify that at no point auction has been entered
   106      Then the following events should NOT be emitted:
   107        | type         |
   108        | AuctionEvent |
   109  
   110    Scenario: 002: A market which enters a state requiring liquidity auction through reduced current stake (e.g. through LP bankruptcy) during a block but then leaves state again prior to block completion never enters liquidity auction. (0035-LIQM-006)
   111  
   112      And the average block duration is "1"
   113  
   114      And the parties submit the following liquidity provision:
   115        | id  | party  | market id | commitment amount | fee   | lp type    |
   116        | lp1 | lprov1 | ETH/MAR22 | 50000             | 0.001 | submission |
   117        | lp1 | lprov1 | ETH/MAR22 | 50000             | 0.001 | amendment  |
   118      And the parties place the following pegged iceberg orders:
   119        | party  | market id | peak size | minimum visible size | side | pegged reference | volume | offset |
   120        | lprov1 | ETH/MAR22 | 2         | 1                    | sell | ASK              | 500    | 20     |
   121        | lprov1 | ETH/MAR22 | 2         | 1                    | buy  | BID              | 500    | 20     |
   122      And the parties place the following orders:
   123        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference  |
   124        | party1 | ETH/MAR22 | buy  | 1      | 990   | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-1  |
   125        | party1 | ETH/MAR22 | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-2  |
   126        | party2 | ETH/MAR22 | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-3 |
   127        | party2 | ETH/MAR22 | sell | 1      | 1010  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-1 |
   128  
   129      When the opening auction period ends for market "ETH/MAR22"
   130      Then the auction ends with a traded volume of "10" at a price of "1000"
   131      And the insurance pool balance should be "0" for the market "ETH/MAR22"
   132      And the market data for the market "ETH/MAR22" should be:
   133        | mark price | trading mode            | target stake | supplied stake | open interest |
   134        | 1000       | TRADING_MODE_CONTINUOUS | 35569        | 50000          | 10            |
   135  
   136      When the parties place the following orders:
   137        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference    |
   138        | party3 | ETH/MAR22 | buy  | 30     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | party3-buy-1 |
   139      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR22"
   140  
   141      When the parties place the following orders:
   142        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference     |
   143        | party2 | ETH/MAR22 | sell | 50     | 1000  | 1                | TYPE_LIMIT | TIF_GTC | party2-sell-4 |
   144  
   145      And clear all events
   146      Then the market data for the market "ETH/MAR22" should be:
   147        | mark price | trading mode            | target stake | supplied stake | open interest |
   148        | 1000       | TRADING_MODE_CONTINUOUS | 142276       | 50000          | 40            |
   149  
   150      Then the parties submit the following liquidity provision:
   151        | id  | party  | market id | commitment amount | fee   | lp type    |
   152        | lp2 | lprov2 | ETH/MAR22 | 92276             | 0.001 | submission |
   153        | lp2 | lprov2 | ETH/MAR22 | 92276             | 0.001 | amendment  |
   154      And the parties place the following pegged iceberg orders:
   155        | party  | market id | peak size | minimum visible size | side | pegged reference | volume | offset |
   156        | lprov2 | ETH/MAR22 | 2         | 1                    | sell | ASK              | 100    | 20     |
   157        | lprov2 | ETH/MAR22 | 2         | 1                    | buy  | BID              | 100    | 20     |
   158  
   159      # move to the next block to perform liquidity check, we should still be in continuous trading
   160      Then the network moves ahead "1" blocks
   161      And the market data for the market "ETH/MAR22" should be:
   162        | trading mode            | auction trigger             | target stake | supplied stake | open interest |
   163        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 142276       | 142276         | 40            |
   164  
   165      # verify that at no point auction has been entered
   166      Then the following events should NOT be emitted:
   167        | type         |
   168        | AuctionEvent |
   169  
   170    # perhaps a bit pointless, liquidity auction was removed, keeping the scenario to make sure everything else works as expected.
   171    Scenario: 004: When the Max Open Interest field decreases for a created block to a level such that a liquidity auction which is active at the start of a block can now be exited the block stays in auction within the block but leaves at the end. (0035-LIQM-008)
   172  
   173      Given the following network parameters are set:
   174        | name                                  | value |
   175        | market.liquidity.bondPenaltyParameter | 1     |
   176      Given the liquidity monitoring parameters:
   177        | name               | triggering ratio | time window | scaling factor |
   178        | updated-lqm-params | 1.0              | 5s          | 1              |
   179      When the markets are updated:
   180        | id        | liquidity monitoring | linear slippage factor | quadratic slippage factor |
   181        | ETH/DEC21 | updated-lqm-params   | 0.5                    | 0                         |
   182  
   183      And the parties deposit on asset's general account the following amount:
   184        | party          | asset | amount |
   185        | lprov1         | ETH   | 1000   |
   186        | lp2Bdistressed | ETH   | 101    |
   187      And the parties submit the following liquidity provision:
   188        | id  | party          | market id | commitment amount | fee   | lp type    |
   189        | lp1 | lprov1         | ETH/DEC21 | 5999              | 0.001 | submission |
   190        | lp1 | lprov1         | ETH/DEC21 | 5999              | 0.001 |            |
   191        | lp2 | lp2Bdistressed | ETH/DEC21 | 1                 | 0.001 | submission |
   192        | lp2 | lp2Bdistressed | ETH/DEC21 | 1                 | 0.001 |            |
   193      And the parties place the following pegged iceberg orders:
   194        | party          | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference |
   195        | lprov1         | ETH/DEC21 | 2         | 1                    | buy  | BID              | 1      | 2      | lp1_buy   |
   196        | lprov1         | ETH/DEC21 | 2         | 1                    | sell | ASK              | 1      | 2      | lp1_sell  |
   197        | lp2Bdistressed | ETH/DEC21 | 2         | 1                    | buy  | BID              | 1      | 10     | lp2_buy   |
   198        | lp2Bdistressed | ETH/DEC21 | 2         | 1                    | sell | ASK              | 1      | 10     | lp2_sell  |
   199      And the parties place the following orders:
   200        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   201        | party1 | ETH/DEC21 | buy  | 1      | 970   | 0                | TYPE_LIMIT | TIF_GTC |
   202        | party1 | ETH/DEC21 | buy  | 60     | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   203        | party3 | ETH/DEC21 | buy  | 100    | 950   | 0                | TYPE_LIMIT | TIF_GTC |
   204        | party4 | ETH/DEC21 | sell | 199    | 1050  | 0                | TYPE_LIMIT | TIF_GTC |
   205        | party2 | ETH/DEC21 | sell | 1      | 1030  | 0                | TYPE_LIMIT | TIF_GTC |
   206        | party2 | ETH/DEC21 | sell | 60     | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   207  
   208      When the opening auction period ends for market "ETH/DEC21"
   209      Then the market data for the market "ETH/DEC21" should be:
   210        | mark price | trading mode            | open interest | best static bid price | static mid price | best static offer price | target stake | supplied stake |
   211        | 1000       | TRADING_MODE_CONTINUOUS | 60            | 970                   | 1000             | 1030                    | 6000         | 6000           |
   212  
   213      When the network moves ahead "1" blocks
   214      Then the orders should have the following states:
   215        | party          | market id | side | volume | remaining | price | status        | reference |
   216        | lprov1         | ETH/DEC21 | buy  | 1      | 1         | 968   | STATUS_ACTIVE | lp1_buy   |
   217        | lprov1         | ETH/DEC21 | sell | 1      | 1         | 1032  | STATUS_ACTIVE | lp1_sell  |
   218        | lp2Bdistressed | ETH/DEC21 | buy  | 1      | 1         | 960   | STATUS_ACTIVE | lp2_buy   |
   219        | lp2Bdistressed | ETH/DEC21 | sell | 1      | 1         | 1040  | STATUS_ACTIVE | lp2_sell  |
   220      And the parties should have the following margin levels:
   221        | party          | market id | maintenance | initial |
   222        | lp2Bdistressed | ETH/DEC21 | 100         | 100     |
   223      And the liquidity provisions should have the following states:
   224        | id  | party          | market    | commitment amount | status        |
   225        | lp1 | lprov1         | ETH/DEC21 | 5999              | STATUS_ACTIVE |
   226        | lp2 | lp2Bdistressed | ETH/DEC21 | 1                 | STATUS_ACTIVE |
   227  
   228      When the parties place the following orders with ticks:
   229        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   230        | party2 | ETH/DEC21 | buy  | 50     | 1010  | 0                | TYPE_LIMIT | TIF_GTC |
   231        | party1 | ETH/DEC21 | sell | 50     | 1010  | 1                | TYPE_LIMIT | TIF_FOK |
   232      And the network moves ahead "5" blocks
   233      Then the market data for the market "ETH/DEC21" should be:
   234        | mark price | trading mode            | auction trigger             | open interest | target stake | supplied stake |
   235        | 1010       | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 10            | 1010         | 5999           |
   236      And the liquidity provisions should have the following states:
   237        | id  | party          | market    | commitment amount | status           |
   238        | lp2 | lp2Bdistressed | ETH/DEC21 | 1                 | STATUS_CANCELLED |