code.vegaprotocol.io/vega@v0.79.0/core/integration/features/spot/accounts_and_fees/0070-MKTD-011.feature (about)

     1  Feature: Spot market SLA
     2  
     3    Scenario: 001 0070-MKTD-010
     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  
    13      And the price monitoring named "price-monitoring-1":
    14        | horizon | probability | auction extension |
    15        | 3600    | 0.999       | 300               |
    16  
    17      And the liquidity sla params named "SLA-1":
    18        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
    19        | 1           | 0.6                          | 2                             | 0.2                    |
    20  
    21      Given the following assets are registered:
    22        | id  | decimal places |
    23        | ETH | 2              |
    24        | BTC | 2              |
    25  
    26      And the following network parameters are set:
    27        | name                                                | value |
    28        | network.markPriceUpdateMaximumFrequency             | 2s    |
    29        | market.liquidity.earlyExitPenalty                   | 0.25  |
    30        | market.liquidity.bondPenaltyParameter               | 0.2   |
    31        | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0     |
    32        | market.liquidity.sla.nonPerformanceBondPenaltyMax   | 0     |
    33        | market.liquidity.maximumLiquidityFeeFactorLevel     | 0.4   |
    34        | validators.epoch.length                             | 2s    |
    35        | limits.markets.maxPeggedOrders                      | 10    |
    36  
    37      And the spot markets:
    38        | id          | name      | base asset | quote asset | risk model             | auction duration | fees          | price monitoring   | decimal places | position decimal places | sla params |
    39        | BTC/ETH_D11 | BTC/ETH11 | BTC        | ETH         | lognormal-risk-model-1 | 1                | fees-config-1 | price-monitoring-1 | 1              | 1                       | SLA-1      |
    40        | BTC/ETH_D10 | BTC/ETH11 | BTC        | ETH         | lognormal-risk-model-1 | 1                | fees-config-1 | price-monitoring-1 | 1              | 0                       | SLA-1      |
    41        | BTC/ETH_D21 | BTC/ETH11 | BTC        | ETH         | lognormal-risk-model-1 | 1                | fees-config-1 | price-monitoring-1 | 2              | 1                       | SLA-1      |
    42  
    43      And the following network parameters are set:
    44        | name                                             | value |
    45        | market.liquidity.providersFeeCalculationTimeStep | 1s    |
    46        | market.liquidity.stakeToCcyVolume                | 1     |
    47  
    48      Given the parties deposit on asset's general account the following amount:
    49        | party  | asset | amount |
    50        | party1 | ETH   | 300000 |
    51        | party2 | BTC   | 15000  |
    52        | lp1    | ETH   | 120000 |
    53        | lp1    | BTC   | 1800   |
    54        | lp2    | ETH   | 120000 |
    55        | lp2    | BTC   | 1800   |
    56  
    57      And the average block duration is "1"
    58  
    59      Given the liquidity monitoring parameters:
    60        | name               | triggering ratio | time window | scaling factor |
    61        | updated-lqm-params | 0.2              | 20s         | 0.8            |
    62  
    63      When the spot markets are updated:
    64        | id          | liquidity monitoring | linear slippage factor | quadratic slippage factor |
    65        | BTC/ETH_D11 | updated-lqm-params   | 0.5                    | 0.5                       |
    66        | BTC/ETH_D10 | updated-lqm-params   | 0.5                    | 0.5                       |
    67        | BTC/ETH_D21 | updated-lqm-params   | 0.5                    | 0.5                       |
    68  
    69      When the parties submit the following liquidity provision:
    70        | id  | party | market id   | commitment amount | fee | lp type    |
    71        | lp1 | lp1   | BTC/ETH_D11 | 3000              | 0.1 | submission |
    72        | lp2 | lp2   | BTC/ETH_D11 | 3000              | 0.1 | submission |
    73        | lp3 | lp1   | BTC/ETH_D10 | 3000              | 0.1 | submission |
    74        | lp4 | lp2   | BTC/ETH_D10 | 3000              | 0.1 | submission |
    75        | lp5 | lp1   | BTC/ETH_D21 | 3000              | 0.1 | submission |
    76        | lp6 | lp2   | BTC/ETH_D21 | 3000              | 0.1 | submission |
    77  
    78      Then the network moves ahead "1" blocks
    79  
    80      Then the market data for the market "BTC/ETH_D11" should be:
    81        | mark price | trading mode                 | auction trigger         | target stake | supplied stake | open interest |
    82        | 0          | TRADING_MODE_OPENING_AUCTION | AUCTION_TRIGGER_OPENING | 4800         | 6000           | 0             |
    83      Then the market data for the market "BTC/ETH_D10" should be:
    84        | mark price | trading mode                 | auction trigger         | target stake | supplied stake | open interest |
    85        | 0          | TRADING_MODE_OPENING_AUCTION | AUCTION_TRIGGER_OPENING | 4800         | 6000           | 0             |
    86      Then the market data for the market "BTC/ETH_D21" should be:
    87        | mark price | trading mode                 | auction trigger         | target stake | supplied stake | open interest |
    88        | 0          | TRADING_MODE_OPENING_AUCTION | AUCTION_TRIGGER_OPENING | 4800         | 6000           | 0             |
    89  
    90      #0070-MKTD-010:As a user all orders placed (either directly or through LP) are shown in events with prices in market precision
    91      And the parties place the following orders:
    92        | party  | market id   | side | volume | price | resulting trades | type       | tif     | reference    | only |
    93        | party1 | BTC/ETH_D11 | buy  | 60     | 80    | 0                | TYPE_LIMIT | TIF_GTC | party-order5 |      |
    94        | party1 | BTC/ETH_D11 | buy  | 10     | 150   | 0                | TYPE_LIMIT | TIF_GTC | party-order3 |      |
    95        | party2 | BTC/ETH_D11 | sell | 10     | 150   | 0                | TYPE_LIMIT | TIF_GTC | party-order4 |      |
    96        | party2 | BTC/ETH_D11 | sell | 60     | 240   | 0                | TYPE_LIMIT | TIF_GTC | party-order6 |      |
    97        | party1 | BTC/ETH_D10 | buy  | 6      | 80    | 0                | TYPE_LIMIT | TIF_GTC | party-order5 |      |
    98        | party1 | BTC/ETH_D10 | buy  | 1      | 150   | 0                | TYPE_LIMIT | TIF_GTC | party-order3 |      |
    99        | party2 | BTC/ETH_D10 | sell | 1      | 150   | 0                | TYPE_LIMIT | TIF_GTC | party-order4 |      |
   100        | party2 | BTC/ETH_D10 | sell | 6      | 240   | 0                | TYPE_LIMIT | TIF_GTC | party-order6 |      |
   101        | party1 | BTC/ETH_D21 | buy  | 60     | 800   | 0                | TYPE_LIMIT | TIF_GTC | party-order5 |      |
   102        | party1 | BTC/ETH_D21 | buy  | 10     | 1500  | 0                | TYPE_LIMIT | TIF_GTC | party-order3 |      |
   103        | party2 | BTC/ETH_D21 | sell | 10     | 1500  | 0                | TYPE_LIMIT | TIF_GTC | party-order4 |      |
   104        | party2 | BTC/ETH_D21 | sell | 60     | 2400  | 0                | TYPE_LIMIT | TIF_GTC | party-order6 |      |
   105  
   106      When the network moves ahead "2" blocks
   107      #0070-MKTD-015:Trades prices, like orders, are shown in market precision. The transfers and margin requirements are in asset precision.
   108      Then the following trades should be executed:
   109        | buyer  | price | size | seller |
   110        | party1 | 150   | 10   | party2 |
   111        | party1 | 150   | 1    | party2 |
   112        | party1 | 1500  | 10   | party2 |
   113  
   114      #0070-MKTD-014:offsets specified in pegged orders represent the smallest incremental value to tick away from the pegged price of a pegged order according to the market precision
   115      When the parties place the following pegged orders:
   116        | party  | market id   | side | volume | pegged reference | offset | reference   | error |
   117        | party1 | BTC/ETH_D11 | buy  | 1      | BID              | 1      | peggedbuy1  |       |
   118        | party2 | BTC/ETH_D11 | sell | 1      | ASK              | 1      | peggedsell1 |       |
   119        | party1 | BTC/ETH_D10 | buy  | 1      | BID              | 1      | peggedbuy2  |       |
   120        | party2 | BTC/ETH_D10 | sell | 1      | ASK              | 1      | peggedsell2 |       |
   121        | party1 | BTC/ETH_D21 | buy  | 1      | BID              | 1      | peggedbuy3  |       |
   122        | party2 | BTC/ETH_D21 | sell | 1      | ASK              | 1      | peggedsell3 |       |
   123  
   124      And the order book should have the following volumes for market "BTC/ETH_D11":
   125        | side | price | volume |
   126        | buy  | 79    | 1      |
   127        | sell | 241   | 1      |
   128      And the order book should have the following volumes for market "BTC/ETH_D10":
   129        | side | price | volume |
   130        | buy  | 79    | 1      |
   131        | sell | 241   | 1      |
   132      And the order book should have the following volumes for market "BTC/ETH_D21":
   133        | side | price | volume |
   134        | buy  | 799   | 1      |
   135        | sell | 2401  | 1      |
   136  
   137      Then the market data for the market "BTC/ETH_D11" should be:
   138        | mark price | trading mode            | auction trigger             | horizon | min bound | max bound | target stake | supplied stake | open interest |
   139        | 150        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 3600    | 144       | 156       | 4800         | 6000           | 0             |
   140      Then the market data for the market "BTC/ETH_D10" should be:
   141        | mark price | trading mode            | auction trigger             | horizon | min bound | max bound | target stake | supplied stake | open interest |
   142        | 150        | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 3600    | 144       | 156       | 4800         | 6000           | 0             |
   143      #0070-MKTD-012: As a user I should see the market data prices using market precision.
   144      #0070-MKTD-013: Price bounds are calculated in asset precision, but enforced rounded to the closest value in market precision in range
   145      Then the market data for the market "BTC/ETH_D21" should be:
   146        | mark price | trading mode            | auction trigger             | horizon | min bound | max bound | target stake | supplied stake | open interest |
   147        | 1500       | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 3600    | 1438      | 1564      | 4800         | 6000           | 0             |
   148      Then "lp1" should have general account balance of "111000" for asset "ETH"
   149      Then "lp2" should have general account balance of "111000" for asset "ETH"
   150  
   151      When the parties submit the following liquidity provision:
   152        | id  | party | market id   | commitment amount | fee | lp type   |
   153        | lp1 | lp1   | BTC/ETH_D11 | 2000              | 0.1 | amendment |
   154        | lp4 | lp1   | BTC/ETH_D10 | 2000              | 0.1 | amendment |
   155        | lp5 | lp1   | BTC/ETH_D21 | 2000              | 0.1 | amendment |
   156  
   157      Then the network moves ahead "4" blocks
   158      When the parties submit the following liquidity provision:
   159        | id  | party | market id   | commitment amount | fee | lp type   |
   160        | lp2 | lp2   | BTC/ETH_D11 | 2000              | 0.1 | amendment |
   161  
   162      Then the network moves ahead "4" blocks
   163  
   164      #bond penalty for lp2 = 800*0.25 =200
   165      #0070-MKTD-011:As a user all transfers (margin top-up, release, MTM settlement) are calculated and communicated (via events) in asset precision
   166      And the network treasury balance should be "200" for the asset "ETH"
   167      Then the party "lp1" lp liquidity bond account balance should be "2000" for the market "BTC/ETH_D11"
   168      Then the party "lp1" lp liquidity bond account balance should be "2000" for the market "BTC/ETH_D10"
   169      Then the party "lp1" lp liquidity bond account balance should be "2000" for the market "BTC/ETH_D21"
   170      Then the party "lp2" lp liquidity bond account balance should be "2000" for the market "BTC/ETH_D11"
   171      Then the party "lp2" lp liquidity bond account balance should be "3000" for the market "BTC/ETH_D10"
   172      Then the party "lp2" lp liquidity bond account balance should be "3000" for the market "BTC/ETH_D21"
   173  
   174      Then "lp1" should have general account balance of "114000" for asset "ETH"
   175      Then "lp2" should have general account balance of "111800" for asset "ETH"
   176  
   177  
   178