code.vegaprotocol.io/vega@v0.79.0/core/integration/features/spot/liquidity_provision/0034-PROB-008.feature (about)

     1  Feature: Probability of trading decreases away from the mid-price in Spot market
     2  
     3    Scenario: 001 0034-PROB-008, lp1, lp2, lp3 are making the same amount of liuquidity commitment, but with different orders, lp1 places orders the furthest to mid while lp3 places orders closest to the mid
     4    #when liquidity fee is distributed, lp1 gets the least liquidity fee while lp3 gets the most liquidity fee
     5    #it demonstrates the fact that probability of trading decreases away from the mid-price in Spot market
     6  
     7      Given time is updated to "2023-07-20T00:00:00Z"
     8  
     9      Given the fees configuration named "fees-config-1":
    10        | maker fee | infrastructure fee |
    11        | 0         | 0                  |
    12      Given the log normal risk model named "lognormal-risk-model-1":
    13        | risk aversion | tau  | mu | r   | sigma |
    14        | 0.001         | 0.01 | 0  | 0.0 | 1.2   |
    15  
    16      And the price monitoring named "price-monitoring-1":
    17        | horizon | probability | auction extension |
    18        | 3600000 | 0.999       | 300               |
    19  
    20      And the liquidity sla params named "SLA-1":
    21        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
    22        | 1           | 0.1                          | 2                             | 0.2                    |
    23  
    24      Given the following assets are registered:
    25        | id  | decimal places |
    26        | ETH | 1              |
    27        | BTC | 1              |
    28  
    29      And the following network parameters are set:
    30        | name                                                | value |
    31        | network.markPriceUpdateMaximumFrequency             | 2s    |
    32        | market.liquidity.earlyExitPenalty                   | 0.25  |
    33        | market.liquidity.bondPenaltyParameter               | 0     |
    34        | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0.5   |
    35        | market.liquidity.sla.nonPerformanceBondPenaltyMax   | 0.2   |
    36        | market.liquidity.maximumLiquidityFeeFactorLevel     | 0.4   |
    37        | validators.epoch.length                             | 2s    |
    38        | limits.markets.maxPeggedOrders                      | 10    |
    39        | market.liquidity.probabilityOfTrading.tau.scaling   | 0.1   |
    40  
    41      And the spot markets:
    42        | id      | name    | base asset | quote asset | risk model             | auction duration | fees          | price monitoring   | sla params |
    43        | BTC/ETH | BTC/ETH | BTC        | ETH         | lognormal-risk-model-1 | 1                | fees-config-1 | price-monitoring-1 | SLA-1      |
    44      And the following network parameters are set:
    45        | name                                             | value |
    46        | market.liquidity.providersFeeCalculationTimeStep | 2s    |
    47  
    48      Given the parties deposit on asset's general account the following amount:
    49        | party  | asset | amount |
    50        | party1 | ETH   | 100000 |
    51        | party2 | BTC   | 5000   |
    52        | lp1    | ETH   | 4000   |
    53        | lp1    | BTC   | 600    |
    54        | lp2    | ETH   | 4000   |
    55        | lp2    | BTC   | 600    |
    56        | lp3    | ETH   | 4000   |
    57        | lp3    | BTC   | 600    |
    58  
    59      And the average block duration is "1"
    60  
    61      Given the liquidity monitoring parameters:
    62        | name               | triggering ratio | time window | scaling factor |
    63        | updated-lqm-params | 0.2              | 20s         | 0.8            |
    64  
    65      When the spot markets are updated:
    66        | id      | liquidity monitoring | linear slippage factor | quadratic slippage factor |
    67        | BTC/ETH | updated-lqm-params   | 0.5                    | 0.5                       |
    68  
    69      When the parties submit the following liquidity provision:
    70        | id  | party | market id | commitment amount | fee | lp type    |
    71        | lp1 | lp1   | BTC/ETH   | 2000              | 0.4 | submission |
    72        | lp2 | lp2   | BTC/ETH   | 2000              | 0.4 | submission |
    73        | lp3 | lp3   | BTC/ETH   | 2000              | 0.4 | submission |
    74  
    75      And the parties should have the following account balances:
    76        | party | asset | market id | general |
    77        | lp1   | BTC   | BTC/ETH   | 600     |
    78        | lp1   | ETH   | BTC/ETH   | 2000    |
    79  
    80      Then the network moves ahead "1" blocks 
    81      Then the market data for the market "BTC/ETH" should be:
    82        | mark price | trading mode                 | auction trigger         | target stake | supplied stake | open interest |
    83        | 0          | TRADING_MODE_OPENING_AUCTION | AUCTION_TRIGGER_OPENING | 4800         | 6000           | 0             |
    84  
    85      # place orders and generate trades
    86      And the parties place the following orders:
    87        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference    | only |
    88        | party1 | BTC/ETH   | buy  | 1      | 14    | 0                | TYPE_LIMIT | TIF_GTC | party-order1 |      |
    89        | party1 | BTC/ETH   | buy  | 1      | 15    | 0                | TYPE_LIMIT | TIF_GTC | party-order3 |      |
    90        | party2 | BTC/ETH   | sell | 1      | 15    | 0                | TYPE_LIMIT | TIF_GTC | party-order4 |      |
    91        | party2 | BTC/ETH   | sell | 1      | 18    | 0                | TYPE_LIMIT | TIF_GTC | party-order2 |      |
    92  
    93      When the network moves ahead "1" blocks
    94  
    95      Then the market data for the market "BTC/ETH" should be:
    96        | mark price | trading mode            | auction trigger             | horizon | min bound | max bound | target stake | supplied stake | open interest |
    97        | 15         | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 3600000 | 4         | 52        | 4800         | 6000           | 0             |
    98  
    99      And the parties place the following pegged orders:
   100        | party | market id | side | volume | pegged reference | offset | reference |
   101        | lp1   | BTC/ETH   | buy  | 10     | BID              | 7      | lp1-b     |
   102        | lp1   | BTC/ETH   | sell | 10     | ASK              | 7      | lp1-s     |
   103        | lp2   | BTC/ETH   | buy  | 10     | BID              | 2      | lp2-b     |
   104        | lp2   | BTC/ETH   | sell | 10     | ASK              | 2      | lp2-s     |
   105        | lp3   | BTC/ETH   | buy  | 10     | BID              | 1      | lp3-b     |
   106        | lp3   | BTC/ETH   | sell | 10     | ASK              | 1      | lp3-s     |
   107  
   108      And the parties place the following orders:
   109        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference    | only |
   110        | party1 | BTC/ETH   | buy  | 100    | 15    | 0                | TYPE_LIMIT | TIF_GTC | party-order3 |      |
   111        | party2 | BTC/ETH   | sell | 100    | 15    | 1                | TYPE_LIMIT | TIF_GTC | party-order4 |      |
   112  
   113      Then the accumulated liquidity fees should be "6000" for the market "BTC/ETH"
   114      When the network moves ahead "4" blocks
   115  
   116      Then the following transfers should happen:
   117        | from   | to  | from account                | to account                     | market id | amount | asset |
   118        | market | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | BTC/ETH   | 1000   | ETH   |
   119        | market | lp2 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | BTC/ETH   | 1829   | ETH   |
   120        | market | lp3 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | BTC/ETH   | 3170   | ETH   |