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

     1  
     2  Feature: Test liquidity provider reward distribution; Check what happens when distribution period is large (both in genesis)
     3  
     4    Background:
     5  
     6      Given the simple risk model named "simple-risk-model-1":
     7        | long | short | max move up | min move down | probability of trading |
     8        | 0.1  | 0.1   | 500         | 500           | 0.1                    |
     9      And the fees configuration named "fees-config-1":
    10        | maker fee | infrastructure fee |
    11        | 0.0004    | 0.001              |
    12      And the price monitoring named "price-monitoring":
    13        | horizon | probability | auction extension |
    14        | 1       | 0.99        | 3                 |
    15      And the following network parameters are set:
    16        | name                                                | value |
    17        | market.value.windowLength                           | 1h    |
    18        | network.markPriceUpdateMaximumFrequency             | 0s    |
    19        | limits.markets.maxPeggedOrders                      | 4     |
    20      Given the liquidity monitoring parameters:
    21        | name               | triggering ratio | time window | scaling factor |
    22        | lqm-params         | 0.0              | 24h         | 1.0            |
    23      And the liquidity sla params named "SLA":
    24        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
    25        | 1.0         | 0.5                          | 1                             | 1.0                    |
    26      And the markets:
    27        | 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 |
    28        | ETH/MAR22 | USD        | USD   | lqm-params           | simple-risk-model-1 | default-margin-calculator | 2                | fees-config-1 | price-monitoring | default-eth-for-future | 0.032                  | 0                         | SLA        |
    29      And the following network parameters are set:
    30        | name                                               | value    |
    31        | market.liquidity.providersFeeCalculationTimeStep | 24h0m0s  |
    32  
    33      Given the average block duration is "2"
    34  
    35    Scenario: 001: 1 LP joining at start, checking liquidity rewards over 3 periods, 1 period with no trades (0042-LIQF-006)
    36      # setup accounts
    37      Given the parties deposit on asset's general account the following amount:
    38        | party  | asset | amount     |
    39        | lp1 | USD | 2000000000 |
    40        | party1 | USD   | 100000000  |
    41        | party2 | USD   | 100000000  |
    42        | party3 | USD | 100000000 |
    43  
    44      And the parties submit the following liquidity provision:
    45        | id  | party | market id | commitment amount | fee   | lp type    |
    46        | lp1 | lp1   | ETH/MAR22 | 10000             | 0.001 | submission |
    47  
    48      And the parties place the following pegged iceberg orders:
    49        | party | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
    50        | lp1 | ETH/MAR22 | 4 | 1 | buy  | BID | 4 | 2 |
    51        | lp1 | ETH/MAR22 | 7 | 1 | buy  | MID | 7 | 1 |
    52        | lp1 | ETH/MAR22 | 4 | 1 | sell | ASK | 4 | 2 |
    53        | lp1 | ETH/MAR22 | 7 | 1 | sell | MID | 7 | 1 |
    54   
    55      Then the parties place the following orders:
    56        | party  | market id | side | volume | price | resulting trades | type       | tif     |
    57        | party1 | ETH/MAR22 | buy  | 1      | 900   | 0                | TYPE_LIMIT | TIF_GTC |
    58        | party1 | ETH/MAR22 | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    59        | party2 | ETH/MAR22 | sell | 1      | 1100  | 0                | TYPE_LIMIT | TIF_GTC |
    60        | party2 | ETH/MAR22 | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    61  
    62      Then the opening auction period ends for market "ETH/MAR22"
    63  
    64      And the following trades should be executed:
    65        | buyer  | price | size | seller |
    66        | party1 | 1000  | 10   | party2 |
    67  
    68  
    69  
    70      And the market data for the market "ETH/MAR22" should be:
    71        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
    72        | 1000 | TRADING_MODE_CONTINUOUS | 1 | 500 | 1500 | 1000 | 10000 | 10 |
    73  
    74      Then the order book should have the following volumes for market "ETH/MAR22":
    75        | side | price | volume |
    76        | buy  | 898   | 4      |
    77        | buy  | 900   | 1      |
    78        | buy  | 999   | 7      |
    79        | sell | 1001  | 7      |
    80        | sell | 1100  | 1      |
    81        | sell | 1102  | 4      |
    82  
    83      #volume = ceiling(liquidity_obligation x liquidity-normalised-proportion / probability_of_trading / price)
    84      #for any price better than the bid price or better than the ask price it returns 0.5
    85      #for any price in within 500 price ticks from the best bid/ask (i.e. worse than) it returns the probability as returned by the risk model (in this case 0.1 scaled by 0.5.
    86      #priceLvel at 898:10000*(1/3)/898=4
    87      #priceLvel at 999:10000*(2/3)/999=7
    88      #priceLvel at 1001:10000*(2/3)/1001=7
    89      #priceLvel at 1102:10000*(1/3)/1102=4
    90  
    91      And the liquidity provider fee shares for the market "ETH/MAR22" should be:
    92        | party | equity like share | average entry valuation |
    93        | lp1   | 1                 | 10000                   |
    94  
    95  
    96      And the parties should have the following account balances:
    97        | party  | asset | market id | margin | general   | bond  |
    98        | lp1 | USD | ETH/MAR22 | 1320 | 1999988680 | 10000 |
    99        # | party1 | USD   | ETH/MAR22 | 1704   | 99998296  |       |
   100        # | party2 | USD   | ETH/MAR22 | 1692   | 99998308  |       |
   101  
   102      # party1 margin = 11*1000*0.1 + 1000*0.032 = 1420
   103      # party2 margin = 11*1000*0.1 + 1000*0.032 = 1420
   104      Then the parties should have the following margin levels:
   105        | party  | market id | maintenance |
   106        | party1 | ETH/MAR22 | 1420        |
   107        | party2 | ETH/MAR22 | 1420        |
   108  
   109      Then the network moves ahead "1" blocks
   110  
   111      And the price monitoring bounds for the market "ETH/MAR22" should be:
   112        | min bound | max bound |
   113        | 500       | 1500      |
   114  
   115      And the liquidity fee factor should be "0.001" for the market "ETH/MAR22"
   116  
   117      Then the parties place the following orders:
   118        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference   |
   119        | party1 | ETH/MAR22 | sell | 20     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | party1-sell |
   120        | party2 | ETH/MAR22 | buy  | 20     | 1000  | 2                | TYPE_LIMIT | TIF_GTC | party2-buy  |
   121  
   122      And the parties should have the following account balances:
   123        | party  | asset | market id | margin | general   | bond  |
   124        | lp1 | USD | ETH/MAR22 | 1320 | 1999988683 | 10000 |
   125        | party1 | USD | ETH/MAR22 | 2400 | 99997606  |       |
   126        | party2 | USD | ETH/MAR22 | 2400 | 99997551  |       |
   127  
   128      Then the parties should have the following account balances:
   129        | party | asset | market id | margin | general   | bond  |
   130        | lp1 | USD | ETH/MAR22 | 1320 | 1999988683 | 10000 |
   131      When the network moves ahead "2" blocks
   132  
   133      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR22"
   134      And the accumulated liquidity fees should be "20" for the market "ETH/MAR22"
   135  
   136      # opening auction + time window
   137      Then time is updated to "2019-11-30T00:10:05Z"
   138  
   139      # lp fee got cumulated since the distribution period is large
   140      And the accumulated liquidity fees should be "20" for the market "ETH/MAR22"
   141      Then time is updated to "2019-11-30T00:20:05Z"
   142  
   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 | 1       | 500       | 1500      | 1000         | 10000          | 10            |
   146  
   147      Then the order book should have the following volumes for market "ETH/MAR22":
   148        | side | price | volume |
   149        | buy  | 898   | 4      |
   150        | buy  | 900   | 1      |
   151        | buy  | 949   | 7      |
   152        | sell | 951   | 0      |
   153        | sell | 1000  | 7      |
   154        | sell | 1002  | 4      |
   155        | sell | 1100  | 1      |
   156  
   157      When the parties place the following orders:
   158        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference  |
   159        | party2 | ETH/MAR22 | buy  | 7 | 1002 | 1 | TYPE_LIMIT | TIF_GTC | party1-buy  |
   160        | party2 | ETH/MAR22 | sell | 4 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | party2-sell |
   161  
   162      Then the following transfers should happen:
   163        | from   | to     | from account         | to account                  | market id | amount | asset |
   164        | party2 | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_LIQUIDITY | ETH/MAR22 | 7      | USD   |
   165  
   166  # this transfer goes from party2’s general account to market liquidity fee account
   167      And the accumulated liquidity fees should be "27" for the market "ETH/MAR22"
   168      And the party "lp1" lp liquidity fee account balance should be "0" for the market "ETH/MAR22"
   169  
   170  #lp fee got paid from market liquidity fee account to lp1 liquidity fee account when time is over the "market.liquidity.providers.fee.calculationTimeStep"
   171      Then time is updated to "2024-12-30T00:30:05Z"
   172  
   173      And the accumulated liquidity fees should be "0" for the market "ETH/MAR22"
   174      And the party "lp1" lp liquidity fee account balance should be "27" for the market "ETH/MAR22"
   175  
   176      Then the following transfers should happen:
   177        | from   | to  | from account                | to account                     | market id | amount | asset |
   178        | market | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/MAR22 | 27     | USD   |
   179  
   180      Then the parties should have the following profit and loss:
   181        | party | volume | unrealised pnl | realised pnl |
   182        | lp1   | -7     | -343           | 0            |
   183  
   184      Then the parties should have the following account balances:
   185        | party | asset | market id | margin | general    |
   186        | lp1   | USD   | ETH/MAR22 | 1588   | 1999988072 |