code.vegaprotocol.io/vega@v0.79.0/core/integration/features/liquidity-provision/0044-LIME-063.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.1   |
    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-063, 0044-LIME-079, 0044-LIME-081, 0044-LIME-101
    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        | lp3    | USD   | 100000 |
    65        | party1 | USD   | 100000 |
    66        | party2 | USD   | 100000 |
    67        | party3 | USD   | 100000 |
    68        | ptbuy  | USD   | 100000 |
    69        | ptsell | USD   | 100000 |
    70  
    71      And the parties submit the following liquidity provision:
    72        | id   | party | market id | commitment amount | fee   | lp type    |
    73        | lp_1 | lp1   | ETH/MAR22 | 6000              | 0.02  | submission |
    74        | lp_2 | lp2   | ETH/MAR22 | 4000              | 0.015 | submission |
    75  
    76      When the network moves ahead "4" blocks
    77      And the current epoch is "0"
    78      Then the parties place the following orders:
    79        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    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        | lp1    | ETH/MAR22 | buy  | 10     | 950   | 0                | TYPE_LIMIT | TIF_GTC | lp1-b     |
    85        | lp2    | ETH/MAR22 | buy  | 10     | 970   | 0                | TYPE_LIMIT | TIF_GTC | lp2-b     |
    86        | lp2    | ETH/MAR22 | sell | 10     | 1020  | 0                | TYPE_LIMIT | TIF_GTC | lp2-s     |
    87        | lp1    | ETH/MAR22 | sell | 10     | 1050  | 0                | TYPE_LIMIT | TIF_GTC | lp1-s     |
    88  
    89      Then the opening auction period ends for market "ETH/MAR22"
    90      And the following trades should be executed:
    91        | buyer  | price | size | seller |
    92        | party1 | 1000  | 1    | party2 |
    93  
    94      And the market data for the market "ETH/MAR22" should be:
    95        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
    96        | 1000       | TRADING_MODE_CONTINUOUS | 3600    | 973       | 1027      | 3556         | 10000          | 1             |
    97      # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1000 x 1 x 1 x 3.5569036 =3556
    98  
    99      Then the parties cancel the following orders:
   100        | party | reference |
   101        | lp1   | lp1-b     |
   102        | lp2   | lp2-b     |
   103        | lp2   | lp2-s     |
   104        | lp1   | lp1-s     |
   105      #GFA orders got rejected during continous mode
   106      Then the parties place the following orders:
   107        | party | market id | side | volume | price | resulting trades | type       | tif     | error                                        |
   108        | lp1   | ETH/MAR22 | buy  | 10     | 950   | 0                | TYPE_LIMIT | TIF_GFA | gfa order received during continuous trading |
   109        | lp2   | ETH/MAR22 | buy  | 10     | 970   | 0                | TYPE_LIMIT | TIF_GFA | gfa order received during continuous trading |
   110        | lp2   | ETH/MAR22 | sell | 10     | 1020  | 0                | TYPE_LIMIT | TIF_GFA | gfa order received during continuous trading |
   111        | lp1   | ETH/MAR22 | sell | 10     | 1050  | 0                | TYPE_LIMIT | TIF_GFA | gfa order received during continuous trading |
   112  
   113      When the network moves ahead "4" blocks
   114      And the current epoch is "0"
   115  
   116      #AC 0044-LIME-063: When the LP increases its commitment and the increment is higher than its general account balance, the increments are rejected
   117      And the parties submit the following liquidity provision:
   118        | id   | party | market id | commitment amount | fee  | lp type   | error                             |
   119        | lp_1 | lp1   | ETH/MAR22 | 600000            | 0.02 | amendment | commitment submission rejected, not enough stake |
   120  
   121      #AC 0044-LIME-101: During continuous trading an LP can submit a transaction to decrease commitment but it will only happen at the end of current epoch.
   122      And the parties submit the following liquidity provision:
   123        | id   | party | market id | commitment amount | fee  | lp type   |
   124        | lp_1 | lp1   | ETH/MAR22 | 3000              | 0.02 | amendment |
   125      And the supplied stake should be "10000" for the market "ETH/MAR22"
   126      When the network moves ahead "4" blocks
   127      And the supplied stake should be "6000" for the market "ETH/MAR22"
   128      And the current epoch is "1"
   129  
   130      Then the parties should have the following account balances:
   131        | party | asset | market id | margin | general | bond |
   132        | lp1   | USD   | ETH/MAR22 | 0      | 97000   | 2400 |
   133        | lp2   | USD   | ETH/MAR22 | 0      | 96000   | 3600 |
   134  
   135      Then the parties place the following orders:
   136        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   137        | party1 | ETH/MAR22 | buy  | 2      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   138        | party2 | ETH/MAR22 | sell | 2      | 1000  | 1                | TYPE_LIMIT | TIF_GTC |
   139  
   140      When the network moves ahead "1" blocks
   141      Then the current epoch is "1"
   142      # Check the current price bounds, then place some orders to trigger the auction
   143      And the market data for the market "ETH/MAR22" should be:
   144        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   145        | 1000       | TRADING_MODE_CONTINUOUS | 3600    | 973       | 1027      | 10670        | 6000           | 3             |
   146      When the parties place the following orders:
   147        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   148        | ptbuy  | ETH/MAR22 | buy  | 2      | 970   | 0                | TYPE_LIMIT | TIF_GTC |
   149        | ptsell | ETH/MAR22 | sell | 2      | 970   | 0                | TYPE_LIMIT | TIF_GTC |
   150        | ptsell | ETH/MAR22 | sell | 1      | 990   | 0                | TYPE_LIMIT | TIF_GTC |
   151        | ptbuy  | ETH/MAR22 | buy  | 1      | 900   | 0                | TYPE_LIMIT | TIF_GTC |
   152      Then the network moves ahead "1" blocks
   153      And the market data for the market "ETH/MAR22" should be:
   154        | mark price | trading mode                    | auction trigger       | target stake | supplied stake | open interest | auction end |
   155        | 1000       | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | 17250        | 6000           | 3             | 3           |
   156      Then the parties should have the following account balances:
   157        | party | asset | market id | margin | general | bond |
   158        | lp1   | USD   | ETH/MAR22 | 0      | 97000   | 2400 |
   159        | lp2   | USD   | ETH/MAR22 | 0      | 96000   | 3600 |
   160      #AC 0044-LIME-079: GFA orders during auction from LP count towards LPs liquidity commitment, we check the bond account+general account from the of auction
   161      Then the parties place the following orders:
   162        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
   163        | lp1   | ETH/MAR22 | buy  | 10     | 950   | 0                | TYPE_LIMIT | TIF_GFA | lp1-GFA-b |
   164        | lp2   | ETH/MAR22 | buy  | 10     | 970   | 0                | TYPE_LIMIT | TIF_GFA | lp2-GFA-b |
   165        | lp2   | ETH/MAR22 | sell | 10     | 1020  | 0                | TYPE_LIMIT | TIF_GFA | lp2-GFA-s |
   166        | lp1   | ETH/MAR22 | sell | 10     | 1050  | 0                | TYPE_LIMIT | TIF_GFA | lp1-GFA-s |
   167      Then the network moves ahead "1" epochs
   168      And the current epoch is "2"
   169      And the market data for the market "ETH/MAR22" should be:
   170        | mark price | trading mode            | auction trigger             | target stake | supplied stake | open interest | auction end |
   171        | 970        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 17250        | 5652           | 5             | 0           |
   172  
   173      ## No margin for lp1 and lp2, orders were GFA only
   174      Then the parties should have the following account balances:
   175        | party | asset | market id | margin | general | bond |
   176        | lp1   | USD   | ETH/MAR22 | 0      | 97000   | 2261 |
   177        | lp2   | USD   | ETH/MAR22 | 0      | 96000   | 3391 |
   178        #| lp1   | USD   | ETH/MAR22 | 56022  | 40978   | 2400 |
   179        #| lp2 | USD | ETH/MAR22 | 54421 | 41579 | 3600 |
   180  
   181      #lp3 mades a new LP commitment and get the market out of liquidity auction
   182      And the parties submit the following liquidity provision:
   183        | id   | party | market id | commitment amount | fee  | lp type    |
   184        | lp_3 | lp3   | ETH/MAR22 | 5000              | 0.02 | submission |
   185      When the network moves ahead "5" blocks
   186      And the current epoch is "2"
   187      And the market data for the market "ETH/MAR22" should be:
   188        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   189        | 970        | TRADING_MODE_CONTINUOUS | 3600    | 944       | 996       | 17250        | 10652          | 5             |
   190  
   191      Then the parties should have the following account balances:
   192        | party | asset | market id | margin | general | bond |
   193        | lp1   | USD   | ETH/MAR22 | 0      | 97000   | 2261 |
   194        | lp2   | USD   | ETH/MAR22 | 0      | 96000   | 3391 |
   195      And the insurance pool balance should be "1417" for the market "ETH/MAR22"
   196  
   197      Then the network moves ahead "1" epochs
   198      And the current epoch is "3"
   199      #AC 0044-LIME-081: GFA orders during continuous trading mode from LP do not count towards the LP's liquidity commitment
   200      Then the parties should have the following account balances:
   201        | party | asset | market id | margin | general | bond |
   202        | lp1   | USD   | ETH/MAR22 | 0      | 97000   | 2035 |
   203        | lp2   | USD   | ETH/MAR22 | 0      | 96000   | 3052 |
   204  
   205      Then the following transfers should happen:
   206        | from | to     | from account      | to account             | market id | amount | asset |
   207        | lp1  | market | ACCOUNT_TYPE_BOND | ACCOUNT_TYPE_INSURANCE | ETH/MAR22 | 226    | USD   |
   208        | lp2  | market | ACCOUNT_TYPE_BOND | ACCOUNT_TYPE_INSURANCE | ETH/MAR22 | 339    | USD   |
   209      And the insurance pool balance should be "1982" for the market "ETH/MAR22"