code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/0029-FEES-040.feature (about)

     1  Feature: Fees calculations
     2  
     3    Background:
     4      Given the fees configuration named "fees-config-1":
     5        | maker fee | infrastructure fee |
     6        | 0.5       | 0.6                |
     7      And the price monitoring named "price-monitoring":
     8        | horizon | probability | auction extension |
     9        | 60      | 0.99        | 2                 |
    10      And the simple risk model named "simple-risk-model-1":
    11        | long | short | max move up | min move down | probability of trading |
    12        | 0.2  | 0.1   | 100         | -100          | 0.1                    |
    13  
    14      And the following network parameters are set:
    15        | name                                    | value |
    16        | network.markPriceUpdateMaximumFrequency | 0s    |
    17        | limits.markets.maxPeggedOrders          | 2     |
    18        | market.fee.factors.buybackFee           | 0.001 |
    19        | market.fee.factors.treasuryFee          | 0.002 |
    20  
    21      And the markets:
    22        | id        | quote name | asset | risk model          | margin calculator         | auction duration | fees          | price monitoring | data source config     | linear slippage factor | quadratic slippage factor | sla params      |
    23        | ETH/DEC21 | ETH/USD    | USD   | simple-risk-model-1 | default-margin-calculator | 2                | fees-config-1 | price-monitoring | default-eth-for-future | 0.25                   | 0                         | default-futures |
    24  
    25      And the average block duration is "2"
    26    Scenario: 001: Testing fees get collected when amended order trades (0029-FEES-005)
    27      Given the parties deposit on asset's general account the following amount:
    28        | party   | asset | amount |
    29        | aux1    | USD   | 100000 |
    30        | aux2    | USD   | 100000 |
    31        | aux3    | USD   | 100000 |
    32        | aux4    | USD   | 100000 |
    33        | trader1 | USD   | 9000   |
    34        | trader2 | USD   | 300    |
    35        | trader3 | USD   | 2000   |
    36        | trader4 | USD   | 2000   |
    37        | trader5 | USD   | 5000   |
    38        | trader6 | USD   | 5000   |
    39  
    40      When the parties submit the following liquidity provision:
    41        | id      | party   | market id | commitment amount | fee   | lp type    |
    42        | lp1     | aux1    | ETH/DEC21 | 10000             | 0.002 | submission |
    43        | lp1     | aux1    | ETH/DEC21 | 10000             | 0.002 | submission |
    44        | trader2 | trader2 | ETH/DEC21 | 100               | 0.002 | submission |
    45      When the network moves ahead "2" blocks
    46  
    47      And the parties place the following orders:
    48        | party | market id | side | volume | price | resulting trades | type       | tif     |
    49        | aux1  | ETH/DEC21 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    50        | aux2  | ETH/DEC21 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
    51        | aux3  | ETH/DEC21 | buy  | 1      | 820   | 0                | TYPE_LIMIT | TIF_GTC |
    52        | aux4  | ETH/DEC21 | sell | 1      | 1180  | 0                | TYPE_LIMIT | TIF_GTC |
    53      Then the opening auction period ends for market "ETH/DEC21"
    54      And the market data for the market "ETH/DEC21" should be:
    55        | mark price | trading mode            |
    56        | 1000       | TRADING_MODE_CONTINUOUS |
    57  
    58      And the following trades should be executed:
    59        | buyer | price | size | seller |
    60        | aux1  | 1000  | 1    | aux2   |
    61      Then the parties should have the following account balances:
    62        | party | asset | market id | margin | general | bond |
    63        | aux1  | USD   | ETH/DEC21 | 540    | 89460   |      |
    64  
    65      #0029-FEES-040:In continuous trading mode, if the price taker has insufficient asset to cover the total fee in their general + margin account, then the trade should be discarded, the orders on the book that would have been hit should remain in place with previous remaining size intact and the incoming order should be rejected (not enough fees error).
    66  
    67      When the parties place the following orders:
    68        | party   | market id | side | volume | price | resulting trades | type       | tif     | reference | error                                      |
    69        | trader1 | ETH/DEC21 | buy  | 2      | 1002  | 0                | TYPE_LIMIT | TIF_GTC | t1-b2-01  |                                            |
    70        | trader2 | ETH/DEC21 | sell | 2      | 1002  | 0                | TYPE_LIMIT | TIF_GTC | t2-s4-01  | party has insufficient funds to cover fees |
    71  
    72      Then the parties should have the following account balances:
    73        | party   | asset | market id | margin | general | bond |
    74        | trader1 | USD   | ETH/DEC21 | 480    | 8520    |      |
    75        | trader2 | USD   | ETH/DEC21 | 0      | 240     | 60   |
    76  
    77      And the orders should have the following status:
    78        | party   | reference | status          |
    79        | trader2 | t2-s4-01  | STATUS_REJECTED |
    80  
    81      And the order book should have the following volumes for market "ETH/DEC21":
    82        | side | price | volume |
    83        | buy  | 1002  | 2      |
    84        | sell | 1002  | 0      |
    85  
    86      Then the parties cancel the following orders:
    87        | party   | reference |
    88        | trader1 | t1-b2-01  |
    89  
    90      When the parties place the following orders:
    91        | party   | market id | side | volume | price | resulting trades | type       | tif     | reference |
    92        | trader3 | ETH/DEC21 | buy  | 2      | 1101  | 0                | TYPE_LIMIT | TIF_GTC | t1-b2-03  |
    93        | trader4 | ETH/DEC21 | sell | 2      | 1101  | 0                | TYPE_LIMIT | TIF_GTC | t2-s4-04  |
    94  
    95      And the market data for the market "ETH/DEC21" should be:
    96        | mark price | trading mode                    | horizon | min bound | max bound |
    97        | 1000       | TRADING_MODE_MONITORING_AUCTION | 60      | 900       | 1100      |
    98  
    99      Then the parties cancel the following orders:
   100        | party   | reference |
   101        | trader3 | t1-b2-03  |
   102        | trader4 | t2-s4-04  |
   103  
   104      And the order book should have the following volumes for market "ETH/DEC21":
   105        | side | price | volume |
   106        | buy  | 1002  | 0      |
   107        | buy  | 1101  | 0      |
   108        | sell | 1002  | 0      |
   109        | buy  | 1101  | 0      |
   110  
   111      #0029-FEES-041:In auction mode, if the price taker has insufficient asset to cover the total fee in their general + margin account, then the shortfall should be ignored, the orders should remain (instead of being rejected)
   112      When the parties place the following orders:
   113        | party   | market id | side | volume | price | resulting trades | type       | tif     | reference |
   114        | trader1 | ETH/DEC21 | buy  | 2      | 1002  | 0                | TYPE_LIMIT | TIF_GTC | t1-b2-05  |
   115        | trader2 | ETH/DEC21 | sell | 2      | 1002  | 0                | TYPE_LIMIT | TIF_GTC | t2-s4-06  |
   116  
   117      And the order book should have the following volumes for market "ETH/DEC21":
   118        | side | price | volume |
   119        | buy  | 1002  | 2      |
   120        | buy  | 1101  | 0      |
   121        | sell | 1002  | 2      |
   122        | buy  | 1101  | 0      |
   123  
   124      When the network moves ahead "4" blocks
   125  
   126      And the market data for the market "ETH/DEC21" should be:
   127        | mark price | trading mode            |
   128        | 1002       | TRADING_MODE_CONTINUOUS |
   129  
   130      And the orders should have the following status:
   131        | party   | reference | status        |
   132        | trader2 | t2-s4-06  | STATUS_FILLED |
   133  
   134      #trader2 is closed out, after paying infra fee, trader2 does not have enough left to cover margin
   135      Then the parties should have the following account balances:
   136        | party   | asset | market id | margin | general | bond |
   137        | trader1 | USD   | ETH/DEC21 | 1082   | 7308    |      |
   138        | trader2 | USD   | ETH/DEC21 | 0      | 0       | 0    |
   139  
   140