code.vegaprotocol.io/vega@v0.79.0/core/integration/features/liquidity-provision/0044-LIME-119.feature (about)

     1  Feature: Test LP mechanics when there are multiple liquidity providers;
     2  
     3    Background:
     4  
     5      Given the log normal risk model named "log-normal-risk-model":
     6        | risk aversion | tau | mu | r | sigma |
     7        | 0.000001      | 0.1 | 0  | 0 | 1.0   |
     8      #risk factor short:3.5569036
     9      #risk factor long:0.801225765
    10      And the following assets are registered:
    11        | id  | decimal places |
    12        | USD | 0              |
    13      And the fees configuration named "fees-config-1":
    14        | maker fee | infrastructure fee |
    15        | 0.0004    | 0.001              |
    16      # price monitoring duration should be > 3 epochs
    17      And the price monitoring named "price-monitoring":
    18        | horizon | probability | auction extension |
    19        | 3600    | 0.99        | 40                |
    20  
    21      And the liquidity sla params named "SLA":
    22        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
    23        | 0.05        | 1                            | 1                             | 1.0                    |
    24  
    25      And the liquidity monitoring parameters:
    26        | name       | triggering ratio | time window | scaling factor |
    27        | lqm-params | 10               | 3600s       | 1              |
    28  
    29      And the following network parameters are set:
    30        | name                                                | value |
    31        | market.value.windowLength                           | 60s   |
    32        | network.markPriceUpdateMaximumFrequency             | 0s    |
    33        | limits.markets.maxPeggedOrders                      | 6     |
    34        | market.auction.minimumDuration                      | 1     |
    35        | market.fee.factors.infrastructureFee                | 0.001 |
    36        | market.fee.factors.makerFee                         | 0.004 |
    37        | market.liquidity.bondPenaltyParameter               | 0.2   |
    38        | validators.epoch.length                             | 5s    |
    39        | market.liquidity.stakeToCcyVolume                   | 1     |
    40        | market.liquidity.successorLaunchWindowLength        | 1h    |
    41        | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0.5   |
    42        | market.liquidity.sla.nonPerformanceBondPenaltyMax   | 1     |
    43        | validators.epoch.length                             | 10s   |
    44        | market.liquidity.providersFeeCalculationTimeStep    | 10s   |
    45      And the liquidity monitoring parameters:
    46        | name       | triggering ratio | time window | scaling factor |
    47        | lqm-params | 0.5              | 20s         | 1              |
    48  
    49      And the spot markets:
    50        | id      | name    | base asset | quote asset | liquidity monitoring | risk model            | auction duration | fees          | price monitoring | sla params    | sla params |
    51        | BTC/ETH | BTC/ETH | BTC        | ETH         | lqm-params           | log-normal-risk-model | 2                | fees-config-1 | price-monitoring | default-basic | SLA        |
    52  
    53      Given the average block duration is "2"
    54  
    55    @Now
    56    Scenario: An LP with bid orders inside valid range during auction (and market has no indicative price), is not penalised (0044-LIME-119)
    57      Given the parties deposit on asset's general account the following amount:
    58        | party  | asset | amount     |
    59        | lp1    | ETH   | 20000000   |
    60        | party1 | ETH   | 1000000000 |
    61        | party2 | ETH   | 1000000000 |
    62        | party3 | ETH   | 1000000    |
    63        | ptbuy  | ETH   | 10000000   |
    64        | ptsell | ETH   | 10000000   |
    65        | lp1    | BTC   | 20000000   |
    66        | party1 | BTC   | 1000000000 |
    67        | party2 | BTC   | 1000000000 |
    68        | party3 | BTC   | 1000000    |
    69        | ptbuy  | BTC   | 10000000   |
    70        | ptsell | BTC   | 10000000   |
    71  
    72      And the parties submit the following liquidity provision:
    73        | id   | party | market id | commitment amount | fee  | lp type    |
    74        | lp_1 | lp1   | BTC/ETH   | 180000            | 0.02 | submission |
    75  
    76      When the network moves ahead "2" blocks
    77      Then the parties place the following orders:
    78        | party  | market id | side | volume | price | resulting trades | type       | tif     |
    79        | lp1    | BTC/ETH   | buy  | 100    | 4750  | 0                | TYPE_LIMIT | TIF_GTC |
    80        | lp1    | BTC/ETH   | sell | 100    | 5250  | 0                | TYPE_LIMIT | TIF_GTC |
    81        | party1 | BTC/ETH   | buy  | 1      | 5000  | 0                | TYPE_LIMIT | TIF_GTC |
    82        | party2 | BTC/ETH   | sell | 10     | 5100  | 0                | TYPE_LIMIT | TIF_GTC |
    83        | party2 | BTC/ETH   | sell | 1      | 5000  | 0                | TYPE_LIMIT | TIF_GTC |
    84      # Remove this so we can trigger price auction, we add it back later
    85      #| party1 | BTC/ETH | buy  | 10     | 4900  | 0                | TYPE_LIMIT | TIF_GTC |
    86  
    87      Then the opening auction period ends for market "BTC/ETH"
    88      And the following trades should be executed:
    89        | buyer  | price | size | seller |
    90        | party1 | 5000  | 1    | party2 |
    91  
    92      And the market data for the market "BTC/ETH" should be:
    93        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake |
    94        | 5000       | TRADING_MODE_CONTINUOUS | 3600    | 4865      | 5139      | 180000       | 180000         |
    95  
    96      Then the parties place the following orders:
    97        | party  | market id | side | volume | price | resulting trades | type       | tif     |
    98        | party1 | BTC/ETH   | buy  | 5000   | 5000  | 0                | TYPE_LIMIT | TIF_GTC |
    99        | party2 | BTC/ETH   | sell | 5000   | 5000  | 1                | TYPE_LIMIT | TIF_GTC |
   100  
   101      When the network moves ahead "1" blocks
   102      Then the market data for the market "BTC/ETH" should be:
   103        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake |
   104        | 5000       | TRADING_MODE_CONTINUOUS | 3600    | 4865      | 5139      | 180000       | 180000         |
   105  
   106      ## Now trigger price monitoring auction - sell outside of max bound, and make sure orders can't uncross with existing volume
   107      When the parties place the following orders:
   108        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   109        | ptbuy  | BTC/ETH   | buy  | 1      | 4740  | 0                | TYPE_LIMIT | TIF_GTC | pt-buy    |
   110        | ptsell | BTC/ETH   | sell | 1      | 4740  | 0                | TYPE_LIMIT | TIF_GTC | pt-sell   |
   111      Then the market data for the market "BTC/ETH" should be:
   112        | mark price | trading mode                    | auction trigger       | target stake | supplied stake | auction end |
   113        | 5000       | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | 180000       | 180000         | 40          |
   114      Then the parties place the following orders:
   115        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   116        | party1 | BTC/ETH   | buy  | 10     | 4900  | 0                | TYPE_LIMIT | TIF_GTC |
   117        | party1 | BTC/ETH   | buy  | 1      | 5000  | 0                | TYPE_LIMIT | TIF_GTC |
   118        | party2 | BTC/ETH   | sell | 1      | 5000  | 0                | TYPE_LIMIT | TIF_GTC |
   119  
   120      When the network moves ahead "1" epochs
   121      And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "BTC/ETH"
   122      Then the parties should have the following account balances:
   123        | party | asset | market id | general  | bond   |
   124        | lp1   | ETH   | BTC/ETH   | 19340012 | 162000 |
   125  
   126      When the network moves ahead "2" epochs
   127      Then the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "BTC/ETH"
   128      Then the parties should have the following account balances:
   129        | party | asset | market id | general  | bond   |
   130        | lp1   | ETH   | BTC/ETH   | 19340012 | 162000 |
   131  
   132  Scenario: An LP with ask orders outside valid range during auction is penalised (0044-LIME-114)
   133    Given the parties deposit on asset's general account the following amount:
   134      | party  | asset | amount     |
   135      | lp1    | ETH   | 20000000   |
   136      | party1 | ETH   | 1000000000 |
   137      | party2 | ETH   | 1000000000 |
   138      | party3 | ETH   | 1000000    |
   139      | ptbuy  | ETH   | 10000000   |
   140      | ptsell | ETH   | 10000000   |
   141      | lp1    | BTC   | 20000000   |
   142      | party1 | BTC   | 1000000000 |
   143      | party2 | BTC   | 1000000000 |
   144      | party3 | BTC   | 1000000    |
   145      | ptbuy  | BTC   | 10000000   |
   146      | ptsell | BTC   | 10000000   |
   147  
   148    And the parties submit the following liquidity provision:
   149      | id   | party | market id | commitment amount | fee  | lp type    |
   150      | lp_1 | lp1   | BTC/ETH   | 180000            | 0.02 | submission |
   151  
   152    When the network moves ahead "2" blocks
   153    Then the parties place the following orders:
   154      | party  | market id | side | volume | price | resulting trades | type       | tif     |
   155      | lp1    | BTC/ETH   | buy  | 100    | 3790  | 0                | TYPE_LIMIT | TIF_GTC |
   156      | lp1    | BTC/ETH   | sell | 100    | 5250  | 0                | TYPE_LIMIT | TIF_GTC |
   157      | party1 | BTC/ETH   | buy  | 1      | 5000  | 0                | TYPE_LIMIT | TIF_GTC |
   158      | party2 | BTC/ETH   | sell | 10     | 5100  | 0                | TYPE_LIMIT | TIF_GTC |
   159      | party2 | BTC/ETH   | sell | 1      | 5000  | 0                | TYPE_LIMIT | TIF_GTC |
   160  
   161    Then the opening auction period ends for market "BTC/ETH"
   162    And the following trades should be executed:
   163      | buyer  | price | size | seller |
   164      | party1 | 5000  | 1    | party2 |
   165  
   166    And the market data for the market "BTC/ETH" should be:
   167      | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake |
   168      | 5000       | TRADING_MODE_CONTINUOUS | 3600    | 4865      | 5139      | 180000       | 180000         |
   169  
   170    When the parties place the following orders:
   171      | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   172      | ptbuy  | BTC/ETH   | buy  | 1      | 4740  | 0                | TYPE_LIMIT | TIF_GTC | pt-buy    |
   173      | ptsell | BTC/ETH   | sell | 1      | 4740  | 0                | TYPE_LIMIT | TIF_GTC | pt-sell   |
   174    And the network moves ahead "2" blocks
   175    Then the market data for the market "BTC/ETH" should be:
   176      | mark price | trading mode                    | auction trigger       | target stake | supplied stake | auction end |
   177      | 5000       | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | 180000       | 180000         | 40          |
   178  
   179    When the parties place the following orders:
   180      | party  | market id | side | volume | price | resulting trades | type       | tif     |
   181      | party1 | BTC/ETH   | buy  | 10     | 4900  | 0                | TYPE_LIMIT | TIF_GTC |
   182      | party1 | BTC/ETH   | buy  | 1      | 4000  | 0                | TYPE_LIMIT | TIF_GTC |
   183      | party2 | BTC/ETH   | sell | 1      | 4000  | 0                | TYPE_LIMIT | TIF_GTC |
   184    Then the network moves ahead "1" epochs
   185    And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "BTC/ETH"
   186    And the parties should have the following account balances:
   187      | party | asset | market id | general  | bond  |
   188      | lp1   | ETH   | BTC/ETH   | 19437020 | 90000 |
   189  
   190    When the network moves ahead "2" epochs
   191    Then the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "BTC/ETH"
   192    Then the parties should have the following account balances:
   193      | party | asset | market id | general  | bond  |
   194      | lp1   | ETH   | BTC/ETH   | 19437020 | 22500 |
   195  
   196    Then the following transfers should happen:
   197      | from | to     | from account      | to account                    | market id | amount | asset |
   198      | lp1  | market | ACCOUNT_TYPE_BOND | ACCOUNT_TYPE_NETWORK_TREASURY | BTC/ETH   | 90000  | ETH   |
   199      | lp1  | market | ACCOUNT_TYPE_BOND | ACCOUNT_TYPE_NETWORK_TREASURY | BTC/ETH   | 45000  | ETH   |
   200      | lp1  | market | ACCOUNT_TYPE_BOND | ACCOUNT_TYPE_NETWORK_TREASURY | BTC/ETH   | 22500  | ETH   |
   201  
   202