code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/0042-LIQF-fees_rewards_multi_lps.feature (about)

     1  Feature: Test liquidity provider reward distribution 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 | 4              |
    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      And the following network parameters are set:
    23        | name                                             | value |
    24        | market.value.windowLength                        | 1h    |
    25        | network.markPriceUpdateMaximumFrequency          | 0s    |
    26        | limits.markets.maxPeggedOrders                   | 8     |
    27        | market.liquidity.providersFeeCalculationTimeStep | 10s   |
    28        | market.liquidity.equityLikeShareFeeFraction      | 1     |
    29      Given the liquidity monitoring parameters:
    30        | name               | triggering ratio | time window | scaling factor |
    31        | lqm-params         | 1.0              | 24h         | 1.0            |
    32      
    33      And the liquidity sla params named "SLA":
    34        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
    35        | 1.0         | 0.5                          | 1                             | 1.0                    |
    36      And the markets:
    37        | 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 |
    38        | ETH/MAR22 | USD        | USD   | lqm-params           | log-normal-risk-model | margin-calculator-1 | 2                | fees-config-1 | price-monitoring | default-eth-for-future | 0.25                   | 0                         | SLA        |
    39  
    40      Given the average block duration is "2"
    41  
    42    @Now
    43    Scenario: 001: All liquidity providers in the market receive a greater than zero amount of liquidity fee
    44      Given the parties deposit on asset's general account the following amount:
    45        | party  | asset | amount         |
    46        | lp1    | USD   | 10000000000000 |
    47        | lp2    | USD   | 10000000000000 |
    48        | lp3    | USD   | 10000000000000 |
    49        | party1 | USD   | 1000000000000  |
    50        | party2 | USD   | 100000000000   |
    51  
    52      And the parties submit the following liquidity provision:
    53        | id  | party | market id | commitment amount | fee   | lp type    |
    54        | lp1 | lp1   | ETH/MAR22 | 10000             | 0.001 | submission |
    55        | lp1 | lp1   | ETH/MAR22 | 10000             | 0.001 | amendment  |
    56        | lp2 | lp2   | ETH/MAR22 | 1000000           | 0.002 | submission |
    57        | lp2 | lp2   | ETH/MAR22 | 1000000           | 0.002 | amendment  |
    58        | lp3 | lp3   | ETH/MAR22 | 1000000000        | 0.003 | submission |
    59        | lp3 | lp3   | ETH/MAR22 | 1000000000        | 0.003 | amendment  |
    60      When the network moves ahead "2" blocks
    61      And the parties place the following pegged iceberg orders:
    62        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset |
    63        | lp1   | ETH/MAR22 | 38        | 1                    | buy  | BID              | 38     | 20     |
    64        | lp1   | ETH/MAR22 | 31        | 1                    | sell | ASK              | 31     | 20     |
    65        | lp2   | ETH/MAR22 | 38        | 1                    | buy  | BID              | 38     | 20     |
    66        | lp2   | ETH/MAR22 | 31        | 1                    | sell | ASK              | 31     | 20     |
    67        | lp3   | ETH/MAR22 | 38        | 1                    | buy  | BID              | 38     | 20     |
    68        | lp3   | ETH/MAR22 | 31        | 1                    | sell | ASK              | 31     | 20     |
    69   
    70      Then the parties place the following orders:
    71        | party  | market id | side | volume | price | resulting trades | type       | tif     |
    72        | party1 | ETH/MAR22 | buy  | 10     | 900   | 0                | TYPE_LIMIT | TIF_GTC |
    73        | party1 | ETH/MAR22 | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    74        | party2 | ETH/MAR22 | sell | 10     | 1100  | 0                | TYPE_LIMIT | TIF_GTC |
    75        | party2 | ETH/MAR22 | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    76  
    77      Then the opening auction period ends for market "ETH/MAR22"
    78      And the following trades should be executed:
    79        | buyer  | price | size | seller |
    80        | party1 | 1000  | 10   | party2 |
    81  
    82      And the market data for the market "ETH/MAR22" should be:
    83        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
    84        | 1000       | TRADING_MODE_CONTINUOUS | 3600    | 973       | 1027      | 355690000    | 1001010000     | 10            |
    85      # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1000 x 10 x 1 x 3.5569036*10000
    86  
    87      Then the order book should have the following volumes for market "ETH/MAR22":
    88        | side | price | volume |
    89        | buy  | 880   | 114    |
    90        | buy  | 900   | 10     |
    91        | sell | 1100  | 10     |
    92        | sell | 1120  | 93     |
    93  
    94      And the liquidity provider fee shares for the market "ETH/MAR22" should be:
    95        | party | equity like share  | average entry valuation |
    96        | lp1   | 0.0000099899101907 | 10000                   |
    97        | lp2   | 0.0009989910190707 | 1010000                 |
    98        | lp3   | 0.9989910190707386 | 1001010000              |
    99  
   100      And the parties should have the following account balances:
   101        | party  | asset | market id | margin     | general       | bond       |
   102        | lp1    | USD   | ETH/MAR22 | 1653960171 | 9998346029829 | 10000      |
   103        | lp2    | USD   | ETH/MAR22 | 1653960171 | 9998345039829 | 1000000    |
   104        | lp3    | USD   | ETH/MAR22 | 1653960171 | 9997346039829 | 1000000000 |
   105        | party1 | USD   | ETH/MAR22 | 228207540  | 999771792460  |            |
   106        | party2 | USD   | ETH/MAR22 | 1120424632 | 98879575368   |            |
   107  
   108      Then the network moves ahead "1" blocks
   109  
   110      And the liquidity fee factor should be "0.003" for the market "ETH/MAR22"
   111  
   112      Then the parties place the following orders:
   113        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference   |
   114        | party1 | ETH/MAR22 | sell | 20     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | party1-sell |
   115        | party2 | ETH/MAR22 | buy  | 20     | 1000  | 1                | TYPE_LIMIT | TIF_GTC | party2-buy  |
   116  
   117      Then the following transfers should happen:
   118        | from   | to     | from account         | to account                  | market id | amount | asset |
   119        | party2 | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_LIQUIDITY | ETH/MAR22 | 600000 | USD   |
   120  
   121      And the accumulated liquidity fees should be "600000" for the market "ETH/MAR22"
   122  
   123      And the parties should have the following account balances:
   124        | party  | asset | market id | margin     | general       | bond       |
   125        | lp1    | USD   | ETH/MAR22 | 1653960171 | 9998346029829 | 10000      |
   126        | lp2    | USD   | ETH/MAR22 | 1653960171 | 9998345039829 | 1000000    |
   127        | lp3    | USD   | ETH/MAR22 | 1653960171 | 9997346039829 | 1000000000 |
   128        | party1 | USD   | ETH/MAR22 | 1067071078 | 998933008922  |            |
   129        | party2 | USD   | ETH/MAR22 | 1120424632 | 98878695368   |            |
   130  
   131      Then the order book should have the following volumes for market "ETH/MAR22":
   132        | side | price | volume |
   133        | buy  | 880   | 114    |
   134        | buy  | 900   | 10     |
   135        | sell | 1100  | 10     |
   136        | sell | 1120  | 93     |
   137  
   138      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR22"
   139      And the accumulated liquidity fees should be "600000" for the market "ETH/MAR22"
   140      Then the network moves ahead "11" blocks
   141  
   142  
   143      And the following transfers should happen:
   144        | from   | to  | from account                | to account                     | market id | amount | asset |
   145        | market | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/MAR22 | 5      | USD   |
   146        | market | lp2 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/MAR22 | 599    | USD   |
   147        | market | lp3 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/MAR22 | 599394 | USD   |
   148  
   149      And the accumulated liquidity fees should be "1" for the market "ETH/MAR22"
   150  
   151  # # liquidity fee lp1 = 600000 * 0.0000099899101907 = 5
   152  # # liquidity fee lp2 = 600000 * 0.0009989910190707 = 599
   153  # # liquidity fee lp3 = 600000 * 0.9989910190707386 = 599396
   154  
   155