code.vegaprotocol.io/vega@v0.79.0/core/integration/features/spot/liquidity_provision/0044-LIME-107.feature (about)

     1  Feature: Spot market SLA
     2  
     3    Scenario: 001 0044-LIME-107
     4      Given time is updated to "2023-07-20T00:00:00Z"
     5  
     6      Given the fees configuration named "fees-config-1":
     7        | maker fee | infrastructure fee |
     8        | 0         | 0                  |
     9      Given the log normal risk model named "lognormal-risk-model-1":
    10        | risk aversion | tau  | mu | r   | sigma |
    11        | 0.001         | 0.01 | 0  | 0.0 | 1.2   |
    12      And the fees configuration named "fees-config-4":
    13        | maker fee | infrastructure fee | liquidity fee method | liquidity fee constant |
    14        | 0.0004    | 0.001              | METHOD_MARGINAL_COST | 0.01                   |
    15  
    16      And the price monitoring named "price-monitoring-1":
    17        | horizon | probability | auction extension |
    18        | 3600    | 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.6                          | 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.2   |
    34        | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0.15  |
    35        | market.liquidity.sla.nonPerformanceBondPenaltyMax   | 0.3   |
    36        | market.liquidity.maximumLiquidityFeeFactorLevel     | 0.4   |
    37        | validators.epoch.length                             | 4s    |
    38  
    39      And the spot markets:
    40        | id      | name    | base asset | quote asset | risk model             | auction duration | fees          | price monitoring   | sla params |
    41        | BTC/ETH | BTC/ETH | BTC        | ETH         | lognormal-risk-model-1 | 1                | fees-config-4 | price-monitoring-1 | SLA-1      |
    42      And the following network parameters are set:
    43        | name                                             | value |
    44        | market.liquidity.providersFeeCalculationTimeStep | 1s    |
    45        | market.liquidity.stakeToCcyVolume                | 1     |
    46  
    47      Given the parties deposit on asset's general account the following amount:
    48        | party  | asset | amount |
    49        | party1 | ETH   | 10000  |
    50        | party2 | BTC   | 500    |
    51        | lp1    | ETH   | 4000   |
    52        | lp1    | BTC   | 60     |
    53        | lp2    | ETH   | 4000   |
    54        | lp2    | BTC   | 60     |
    55        | lp3    | ETH   | 70000  |
    56        | lp3    | BTC   | 2500   |
    57        | lp4    | ETH   | 70000  |
    58        | lp4    | BTC   | 2500   |
    59  
    60      And the average block duration is "1"
    61  
    62      Given the liquidity monitoring parameters:
    63        | name               | triggering ratio | time window | scaling factor |
    64        | updated-lqm-params | 0.2              | 20s         | 0.8            |
    65  
    66      When the spot markets are updated:
    67        | id      | liquidity monitoring | linear slippage factor | quadratic slippage factor |
    68        | BTC/ETH | updated-lqm-params   | 0.5                    | 0.5                       |
    69  
    70      When the parties submit the following liquidity provision:
    71        | id  | party | market id | commitment amount | fee | lp type    |
    72        | lp1 | lp1   | BTC/ETH   | 3000              | 0.1 | submission |
    73        | lp2 | lp2   | BTC/ETH   | 3000              | 0.1 | submission |
    74  
    75      Then the network moves ahead "1" blocks
    76      And the network treasury balance should be "0" for the asset "ETH"
    77      And the global insurance pool balance should be "0" for the asset "ETH"
    78      And the global insurance pool balance should be "0" for the asset "BTC"
    79      And the party "lp1" lp liquidity fee account balance should be "0" for the market "BTC/ETH"
    80      Then the party "lp1" lp liquidity bond account balance should be "3000" for the market "BTC/ETH"
    81  
    82      Then the market data for the market "BTC/ETH" should be:
    83        | mark price | trading mode                 | auction trigger         | target stake | supplied stake | open interest |
    84        | 0          | TRADING_MODE_OPENING_AUCTION | AUCTION_TRIGGER_OPENING | 4800         | 6000           | 0             |
    85  
    86      # place orders and generate trades
    87      And the parties place the following orders:
    88        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference    | only |
    89        | party1 | BTC/ETH   | buy  | 6      | 8     | 0                | TYPE_LIMIT | TIF_GTC | party-order5 |      |
    90        | party1 | BTC/ETH   | buy  | 1      | 15    | 0                | TYPE_LIMIT | TIF_GTC | party-order3 |      |
    91        | party2 | BTC/ETH   | sell | 1      | 15    | 0                | TYPE_LIMIT | TIF_GTC | party-order4 |      |
    92        | party2 | BTC/ETH   | sell | 6      | 24    | 0                | TYPE_LIMIT | TIF_GTC | party-order6 |      |
    93  
    94      When the network moves ahead "2" blocks
    95  
    96      Then the following trades should be executed:
    97        | buyer  | price | size | seller |
    98        | party1 | 15    | 1    | party2 |
    99  
   100      Then the market data for the market "BTC/ETH" should be:
   101        | mark price | trading mode            | auction trigger             | target stake | supplied stake | open interest |
   102        | 15         | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 4800         | 6000           | 0             |
   103  
   104      Then "lp1" should have general account balance of "1000" for asset "ETH"
   105      Then "lp2" should have general account balance of "1000" for asset "ETH"
   106  
   107      #0044-LIME-108:If a liquidity provider with an active liquidity provision at the start of an epoch amends the fee level associated to this commitment during the epoch, this change will only take effect at the end of the epoch.
   108      #0044-LIME-109:If a liquidity provider with an active liquidity provision at the start of an epoch increases their liquidity provision staked commitment during the epoch
   109      #0044-LIME-110:the protocol will increase the bond to the new level if they have sufficient collateral in the settlement asset of the market to meet new commitment amount
   110  
   111      When the parties submit the following liquidity provision:
   112        | id  | party | market id | commitment amount | fee | lp type   | error                                            |
   113        | lp1 | lp1   | BTC/ETH   | 20000             | 0.2 | amendment | commitment submission rejected, not enough stake |
   114      When the parties submit the following liquidity provision:
   115        | id  | party | market id | commitment amount | fee | lp type   |
   116        | lp1 | lp1   | BTC/ETH   | 2000              | 0.2 | amendment |
   117        | lp2 | lp2   | BTC/ETH   | 4000              | 0.4 | amendment |
   118      Then the market data for the market "BTC/ETH" should be:
   119        | mark price | trading mode            | auction trigger             | target stake | supplied stake | open interest |
   120        | 15         | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 4800         | 7000           | 0             |
   121  
   122      Then the party "lp1" lp liquidity bond account balance should be "3000" for the market "BTC/ETH"
   123      Then the party "lp2" lp liquidity bond account balance should be "4000" for the market "BTC/ETH"
   124      And the liquidity fee factor should be "0.1" for the market "BTC/ETH"
   125  
   126      Then the network moves ahead "5" blocks
   127      #supplied stake has been reduced after SLA bond penalty, target stake went up temperarily since lp2 increased commitment and its reflected in bond account immediately
   128      Then the market data for the market "BTC/ETH" should be:
   129        | mark price | trading mode            | auction trigger             | target stake | supplied stake | open interest |
   130        | 15         | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 5600         | 5100           | 0             |
   131      #0044-LIME-107:Lp reduces LP commitment and got slashed during the epoch, and the lower (slashed) LP bond stake will be retained
   132      Then the party "lp1" lp liquidity bond account balance should be "1550" for the market "BTC/ETH"
   133      #0044-LIME-111:at the end of the current epoch rewards / penalties are evaluated based on the balance of the bond account at start of epoch
   134      Then the party "lp2" lp liquidity bond account balance should be "3550" for the market "BTC/ETH"
   135      And the liquidity fee factor should be "0.4" for the market "BTC/ETH"
   136  
   137      Then the market data for the market "BTC/ETH" should be:
   138        | mark price | trading mode            | auction trigger             | target stake | supplied stake | open interest |
   139        | 15         | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 5600         | 5100           | 0             |
   140  
   141      Then the following transfers should happen:
   142        | from | to     | from account      | to account                    | market id | amount | asset |
   143        | lp1  | market | ACCOUNT_TYPE_BOND | ACCOUNT_TYPE_NETWORK_TREASURY | BTC/ETH   | 450    | ETH   |
   144        | lp2  | market | ACCOUNT_TYPE_BOND | ACCOUNT_TYPE_NETWORK_TREASURY | BTC/ETH   | 450    | ETH   |
   145      Then the network moves ahead "1" blocks
   146  
   147      When the parties submit the following liquidity provision:
   148        | id  | party | market id | commitment amount | fee | lp type    |
   149        | lp3 | lp3   | BTC/ETH   | 3000              | 0.1 | submission |
   150      Then the market data for the market "BTC/ETH" should be:
   151        | mark price | trading mode            | auction trigger             | target stake | supplied stake | open interest |
   152        | 15         | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 5600         | 8100           | 0             |
   153      And the parties place the following orders:
   154        | party | market id | side | volume | price | resulting trades | type       | tif     |
   155        | lp3   | BTC/ETH   | buy  | 500    | 7     | 0                | TYPE_LIMIT | TIF_GTC |
   156        | lp3   | BTC/ETH   | sell | 200    | 25    | 0                | TYPE_LIMIT | TIF_GTC |
   157      Then the party "lp3" lp liquidity bond account balance should be "3000" for the market "BTC/ETH"
   158  
   159      Then the network moves ahead "5" blocks
   160      Then the market data for the market "BTC/ETH" should be:
   161        | mark price | trading mode            | auction trigger             | target stake | supplied stake | open interest |
   162        | 15         | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 6480         | 7336           | 0             |
   163  
   164      When the parties submit the following liquidity provision:
   165        | id  | party | market id | commitment amount | fee | lp type   |
   166        | lp3 | lp3   | BTC/ETH   | 2900              | 0.1 | amendment |
   167      Then the market data for the market "BTC/ETH" should be:
   168        | mark price | trading mode            | auction trigger             | target stake | supplied stake | open interest |
   169        | 15         | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 6480         | 7336           | 0             |
   170  
   171      #0044-LIME-112:A liquidity provider who reduces their liquidity provision such that the total stake on the market is still above the target stake
   172      Then the party "lp3" lp liquidity bond account balance should be "3000" for the market "BTC/ETH"
   173  
   174      #0044-LIME-105:A liquidity provider with an active liquidity provision at the start of an epoch reduces their liquidity provision staked commitment during the epoch
   175      Then the network moves ahead "2" blocks
   176      Then the party "lp3" lp liquidity bond account balance should be "3000" for the market "BTC/ETH"
   177      Then the network moves ahead "2" blocks
   178      Then the party "lp3" lp liquidity bond account balance should be "3000" for the market "BTC/ETH"
   179  
   180      Then the network moves ahead "2" blocks
   181      Then the party "lp3" lp liquidity bond account balance should be "2900" for the market "BTC/ETH"
   182      Then "lp3" should have general account balance of "32100" for asset "ETH"
   183      Then "lp3" should have holding account balance of "35000" for asset "ETH"
   184  
   185      When the parties submit the following liquidity provision:
   186        | id  | party | market id | commitment amount | fee | lp type    |
   187        | lp4 | lp4   | BTC/ETH   | 3000              | 0.1 | submission |
   188      And the parties place the following orders:
   189        | party | market id | side | volume | price | resulting trades | type       | tif     |
   190        | lp4   | BTC/ETH   | buy  | 500    | 7     | 0                | TYPE_LIMIT | TIF_GTC |
   191        | lp4   | BTC/ETH   | sell | 200    | 25    | 0                | TYPE_LIMIT | TIF_GTC |
   192      Then the party "lp4" lp liquidity bond account balance should be "3000" for the market "BTC/ETH"
   193  
   194      When the parties submit the following liquidity provision:
   195        | id  | party | market id | commitment amount | fee | lp type   |
   196        | lp4 | lp4   | BTC/ETH   | 2900              | 0.1 | amendment |
   197      Then the network moves ahead "1" blocks
   198      #0044-LIME-106:Lp reduces commitment a few times during the epoch
   199      When the parties submit the following liquidity provision:
   200        | id  | party | market id | commitment amount | fee | lp type   |
   201        | lp4 | lp4   | BTC/ETH   | 2800              | 0.1 | amendment |
   202      Then the network moves ahead "1" blocks
   203      When the parties submit the following liquidity provision:
   204        | id  | party | market id | commitment amount | fee | lp type   |
   205        | lp4 | lp4   | BTC/ETH   | 2700              | 0.1 | amendment |
   206  
   207      Then the network moves ahead "3" blocks
   208      Then the party "lp4" lp liquidity bond account balance should be "2700" for the market "BTC/ETH"