code.vegaprotocol.io/vega@v0.79.0/core/integration/features/liquidity-provision/lp-distressed-closeout.feature (about)

     1  Feature: Replicate LP getting distressed during continuous trading, and after leaving an auction
     2  
     3    Background:
     4      Given the following network parameters are set:
     5        | name                                          | value |
     6        | market.liquidity.bondPenaltyParameter         | 1     |
     7        | network.markPriceUpdateMaximumFrequency       | 0s    |
     8        | limits.markets.maxPeggedOrders                | 2     |
     9        | validators.epoch.length                       | 5s    |
    10      And the liquidity monitoring parameters:
    11        | name               | triggering ratio | time window | scaling factor |
    12        | lqm-params         | 0.1              | 24h         | 1              |  
    13      And the average block duration is "1"
    14      And the simple risk model named "simple-risk-model-1":
    15        | long | short | max move up | min move down | probability of trading |
    16        | 0.1  | 0.1   | 60          | 50            | 0.2                    |
    17      And the fees configuration named "fees-config-1":
    18        | maker fee | infrastructure fee |
    19        | 0.004     | 0.001              |
    20      And the price monitoring named "price-monitoring-1":
    21        | horizon | probability | auction extension |
    22        | 1       | 0.99        | 5                 |
    23      And the liquidity sla params named "SLA":
    24        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
    25        | 0.01        | 0.5                          | 1                             | 1.0                    |
    26      And the markets:
    27        | 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 |
    28        | ETH/DEC21 | ETH        | ETH   | lqm-params           | simple-risk-model-1 | default-margin-calculator | 1                | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.1                      | 0                         | SLA        |
    29      And the following network parameters are set:
    30        | name                                             | value |
    31        | market.liquidity.providersFeeCalculationTimeStep | 5s    |
    32      And the parties deposit on asset's general account the following amount:
    33        | party  | asset | amount     |
    34        | party0 | ETH   | 1721       |
    35        | party1 | ETH   | 100000000  |
    36        | party2 | ETH   | 100000000  |
    37        | party3 | ETH   | 100000000  |
    38        | party4 | ETH   | 1000000000 |
    39        | party5 | ETH   | 1000000000 |
    40        | party6 | ETH   | 1000000000 |
    41      And the parties submit the following liquidity provision:
    42        | id  | party  | market id | commitment amount | fee   | lp type    |
    43        | lp1 | party0 | ETH/DEC21 | 1000              | 0.001 | submission |
    44        | lp1 | party0 | ETH/DEC21 | 1000              | 0.001 | amendment  |
    45      And the parties place the following pegged iceberg orders:
    46        | party  | market id | peak size | minimum visible size | side | pegged reference | volume | offset |
    47        | party0 | ETH/DEC21 | 2         | 1                    | sell | MID              | 6      | 1      |
    48      And the parties place the following orders:
    49        | party  | market id | side | volume | price | resulting trades | type       | tif     |
    50        | party1 | ETH/DEC21 | buy  | 1000   | 900   | 0                | TYPE_LIMIT | TIF_GTC |
    51        | party1 | ETH/DEC21 | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    52        | party2 | ETH/DEC21 | sell | 1000   | 1100  | 0                | TYPE_LIMIT | TIF_GTC |
    53        | party2 | ETH/DEC21 | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    54  
    55    @Liquidation
    56    Scenario: 001, LP gets distressed during continuous trading (0042-LIQF-014)
    57      When the opening auction period ends for market "ETH/DEC21"
    58      And the auction ends with a traded volume of "10" at a price of "1000"
    59      Then the market data for the market "ETH/DEC21" should be:
    60        | mark price | trading mode            | target stake | supplied stake | open interest | best static bid price | static mid price | best static offer price |
    61        | 1000       | TRADING_MODE_CONTINUOUS | 1000         | 1000           | 10            | 900                   | 1000             | 1100                    |
    62      And the parties should have the following account balances:
    63        | party  | asset | market id | margin | general | bond |
    64        | party0 | ETH   | ETH/DEC21 | 720    | 1       | 1000 |
    65  
    66      # Now let's trade with LP to increase their margin
    67      When the parties place the following orders with ticks:
    68        | party  | market id | side | volume | price | resulting trades | type       | tif     |
    69        | party3 | ETH/DEC21 | buy  | 6      | 1010  | 1                | TYPE_LIMIT | TIF_GTC |
    70      Then the following trades should be executed:
    71        | buyer  | price | size | seller |
    72        | party3 | 1001  | 6    | party0 |
    73      And the parties should have the following profit and loss:
    74        | party  | volume | unrealised pnl | realised pnl |
    75        | party0 | -6     | 0              | 0            |
    76      # LP margin requirement increased, had to dip in to bond account to top up the margin
    77      And the parties should have the following account balances:
    78        | party  | asset | market id | margin | general | bond |
    79        | party0 | ETH   | ETH/DEC21 | 658    | 0       | 0    |
    80      And the market data for the market "ETH/DEC21" should be:
    81        | mark price | trading mode            | target stake | supplied stake | open interest | best static bid price | static mid price | best static offer price |
    82        | 1001       | TRADING_MODE_CONTINUOUS | 1601         | 1000           | 16            | 900                   | 1000             | 1100                    |
    83  
    84      # Raise mark price so that the LP gets liquidated
    85      When the parties place the following orders with ticks:
    86        | party  | market id | side | volume | price | resulting trades | type       | tif     |
    87        | party5 | ETH/DEC21 | buy  | 1      | 1055  | 0                | TYPE_LIMIT | TIF_GTC |
    88        | party4 | ETH/DEC21 | sell | 1      | 1055  | 1                | TYPE_LIMIT | TIF_FOK |
    89      Then the market data for the market "ETH/DEC21" should be:
    90        | mark price | trading mode            | open interest |
    91        | 1055       | TRADING_MODE_CONTINUOUS | 17            |
    92      And the parties should have the following account balances:
    93        | party  | asset | market id | margin | general | bond |
    94        | party0 | ETH   | ETH/DEC21 | 0      | 0       | 0    |
    95      And the parties should have the following margin levels:
    96        | party  | market id | maintenance |
    97        | party0 | ETH/DEC21 | 0           |
    98  
    99      When the network moves ahead "7" blocks
   100      Then the liquidity provisions should have the following states:
   101        | id  | party  | market    | commitment amount | status           |
   102        | lp1 | party0 | ETH/DEC21 | 1000              | STATUS_CANCELLED |
   103      And the insurance pool balance should be "1422" for the market "ETH/DEC21"
   104  
   105    @Liquidation
   106    Scenario: 002, LP gets distressed after auction (0044-LIME-073)
   107      When the parties submit the following liquidity provision:
   108        | id  | party  | market id | commitment amount | fee   | lp type    |
   109        | lp2 | party6 | ETH/DEC21 | 1000              | 0.001 | submission |
   110        | lp2 | party6 | ETH/DEC21 | 1000              | 0.001 |            |
   111      And the parties place the following pegged iceberg orders:
   112        | party  | market id | peak size | minimum visible size | side | pegged reference | volume | offset |
   113        | party6 | ETH/DEC21 | 2         | 1                    | buy  | MID              | 600    | 100    |
   114        | party6 | ETH/DEC21 | 2         | 1                    | sell | MID              | 600    | 100    |
   115      And the opening auction period ends for market "ETH/DEC21"
   116      Then the auction ends with a traded volume of "10" at a price of "1000"
   117      And the market data for the market "ETH/DEC21" should be:
   118        | mark price | trading mode            | target stake | supplied stake | open interest | best static bid price | static mid price | best static offer price |
   119        | 1000       | TRADING_MODE_CONTINUOUS | 1000         | 2000           | 10            | 900                   | 1000             | 1100                    |
   120      And the parties should have the following account balances:
   121        | party  | asset | market id | margin | general | bond |
   122        | party0 | ETH   | ETH/DEC21 | 720    | 1       | 1000 |
   123  
   124      # Now let's trade with LP1 to increase their margin
   125      When the parties place the following orders with ticks:
   126        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   127        | party3 | ETH/DEC21 | buy  | 6      | 1010  | 1                | TYPE_LIMIT | TIF_GTC |
   128      Then the following trades should be executed:
   129        | buyer  | price | size | seller |
   130        | party3 | 1001  | 6    | party0 |
   131      And the parties should have the following profit and loss:
   132        | party  | volume | unrealised pnl | realised pnl |
   133        | party0 | -6     | 0              | 0            |
   134      # LP1 margin requirement increased, had to dip in to bond account to top up the margin
   135      And the parties should have the following account balances:
   136        | party  | asset | market id | margin | general | bond |
   137        | party0 | ETH   | ETH/DEC21 | 658    | 0       | 0    |
   138      And the market data for the market "ETH/DEC21" should be:
   139        | mark price | trading mode            | target stake | supplied stake | open interest | best static bid price | static mid price | best static offer price | horizon | min bound | max bound |
   140        | 1001       | TRADING_MODE_CONTINUOUS | 1601         | 2000           | 16            | 900                   | 1000             | 1100                    | 1       | 950       | 1060      |
   141  
   142      # Generate a trade outwith price monitoring bounds so that LP1 gets liquidated upon auction uncrossing
   143      When the parties place the following orders with ticks:
   144        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   145        | party0 | ETH/DEC21 | buy  | 1      | 1060  | 0                | TYPE_LIMIT | TIF_GTC |
   146        | party5 | ETH/DEC21 | buy  | 1      | 1061  | 0                | TYPE_LIMIT | TIF_GTC |
   147        | party4 | ETH/DEC21 | sell | 1      | 1061  | 0                | TYPE_LIMIT | TIF_GTC |
   148      Then the order book should have the following volumes for market "ETH/DEC21":
   149        | side | price | volume |
   150        | buy  | 1060  | 1      |
   151      Then the market data for the market "ETH/DEC21" should be:
   152        | mark price | trading mode                    | open interest |
   153        | 1001       | TRADING_MODE_MONITORING_AUCTION | 16            |
   154      And the parties should have the following account balances:
   155        | party  | asset | market id | margin | general | bond |
   156        | party0 | ETH   | ETH/DEC21 | 658    | 0       | 0    |
   157      And the parties should have the following margin levels:
   158        | party  | market id | maintenance |
   159        | party0 | ETH/DEC21 | 1202        |
   160  
   161      When the network moves ahead "7" blocks
   162      Then the market data for the market "ETH/DEC21" should be:
   163        | mark price | trading mode            | auction trigger             | target stake | supplied stake | open interest |
   164        | 1061       | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 1803         | 1000           | 17            |
   165      And the parties should have the following account balances:
   166        | party  | asset | market id | margin | general | bond |
   167        | party0 | ETH   | ETH/DEC21 | 0      | 3       | 0    |
   168      And the order book should have the following volumes for market "ETH/DEC21":
   169        | side | price | volume |
   170        | buy  | 1060  | 0      |
   171      And the parties should have the following margin levels:
   172        | party  | market id | maintenance |
   173        | party0 | ETH/DEC21 | 0           |
   174      And the liquidity provisions should have the following states:
   175        | id  | party  | market    | commitment amount | status           |
   176        | lp1 | party0 | ETH/DEC21 | 1000              | STATUS_CANCELLED |
   177      And the insurance pool balance should be "1111" for the market "ETH/DEC21"
   178  
   179    @Liquidation
   180    Scenario: 003, 2 LPs on the market, LP1 gets distressed and closed-out during continuous trading (0042-LIQF-014)
   181      When the parties submit the following liquidity provision:
   182        | id  | party  | market id | commitment amount | fee   | lp type    |
   183        | lp2 | party6 | ETH/DEC21 | 1000              | 0.001 | submission |
   184        | lp2 | party6 | ETH/DEC21 | 1000              | 0.001 |            |
   185      And the parties place the following pegged iceberg orders:
   186        | party  | market id | peak size | minimum visible size | side | pegged reference | volume | offset |
   187        | party6 | ETH/DEC21 | 2         | 1                    | buy  | MID              | 600    | 100    |
   188        | party6 | ETH/DEC21 | 2         | 1                    | sell | MID              | 600    | 100    |
   189      And the opening auction period ends for market "ETH/DEC21"
   190      Then the auction ends with a traded volume of "10" at a price of "1000"
   191      And the market data for the market "ETH/DEC21" should be:
   192        | mark price | trading mode            | target stake | supplied stake | open interest | best static bid price | static mid price | best static offer price |
   193        | 1000       | TRADING_MODE_CONTINUOUS | 1000         | 2000           | 10            | 900                   | 1000             | 1100                    |
   194      And the parties should have the following account balances:
   195        | party  | asset | market id | margin | general | bond |
   196        | party0 | ETH   | ETH/DEC21 | 720    | 1       | 1000 |
   197  
   198      # Now let's trade with LP1 to increase their margin
   199      When the parties place the following orders with ticks:
   200        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   201        | party3 | ETH/DEC21 | buy  | 6      | 1010  | 1                | TYPE_LIMIT | TIF_GTC |
   202      Then the following trades should be executed:
   203        | buyer  | price | size | seller |
   204        | party3 | 1001  | 6    | party0 |
   205      And the parties should have the following profit and loss:
   206        | party  | volume | unrealised pnl | realised pnl |
   207        | party0 | -6     | 0              | 0            |
   208      # LP1 margin requirement increased, had to dip in to bond account to top up the margin
   209      And the parties should have the following account balances:
   210        | party  | asset | market id | margin | general | bond |
   211        | party0 | ETH   | ETH/DEC21 | 658    | 0       | 0    |
   212      And the market data for the market "ETH/DEC21" should be:
   213        | mark price | trading mode            | target stake | supplied stake | open interest | best static bid price | static mid price | best static offer price |
   214        | 1001       | TRADING_MODE_CONTINUOUS | 1601         | 2000           | 16            | 900                   | 1000             | 1100                    |
   215  
   216      # Raise mark price so that the LP1 gets liquidated
   217      When the parties place the following orders with ticks:
   218        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   219        | party5 | ETH/DEC21 | buy  | 1      | 1055  | 0                | TYPE_LIMIT | TIF_GTC |
   220        | party4 | ETH/DEC21 | sell | 1      | 1055  | 1                | TYPE_LIMIT | TIF_FOK |
   221      Then the market data for the market "ETH/DEC21" should be:
   222        | mark price | trading mode            | open interest |
   223        | 1055       | TRADING_MODE_CONTINUOUS | 17            |
   224      And the parties should have the following account balances:
   225        | party  | asset | market id | margin | general | bond |
   226        | party0 | ETH   | ETH/DEC21 | 0      | 0       | 0    |
   227      And the parties should have the following margin levels:
   228        | party  | market id | maintenance |
   229        | party0 | ETH/DEC21 | 0           |
   230  
   231      When the network moves ahead "7" blocks
   232      Then the liquidity provisions should have the following states:
   233        | id  | party  | market    | commitment amount | status           |
   234        | lp1 | party0 | ETH/DEC21 | 1000              | STATUS_CANCELLED |
   235      And the market data for the market "ETH/DEC21" should be:
   236        | mark price | trading mode            | auction trigger             | target stake | supplied stake | open interest |
   237        | 1055       | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 1793         | 1000           | 17            |
   238      And the insurance pool balance should be "1422" for the market "ETH/DEC21"