code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/liquidity-provision-bond-account.feature (about)

     1  Feature: Replicate LP getting distressed during continuous trading, check if penalty is implemented correctly
     2  
     3    Background:
     4  
     5      Given the log normal risk model named "log-normal-risk-model-1":
     6        | risk aversion | tau | mu | r | sigma |
     7        | 0.000001      | 0.1 | 0  | 0 | 1.0   |
     8      And the fees configuration named "fees-config-1":
     9        | maker fee | infrastructure fee |
    10        | 0.004     | 0.001              |
    11      And the price monitoring named "price-monitoring-1":
    12        | horizon | probability | auction extension |
    13        | 1       | 0.99        | 300               |
    14      Given the liquidity monitoring parameters:
    15        | name               | triggering ratio | time window | scaling factor |
    16        | lqm-params         | 0.24             | 24h         | 1.0            |
    17      And the markets:
    18        | 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      |
    19        | ETH/MAR22 | ETH        | USD   | lqm-params           | log-normal-risk-model-1 | default-margin-calculator | 1                | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.7                    | 0                         | default-futures |
    20      And the parties deposit on asset's general account the following amount:
    21        | party  | asset | amount    |
    22        | party0 | USD   | 500000    |
    23        | party1 | USD   | 100000000 |
    24        | party2 | USD   | 100000000 |
    25        | party3 | USD   | 100000000 |
    26        | party4 | USD   | 100000000 |
    27        | party5 | USD   | 100000000 |
    28      And the following network parameters are set:
    29        | name                                    | value |
    30        | network.markPriceUpdateMaximumFrequency | 0s    |
    31        | limits.markets.maxPeggedOrders          | 2     |
    32        | market.liquidity.bondPenaltyParameter               | 0    |
    33        | validators.epoch.length                               | 5s   |
    34        | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0    |
    35      
    36  
    37    @Now
    38    Scenario: 001, LP gets distressed during continuous trading, no DPD setting (0044-LIME-002, 0035-LIQM-004)
    39  
    40      Given the liquidity monitoring parameters:
    41        | name               | triggering ratio | time window | scaling factor |
    42        | updated-lqm-params | 0.24             | 24h         | 1              |
    43      When the markets are updated:
    44        | id        | liquidity monitoring | linear slippage factor | quadratic slippage factor |
    45        | ETH/MAR22 | updated-lqm-params   | 0.7                    | 0                         |
    46      And the following network parameters are set:
    47        | name                                  | value |
    48        | market.liquidity.bondPenaltyParameter | 0.2   |
    49      And the parties deposit on asset's general account the following amount:
    50        | party  | asset | amount |
    51        | party0 | USD   | 12500  |
    52      And the average block duration is "1"
    53  
    54      And the parties submit the following liquidity provision:
    55        | id  | party  | market id | commitment amount | fee   | lp type    |
    56        | lp1 | party0 | ETH/MAR22 | 50000             | 0.001 | submission |
    57        | lp1 | party0 | ETH/MAR22 | 50000             | 0.001 | amendment  |
    58      And the parties place the following pegged iceberg orders:
    59        | party  | market id | peak size | minimum visible size | side | pegged reference | volume  | offset |
    60        | party0 | ETH/MAR22 | 49        | 1                    | sell | ASK              | 49      | 20     |
    61        | party0 | ETH/MAR22 | 52        | 1                    | buy  | BID              | 52      | 20     |
    62  
    63      And the parties place the following orders:
    64        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference  |
    65        | party4 | ETH/MAR22 | buy  | 100    | 850   | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-4  |
    66        | party1 | ETH/MAR22 | buy  | 1      | 900   | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-1  |
    67        | party1 | ETH/MAR22 | buy  | 1      | 990   | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-1  |
    68        | party1 | ETH/MAR22 | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-2  |
    69        | party2 | ETH/MAR22 | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-3 |
    70        | party2 | ETH/MAR22 | sell | 1      | 1010  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-1 |
    71        | party2 | ETH/MAR22 | sell | 1      | 1100  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-2 |
    72        | party5 | ETH/MAR22 | sell | 100    | 1200  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-5 |
    73  
    74      When the opening auction period ends for market "ETH/MAR22"
    75      Then the auction ends with a traded volume of "10" at a price of "1000"
    76  # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1000 x 10 x 1 x 3.5569
    77      And the insurance pool balance should be "0" for the market "ETH/MAR22"
    78      And the market data for the market "ETH/MAR22" should be:
    79        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
    80        | 1000       | TRADING_MODE_CONTINUOUS | 1       | 1000      | 1000      | 35569        | 50000          | 10            |
    81  
    82      And the parties should have the following account balances:
    83        | party  | asset | market id | margin | general  | bond  |
    84        | party0 | USD   | ETH/MAR22 | 209146 | 253354   | 50000 |
    85        | party1 | USD   | ETH/MAR22 | 19930  | 99980070 |       |
    86        | party2 | USD   | ETH/MAR22 | 59619  | 99940381 |       |
    87      #check the margin levels
    88      Then the parties should have the following margin levels:
    89        | party  | market id | maintenance |
    90        | party0 | ETH/MAR22 | 174289      |
    91        | party1 | ETH/MAR22 | 16609       |
    92        | party2 | ETH/MAR22 | 49683       |
    93      #check position (party0 has no position)
    94      Then the parties should have the following profit and loss:
    95        | party  | volume | unrealised pnl | realised pnl |
    96        | party1 | 10     | 0              | 0            |
    97        | party2 | -10    | 0              | 0            |
    98  
    99      When the parties place the following orders:
   100        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference    |
   101        | party3 | ETH/MAR22 | buy  | 30     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | party3-buy-1 |
   102  
   103      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR22"
   104  
   105      When the parties place the following orders:
   106        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference     |
   107        | party2 | ETH/MAR22 | sell | 50     | 1000  | 1                | TYPE_LIMIT | TIF_GTC | party2-sell-4 |
   108  
   109      And the market data for the market "ETH/MAR22" should be:
   110        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   111        | 1000       | TRADING_MODE_CONTINUOUS | 1       | 1000      | 1000      | 142276       | 50000          | 40            |
   112      # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1000 x 40 x 1 x 3.5569=142276
   113  
   114      And the parties should have the following account balances:
   115        | party  | asset | market id | margin | general  | bond  |
   116        | party0 | USD   | ETH/MAR22 | 209146 | 253354   | 50000 |
   117        | party1 | USD   | ETH/MAR22 | 19930  | 99980070 |       |
   118        | party2 | USD   | ETH/MAR22 | 273034 | 99726786 |       |
   119      #check the margin levels
   120      Then the parties should have the following margin levels:
   121        | party  | market id | maintenance |
   122        | party0 | ETH/MAR22 | 174289      |
   123  
   124      And the insurance pool balance should be "0" for the market "ETH/MAR22"
   125  
   126      # update linear slippage factor more in line with what book-based slippage used to be
   127      And the markets are updated:
   128        | id          | linear slippage factor |
   129        | ETH/MAR22   | 0.05                   |
   130  
   131      When the parties place the following orders:
   132        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference     |
   133        | party0 | ETH/MAR22 | sell | 70     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | party0-sell-3 |
   134        | party1 | ETH/MAR22 | buy  | 100    | 1000  | 2                | TYPE_LIMIT | TIF_GTC | party1-buy-4  |
   135  
   136      Then the network moves ahead "1" blocks
   137  
   138      Then the parties should have the following margin levels:
   139        | party  | market id | maintenance |
   140        | party0 | ETH/MAR22 | 426772      |
   141        | party1 | ETH/MAR22 | 94682       |
   142  
   143      And the insurance pool balance should be "9085" for the market "ETH/MAR22"
   144  
   145      #check the requried balances
   146      And the parties should have the following account balances:
   147        | party  | asset | market id | margin | general | bond |
   148        | party0 | USD   | ETH/MAR22 | 503415 | 0       | 280  |