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

     1  Feature: Calculating SLA Performance
     2  
     3    Background:
     4      Given the markets:
     5        | id        | quote name | asset | risk model                    | margin calculator         | auction duration | fees         | price monitoring | data source config     | linear slippage factor | quadratic slippage factor | sla params    |
     6        | ETH/DEC23 | ETH        | USD   | default-log-normal-risk-model | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 1e-3                   | 0                         | default-basic |
     7      And the following network parameters are set:
     8        | name                                             | value |
     9        | limits.markets.maxPeggedOrders                   | 2     |
    10        | network.markPriceUpdateMaximumFrequency          | 0s    |
    11        | market.liquidity.providersFeeCalculationTimeStep | 1s    |
    12        | validators.epoch.length                          | 58s   |
    13        | market.liquidity.stakeToCcyVolume                | 1     |
    14        | market.liquidity.equityLikeShareFeeFraction      | 1     |
    15  
    16      And the average block duration is "1"
    17  
    18      Given the parties deposit on asset's general account the following amount:
    19        | party  | asset | amount              |
    20        | lp1    | USD   | 1000000000000000000 |
    21        | lp2    | USD   | 1000000000000000000 |
    22        | lp3    | USD   | 1000000000000000000 |
    23        | lp4    | USD   | 1000000000000000000 |
    24        | aux1   | USD   | 1000000000000000000 |
    25        | aux2   | USD   | 1000000000000000000 |
    26        | party1 | USD   | 1000000000000000000 |
    27        | party2 | USD   | 1000000000000000000 |
    28  
    29  
    30    Scenario: LP fulfills the mininum time fraction but only provides liquidity at the start of the epoch (0042-LIQF-037)(0042-LIQF-043)(0042-LIQF-046)
    31  
    32      # Initialise the market with the required parameters
    33      Given the liquidity sla params named "scenario-sla-params":
    34        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
    35        | 1           | 0.5                          | 0                             | 1.0                    |
    36      And the markets are updated:
    37        | id        | sla params          | linear slippage factor | quadratic slippage factor |
    38        | ETH/DEC23 | scenario-sla-params | 1e-3                   | 0                         |
    39  
    40      # Setup the market with 1 LP who is initially meeting their commitment
    41      Given the parties submit the following liquidity provision:
    42        | id  | party | market id | commitment amount | fee | lp type    |
    43        | lp1 | lp1   | ETH/DEC23 | 10000             | 0.1 | submission |
    44      And the parties place the following pegged iceberg orders:
    45        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
    46        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-1  |
    47        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-1 |
    48      When the parties place the following orders:
    49        | party | market id | side | volume | price | resulting trades | type       | tif     |
    50        | aux1  | ETH/DEC23 | buy  | 1      | 990   | 0                | TYPE_LIMIT | TIF_GTC |
    51        | aux2  | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    52        | aux1  | ETH/DEC23 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    53        | aux2  | ETH/DEC23 | sell | 1      | 1010  | 0                | TYPE_LIMIT | TIF_GTC |
    54      And the opening auction period ends for market "ETH/DEC23"
    55      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC23"
    56  
    57      # Generate liquidity fees to be allocated to the LP
    58      Given the parties place the following orders:
    59        | party  | market id | side | volume | price | resulting trades | type       | tif     |
    60        | party1 | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    61        | party2 | ETH/DEC23 | sell | 1      | 1000  | 1                | TYPE_LIMIT | TIF_GTC |
    62      Then the accumulated liquidity fees should be "100" for the market "ETH/DEC23"
    63  
    64      # Ensure LPs timeBookFraction ~=0.75, then check ~0.5 fees are penalised (then returned as a bonus as they are the only LP)
    65      Given the network moves ahead "45" blocks
    66      And the parties cancel the following orders:
    67        | party | reference      |
    68        | lp1   | lp1-ice-buy-1  |
    69        | lp1   | lp1-ice-sell-1 |
    70      When the network moves ahead "1" epochs
    71      Then the following transfers should happen:
    72        | from | to  | from account                                   | to account                                     | market id | amount | asset |
    73        |      | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY                    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ETH/DEC23 | 100    | USD   |
    74        | lp1  | lp1 | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_GENERAL                           | ETH/DEC23 | 50     | USD   |
    75        | lp1  |     | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ETH/DEC23 | 50     | USD   |
    76        |      | lp1 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ACCOUNT_TYPE_GENERAL                           | ETH/DEC23 | 50     | USD   |
    77  
    78  
    79    Scenario: LP fulfills the mininum time fraction but only provides liquidity scattered throughout the epoch (0042-LIQF-038)(0042-LIQF-043)(0042-LIQF-046)
    80  
    81      # Initialise the market with the required parameters
    82      Given the liquidity sla params named "scenario-sla-params":
    83        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
    84        | 1           | 0.5                          | 0                             | 1.0                    |
    85      And the markets are updated:
    86        | id        | sla params          | linear slippage factor | quadratic slippage factor |
    87        | ETH/DEC23 | scenario-sla-params | 1e-3                   | 0                         |
    88  
    89      # Setup the market with 1 LP who is initially meeting their commitment
    90      Given the parties submit the following liquidity provision:
    91        | id  | party | market id | commitment amount | fee | lp type    |
    92        | lp1 | lp1   | ETH/DEC23 | 10000             | 0.1 | submission |
    93      And the parties place the following pegged iceberg orders:
    94        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
    95        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-1  |
    96        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-1 |
    97      When the parties place the following orders:
    98        | party | market id | side | volume | price | resulting trades | type       | tif     |
    99        | aux1  | ETH/DEC23 | buy  | 1      | 990   | 0                | TYPE_LIMIT | TIF_GTC |
   100        | aux2  | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   101        | aux1  | ETH/DEC23 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   102        | aux2  | ETH/DEC23 | sell | 1      | 1010  | 0                | TYPE_LIMIT | TIF_GTC |
   103      And the opening auction period ends for market "ETH/DEC23"
   104      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC23"
   105  
   106      # Generate liquidity fees to be allocated to the LP
   107      Given the parties place the following orders:
   108        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   109        | party1 | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   110        | party2 | ETH/DEC23 | sell | 1      | 1000  | 1                | TYPE_LIMIT | TIF_GTC |
   111      Then the accumulated liquidity fees should be "100" for the market "ETH/DEC23"
   112  
   113      # Ensure LPs timeBookFraction ~=0.75, then check ~0.5 fees are penalised (then returned as a bonus as they are the only LP)
   114      Given the network moves ahead "10" blocks
   115      And the parties cancel the following orders:
   116        | party | reference      |
   117        | lp1   | lp1-ice-buy-1  |
   118        | lp1   | lp1-ice-sell-1 |
   119      And the network moves ahead "5" blocks
   120      And the parties place the following pegged iceberg orders:
   121        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
   122        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-2  |
   123        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-2 |
   124      And the network moves ahead "10" blocks
   125      And the parties cancel the following orders:
   126        | party | reference      |
   127        | lp1   | lp1-ice-buy-2  |
   128        | lp1   | lp1-ice-sell-2 |
   129      And the network moves ahead "5" blocks
   130      And the parties place the following pegged iceberg orders:
   131        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
   132        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-3  |
   133        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-3 |
   134      And the network moves ahead "10" blocks
   135      And the parties cancel the following orders:
   136        | party | reference      |
   137        | lp1   | lp1-ice-buy-3  |
   138        | lp1   | lp1-ice-sell-3 |
   139      And the network moves ahead "5" blocks
   140      And the parties place the following pegged iceberg orders:
   141        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
   142        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-4  |
   143        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-4 |
   144      When the network moves ahead "1" epochs
   145      Then the following transfers should happen:
   146        | from | to  | from account                                   | to account                                     | market id | amount | asset |
   147        |      | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY                    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ETH/DEC23 | 100    | USD   |
   148        | lp1  | lp1 | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_GENERAL                           | ETH/DEC23 | 50     | USD   |
   149        | lp1  |     | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ETH/DEC23 | 50     | USD   |
   150        |      | lp1 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ACCOUNT_TYPE_GENERAL                           | ETH/DEC23 | 50     | USD   |
   151  
   152  
   153    Scenario: LP fulfills the mininum time fraction but is not always on the book when the sla competition factor is zero. (0042-LIQF-041)(0042-LIQF-043)
   154  
   155      # Initialise the market with the required parameters
   156      Given the liquidity sla params named "scenario-sla-params":
   157        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
   158        | 1           | 0.5                          | 0                             | 0                      |
   159      And the markets are updated:
   160        | id        | sla params          | linear slippage factor | quadratic slippage factor |
   161        | ETH/DEC23 | scenario-sla-params | 1e-3                   | 0                         |
   162  
   163      # Setup the market with 1 LP who is initially meeting their commitment
   164      Given the parties submit the following liquidity provision:
   165        | id  | party | market id | commitment amount | fee | lp type    |
   166        | lp1 | lp1   | ETH/DEC23 | 10000             | 0.1 | submission |
   167      And the parties place the following pegged iceberg orders:
   168        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
   169        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-1  |
   170        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-1 |
   171      When the parties place the following orders:
   172        | party | market id | side | volume | price | resulting trades | type       | tif     |
   173        | aux1  | ETH/DEC23 | buy  | 1      | 990   | 0                | TYPE_LIMIT | TIF_GTC |
   174        | aux2  | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   175        | aux1  | ETH/DEC23 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   176        | aux2  | ETH/DEC23 | sell | 1      | 1010  | 0                | TYPE_LIMIT | TIF_GTC |
   177      And the opening auction period ends for market "ETH/DEC23"
   178      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC23"
   179  
   180      # Generate liquidity fees to be allocated to the LP
   181      Given the parties place the following orders:
   182        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   183        | party1 | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   184        | party2 | ETH/DEC23 | sell | 1      | 1000  | 1                | TYPE_LIMIT | TIF_GTC |
   185      Then the accumulated liquidity fees should be "100" for the market "ETH/DEC23"
   186  
   187      # Ensure LPs timeBookFraction ~=0.75, then check ~0.0 fees are penalised
   188      Given the network moves ahead "45" blocks
   189      And the parties cancel the following orders:
   190        | party | reference      |
   191        | lp1   | lp1-ice-buy-1  |
   192        | lp1   | lp1-ice-sell-1 |
   193      When the network moves ahead "1" epochs
   194      Then the following transfers should happen:
   195        | from | to  | from account                   | to account                     | market id | amount | asset |
   196        |      | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/DEC23 | 100    | USD   |
   197        | lp1  | lp1 | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ACCOUNT_TYPE_GENERAL           | ETH/DEC23 | 100    | USD   |
   198  
   199  
   200    Scenario: LP fulfills the mininum time fraction but is not always on the book when the sla competition factor is non-zero. (0042-LIQF-042)(0042-LIQF-043)
   201  
   202      # Initialise the market with the required parameters
   203      Given the liquidity sla params named "scenario-sla-params":
   204        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
   205        | 1           | 0.5                          | 0                             | 0.5                    |
   206      And the markets are updated:
   207        | id        | sla params          | linear slippage factor | quadratic slippage factor |
   208        | ETH/DEC23 | scenario-sla-params | 1e-3                   | 0                         |
   209  
   210      # Setup the market with 1 LP who is initially meeting their commitment
   211      Given the parties submit the following liquidity provision:
   212        | id  | party | market id | commitment amount | fee | lp type    |
   213        | lp1 | lp1   | ETH/DEC23 | 10000             | 0.1 | submission |
   214      And the parties place the following pegged iceberg orders:
   215        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
   216        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-1  |
   217        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-1 |
   218      When the parties place the following orders:
   219        | party | market id | side | volume | price | resulting trades | type       | tif     |
   220        | aux1  | ETH/DEC23 | buy  | 1      | 990   | 0                | TYPE_LIMIT | TIF_GTC |
   221        | aux2  | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   222        | aux1  | ETH/DEC23 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   223        | aux2  | ETH/DEC23 | sell | 1      | 1010  | 0                | TYPE_LIMIT | TIF_GTC |
   224      And the opening auction period ends for market "ETH/DEC23"
   225      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC23"
   226  
   227      # Generate liquidity fees to be allocated to the LP
   228      Given the parties place the following orders:
   229        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   230        | party1 | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   231        | party2 | ETH/DEC23 | sell | 1      | 1000  | 1                | TYPE_LIMIT | TIF_GTC |
   232      Then the accumulated liquidity fees should be "100" for the market "ETH/DEC23"
   233  
   234      # Ensure LPs timeBookFraction ~=0.75, then check ~0.25 fees are penalised (then returned as a bonus as they are the only LP)
   235      Given the network moves ahead "45" blocks
   236      And the parties cancel the following orders:
   237        | party | reference      |
   238        | lp1   | lp1-ice-buy-1  |
   239        | lp1   | lp1-ice-sell-1 |
   240      When the network moves ahead "1" epochs
   241      Then the following transfers should happen:
   242        | from | to  | from account                                   | to account                                     | market id | amount | asset |
   243        |      | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY                    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ETH/DEC23 | 100    | USD   |
   244        | lp1  | lp1 | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_GENERAL                           | ETH/DEC23 | 75     | USD   |
   245        | lp1  |     | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ETH/DEC23 | 25     | USD   |
   246        |      | lp1 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ACCOUNT_TYPE_GENERAL                           | ETH/DEC23 | 25     | USD   |
   247  
   248  
   249    Scenario: LP fulfills the mininum time fraction and provides liquidity throughout the epoch when performance hysteresis epochs is 1. (0042-LIQF-035)(0042-LIQF-043)
   250  
   251      # Initialise the market with the required parameters
   252      Given the liquidity sla params named "scenario-sla-params":
   253        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
   254        | 1           | 1                            | 1                             | 1                      |
   255      And the markets are updated:
   256        | id        | sla params          | linear slippage factor | quadratic slippage factor |
   257        | ETH/DEC23 | scenario-sla-params | 1e-3                   | 0                         |
   258  
   259      # Setup the market with 1 LP who is initially meeting their commitment
   260      Given the parties submit the following liquidity provision:
   261        | id  | party | market id | commitment amount | fee | lp type    |
   262        | lp1 | lp1   | ETH/DEC23 | 10000             | 0.1 | submission |
   263      And the parties place the following pegged iceberg orders:
   264        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
   265        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-1  |
   266        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-1 |
   267      When the parties place the following orders:
   268        | party | market id | side | volume | price | resulting trades | type       | tif     |
   269        | aux1  | ETH/DEC23 | buy  | 1      | 990   | 0                | TYPE_LIMIT | TIF_GTC |
   270        | aux2  | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   271        | aux1  | ETH/DEC23 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   272        | aux2  | ETH/DEC23 | sell | 1      | 1010  | 0                | TYPE_LIMIT | TIF_GTC |
   273      And the opening auction period ends for market "ETH/DEC23"
   274      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC23"
   275  
   276      # Generate liquidity fees to be allocated to the LP
   277      Given the parties place the following orders:
   278        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   279        | party1 | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   280        | party2 | ETH/DEC23 | sell | 1      | 1000  | 1                | TYPE_LIMIT | TIF_GTC |
   281      Then the accumulated liquidity fees should be "100" for the market "ETH/DEC23"
   282  
   283      # Ensure LPs timeBookFraction ~=1.00, then check ~0.0 fees are penalised
   284      When the network moves ahead "1" epochs
   285      Then the following transfers should happen:
   286        | from | to  | from account                   | to account           | market id | amount | asset |
   287        | lp1  | lp1 | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ACCOUNT_TYPE_GENERAL | ETH/DEC23 | 100    | USD   |
   288  
   289  
   290    Scenario: LP does not fulfill the mininum time fraction when performance hysteresis epochs is 1. (0042-LIQF-043)(0042-LIQF-049)
   291  
   292      # Initialise the market with the required parameters
   293      Given the liquidity sla params named "scenario-sla-params":
   294        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
   295        | 1           | 1                            | 1                             | 1                      |
   296      And the markets are updated:
   297        | id        | sla params          | linear slippage factor | quadratic slippage factor |
   298        | ETH/DEC23 | scenario-sla-params | 1e-3                   | 0                         |
   299  
   300      # Setup the market with 1 LP who is initially meeting their commitment
   301      Given the parties submit the following liquidity provision:
   302        | id  | party | market id | commitment amount | fee | lp type    |
   303        | lp1 | lp1   | ETH/DEC23 | 10000             | 0.1 | submission |
   304      And the parties place the following pegged iceberg orders:
   305        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
   306        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-1  |
   307        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-1 |
   308      When the parties place the following orders:
   309        | party | market id | side | volume | price | resulting trades | type       | tif     |
   310        | aux1  | ETH/DEC23 | buy  | 1      | 990   | 0                | TYPE_LIMIT | TIF_GTC |
   311        | aux2  | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   312        | aux1  | ETH/DEC23 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   313        | aux2  | ETH/DEC23 | sell | 1      | 1010  | 0                | TYPE_LIMIT | TIF_GTC |
   314      And the opening auction period ends for market "ETH/DEC23"
   315      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC23"
   316  
   317      # Generate liquidity fees to be allocated to the LP
   318      Given the parties place the following orders:
   319        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   320        | party1 | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   321        | party2 | ETH/DEC23 | sell | 1      | 1000  | 1                | TYPE_LIMIT | TIF_GTC |
   322      Then the accumulated liquidity fees should be "100" for the market "ETH/DEC23"
   323  
   324      # Ensure LPs timeBookFraction <1.00, then check ~1.0 fees are penalised
   325      Given the network moves ahead "1" blocks
   326      And the parties cancel the following orders:
   327        | party | reference      |
   328        | lp1   | lp1-ice-buy-1  |
   329        | lp1   | lp1-ice-sell-1 |
   330      When the network moves ahead "1" epochs
   331      Then the following transfers should happen:
   332        | from | to  | from account                   | to account                     | market id | amount | asset |
   333        |      | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/DEC23 | 100    | USD   |
   334        | lp1  |     | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ACCOUNT_TYPE_INSURANCE         | ETH/DEC23 | 100    | USD   |
   335  
   336  
   337    Scenario: LPs previous failures to meet the minimum time fraction if the markets performance hysteresis epochs is increased. (0042-LIQF-043)(0042-LIQF-053)
   338  
   339      # Initialise the market with the required parameters
   340      Given the liquidity sla params named "scenario-sla-params":
   341        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
   342        | 1           | 1.0                          | 0                             | 1                      |
   343      And the markets are updated:
   344        | id        | sla params          | linear slippage factor | quadratic slippage factor |
   345        | ETH/DEC23 | scenario-sla-params | 1e-3                   | 0                         |
   346  
   347      # Setup the market with 1 LP who is initially meeting their commitment
   348      Given the parties submit the following liquidity provision:
   349        | id  | party | market id | commitment amount | fee | lp type    |
   350        | lp1 | lp1   | ETH/DEC23 | 10000             | 0.1 | submission |
   351      And the parties place the following pegged iceberg orders:
   352        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
   353        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-1  |
   354        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-1 |
   355      When the parties place the following orders:
   356        | party | market id | side | volume | price | resulting trades | type       | tif     |
   357        | aux1  | ETH/DEC23 | buy  | 1      | 990   | 0                | TYPE_LIMIT | TIF_GTC |
   358        | aux2  | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   359        | aux1  | ETH/DEC23 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   360        | aux2  | ETH/DEC23 | sell | 1      | 1010  | 0                | TYPE_LIMIT | TIF_GTC |
   361  
   362      # Ensure LPs average timeBookFraction ~0.75 over the last 2 epochs, and will be ~1.0 in the next epoch
   363      Given the network moves ahead "45" blocks
   364      And the parties cancel the following orders:
   365        | party | reference      |
   366        | lp1   | lp1-ice-buy-1  |
   367        | lp1   | lp1-ice-sell-1 |
   368      And the network moves ahead "1" epochs
   369      And the parties place the following pegged iceberg orders:
   370        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
   371        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-2  |
   372        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-2 |
   373      And the network moves ahead "45" blocks
   374      And the parties cancel the following orders:
   375        | party | reference      |
   376        | lp1   | lp1-ice-buy-2  |
   377        | lp1   | lp1-ice-sell-2 |
   378  
   379      # Update the market by increasing 'performance hysteresis epochs'. This will take effect for next epoch and
   380      # no penalty should be applied.
   381      Given the liquidity sla params named "updated-sla-params":
   382        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
   383        | 1           | 0.5                          | 2                             | 1                      |
   384      And the markets are updated:
   385        | id        | sla params         | linear slippage factor | quadratic slippage factor |
   386        | ETH/DEC23 | updated-sla-params | 1e-3                   | 0                         |
   387  
   388      And the network moves ahead "1" epochs
   389      And the parties place the following pegged iceberg orders:
   390        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
   391        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-3  |
   392        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-3 |
   393  
   394      # Generate liquidity fees to be allocated to the LP
   395      Given the parties place the following orders:
   396        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   397        | party1 | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   398        | party2 | ETH/DEC23 | sell | 1      | 1000  | 1                | TYPE_LIMIT | TIF_GTC |
   399      Then the accumulated liquidity fees should be "100" for the market "ETH/DEC23"
   400  
   401      When the network moves ahead "1" epochs
   402      Then the following transfers should happen:
   403        | from | to  | from account                   | to account                     | market id | amount | asset |
   404        |      | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/DEC23 | 100    | USD   |
   405        | lp1  | lp1 | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ACCOUNT_TYPE_GENERAL           | ETH/DEC23 | 100    | USD   |
   406  
   407  
   408    Scenario: LPs average penalty over the last N epochs is worse then their current performance when performance hysteresis epochs is > 1. (0042-LIQF-043)(0042-LIQF-047)
   409  
   410      # Initialise the market with the required parameters
   411      Given the liquidity sla params named "scenario-sla-params":
   412        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
   413        | 1           | 0.0                          | 3                             | 1                      |
   414      And the markets are updated:
   415        | id        | sla params          | linear slippage factor | quadratic slippage factor |
   416        | ETH/DEC23 | scenario-sla-params | 1e-3                   | 0                         |
   417  
   418      # Setup the market with 1 LP who is initially meeting their commitment
   419      Given the parties submit the following liquidity provision:
   420        | id  | party | market id | commitment amount | fee | lp type    |
   421        | lp1 | lp1   | ETH/DEC23 | 10000             | 0.1 | submission |
   422      And the parties place the following pegged iceberg orders:
   423        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
   424        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-1  |
   425        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-1 |
   426      When the parties place the following orders:
   427        | party | market id | side | volume | price | resulting trades | type       | tif     |
   428        | aux1  | ETH/DEC23 | buy  | 1      | 990   | 0                | TYPE_LIMIT | TIF_GTC |
   429        | aux2  | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   430        | aux1  | ETH/DEC23 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   431        | aux2  | ETH/DEC23 | sell | 1      | 1010  | 0                | TYPE_LIMIT | TIF_GTC |
   432      And the opening auction period ends for market "ETH/DEC23"
   433      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC23"
   434  
   435      # Ensure LPs average timeBookFraction ~0.75 over the last 2 epochs, and will be ~1.0 in the next epoch
   436      Given the network moves ahead "45" blocks
   437      And the parties cancel the following orders:
   438        | party | reference      |
   439        | lp1   | lp1-ice-buy-1  |
   440        | lp1   | lp1-ice-sell-1 |
   441      And the network moves ahead "1" epochs
   442      And the parties place the following pegged iceberg orders:
   443        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
   444        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-2  |
   445        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-2 |
   446      And the network moves ahead "45" blocks
   447      And the parties cancel the following orders:
   448        | party | reference      |
   449        | lp1   | lp1-ice-buy-2  |
   450        | lp1   | lp1-ice-sell-2 |
   451      And the network moves ahead "1" epochs
   452      And the parties place the following pegged iceberg orders:
   453        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
   454        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-3  |
   455        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-3 |
   456  
   457      # Generate liquidity fees to be allocated to the LP
   458      Given the parties place the following orders:
   459        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   460        | party1 | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   461        | party2 | ETH/DEC23 | sell | 1      | 1000  | 1                | TYPE_LIMIT | TIF_GTC |
   462      Then the accumulated liquidity fees should be "100" for the market "ETH/DEC23"
   463  
   464      When the network moves ahead "1" epochs
   465      Then the following transfers should happen:
   466        | from | to  | from account                                   | to account                                     | market id | amount | asset |
   467        |      | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY                    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ETH/DEC23 | 100    | USD   |
   468        | lp1  | lp1 | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_GENERAL                           | ETH/DEC23 | 75     | USD   |
   469        | lp1  |     | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ETH/DEC23 | 25     | USD   |
   470        |      | lp1 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ACCOUNT_TYPE_GENERAL                           | ETH/DEC23 | 25     | USD   |
   471  
   472  
   473    Scenario: LPs average penalty over the last N epochs is worse then their current performance when performance hysteresis epochs is > 1. (0042-LIQF-039)(0042-LIQF-043)(0042-LIQF-046)
   474  
   475      # Initialise the market with the required parameters
   476      Given the liquidity sla params named "scenario-sla-params":
   477        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
   478        | 1           | 0.0                          | 3                             | 1                      |
   479      And the markets are updated:
   480        | id        | sla params          | linear slippage factor | quadratic slippage factor |
   481        | ETH/DEC23 | scenario-sla-params | 1e-3                   | 0                         |
   482  
   483      # Setup the market with 1 LP who is initially meeting their commitment
   484      Given the parties submit the following liquidity provision:
   485        | id  | party | market id | commitment amount | fee | lp type    |
   486        | lp1 | lp1   | ETH/DEC23 | 10000             | 0.1 | submission |
   487      And the parties place the following pegged iceberg orders:
   488        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
   489        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-1  |
   490        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-1 |
   491      When the parties place the following orders:
   492        | party | market id | side | volume | price | resulting trades | type       | tif     |
   493        | aux1  | ETH/DEC23 | buy  | 1      | 990   | 0                | TYPE_LIMIT | TIF_GTC |
   494        | aux2  | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   495        | aux1  | ETH/DEC23 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   496        | aux2  | ETH/DEC23 | sell | 1      | 1010  | 0                | TYPE_LIMIT | TIF_GTC |
   497      And the opening auction period ends for market "ETH/DEC23"
   498      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC23"
   499  
   500      # Ensure LPs average timeBookFraction ~0.50 over the last 2 epochs, and will be ~1.0 in the next epoch
   501      Given the network moves ahead "30" blocks
   502      And the parties cancel the following orders:
   503        | party | reference      |
   504        | lp1   | lp1-ice-buy-1  |
   505        | lp1   | lp1-ice-sell-1 |
   506      And the network moves ahead "1" epochs
   507      And the parties place the following pegged iceberg orders:
   508        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
   509        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-2  |
   510        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-2 |
   511      And the network moves ahead "30" blocks
   512      And the parties cancel the following orders:
   513        | party | reference      |
   514        | lp1   | lp1-ice-buy-2  |
   515        | lp1   | lp1-ice-sell-2 |
   516      And the network moves ahead "1" epochs
   517      And the parties place the following pegged iceberg orders:
   518        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
   519        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-3  |
   520        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-3 |
   521  
   522      # Generate liquidity fees to be allocated to the LP
   523      Given the parties place the following orders:
   524        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   525        | party1 | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   526        | party2 | ETH/DEC23 | sell | 1      | 1000  | 1                | TYPE_LIMIT | TIF_GTC |
   527      Then the accumulated liquidity fees should be "100" for the market "ETH/DEC23"
   528  
   529      When the network moves ahead "1" epochs
   530      Then the following transfers should happen:
   531        | from | to  | from account                                   | to account                                     | market id | amount | asset |
   532        |      | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY                    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ETH/DEC23 | 100    | USD   |
   533        | lp1  | lp1 | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_GENERAL                           | ETH/DEC23 | 50     | USD   |
   534        | lp1  |     | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ETH/DEC23 | 50     | USD   |
   535        |      | lp1 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ACCOUNT_TYPE_GENERAL                           | ETH/DEC23 | 50     | USD   |
   536  
   537  
   538    Scenario: LPs average penalty over the last N epochs is better then their current performance when performance hysteresis epochs is > 1. (0042-LIQF-040)(0042-LIQF-043)
   539  
   540      # Initialise the market with the required parameters
   541      Given the liquidity sla params named "scenario-sla-params":
   542        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
   543        | 1           | 0.0                          | 3                             | 1                      |
   544      And the markets are updated:
   545        | id        | sla params          | linear slippage factor | quadratic slippage factor |
   546        | ETH/DEC23 | scenario-sla-params | 1e-3                   | 0                         |
   547  
   548      # Setup the market with 1 LP who is initially meeting their commitment
   549      Given the parties submit the following liquidity provision:
   550        | id  | party | market id | commitment amount | fee | lp type    |
   551        | lp1 | lp1   | ETH/DEC23 | 10000             | 0.1 | submission |
   552      And the parties place the following pegged iceberg orders:
   553        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
   554        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-1  |
   555        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-1 |
   556      When the parties place the following orders:
   557        | party | market id | side | volume | price | resulting trades | type       | tif     |
   558        | aux1  | ETH/DEC23 | buy  | 1      | 990   | 0                | TYPE_LIMIT | TIF_GTC |
   559        | aux2  | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   560        | aux1  | ETH/DEC23 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   561        | aux2  | ETH/DEC23 | sell | 1      | 1010  | 0                | TYPE_LIMIT | TIF_GTC |
   562      And the opening auction period ends for market "ETH/DEC23"
   563      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC23"
   564  
   565      # Ensure LPs average timeBookFraction ~0.50 over the last 2 epochs, and will be ~1.0 in the next epoch
   566      Given the network moves ahead "30" blocks
   567      And the parties cancel the following orders:
   568        | party | reference      |
   569        | lp1   | lp1-ice-buy-1  |
   570        | lp1   | lp1-ice-sell-1 |
   571      And the network moves ahead "1" epochs
   572      And the parties place the following pegged iceberg orders:
   573        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
   574        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-2  |
   575        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-2 |
   576      And the network moves ahead "30" blocks
   577      And the parties cancel the following orders:
   578        | party | reference      |
   579        | lp1   | lp1-ice-buy-2  |
   580        | lp1   | lp1-ice-sell-2 |
   581      And the network moves ahead "1" epochs
   582  
   583      # Generate liquidity fees to be allocated to the LP
   584      Given the parties place the following orders:
   585        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   586        | party1 | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   587        | party2 | ETH/DEC23 | sell | 1      | 1000  | 1                | TYPE_LIMIT | TIF_GTC |
   588      Then the accumulated liquidity fees should be "100" for the market "ETH/DEC23"
   589  
   590      When the network moves ahead "1" epochs
   591      Then the following transfers should happen:
   592        | from | to  | from account                   | to account                     | market id | amount | asset |
   593        |      | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/DEC23 | 100    | USD   |
   594        | lp1  |     | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ACCOUNT_TYPE_INSURANCE         | ETH/DEC23 | 100    | USD   |
   595  
   596  
   597    Scenario: 2 LPs fulfill the mininum time fraction but have different SLA performance when the sla competition factor is non-zero.(0042-LIQF-043)(0042-LIQF-044)
   598  
   599      # Initialise the market with the required parameters
   600      Given the liquidity sla params named "scenario-sla-params":
   601        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
   602        | 1           | 0.5                          | 3                             | 1                      |
   603      And the following network parameters are set:
   604        | name                    | value |
   605        | validators.epoch.length | 1m58s |
   606      And the markets are updated:
   607        | id        | sla params          | linear slippage factor | quadratic slippage factor |
   608        | ETH/DEC23 | scenario-sla-params | 1e-3                   | 0                         |
   609  
   610      # Setup the market with 2 LPs who are initially meeting their commitment
   611      Given the parties submit the following liquidity provision:
   612        | id  | party | market id | commitment amount | fee | lp type    |
   613        | lp1 | lp1   | ETH/DEC23 | 10000             | 0.1 | submission |
   614        | lp2 | lp2   | ETH/DEC23 | 10000             | 0.1 | submission |
   615      And the parties place the following pegged iceberg orders:
   616        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
   617        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-1  |
   618        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-1 |
   619        | lp2   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp2-ice-buy-1  |
   620        | lp2   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp2-ice-sell-1 |
   621      When the parties place the following orders:
   622        | party | market id | side | volume | price | resulting trades | type       | tif     |
   623        | aux1  | ETH/DEC23 | buy  | 1      | 990   | 0                | TYPE_LIMIT | TIF_GTC |
   624        | aux2  | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   625        | aux1  | ETH/DEC23 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   626        | aux2  | ETH/DEC23 | sell | 1      | 1010  | 0                | TYPE_LIMIT | TIF_GTC |
   627      And the opening auction period ends for market "ETH/DEC23"
   628      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC23"
   629  
   630      # Generate liquidity fees to be allocated to the LP
   631      Given the parties place the following orders:
   632        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   633        | party1 | ETH/DEC23 | buy  | 2      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   634        | party2 | ETH/DEC23 | sell | 2      | 1000  | 1                | TYPE_LIMIT | TIF_GTC |
   635      Then the accumulated liquidity fees should be "200" for the market "ETH/DEC23"
   636  
   637      # Ensure LP1s average timeBookFraction ~0.75 and penalties will be ~0.5 in the next epoch
   638      Given the network moves ahead "90" blocks
   639      And the parties cancel the following orders:
   640        | party | reference      |
   641        | lp1   | lp1-ice-buy-1  |
   642        | lp1   | lp1-ice-sell-1 |
   643      # Ensure LP2s average timeBookFraction ~0.875 and penalties will be ~0.75 in the next epoch
   644      Given the network moves ahead "15" blocks
   645      And the parties cancel the following orders:
   646        | party | reference      |
   647        | lp2   | lp2-ice-buy-1  |
   648        | lp2   | lp2-ice-sell-1 |
   649      And the network moves ahead "1" epochs
   650      Then the following transfers should happen:
   651        | from | to  | from account                                   | to account                                     | market id | amount | asset |
   652        |      | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY                    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ETH/DEC23 | 100    | USD   |
   653        |      | lp2 | ACCOUNT_TYPE_FEES_LIQUIDITY                    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ETH/DEC23 | 100    | USD   |
   654        | lp1  | lp1 | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_GENERAL                           | ETH/DEC23 | 50     | USD   |
   655        | lp1  |     | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ETH/DEC23 | 50     | USD   |
   656        | lp2  | lp2 | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_GENERAL                           | ETH/DEC23 | 75     | USD   |
   657        | lp2  |     | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ETH/DEC23 | 25     | USD   |
   658        |      | lp1 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ACCOUNT_TYPE_GENERAL                           | ETH/DEC23 | 30     | USD   |
   659        |      | lp2 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ACCOUNT_TYPE_GENERAL                           | ETH/DEC23 | 45     | USD   |
   660  
   661  
   662    Scenario: 2 LPs fulfill the mininum time fraction but have different SLA performance when the sla competition factor is non-zero. (0042-LIQF-043)(0042-LIQF-045)
   663  
   664      # Initialise the market with the required parameters
   665      Given the liquidity sla params named "scenario-sla-params":
   666        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
   667        | 1           | 0.5                          | 3                             | 1                      |
   668      And the markets are updated:
   669        | id        | sla params          | linear slippage factor | quadratic slippage factor |
   670        | ETH/DEC23 | scenario-sla-params | 1e-3                   | 0                         |
   671  
   672      And the following network parameters are set:
   673        | name                    | value |
   674        | validators.epoch.length | 1m58s |
   675  
   676      # Setup the market with 1 LP who is initially meeting their commitment and 1 LP who isn't
   677      Given the parties submit the following liquidity provision:
   678        | id  | party | market id | commitment amount | fee | lp type    |
   679        | lp1 | lp1   | ETH/DEC23 | 10000             | 0.1 | submission |
   680        | lp2 | lp2   | ETH/DEC23 | 10000             | 0.1 | submission |
   681      And the parties place the following pegged iceberg orders:
   682        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference      |
   683        | lp1   | ETH/DEC23 | 200       | 120                  | buy  | BID              | 1000   | 1      | lp1-ice-buy-1  |
   684        | lp1   | ETH/DEC23 | 200       | 120                  | sell | ASK              | 1000   | 1      | lp1-ice-sell-1 |
   685        | lp2   | ETH/DEC23 | 9         | 9                    | buy  | BID              | 1      | 1      | lp1-ice-buy-1  |
   686        | lp2   | ETH/DEC23 | 9         | 9                    | sell | ASK              | 1      | 1      | lp1-ice-sell-1 |
   687      When the parties place the following orders:
   688        | party | market id | side | volume | price | resulting trades | type       | tif     |
   689        | aux1  | ETH/DEC23 | buy  | 1      | 990   | 0                | TYPE_LIMIT | TIF_GTC |
   690        | aux2  | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   691        | aux1  | ETH/DEC23 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   692        | aux2  | ETH/DEC23 | sell | 1      | 1010  | 0                | TYPE_LIMIT | TIF_GTC |
   693      And the opening auction period ends for market "ETH/DEC23"
   694      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC23"
   695  
   696      # Generate liquidity fees to be allocated to the LP
   697      Given the parties place the following orders:
   698        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   699        | party1 | ETH/DEC23 | buy  | 2      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   700        | party2 | ETH/DEC23 | sell | 2      | 1000  | 1                | TYPE_LIMIT | TIF_GTC |
   701      Then the accumulated liquidity fees should be "200" for the market "ETH/DEC23"
   702  
   703      # Ensure LP1s average timeBookFraction ~0.75 and penalties will be ~0.5 in the next epoch
   704      Given the network moves ahead "90" blocks
   705      And the parties cancel the following orders:
   706        | party | reference      |
   707        | lp1   | lp1-ice-buy-1  |
   708        | lp1   | lp1-ice-sell-1 |
   709      And the network moves ahead "1" epochs
   710      Then the following transfers should happen:
   711        | from | to  | from account                                   | to account                                     | market id | amount | asset |
   712        |      | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY                    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ETH/DEC23 | 100    | USD   |
   713        |      | lp2 | ACCOUNT_TYPE_FEES_LIQUIDITY                    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ETH/DEC23 | 100    | USD   |
   714        | lp1  | lp1 | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_GENERAL                           | ETH/DEC23 | 50     | USD   |
   715        | lp1  |     | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ETH/DEC23 | 50     | USD   |
   716        | lp2  |     | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ETH/DEC23 | 100    | USD   |
   717        |      | lp1 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ACCOUNT_TYPE_GENERAL                           | ETH/DEC23 | 150    | USD   |
   718  
   719    Scenario: 4 LPs acheive various penalty fractions, unpaid liquidity fees distributed correctly as a bonus (0042-LIQF-055)
   720  
   721      # Initialise the market with the required parameters
   722      Given the liquidity sla params named "scenario-sla-params":
   723        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
   724        | 1           | 0                            | 1                             | 1                      |
   725      And the markets are updated:
   726        | id        | sla params          | linear slippage factor | quadratic slippage factor |
   727        | ETH/DEC23 | scenario-sla-params | 1e-3                   | 0                         |
   728  
   729      And the following network parameters are set:
   730        | name                    | value |
   731        | validators.epoch.length | 98s   |
   732  
   733      # Setup the market with 4 LPs who initially meet their commitment
   734      Given the parties submit the following liquidity provision:
   735        | id  | party | market id | commitment amount | fee | lp type    |
   736        | lp1 | lp1   | ETH/DEC23 | 10000000          | 0.1 | submission |
   737        | lp2 | lp2   | ETH/DEC23 | 1000000           | 0.1 | submission |
   738        | lp3 | lp3   | ETH/DEC23 | 70000000          | 0.1 | submission |
   739        | lp4 | lp4   | ETH/DEC23 | 919000000         | 0.1 | submission |
   740      When the parties place the following orders:
   741        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
   742        | lp1   | ETH/DEC23 | buy  | 10000  | 999   | 0                | TYPE_LIMIT | TIF_GTC | lp1-bid   |
   743        | lp1   | ETH/DEC23 | sell | 10000  | 1001  | 0                | TYPE_LIMIT | TIF_GTC | lp1-ask   |
   744        | lp2   | ETH/DEC23 | buy  | 1000   | 999   | 0                | TYPE_LIMIT | TIF_GTC | lp2-bid   |
   745        | lp2   | ETH/DEC23 | sell | 1000   | 1001  | 0                | TYPE_LIMIT | TIF_GTC | lp2-ask   |
   746        | lp3   | ETH/DEC23 | buy  | 70000  | 999   | 0                | TYPE_LIMIT | TIF_GTC | lp3-bid   |
   747        | lp3   | ETH/DEC23 | sell | 70000  | 1001  | 0                | TYPE_LIMIT | TIF_GTC | lp3-ask   |
   748        | lp4   | ETH/DEC23 | buy  | 919000 | 999   | 0                | TYPE_LIMIT | TIF_GTC | lp4-bid   |
   749        | lp4   | ETH/DEC23 | sell | 919000 | 1001  | 0                | TYPE_LIMIT | TIF_GTC | lp4-ask   |
   750      When the parties place the following orders:
   751        | party | market id | side | volume | price | resulting trades | type       | tif     |
   752        | aux1  | ETH/DEC23 | buy  | 1      | 990   | 0                | TYPE_LIMIT | TIF_GTC |
   753        | aux2  | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   754        | aux1  | ETH/DEC23 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   755        | aux2  | ETH/DEC23 | sell | 1      | 1010  | 0                | TYPE_LIMIT | TIF_GTC |
   756      And the opening auction period ends for market "ETH/DEC23"
   757      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC23"
   758  
   759      # Generate liquidity fees to be allocated to the LP
   760      Given the network moves ahead "1" epochs
   761      When the parties place the following orders:
   762        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   763        | party1 | ETH/DEC23 | buy  | 1000   | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   764        | party2 | ETH/DEC23 | sell | 1000   | 1000  | 1                | TYPE_LIMIT | TIF_GTC |
   765      Then the accumulated liquidity fees should be "100000" for the market "ETH/DEC23"
   766  
   767      # Ensure LPs have the correct penalty fractions whilst having approx. equal average liquidity scores
   768      Given the parties amend the following orders:
   769        | party | reference | price | size delta | tif     |
   770        | lp4   | lp4-bid   | 999   | -1         | TIF_GTC |
   771        | lp4   | lp4-ask   | 1001  | -1         | TIF_GTC |
   772      And the network moves ahead "40" blocks
   773      And the parties amend the following orders:
   774        | party | reference | price | size delta | tif     |
   775        | lp3   | lp3-bid   | 999   | -1         | TIF_GTC |
   776        | lp3   | lp3-ask   | 1001  | -1         | TIF_GTC |
   777      And the network moves ahead "55" blocks
   778      And the parties amend the following orders:
   779        | party | reference | price | size delta | tif     |
   780        | lp2   | lp2-bid   | 999   | -1         | TIF_GTC |
   781        | lp2   | lp2-ask   | 1001  | -1         | TIF_GTC |
   782      When the network moves ahead "1" epochs
   783      Then the following transfers should happen:
   784        | from | to  | from account                                   | to account                     | market id | amount | asset |
   785        |      | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY                    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/DEC23 | 1000   | USD   |
   786        |      | lp2 | ACCOUNT_TYPE_FEES_LIQUIDITY                    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/DEC23 | 100    | USD   |
   787        |      | lp3 | ACCOUNT_TYPE_FEES_LIQUIDITY                    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/DEC23 | 7000   | USD   |
   788        |      | lp4 | ACCOUNT_TYPE_FEES_LIQUIDITY                    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/DEC23 | 91900  | USD   |
   789        | lp1  | lp1 | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_GENERAL           | ETH/DEC23 | 1000   | USD   |
   790        | lp2  | lp2 | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_GENERAL           | ETH/DEC23 | 95     | USD   |
   791        | lp3  | lp3 | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_GENERAL           | ETH/DEC23 | 2800   | USD   |
   792        |      | lp1 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ACCOUNT_TYPE_GENERAL           | ETH/DEC23 | 24673  | USD   |
   793        |      | lp2 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ACCOUNT_TYPE_GENERAL           | ETH/DEC23 | 2344   | USD   |
   794        |      | lp3 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ACCOUNT_TYPE_GENERAL           | ETH/DEC23 | 69087  | USD   |
   795  
   796    Scenario: 4 LPs acheive various penalty fractions, unpaid liquidity fees distributed correctly as a bonus (0042-LIQF-055) + fee fraction set to 0.5
   797  
   798      Given the following network parameters are set:
   799        | name                                             | value |
   800        | market.liquidity.equityLikeShareFeeFraction      | 0.5   |
   801      # Initialise the market with the required parameters
   802      And the liquidity sla params named "scenario-sla-params":
   803        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
   804        | 1           | 0                            | 1                             | 1                      |
   805      And the markets are updated:
   806        | id        | sla params          | linear slippage factor | quadratic slippage factor |
   807        | ETH/DEC23 | scenario-sla-params | 1e-3                   | 0                         |
   808  
   809      And the following network parameters are set:
   810        | name                    | value |
   811        | validators.epoch.length | 98s   |
   812  
   813      # Setup the market with 4 LPs who initially meet their commitment
   814      Given the parties submit the following liquidity provision:
   815        | id  | party | market id | commitment amount | fee | lp type    |
   816        | lp1 | lp1   | ETH/DEC23 | 10000000          | 0.1 | submission |
   817        | lp2 | lp2   | ETH/DEC23 | 1000000           | 0.1 | submission |
   818        | lp3 | lp3   | ETH/DEC23 | 70000000          | 0.1 | submission |
   819        | lp4 | lp4   | ETH/DEC23 | 919000000         | 0.1 | submission |
   820      When the parties place the following orders:
   821        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
   822        | lp1   | ETH/DEC23 | buy  | 10000  | 999   | 0                | TYPE_LIMIT | TIF_GTC | lp1-bid   |
   823        | lp1   | ETH/DEC23 | sell | 10000  | 1001  | 0                | TYPE_LIMIT | TIF_GTC | lp1-ask   |
   824        | lp2   | ETH/DEC23 | buy  | 1000   | 999   | 0                | TYPE_LIMIT | TIF_GTC | lp2-bid   |
   825        | lp2   | ETH/DEC23 | sell | 1000   | 1001  | 0                | TYPE_LIMIT | TIF_GTC | lp2-ask   |
   826        | lp3   | ETH/DEC23 | buy  | 70000  | 999   | 0                | TYPE_LIMIT | TIF_GTC | lp3-bid   |
   827        | lp3   | ETH/DEC23 | sell | 70000  | 1001  | 0                | TYPE_LIMIT | TIF_GTC | lp3-ask   |
   828        | lp4   | ETH/DEC23 | buy  | 919000 | 999   | 0                | TYPE_LIMIT | TIF_GTC | lp4-bid   |
   829        | lp4   | ETH/DEC23 | sell | 919000 | 1001  | 0                | TYPE_LIMIT | TIF_GTC | lp4-ask   |
   830      When the parties place the following orders:
   831        | party | market id | side | volume | price | resulting trades | type       | tif     |
   832        | aux1  | ETH/DEC23 | buy  | 1      | 990   | 0                | TYPE_LIMIT | TIF_GTC |
   833        | aux2  | ETH/DEC23 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   834        | aux1  | ETH/DEC23 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   835        | aux2  | ETH/DEC23 | sell | 1      | 1010  | 0                | TYPE_LIMIT | TIF_GTC |
   836      And the opening auction period ends for market "ETH/DEC23"
   837      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC23"
   838  
   839      # Generate liquidity fees to be allocated to the LP
   840      Given the network moves ahead "1" epochs
   841      When the parties place the following orders:
   842        | party  | market id | side | volume | price | resulting trades | type       | tif     |
   843        | party1 | ETH/DEC23 | buy  | 1000   | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   844        | party2 | ETH/DEC23 | sell | 1000   | 1000  | 1                | TYPE_LIMIT | TIF_GTC |
   845      Then the accumulated liquidity fees should be "100000" for the market "ETH/DEC23"
   846  
   847      # Ensure LPs have the correct penalty fractions whilst having approx. equal average liquidity scores
   848      Given the parties amend the following orders:
   849        | party | reference | price | size delta | tif     |
   850        | lp4   | lp4-bid   | 999   | -1         | TIF_GTC |
   851        | lp4   | lp4-ask   | 1001  | -1         | TIF_GTC |
   852      And the network moves ahead "40" blocks
   853      And the parties amend the following orders:
   854        | party | reference | price | size delta | tif     |
   855        | lp3   | lp3-bid   | 999   | -1         | TIF_GTC |
   856        | lp3   | lp3-ask   | 1001  | -1         | TIF_GTC |
   857      And the network moves ahead "55" blocks
   858      And the parties amend the following orders:
   859        | party | reference | price | size delta | tif     |
   860        | lp2   | lp2-bid   | 999   | -1         | TIF_GTC |
   861        | lp2   | lp2-ask   | 1001  | -1         | TIF_GTC |
   862      When the network moves ahead "1" epochs
   863      Then the following transfers should happen:
   864        | from | to  | from account                                   | to account                     | market id | amount | asset |
   865        |      | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY                    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/DEC23 | 13000  | USD   |
   866        |      | lp2 | ACCOUNT_TYPE_FEES_LIQUIDITY                    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/DEC23 | 12550  | USD   |
   867        |      | lp3 | ACCOUNT_TYPE_FEES_LIQUIDITY                    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/DEC23 | 16000  | USD   |
   868        |      | lp4 | ACCOUNT_TYPE_FEES_LIQUIDITY                    | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/DEC23 | 58450  | USD   |
   869        | lp1  | lp1 | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_GENERAL           | ETH/DEC23 | 13000  | USD   |
   870        | lp2  | lp2 | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_GENERAL           | ETH/DEC23 | 11922  | USD   |
   871        | lp3  | lp3 | ACCOUNT_TYPE_LP_LIQUIDITY_FEES                 | ACCOUNT_TYPE_GENERAL           | ETH/DEC23 | 6400   | USD   |
   872        |      | lp1 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ACCOUNT_TYPE_GENERAL           | ETH/DEC23 | 28503  | USD   |
   873        |      | lp2 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ACCOUNT_TYPE_GENERAL           | ETH/DEC23 | 26141  | USD   |
   874        |      | lp3 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ACCOUNT_TYPE_GENERAL           | ETH/DEC23 | 14032  | USD   |
   875        |      | lp3 | ACCOUNT_TYPE_LIQUIDITY_FEES_BONUS_DISTRIBUTION | ACCOUNT_TYPE_GENERAL           | ETH/DEC23 | 2      | USD   |