code.vegaprotocol.io/vega@v0.79.0/core/integration/features/liquidity-provision/0042-LIQF-043.feature (about)

     1  Feature: Test LP fee distribution in LP mechanics in 0042
     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 liquidity monitoring parameters:
    12        | name               | triggering ratio | time window | scaling factor |
    13        | lqm-params         | 1.00             | 20s         | 1              |  
    14        
    15      And the following network parameters are set:
    16        | name                                        | value |
    17        | market.value.windowLength                   | 60s   |
    18        | network.markPriceUpdateMaximumFrequency     | 0s    |
    19        | limits.markets.maxPeggedOrders              | 6     |
    20        | market.auction.minimumDuration              | 1     |
    21        | market.fee.factors.infrastructureFee        | 0.001 |
    22        | market.fee.factors.makerFee                 | 0.004 |
    23        | spam.protection.max.stopOrdersPerMarket     | 5     |
    24        | market.liquidity.equityLikeShareFeeFraction | 1     |
    25      #risk factor short:3.5569036
    26      #risk factor long:0.801225765
    27      And the following assets are registered:
    28        | id  | decimal places |
    29        | USD | 0              |
    30      And the fees configuration named "fees-config-1":
    31        | maker fee | infrastructure fee |
    32        | 0.0004    | 0.001              |
    33      And the price monitoring named "price-monitoring":
    34        | horizon | probability | auction extension |
    35        | 3600    | 0.99        | 3                 |
    36  
    37      And the liquidity sla params named "SLA-22":
    38        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
    39        | 0.5         | 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  
    45      And the following network parameters are set:
    46        | name                                                | value |
    47        | market.liquidity.bondPenaltyParameter               | 0.2   |
    48        | market.liquidity.stakeToCcyVolume                   | 1     |
    49        | market.liquidity.successorLaunchWindowLength        | 1h    |
    50        | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0.1   |
    51        | market.liquidity.sla.nonPerformanceBondPenaltyMax   | 0.6   |
    52        | validators.epoch.length                             | 10s   |
    53        | market.liquidity.earlyExitPenalty                   | 0.25  |
    54        | market.liquidity.maximumLiquidityFeeFactorLevel     | 0.25  |
    55  
    56      Given the average block duration is "1"
    57    @Now
    58    Scenario: 001: lp1 and lp2 on the market ETH/MAR22, 0042-LIQF-043
    59      Given the parties deposit on asset's general account the following amount:
    60        | party  | asset | amount |
    61        | lp1    | USD   | 100000 |
    62        | lp2    | USD   | 100000 |
    63        | lp3    | USD   | 100000 |
    64        | party1 | USD   | 100000 |
    65        | party2 | USD   | 100000 |
    66        | party3 | USD   | 100000 |
    67  
    68      And the parties submit the following liquidity provision:
    69        | id   | party | market id | commitment amount | fee   | lp type    |
    70        | lp_1 | lp1   | ETH/MAR22 | 6000              | 0.02  | submission |
    71        | lp_2 | lp2   | ETH/MAR22 | 4000              | 0.015 | submission |
    72  
    73      When the network moves ahead "4" blocks
    74      And the current epoch is "0"
    75  
    76      Then the parties place the following orders:
    77        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    78        | party1 | ETH/MAR22 | buy  | 10     | 900   | 0                | TYPE_LIMIT | TIF_GTC |           |
    79        | party1 | ETH/MAR22 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |           |
    80        | party2 | ETH/MAR22 | sell | 10     | 1100  | 0                | TYPE_LIMIT | TIF_GTC |           |
    81        | party2 | ETH/MAR22 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |           |
    82        | lp1    | ETH/MAR22 | buy  | 10     | 950   | 0                | TYPE_LIMIT | TIF_GTC | lp1-b     |
    83        | lp1    | ETH/MAR22 | sell | 10     | 1050  | 0                | TYPE_LIMIT | TIF_GTC | lp1-s     |
    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      | 3556         | 10000          | 1             |
    93      # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1000 x 1 x 1 x 3.5569036 =3556
    94  
    95      When the network moves ahead "1" epochs
    96      And the supplied stake should be "9600" for the market "ETH/MAR22"
    97      And the insurance pool balance should be "400" for the market "ETH/MAR22"
    98      And the current epoch is "1"
    99      Then the parties should have the following account balances:
   100        | party | asset | market id | margin | general | bond |
   101        | lp1   | USD   | ETH/MAR22 | 56022  | 37978   | 6000 |
   102        | lp2   | USD   | ETH/MAR22 | 0      | 96000   | 3600 |
   103  
   104      Then the parties place the following orders:
   105        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   106        | party1 | ETH/MAR22 | sell | 2      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   107        | party2 | ETH/MAR22 | buy  | 2      | 1000  | 1                | TYPE_LIMIT | TIF_GTC |
   108  
   109      When the network moves ahead "1" epochs
   110      And the insurance pool balance should be "760" for the market "ETH/MAR22"
   111      Then the parties should have the following account balances:
   112        | party | asset | market id | margin | general | bond |
   113        | lp1   | USD   | ETH/MAR22 | 56022  | 38007   | 6000 |
   114        | lp2   | USD   | ETH/MAR22 | 0      | 96000   | 3240 |
   115  
   116      #AC 0042-LIQF-043: The net inflow and outflow into and out of the market's aggregate LP fee account should be zero as a result of penalty collection and bonus distribution.
   117      #lp1 got lp fee 18 and also SLA performance bonus 11, so general account increased from 37978 to 38007
   118      #lp2 did not place any orders, so all the lp fee for lp1 goes back to ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION (which was distributed to lp1)
   119  
   120      Then the following transfers should happen:
   121        | from   | to     | from account                                   | to account                                     | market id | amount | asset |
   122        | market | lp1    | ACCOUNT_TYPE_FEES_LIQUIDITY                    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ETH/MAR22 | 18     | USD   |
   123        | market | lp2    | ACCOUNT_TYPE_FEES_LIQUIDITY                    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ETH/MAR22 | 11     | USD   |
   124        | lp1    | lp1    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_GENERAL                           | ETH/MAR22 | 18     | USD   |
   125        | lp2    | market | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ETH/MAR22 | 11     | USD   |
   126        | market | lp1    | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ACCOUNT_TYPE_GENERAL                           | ETH/MAR22 | 11     | USD   |
   127  
   128    @Now
   129    Scenario: 001b: lp1 and lp2 on the market ETH/MAR22, 0042-LIQF-043 with fee share factor set to 0.5
   130      Given the parties deposit on asset's general account the following amount:
   131        | party  | asset | amount |
   132        | lp1    | USD   | 100000 |
   133        | lp2    | USD   | 100000 |
   134        | lp3    | USD   | 100000 |
   135        | party1 | USD   | 100000 |
   136        | party2 | USD   | 100000 |
   137        | party3 | USD   | 100000 |
   138      And the following network parameters are set:
   139        | name                                        | value |
   140        | market.liquidity.equityLikeShareFeeFraction | 0.5   |
   141  
   142      And the parties submit the following liquidity provision:
   143        | id   | party | market id | commitment amount | fee   | lp type    |
   144        | lp_1 | lp1   | ETH/MAR22 | 6000              | 0.02  | submission |
   145        | lp_2 | lp2   | ETH/MAR22 | 4000              | 0.015 | submission |
   146  
   147      When the network moves ahead "4" blocks
   148      And the current epoch is "0"
   149  
   150      Then the parties place the following orders:
   151        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   152        | party1 | ETH/MAR22 | buy  | 10     | 900   | 0                | TYPE_LIMIT | TIF_GTC |           |
   153        | party1 | ETH/MAR22 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |           |
   154        | party2 | ETH/MAR22 | sell | 10     | 1100  | 0                | TYPE_LIMIT | TIF_GTC |           |
   155        | party2 | ETH/MAR22 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |           |
   156        | lp1    | ETH/MAR22 | buy  | 10     | 950   | 0                | TYPE_LIMIT | TIF_GTC | lp1-b     |
   157        | lp1    | ETH/MAR22 | sell | 10     | 1050  | 0                | TYPE_LIMIT | TIF_GTC | lp1-s     |
   158  
   159      Then the opening auction period ends for market "ETH/MAR22"
   160      And the following trades should be executed:
   161        | buyer  | price | size | seller |
   162        | party1 | 1000  | 1    | party2 |
   163  
   164      And the market data for the market "ETH/MAR22" should be:
   165        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
   166        | 1000       | TRADING_MODE_CONTINUOUS | 3600    | 973       | 1027      | 3556         | 10000          | 1             |
   167      # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1000 x 1 x 1 x 3.5569036 =3556
   168  
   169      When the network moves ahead "1" epochs
   170      And the supplied stake should be "9600" for the market "ETH/MAR22"
   171      And the insurance pool balance should be "400" for the market "ETH/MAR22"
   172      And the current epoch is "1"
   173      Then the parties should have the following account balances:
   174        | party | asset | market id | margin | general | bond |
   175        | lp1   | USD   | ETH/MAR22 | 56022  | 37978   | 6000 |
   176        | lp2   | USD   | ETH/MAR22 | 0      | 96000   | 3600 |
   177  
   178      Then the parties place the following orders:
   179        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   180        | party1 | ETH/MAR22 | sell | 2      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   181        | party2 | ETH/MAR22 | buy  | 2      | 1000  | 1                | TYPE_LIMIT | TIF_GTC |
   182  
   183      When the network moves ahead "1" epochs
   184      And the insurance pool balance should be "760" for the market "ETH/MAR22"
   185      Then the parties should have the following account balances:
   186        | party | asset | market id | margin | general | bond |
   187        | lp1   | USD   | ETH/MAR22 | 56022  | 38007   | 6000 |
   188        | lp2   | USD   | ETH/MAR22 | 0      | 96000   | 3240 |
   189  
   190      #AC 0042-LIQF-043: The net inflow and outflow into and out of the market's aggregate LP fee account should be zero as a result of penalty collection and bonus distribution.
   191      #lp1 got lp fee 18 and also SLA performance bonus 11, so general account increased from 37978 to 38007
   192      #lp2 did not place any orders, so all the lp fee for lp1 goes back to ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION (which was distributed to lp1)
   193  
   194      Then the following transfers should happen:
   195        | from   | to     | from account                                   | to account                                     | market id | amount | asset |
   196        | market | lp1    | ACCOUNT_TYPE_FEES_LIQUIDITY                    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ETH/MAR22 | 16     | USD   |
   197        | market | lp2    | ACCOUNT_TYPE_FEES_LIQUIDITY                    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ETH/MAR22 | 13     | USD   |
   198        | lp1    | lp1    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_GENERAL                           | ETH/MAR22 | 16     | USD   |
   199        | lp2    | market | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ETH/MAR22 | 13     | USD   |
   200        | market | lp1    | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ACCOUNT_TYPE_GENERAL                           | ETH/MAR22 | 13     | USD   |
   201