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

     1  Feature: Test LP mechanics when there are multiple liquidity providers;
     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      #risk factor short:3.5569036
    12      #risk factor long:0.801225765
    13      And the following assets are registered:
    14        | id  | decimal places |
    15        | USD | 0              |
    16      And the fees configuration named "fees-config-1":
    17        | maker fee | infrastructure fee |
    18        | 0.0004    | 0.001              |
    19      And the price monitoring named "price-monitoring":
    20        | horizon | probability | auction extension |
    21        | 3600    | 0.99        | 3                 |
    22  
    23      And the liquidity sla params named "SLA":
    24        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
    25        | 0.5         | 0.5                          | 1                             | 1.0                    |
    26      And the liquidity monitoring parameters:
    27        | name               | triggering ratio | time window | scaling factor |
    28        | lqm-params         | 1.0              | 20s         | 10             |
    29  
    30      And the markets:
    31        | 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 |
    32        | 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        |
    33      And the following network parameters are set:
    34        | name                                               | value |
    35        | market.liquidity.providersFeeCalculationTimeStep | 5s    |
    36  
    37      And the following network parameters are set:
    38        | name                                                | value |
    39        | market.value.windowLength                           | 60s   |
    40        | network.markPriceUpdateMaximumFrequency             | 0s    |
    41        | limits.markets.maxPeggedOrders                      | 6     |
    42        | market.auction.minimumDuration                      | 1     |
    43        | market.fee.factors.infrastructureFee                | 0.001 |
    44        | market.fee.factors.makerFee                         | 0.004 |
    45        | market.liquidity.bondPenaltyParameter               | 0.2   |
    46        | validators.epoch.length                             | 5s    |
    47        | market.liquidity.stakeToCcyVolume                   | 1     |
    48        | market.liquidity.successorLaunchWindowLength        | 1h    |
    49        | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0.5   |
    50        | market.liquidity.sla.nonPerformanceBondPenaltyMax   | 1     |
    51        | validators.epoch.length                             | 10s   |
    52      Given the average block duration is "2"
    53    @Now
    54    Scenario: 001: lp1 and lp2 under supplies liquidity
    55      Given the parties deposit on asset's general account the following amount:
    56        | party  | asset | amount |
    57        | lp1    | USD   | 100000 |
    58        | lp2    | USD   | 100000 |
    59        | party1 | USD   | 100000 |
    60        | party2 | USD   | 100000 |
    61        | party3 | USD   | 100000 |
    62        | ptbuy  | USD   | 100000 |
    63        | ptsell | USD   | 100000 |
    64  
    65      And the parties submit the following liquidity provision:
    66        | id   | party | market id | commitment amount | fee  | lp type    |
    67        | lp_1 | lp1   | ETH/MAR22 | 50000             | 0.02 | submission |
    68        | lp_2 | lp2   | ETH/MAR22 | 10000             | 0.01 | submission |
    69  
    70      When the network moves ahead "2" blocks
    71      And the parties place the following pegged iceberg orders:
    72        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference |
    73        | lp1   | ETH/MAR22 | 12        | 1                    | buy  | BID              | 12     | 20     | lp-b-1    |
    74        | lp1   | ETH/MAR22 | 12        | 1                    | sell | ASK              | 12     | 20     | lp-s-1    |
    75        | lp2   | ETH/MAR22 | 6         | 1                    | buy  | BID              | 6      | 20     | lp-b-2    |
    76        | lp2   | ETH/MAR22 | 6         | 1                    | sell | ASK              | 6      | 20     | lp-s-2    |
    77  
    78      Then the parties place the following orders:
    79        | party  | market id | side | volume | price | resulting trades | type       | tif     |
    80        | party1 | ETH/MAR22 | buy  | 10     | 900   | 0                | TYPE_LIMIT | TIF_GTC |
    81        | party1 | ETH/MAR22 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    82        | party2 | ETH/MAR22 | sell | 10     | 1100  | 0                | TYPE_LIMIT | TIF_GTC |
    83        | party2 | ETH/MAR22 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    84  
    85      Then the opening auction period ends for market "ETH/MAR22"
    86      And the following trades should be executed:
    87        | buyer  | price | size | seller |
    88        | party1 | 1000  | 1    | party2 |
    89  
    90      And the market data for the market "ETH/MAR22" should be:
    91        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
    92        | 1000       | TRADING_MODE_CONTINUOUS | 3600    | 973       | 1027      | 35569        | 45976          | 1             |
    93      # # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1000 x 10 x 1 x 3.5569036
    94  
    95      And the liquidity fee factor should be "0.02" for the market "ETH/MAR22"
    96  
    97      And the parties should have the following margin levels:
    98        | party | market id | maintenance | search | initial | release |
    99        | lp1   | ETH/MAR22 | 42683       | 51219  | 64024   | 72561   |
   100      And the parties should have the following account balances:
   101        | party | asset | market id | margin | general | bond  |
   102        | lp1   | USD   | ETH/MAR22 | 64024  | 0       | 35976 |
   103        | lp2   | USD   | ETH/MAR22 | 32013  | 57987   | 10000 |
   104      #     #margin_intial lp1: 12*1000*3.5569036*1.5=64024
   105      When the network moves ahead "6" blocks
   106      # Trigger auction
   107      And the parties place the following orders:
   108        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   109        | ptbuy  | ETH/MAR22 | buy  | 2      | 970   | 0                | TYPE_LIMIT | TIF_GTC |
   110        | ptsell | ETH/MAR22 | sell | 2      | 970   | 0                | TYPE_LIMIT | TIF_GTC |
   111      And the parties should have the following account balances:
   112        | party | asset | market id | margin | general | bond  |
   113        | lp1   | USD   | ETH/MAR22 | 0      | 64024   | 17988 |
   114        | lp2   | USD   | ETH/MAR22 | 0      | 90000   | 5000  |
   115  
   116    @SLABug
   117    Scenario: 002: lp1 and lp2 amend LP commitment
   118      Given the parties deposit on asset's general account the following amount:
   119        | party  | asset | amount  |
   120        | lp1    | USD   | 1000000 |
   121        | lp2    | USD   | 1000000 |
   122        | party1 | USD   | 100000  |
   123        | party2 | USD   | 100000  |
   124        | party3 | USD   | 100000  |
   125  
   126      And the parties submit the following liquidity provision:
   127        | id   | party | market id | commitment amount | fee  | lp type    |
   128        | lp_1 | lp1   | ETH/MAR22 | 50000             | 0.02 | submission |
   129        | lp_2 | lp2   | ETH/MAR22 | 10000             | 0.01 | submission |
   130  
   131      When the network moves ahead "2" blocks
   132      And the parties place the following pegged iceberg orders:
   133        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference |
   134        | lp1   | ETH/MAR22 | 120       | 1                    | buy  | BID              | 120    | 20     | lp-b-1    |
   135        | lp1   | ETH/MAR22 | 120       | 1                    | sell | ASK              | 120    | 20     | lp-s-1    |
   136        | lp2   | ETH/MAR22 | 60        | 1                    | buy  | BID              | 60     | 20     | lp-b-2    |
   137        | lp2   | ETH/MAR22 | 60        | 1                    | sell | ASK              | 60     | 20     | lp-s-2    |
   138      Then the network moves ahead "2" blocks
   139      And the orders should have the following status:
   140        | party | reference | status        |
   141        | lp1   | lp-b-1    | STATUS_PARKED |
   142  
   143      Then the parties place the following orders:
   144        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   145        | party1 | ETH/MAR22 | buy  | 10     | 900   | 0                | TYPE_LIMIT | TIF_GTC |
   146        | party1 | ETH/MAR22 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   147        | party2 | ETH/MAR22 | sell | 10     | 1100  | 0                | TYPE_LIMIT | TIF_GTC |
   148        | party2 | ETH/MAR22 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   149      Then the network moves ahead "2" blocks
   150  
   151      #Then the opening auction period ends for market "ETH/MAR22"
   152  
   153      And the orders should have the following status:
   154        | party | reference | status        |
   155        | lp1   | lp-b-1    | STATUS_ACTIVE |
   156  
   157      And the following trades should be executed:
   158        | buyer  | price | size | seller |
   159        | party1 | 1000  | 1    | party2 |
   160  
   161      And the parties should have the following account balances:
   162        | party | asset | market id | margin | general | bond  |
   163        | lp1   | USD   | ETH/MAR22 | 640243 | 309757  | 50000 |
   164  
   165      And the market data for the market "ETH/MAR22" should be:
   166        | mark price | trading mode            | target stake | supplied stake | open interest |
   167        | 1000       | TRADING_MODE_CONTINUOUS | 35569        | 60000          | 1             |
   168  
   169      #AC: 0044-LIME-018, lp reduces commitment
   170      And the parties submit the following liquidity provision:
   171        | id   | party | market id | commitment amount | fee  | lp type   |
   172        | lp_1 | lp1   | ETH/MAR22 | 30000             | 0.02 | amendment |
   173      And the supplied stake should be "60000" for the market "ETH/MAR22"
   174      Then the network moves ahead "10" blocks
   175      And the supplied stake should be "40000" for the market "ETH/MAR22"
   176  
   177      #AC: 0044-LIME-019, lp reduces commitment multi times
   178      And the parties submit the following liquidity provision:
   179        | id   | party | market id | commitment amount | fee  | lp type   |
   180        | lp_1 | lp1   | ETH/MAR22 | 28000             | 0.02 | amendment |
   181      And the parties submit the following liquidity provision:
   182        | id   | party | market id | commitment amount | fee  | lp type   |
   183        | lp_1 | lp1   | ETH/MAR22 | 27000             | 0.02 | amendment |
   184      And the parties submit the following liquidity provision:
   185        | id   | party | market id | commitment amount | fee  | lp type   |
   186        | lp_1 | lp1   | ETH/MAR22 | 27000             | 0.02 | amendment |
   187      And the supplied stake should be "40000" for the market "ETH/MAR22"
   188      Then the network moves ahead "7" blocks
   189      And the supplied stake should be "37000" for the market "ETH/MAR22"
   190  
   191      #AC:0044-LIME-021, lp changes fee factor
   192      And the parties submit the following liquidity provision:
   193        | id   | party | market id | commitment amount | fee  | lp type   |
   194        | lp_1 | lp1   | ETH/MAR22 | 50000             | 0.03 | amendment |
   195      And the liquidity fee factor should be "0.02" for the market "ETH/MAR22"
   196      Then the network moves ahead "10" blocks
   197      And the liquidity fee factor should be "0.03" for the market "ETH/MAR22"
   198  
   199      #AC: 0044-LIME-030, lp increases commitment and they do not have sufficient collateral in the settlement asset
   200      And the parties submit the following liquidity provision:
   201        | id   | party | market id | commitment amount | fee  | lp type   | error                             |
   202        | lp_1 | lp1   | ETH/MAR22 | 600000            | 0.02 | amendment | commitment submission rejected, not enough stake |
   203      Then the network moves ahead "1" blocks
   204      And the supplied stake should be "60000" for the market "ETH/MAR22"
   205  
   206      #AC: 0044-LIME-031, lp increases commitment and they have sufficient collateral in the settlement asset
   207      And the parties submit the following liquidity provision:
   208        | id   | party | market id | commitment amount | fee  | lp type   |
   209        | lp_1 | lp1   | ETH/MAR22 | 60000             | 0.02 | amendment |
   210      And the supplied stake should be "70000" for the market "ETH/MAR22"