code.vegaprotocol.io/vega@v0.79.0/core/integration/features/spot/accounts_and_fees/0029-FEES-015.feature (about)

     1  Feature: Spot market fees distribution
     2  
     3    Scenario: 0029-FEES-015: Fees are collected during continuous trading and auction modes and distributed to the appropriate accounts, as described above.
     4  
     5    Background:
     6  
     7      Given the following network parameters are set:
     8        | name                                            | value |
     9        | network.markPriceUpdateMaximumFrequency         | 1s    |
    10        | market.value.windowLength                       | 1h    |
    11        | market.liquidity.maximumLiquidityFeeFactorLevel | 0.4   |
    12        | validators.epoch.length                         | 4s    |
    13  
    14      Given the following assets are registered:
    15        | id  | decimal places |
    16        | ETH | 2              |
    17        | BTC | 2              |
    18  
    19      Given the fees configuration named "fees-config-1":
    20        | maker fee | infrastructure fee |
    21        | 0.01      | 0.03               |
    22      Given the log normal risk model named "lognormal-risk-model-1":
    23        | risk aversion | tau  | mu | r   | sigma |
    24        | 0.001         | 0.01 | 0  | 0.0 | 1.2   |
    25      And the price monitoring named "price-monitoring-1":
    26        | horizon | probability | auction extension |
    27        | 36000   | 0.999       | 1                 |
    28        | 38000   | 0.999       | 2                 |
    29  
    30      And the spot markets:
    31        | id      | name    | base asset | quote asset | risk model             | auction duration | fees          | price monitoring   | decimal places | position decimal places | sla params    |
    32        | BTC/ETH | BTC/ETH | BTC        | ETH         | lognormal-risk-model-1 | 1                | fees-config-1 | price-monitoring-1 | 2              | 2                       | default-basic |
    33  
    34      And the following network parameters are set:
    35        | name                                             | value |
    36        | limits.markets.maxPeggedOrders                   | 2     |
    37        | network.markPriceUpdateMaximumFrequency          | 0s    |
    38        | market.liquidity.providersFeeCalculationTimeStep | 1s    |
    39        | validators.epoch.length                          | 58s   |
    40        | market.liquidity.stakeToCcyVolume                | 1     |
    41  
    42      Given the parties deposit on asset's general account the following amount:
    43        | party  | asset | amount |
    44        | party1 | ETH   | 100000 |
    45        | party1 | BTC   | 10000  |
    46        | party2 | ETH   | 100000 |
    47        | party2 | BTC   | 10000  |
    48        | lp     | ETH   | 100000 |
    49        | lp     | BTC   | 10000  |
    50      And the average block duration is "1"
    51  
    52      # No orders have been places so we shouldn't have any holding accounts
    53      And "party1" should have only the following accounts:
    54        | type                 | asset | amount |
    55        | ACCOUNT_TYPE_GENERAL | ETH   | 100000 |
    56        | ACCOUNT_TYPE_GENERAL | BTC   | 10000  |
    57  
    58      And "party2" should have only the following accounts:
    59        | type                 | asset | amount |
    60        | ACCOUNT_TYPE_GENERAL | ETH   | 100000 |
    61        | ACCOUNT_TYPE_GENERAL | BTC   | 10000  |
    62  
    63      Given the parties submit the following liquidity provision:
    64        | id  | party | market id | commitment amount | fee   | lp type    |
    65        | lp1 | lp    | BTC/ETH   | 500               | 0.025 | submission |
    66      # Place some orders to create the holding accounts
    67      And the parties place the following orders:
    68        | party  | market id | side | volume | price | resulting trades | type       | tif     |
    69        | party1 | BTC/ETH   | buy  | 100    | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    70        | party1 | BTC/ETH   | buy  | 100    | 2000  | 0                | TYPE_LIMIT | TIF_GTC |
    71        | party2 | BTC/ETH   | sell | 100    | 2000  | 0                | TYPE_LIMIT | TIF_GTC |
    72        | party2 | BTC/ETH   | sell | 100    | 3000  | 0                | TYPE_LIMIT | TIF_GTC |
    73  
    74      Then the network moves ahead "2" blocks
    75  
    76      Then the market data for the market "BTC/ETH" should be:
    77        | mark price | trading mode            | auction trigger             | horizon | min bound | max bound | open interest |
    78        | 2000       | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 36000   | 1749      | 2283      | 0             |
    79        | 2000       | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 38000   | 1743      | 2291      | 0             |
    80  
    81      And the parties place the following orders:
    82        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference   |
    83        | party1 | BTC/ETH   | buy  | 100    | 2000  | 0                | TYPE_LIMIT | TIF_GTC |             |
    84        | party2 | BTC/ETH   | sell | 100    | 2000  | 1                | TYPE_LIMIT | TIF_GTC |             |
    85        | party1 | BTC/ETH   | buy  | 100    | 1800  | 0                | TYPE_LIMIT | TIF_GTC |             |
    86        | party2 | BTC/ETH   | sell | 100    | 2200  | 0                | TYPE_LIMIT | TIF_GTC | sell-party2 |
    87  
    88      Then the network moves ahead "1" blocks
    89      #lp fee: 2000*100*0.025=50
    90      And the following transfers should happen:
    91        | from   | to     | from account                | to account                       | market id | amount | asset |
    92        | party2 | market | ACCOUNT_TYPE_GENERAL        | ACCOUNT_TYPE_FEES_MAKER          | BTC/ETH   | 20     | ETH   |
    93        | party2 | market | ACCOUNT_TYPE_GENERAL        | ACCOUNT_TYPE_FEES_INFRASTRUCTURE | BTC/ETH   | 60     | ETH   |
    94        | party2 | market | ACCOUNT_TYPE_GENERAL        | ACCOUNT_TYPE_FEES_LIQUIDITY      | BTC/ETH   | 50     | ETH   |
    95        | market | party1 | ACCOUNT_TYPE_FEES_MAKER     | ACCOUNT_TYPE_GENERAL             | BTC/ETH   | 20     | ETH   |
    96        | market | lp     | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES   | BTC/ETH   | 50     | ETH   |
    97  
    98      #0029-FEES-016:Fees are collected in one case of amends: you amend the price so far that it causes an immediate trade.
    99      And the parties amend the following orders:
   100        | party  | reference   | price | size delta | tif     |
   101        | party2 | sell-party2 | 1800  | 0          | TIF_GTC |
   102  
   103      Then the market data for the market "BTC/ETH" should be:
   104        | mark price | last traded price | trading mode            |
   105        | 2000       | 1800              | TRADING_MODE_CONTINUOUS |
   106      And the following trades should be executed:
   107        | buyer  | price | size | seller |
   108        | party1 | 1800  | 100  | party2 |
   109  
   110      Then the network moves ahead "2" blocks
   111      And the following transfers should happen:
   112        | from   | to     | from account                | to account                       | market id | amount | asset |
   113        | party2 | market | ACCOUNT_TYPE_GENERAL        | ACCOUNT_TYPE_FEES_MAKER          | BTC/ETH   | 18     | ETH   |
   114        | party2 | market | ACCOUNT_TYPE_GENERAL        | ACCOUNT_TYPE_FEES_INFRASTRUCTURE | BTC/ETH   | 54     | ETH   |
   115        | party2 | market | ACCOUNT_TYPE_GENERAL        | ACCOUNT_TYPE_FEES_LIQUIDITY      | BTC/ETH   | 45     | ETH   |
   116        | market | party1 | ACCOUNT_TYPE_FEES_MAKER     | ACCOUNT_TYPE_GENERAL             | BTC/ETH   | 18     | ETH   |
   117        | market | lp     | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES   | BTC/ETH   | 45     | ETH   |
   118  
   119      And the parties place the following orders:
   120        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   121        | party1 | BTC/ETH   | buy  | 100    | 1745  | 0                | TYPE_LIMIT | TIF_GTC |           |
   122        | party2 | BTC/ETH   | sell | 100    | 1745  | 0                | TYPE_LIMIT | TIF_GTC |           |
   123  
   124      Then the market data for the market "BTC/ETH" should be:
   125        | mark price | trading mode                    | auction trigger       |
   126        | 1800       | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE |
   127      Then the network moves ahead "2" blocks
   128  
   129      Then the market data for the market "BTC/ETH" should be:
   130        | mark price | trading mode            | auction trigger             |
   131        | 1745       | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED |
   132  
   133      #The LP fees and infrastructure fees are split between the two parties for the trade during monitoring auction
   134      #lp fee: 1745*1*0.025 = 44
   135      And the following transfers should happen:
   136        | from   | to     | from account                | to account                       | market id | amount | asset |
   137        | party1 | market | ACCOUNT_TYPE_GENERAL        | ACCOUNT_TYPE_FEES_INFRASTRUCTURE | BTC/ETH   | 27     | ETH   |
   138        | party2 | market | ACCOUNT_TYPE_GENERAL        | ACCOUNT_TYPE_FEES_INFRASTRUCTURE | BTC/ETH   | 27     | ETH   |
   139        | party1 | market | ACCOUNT_TYPE_GENERAL        | ACCOUNT_TYPE_FEES_LIQUIDITY      | BTC/ETH   | 22     | ETH   |
   140        | party2 | market | ACCOUNT_TYPE_GENERAL        | ACCOUNT_TYPE_FEES_LIQUIDITY      | BTC/ETH   | 22     | ETH   |
   141        | market | lp     | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES   | BTC/ETH   | 44     | ETH   |
   142  
   143      And the parties place the following orders:
   144        | party  | market id | side | volume | price | resulting trades | type        | tif     | reference |
   145        | party1 | BTC/ETH   | buy  | 100    | 1780  | 0                | TYPE_LIMIT  | TIF_GTC |           |
   146        | party1 | BTC/ETH   | buy  | 23     | 1780  | 0                | TYPE_LIMIT  | TIF_GTC |           |
   147        | party2 | BTC/ETH   | sell | 123    | 1780  | 2                | TYPE_MARKET | TIF_IOC |           |
   148  
   149      And the following trades should be executed:
   150        | buyer  | price | size | seller |
   151        | party1 | 1780  | 100  | party2 |
   152        | party1 | 1780  | 23   | party2 |
   153  
   154      Then the network moves ahead "2" blocks
   155  
   156      Then the market data for the market "BTC/ETH" should be:
   157        | mark price | trading mode            | auction trigger             |
   158        | 1780       | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED |
   159  
   160      #0029-FEES-021: market order fee distribution in spot market
   161      #liquidity fee: 1780*0.23*0.025=11; 1780*1*0.025=45
   162      And the following transfers should happen:
   163        | from   | to     | from account                | to account                       | market id | amount | asset |
   164        | party2 | market | ACCOUNT_TYPE_GENERAL        | ACCOUNT_TYPE_FEES_MAKER          | BTC/ETH   | 5      | ETH   |
   165        | party2 | market | ACCOUNT_TYPE_GENERAL        | ACCOUNT_TYPE_FEES_INFRASTRUCTURE | BTC/ETH   | 13     | ETH   |
   166        | party2 | market | ACCOUNT_TYPE_GENERAL        | ACCOUNT_TYPE_FEES_LIQUIDITY      | BTC/ETH   | 11     | ETH   |
   167        | party2 | market | ACCOUNT_TYPE_GENERAL        | ACCOUNT_TYPE_FEES_LIQUIDITY      | BTC/ETH   | 45     | ETH   |
   168        | market | party1 | ACCOUNT_TYPE_FEES_MAKER     | ACCOUNT_TYPE_GENERAL             | BTC/ETH   | 5      | ETH   |
   169        | market | lp     | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES   | BTC/ETH   | 56     | ETH   |
   170  
   171  
   172  
   173