code.vegaprotocol.io/vega@v0.79.0/core/integration/features/liquidity-provision/lp-distressed-closeout-pdp.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 | position decimal places |
    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        | 2                       |
    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 | 200       | 100                  | sell | MID              | 600     | 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  | 100000   | 900   | 0                | TYPE_LIMIT | TIF_GTC |
    51        | party1 | ETH/DEC21 | buy  | 1000     | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    52        | party2 | ETH/DEC21 | sell | 100000   | 1100  | 0                | TYPE_LIMIT | TIF_GTC |
    53        | party2 | ETH/DEC21 | sell | 1000     | 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 "1000" 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           | 1000          | 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  | 600    | 1010  | 1                | TYPE_LIMIT | TIF_GTC |
    70      Then the following trades should be executed:
    71        | buyer  | price | size | seller |
    72        | party3 | 1001  | 600  | party0 |
    73      And the parties should have the following profit and loss:
    74        | party  | volume | unrealised pnl | realised pnl |
    75        | party0 | -600   | 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           | 1600          | 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  | 100    | 1055  | 0                | TYPE_LIMIT | TIF_GTC |
    88        | party4 | ETH/DEC21 | sell | 100    | 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 | 1700          |
    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
   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 | 200       | 100                  | buy  | MID              | 60000   | 100    |
   114        | party6 | ETH/DEC21 | 200       | 100                  | sell | MID              | 60000   | 100    |
   115      And the opening auction period ends for market "ETH/DEC21"
   116      Then the auction ends with a traded volume of "1000" 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           | 1000          | 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  | 600    | 1010  | 1                | TYPE_LIMIT | TIF_GTC |
   128      Then the following trades should be executed:
   129        | buyer  | price | size | seller |
   130        | party3 | 1001  | 600  | party0 |
   131      And the parties should have the following profit and loss:
   132        | party  | volume | unrealised pnl | realised pnl |
   133        | party0 | -600   | 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           | 1600          | 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        | party5 | ETH/DEC21 | buy  | 100    | 1061  | 0                | TYPE_LIMIT | TIF_GTC |
   146        | party4 | ETH/DEC21 | sell | 100    | 1061  | 0                | TYPE_LIMIT | TIF_GTC |
   147      Then the market data for the market "ETH/DEC21" should be:
   148        | mark price | trading mode                    | open interest |
   149        | 1001       | TRADING_MODE_MONITORING_AUCTION | 1600          |
   150      And the parties should have the following account balances:
   151        | party  | asset | market id | margin | general | bond |
   152        | party0 | ETH   | ETH/DEC21 | 658      | 0       | 0    |
   153      And the parties should have the following margin levels:
   154        | party  | market id | maintenance |
   155        | party0 | ETH/DEC21 | 1202        |
   156      
   157      When the network moves ahead "7" blocks
   158      Then the market data for the market "ETH/DEC21" should be:
   159        | mark price | trading mode             | auction trigger             | target stake | supplied stake | open interest |
   160        | 1061       | TRADING_MODE_CONTINUOUS  | AUCTION_TRIGGER_UNSPECIFIED | 1803         | 1000           | 1700          |
   161      And the parties should have the following account balances:
   162        | party  | asset | market id | margin | general | bond |
   163        | party0 | ETH   | ETH/DEC21 | 0      | 3       | 0    |
   164      And the parties should have the following margin levels:
   165        | party  | market id | maintenance |
   166        | party0 | ETH/DEC21 | 0           |
   167      And the liquidity provisions should have the following states:
   168        | id  | party  | market    | commitment amount | status           |
   169        | lp1 | party0 | ETH/DEC21 | 1000              | STATUS_CANCELLED |
   170      And the insurance pool balance should be "1111" for the market "ETH/DEC21"
   171  
   172    @Liquidation
   173    Scenario: 003, 2 LPs on the market, LP1 gets distressed and closed-out during continuous trading (0042-LIQF-014)
   174      When the parties submit the following liquidity provision:
   175        | id  | party  | market id | commitment amount | fee   | lp type    |
   176        | lp2 | party6 | ETH/DEC21 | 1000              | 0.001 | submission |
   177        | lp2 | party6 | ETH/DEC21 | 1000              | 0.001 |            |
   178      And the parties place the following pegged iceberg orders:
   179        | party  | market id | peak size | minimum visible size | side | pegged reference | volume  | offset |
   180        | party6 | ETH/DEC21 | 200       | 100                  | buy  | MID              | 60000   | 100    |
   181        | party6 | ETH/DEC21 | 200       | 100                  | sell | MID              | 60000   | 100    |
   182      And the opening auction period ends for market "ETH/DEC21"
   183      Then the auction ends with a traded volume of "1000" at a price of "1000"
   184      And the market data for the market "ETH/DEC21" should be:
   185        | mark price | trading mode            | target stake | supplied stake | open interest | best static bid price | static mid price | best static offer price |
   186        | 1000       | TRADING_MODE_CONTINUOUS | 1000         | 2000           | 1000          | 900                   | 1000             | 1100                    |
   187      And the parties should have the following account balances:
   188        | party  | asset | market id | margin | general | bond |
   189        | party0 | ETH   | ETH/DEC21 | 720    | 1       | 1000 |
   190     
   191      # Now let's trade with LP1 to increase their margin
   192      When the parties place the following orders with ticks:
   193        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   194        | party3 | ETH/DEC21 | buy  | 600    | 1010  | 1                | TYPE_LIMIT | TIF_GTC |
   195      Then the following trades should be executed:
   196        | buyer  | price | size | seller |
   197        | party3 | 1001  | 600  | party0 |
   198      And the parties should have the following profit and loss:
   199        | party  | volume | unrealised pnl | realised pnl |
   200        | party0 | -600   | 0              | 0            |
   201      # LP1 margin requirement increased, had to dip in to bond account to top up the margin
   202      And the parties should have the following account balances:
   203        | party  | asset | market id | margin  | general | bond |
   204        | party0 | ETH   | ETH/DEC21 | 658     | 0       |  0   |
   205      And the market data for the market "ETH/DEC21" should be:
   206        | mark price | trading mode            | target stake | supplied stake | open interest | best static bid price | static mid price | best static offer price |
   207        | 1001       | TRADING_MODE_CONTINUOUS | 1601         | 2000           | 1600          | 900                   | 1000             | 1100                    |
   208      
   209      # Raise mark price so that the LP1 gets liquidated
   210      When the parties place the following orders with ticks:
   211        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   212        | party5 | ETH/DEC21 | buy  | 100    | 1055  | 0                | TYPE_LIMIT | TIF_GTC |
   213        | party4 | ETH/DEC21 | sell | 100    | 1055  | 1                | TYPE_LIMIT | TIF_FOK |
   214      Then the market data for the market "ETH/DEC21" should be:
   215        | mark price | trading mode            | open interest |
   216        | 1055       | TRADING_MODE_CONTINUOUS | 1700          |
   217      And the parties should have the following account balances:
   218        | party  | asset | market id | margin | general | bond |
   219        | party0 | ETH   | ETH/DEC21 | 0      | 0       | 0    |
   220      And the parties should have the following margin levels:
   221        | party  | market id | maintenance |
   222        | party0 | ETH/DEC21 | 0           |
   223      
   224      When the network moves ahead "7" blocks
   225      Then the liquidity provisions should have the following states:
   226        | id  | party  | market    | commitment amount | status           |
   227        | lp1 | party0 | ETH/DEC21 | 1000              | STATUS_CANCELLED |
   228      And the market data for the market "ETH/DEC21" should be:
   229        | mark price | trading mode             | auction trigger             | target stake | supplied stake | open interest |
   230        | 1055       | TRADING_MODE_CONTINUOUS  | AUCTION_TRIGGER_UNSPECIFIED | 1793         | 1000           | 1700          |
   231      And the insurance pool balance should be "1422" for the market "ETH/DEC21"