code.vegaprotocol.io/vega@v0.79.0/core/integration/features/liquidity-provision/0044-LIME-065.feature (about)

     1  Feature: Test LP mechanics when there are multiple liquidity providers, and LPs try to amend liquidity commitment;
     2  
     3    Background:
     4  
     5      Given the margin calculator named "margin-calculator-1":
     6        | search factor | initial factor | release factor |
     7        | 1.2           | 1.5            | 1.7            |
     8      Given the log normal risk model named "log-normal-risk-model":
     9        | risk aversion | tau | mu | r | sigma |
    10        | 0.000001      | 0.1 | 0  | 0 | 1.0   |
    11      And the following network parameters are set:
    12        | name                                          | value |
    13        | market.value.windowLength                     | 60s   |
    14        | network.markPriceUpdateMaximumFrequency       | 0s    |
    15        | limits.markets.maxPeggedOrders                | 6     |
    16        | market.auction.minimumDuration                | 1     |
    17        | market.fee.factors.infrastructureFee          | 0.001 |
    18        | market.fee.factors.makerFee                   | 0.004 |
    19      And the liquidity monitoring parameters:
    20        | name               | triggering ratio | time window | scaling factor |
    21        | lqm-params         | 1.0              | 20s         | 1              |  
    22      #risk factor short:3.5569036
    23      #risk factor long:0.801225765
    24      And the following assets are registered:
    25        | id  | decimal places |
    26        | USD | 0              |
    27      And the fees configuration named "fees-config-1":
    28        | maker fee | infrastructure fee |
    29        | 0.0004    | 0.001              |
    30      And the price monitoring named "price-monitoring":
    31        | horizon | probability | auction extension |
    32        | 3600    | 0.99        | 3                 |
    33  
    34      And the liquidity sla params named "SLA-22":
    35        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
    36        | 0.5         | 0.6                          | 1                             | 1.0                    |
    37      And the liquidity sla params named "SLA-23":
    38        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
    39        | 0           | 0.6                          | 1                             | 1.0                    |
    40  
    41      And the markets:
    42        | 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 |
    43        | ETH/MAR22 | USD        | USD   | lqm-params           | log-normal-risk-model | margin-calculator-1 | 2                | fees-config-1 | price-monitoring | default-eth-for-future | 1e0                    | 0                         | SLA-22     |
    44        | ETH/MAR23 | USD        | USD   | lqm-params           | log-normal-risk-model | margin-calculator-1 | 2                | fees-config-1 | price-monitoring | default-eth-for-future | 1e0                    | 0                         | SLA-23     |
    45  
    46      And the following network parameters are set:
    47        | name                                                | value |
    48        | market.liquidity.bondPenaltyParameter               | 0.2   |
    49        | market.liquidity.stakeToCcyVolume                   | 1     |
    50        | market.liquidity.successorLaunchWindowLength        | 1h    |
    51        | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0.7   |
    52        | market.liquidity.sla.nonPerformanceBondPenaltyMax   | 0.6   |
    53        | validators.epoch.length                             | 10s   |
    54        | market.liquidity.earlyExitPenalty                   | 0.25  |
    55        | market.liquidity.maximumLiquidityFeeFactorLevel     | 0.25  |
    56  
    57      Given the average block duration is "1"
    58    @Now
    59    Scenario: 001: lp1 and lp2 on the market ETH/MAR22, 0044-LIME-065, 0044-LIME-067, 0044-LIME-069, 0044-LIME-071, 0044-LIME-073
    60      Given the parties deposit on asset's general account the following amount:
    61        | party  | asset | amount |
    62        | lp1    | USD   | 100000 |
    63        | lp2    | USD   | 100000 |
    64        | party1 | USD   | 100000 |
    65        | party2 | USD   | 100000 |
    66        | party3 | USD   | 100000 |
    67  
    68      #AC 0044-LIME-069: When an LP creates a new provision with zero commitment, it should be rejected with an error message
    69      And the parties submit the following liquidity provision:
    70        | id   | party | market id | commitment amount | fee  | lp type    | error                     |
    71        | lp_1 | lp1   | ETH/MAR22 | 0                 | 0.02 | submission | commitment amount is zero |
    72  
    73      And the parties submit the following liquidity provision:
    74        | id   | party | market id | commitment amount | fee   | lp type    |
    75        | lp_1 | lp1 | ETH/MAR22 | 6000 | 0.02 | submission |
    76        | lp_2 | lp2   | ETH/MAR22 | 4000              | 0.015 | submission |
    77  
    78      When the network moves ahead "4" blocks
    79      And the current epoch is "0"
    80  
    81      #AC 0044-LIME-071: When an LP amends the Fee Factor to a value greater than `market.liquidity.maximumLiquidityFeeFactorLevel`, the amendments are rejected
    82      And the parties submit the following liquidity provision:
    83        | id   | party | market id | commitment amount | fee | lp type   | error                           |
    84        | lp_1 | lp1 | ETH/MAR22 | 6000 | 0.4 | amendment | invalid liquidity provision fee |
    85  
    86      And the parties place the following pegged iceberg orders:
    87        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference |
    88        | lp1   | ETH/MAR22 | 12        | 1                    | buy  | BID              | 12     | 20     | lp-b-1    |
    89        | lp1   | ETH/MAR22 | 12        | 1                    | sell | ASK              | 12     | 20     | lp-s-1    |
    90        | lp2   | ETH/MAR22 | 12        | 1                    | buy  | BID              | 12     | 20     | lp-b-2    |
    91        | lp2   | ETH/MAR22 | 12        | 1                    | sell | ASK              | 12     | 20     | lp-s-2    |
    92  
    93      Then the parties place the following orders:
    94        | party  | market id | side | volume | price | resulting trades | type       | tif     |
    95        | party1 | ETH/MAR22 | buy  | 10     | 900   | 0                | TYPE_LIMIT | TIF_GTC |
    96        | party1 | ETH/MAR22 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    97        | party2 | ETH/MAR22 | sell | 10     | 1100  | 0                | TYPE_LIMIT | TIF_GTC |
    98        | party2 | ETH/MAR22 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    99  
   100      Then the opening auction period ends for market "ETH/MAR22"
   101      And the following trades should be executed:
   102        | buyer  | price | size | seller |
   103        | party1 | 1000  | 1    | party2 |
   104  
   105      And the market data for the market "ETH/MAR22" should be:
   106        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   107        | 1000 | TRADING_MODE_CONTINUOUS | 3600 | 973 | 1027 | 3556 | 10000 | 1 |
   108      # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1000 x 1 x 1 x 3.5569036 =3556
   109      And the liquidity fee factor should be "0.015" for the market "ETH/MAR22"
   110      Then the parties should have the following account balances:
   111        | party | asset | market id | margin | general |
   112        | lp1   | USD   | ETH/MAR22 | 64024  | 29976   |
   113      And the parties submit the following liquidity provision:
   114        | id   | party | market id | commitment amount | fee  | lp type   |
   115        | lp_1 | lp1   | ETH/MAR22 | 4000              | 0.02 | amendment |
   116  
   117      When the network moves ahead "3" blocks
   118      And the current epoch is "0"
   119      Then the liquidity provider fee shares for the market "ETH/MAR22" should be:
   120        | party | equity like share | average entry valuation |
   121        | lp1 | 0.6 | 6000  |
   122        | lp2 | 0.4 | 10000 |
   123      Then the parties should have the following account balances:
   124        | party | asset | market id | margin | general | bond |
   125        | lp1   | USD   | ETH/MAR22 | 64024  | 29976   | 6000 |
   126        | lp2   | USD   | ETH/MAR22 | 64024  | 31976   | 4000 |
   127  
   128      When the network moves ahead "5" blocks
   129      And the current epoch is "1"
   130  #AC 0044-LIME-065:When LP1 decreases its commitment, we should see this cash flow (6000-4000=2000) going from bond account to general account, and ELS updated
   131      Then the liquidity provider fee shares for the market "ETH/MAR22" should be:
   132        | party | equity like share | average entry valuation |
   133        | lp1 | 0.5 | 6000  |
   134        | lp2 | 0.5 | 10000 |
   135      Then the parties should have the following account balances:
   136        | party | asset | market id | margin | general | bond |
   137        | lp1   | USD   | ETH/MAR22 | 64024  | 31976   | 4000 |
   138        | lp2   | USD   | ETH/MAR22 | 64024  | 31976   | 4000 |
   139  
   140      When the network moves ahead "1" blocks
   141  
   142      Then the parties place the following orders:
   143        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   144        | party1 | ETH/MAR22 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   145        | party2 | ETH/MAR22 | sell | 1      | 1000  | 1                | TYPE_LIMIT | TIF_GTC |
   146  
   147      And the market data for the market "ETH/MAR22" should be:
   148        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   149        | 1000       | TRADING_MODE_CONTINUOUS | 3600    | 973       | 1027      | 7113         | 8000           | 2             |
   150  
   151      And the parties submit the following liquidity provision:
   152        | id   | party | market id | commitment amount | fee  | lp type   |
   153        | lp_1 | lp1   | ETH/MAR22 | 1000              | 0.02 | amendment |
   154      And the current epoch is "1"
   155  
   156      Then the network moves ahead "1" epochs
   157      And the market data for the market "ETH/MAR22" should be:
   158        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   159        | 1000       | TRADING_MODE_CONTINUOUS | 3600    | 973       | 1027      | 7113         | 5001           | 2             |
   160  #AC 0044-LIME-067:When LP1 decreases its commitment more than maximum-penalty-free-reduction-amount, then penalty-incurring-reduction-amount= 3000-(8000-7113) = 2112,we should see SLA bond peanlty by transfering 0.25*2112=528 in insurance pool and 0.75*2112=1584 to general account, and ELS updated
   161  
   162      Then the liquidity provider fee shares for the market "ETH/MAR22" should be:
   163        | party | equity like share  | average entry valuation |
   164        | lp1   | 0.2001599680063987 | 6000                    |
   165        | lp2   | 0.7998400319936013 | 10000                   |
   166      Then the parties should have the following account balances:
   167        | party | asset | market id | margin | general | bond |
   168        | lp1   | USD   | ETH/MAR22 | 64024  | 34454   | 1001 |
   169        | lp2   | USD   | ETH/MAR22 | 64024  | 31983   | 4000 |
   170      And the insurance pool balance should be "528" for the market "ETH/MAR22"
   171      And the current epoch is "2"
   172