code.vegaprotocol.io/vega@v0.79.0/core/integration/features/rewards/asset_fees_rewards.feature (about)

     1  Feature: Fees reward calculations for a single asset, single market
     2  
     3    Background:
     4      Given the following network parameters are set:
     5        | name                                              | value  |
     6        | reward.asset                                      | VEGA   |
     7        | validators.epoch.length                           | 10s    |
     8        | validators.delegation.minAmount                   | 10     |
     9        | reward.staking.delegation.delegatorShare          | 0.883  |
    10        | reward.staking.delegation.minimumValidatorStake   | 100    |
    11        | reward.staking.delegation.maxPayoutPerParticipant | 100000 |
    12        | reward.staking.delegation.competitionLevel        | 1.1    |
    13        | reward.staking.delegation.minValidators           | 5      |
    14        | reward.staking.delegation.optimalStakeMultiplier  | 5.0    |
    15        | network.markPriceUpdateMaximumFrequency           | 0s     |
    16        | limits.markets.maxPeggedOrders                    | 2      |
    17  
    18      Given time is updated to "2021-08-26T00:00:00Z"
    19      Given the average block duration is "2"
    20  
    21      #complete the epoch to advance to a meaningful epoch (can't setup transfer to start at epoch 0)
    22      Then the network moves ahead "7" blocks
    23  
    24    Scenario: Testing fees in continuous trading with one trade and no liquidity providers - testing maker fee received
    25      Given the fees configuration named "fees-config-1":
    26        | maker fee | infrastructure fee |
    27        | 0.005     | 0.002              |
    28      And the price monitoring named "price-monitoring":
    29        | horizon | probability | auction extension |
    30        | 3600 | 0.99 | 3 |
    31  
    32      And the simple risk model named "simple-risk-model-1":
    33        | long | short | max move up | min move down | probability of trading |
    34        | 0.2  | 0.1   | 100         | -100          | 0.1                    |
    35  
    36      And the markets:
    37        | id        | quote name | asset | risk model          | margin calculator         | auction duration | fees          | price monitoring | data source config     | linear slippage factor | quadratic slippage factor | sla params      |
    38        | ETH/DEC21 | ETH        | ETH   | simple-risk-model-1 | default-margin-calculator | 2                | fees-config-1 | price-monitoring | default-eth-for-future | 0.25                   | 0                         | default-futures |
    39  
    40      Given the parties deposit on asset's general account the following amount:
    41        | party                                                            | asset | amount  |
    42        | a3c024b4e23230c89884a54a813b1ecb4cb0f827a38641c66eeca466da6b2ddf | VEGA  | 1000000 |
    43  
    44      # setup recurring transfer to the maker fee reward account - this will start at the end of this epoch (1)
    45      Given the parties submit the following recurring transfers:
    46        | id | from                                                             | from_account_type    | to                                                               | to_account_type                         | asset | amount | start_epoch | end_epoch | factor | metric                              | metric_asset | markets |
    47        | 1  | a3c024b4e23230c89884a54a813b1ecb4cb0f827a38641c66eeca466da6b2ddf | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES | VEGA  | 10000  | 1           |           | 1      | DISPATCH_METRIC_MAKER_FEES_RECEIVED | ETH          |         |
    48  
    49      # setup accounts
    50      Given the parties deposit on asset's general account the following amount:
    51        | party   | asset | amount    |
    52        | aux1    | ETH   | 100000000 |
    53        | aux2    | ETH   | 100000000 |
    54        | trader3 | ETH   | 10000     |
    55        | trader4 | ETH   | 10000     |
    56        | lpprov  | ETH   | 100000000 |
    57  
    58      When the parties submit the following liquidity provision:
    59        | id  | party  | market id | commitment amount | fee | lp type    |
    60        | lp1 | lpprov | ETH/DEC21 | 90000             | 0.1 | submission |
    61        | lp1 | lpprov | ETH/DEC21 | 90000             | 0.1 | submission |
    62  
    63      And the parties place the following pegged iceberg orders:
    64        | party  | market id | peak size | minimum visible size | side | pegged reference | volume | offset |
    65        | lpprov | ETH/DEC21 | 90        | 1                    | buy  | BID              | 90     | 10     |
    66        | lpprov | ETH/DEC21 | 90        | 1                    | sell | ASK              | 90     | 10     |
    67  
    68      Then the parties place the following orders:
    69        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
    70        | aux1  | ETH/DEC21 | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC |           |
    71        | aux2  | ETH/DEC21 | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC |           |
    72        | aux1  | ETH/DEC21 | buy  | 1      | 900   | 0                | TYPE_LIMIT | TIF_GTC | buy1      |
    73        | aux2  | ETH/DEC21 | sell | 1      | 1100  | 0                | TYPE_LIMIT | TIF_GTC | sell1     |
    74  
    75      Then the opening auction period ends for market "ETH/DEC21"
    76      And the market data for the market "ETH/DEC21" should be:
    77        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
    78        | 1000       | TRADING_MODE_CONTINUOUS | 3600    | 900       | 1100      | 20000        | 90000          | 10            |
    79  
    80      When the parties place the following orders with ticks:
    81        | party   | market id | side | volume | price | resulting trades | type       | tif     |
    82        | trader3 | ETH/DEC21 | buy  | 3      | 1002  | 0                | TYPE_LIMIT | TIF_GTC |
    83  
    84      Then the parties should have the following account balances:
    85        | party   | asset | market id | margin | general |
    86        | trader3 | ETH | ETH/DEC21 | 720 | 9280 |
    87  
    88      And the accumulated infrastructure fees should be "0" for the asset "ETH"
    89      And the accumulated liquidity fees should be "0" for the market "ETH/DEC21"
    90      And the market data for the market "ETH/DEC21" should be:
    91        | mark price | trading mode            |
    92        | 1000       | TRADING_MODE_CONTINUOUS |
    93  
    94      Then the parties place the following orders with ticks:
    95        | party   | market id | side | volume | price | resulting trades | type       | tif     |
    96        | trader4 | ETH/DEC21 | sell | 4      | 1002  | 1                | TYPE_LIMIT | TIF_GTC |
    97  
    98      And the market data for the market "ETH/DEC21" should be:
    99        | mark price | trading mode            |
   100        | 1002       | TRADING_MODE_CONTINUOUS |
   101  
   102      Then the following trades should be executed:
   103        | buyer   | price | size | seller  | aggressor side |
   104        | trader3 | 1002  | 3    | trader4 | sell           |
   105  
   106  # trade_value_for_fee_purposes = size_of_trade 0000000000000000000000000000000000000000000000000000000000000000 price_of_trade = 3 00000000000000000000000000000000000000000000000000000000000000001002 = 3006
   107  # infrastructure_fee = fee_factor[infrastructure] 0000000000000000000000000000000000000000000000000000000000000000 trade_value_for_fee_purposes = 0.002 0000000000000000000000000000000000000000000000000000000000000000 3006 = 6.012 = 7 (rounded up to nearest whole value)
   108  # maker_fee =  fee_factor[maker]  0000000000000000000000000000000000000000000000000000000000000000 trade_value_for_fee_purposes = 0.005 0000000000000000000000000000000000000000000000000000000000000000 3006 = 15.030 = 16 (rounded up to nearest whole value)
   109  # liquidity_fee = fee_factor[liquidity] 0000000000000000000000000000000000000000000000000000000000000000 trade_value_for_fee_purposes = 0 0000000000000000000000000000000000000000000000000000000000000000 3006 = 0
   110  
   111      And the following transfers should happen:
   112        | from    | to      | from account            | to account                       | market id | amount | asset |
   113        | trader4 | market  | ACCOUNT_TYPE_GENERAL    | ACCOUNT_TYPE_FEES_MAKER          | ETH/DEC21 | 16     | ETH   |
   114        | trader4 |         | ACCOUNT_TYPE_GENERAL    | ACCOUNT_TYPE_FEES_INFRASTRUCTURE |           | 7      | ETH   |
   115        | trader4 | market  | ACCOUNT_TYPE_GENERAL    | ACCOUNT_TYPE_FEES_LIQUIDITY      | ETH/DEC21 | 301    | ETH   |
   116        | market  | trader3 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL             | ETH/DEC21 | 16     | ETH   |
   117  
   118  # total_fee = infrastructure_fee + maker_fee + liquidity_fee = 7 + 16 + 0 = 23
   119  
   120      And the accumulated infrastructure fees should be "7" for the asset "ETH"
   121      And the accumulated liquidity fees should be "301" for the market "ETH/DEC21"
   122  
   123      #complete the epoch for rewards to take place
   124      Then the network moves ahead "7" blocks
   125      # only trader3 received the maker fees so only they get the reward of 10k
   126      Then "trader3" should have vesting account balance of "10000" for asset "VEGA"
   127  
   128      #complete the epoch for rewards to take place
   129      Then the network moves ahead "7" blocks
   130      Then "trader3" should have vesting account balance of "10000" for asset "VEGA"
   131  
   132    Scenario: Testing fees in continuous trading with two trades and no liquidity providers - testing maker fee received and maker fee paid
   133  
   134      Given the fees configuration named "fees-config-1":
   135        | maker fee | infrastructure fee |
   136        | 0.005     | 0.002              |
   137      And the price monitoring named "price-monitoring":
   138        | horizon | probability | auction extension |
   139        | 1       | 0.99        | 3                 |
   140  
   141      When the simple risk model named "simple-risk-model-1":
   142        | long | short | max move up | min move down | probability of trading |
   143        | 0.2  | 0.1   | 100         | -100          | 0.1                    |
   144  
   145      And the markets:
   146        | id        | quote name | asset | risk model          | margin calculator         | auction duration | fees          | price monitoring | data source config     | linear slippage factor | quadratic slippage factor | sla params      |
   147        | ETH/DEC21 | ETH        | ETH   | simple-risk-model-1 | default-margin-calculator | 2                | fees-config-1 | price-monitoring | default-eth-for-future | 0.25                   | 0                         | default-futures |
   148  
   149      Given the parties deposit on asset's general account the following amount:
   150        | party                                                            | asset | amount   |
   151        | a3c024b4e23230c89884a54a813b1ecb4cb0f827a38641c66eeca466da6b2ddf | VEGA  | 10000000 |
   152  
   153      # setup recurring transfer to the maker fee reward account - this will start at the end of this epoch (1)
   154      Given the parties submit the following recurring transfers:
   155        | id | from                                                             | from_account_type    | to                                                               | to_account_type                         | asset | amount | start_epoch | end_epoch | factor | metric                              | metric_asset | markets   |
   156        | 1  | a3c024b4e23230c89884a54a813b1ecb4cb0f827a38641c66eeca466da6b2ddf | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES | VEGA  | 10000  | 1           |           | 1      | DISPATCH_METRIC_MAKER_FEES_RECEIVED | ETH          |           |
   157        | 2  | a3c024b4e23230c89884a54a813b1ecb4cb0f827a38641c66eeca466da6b2ddf | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES     | VEGA  | 1234   | 1           |           | 2      | DISPATCH_METRIC_MAKER_FEES_PAID     | ETH          | ETH/DEC21 |
   158  
   159      # setup accounts
   160      Given the parties deposit on asset's general account the following amount:
   161        | party    | asset | amount    |
   162        | aux1     | ETH   | 100000000 |
   163        | aux2     | ETH   | 100000000 |
   164        | trader3a | ETH   | 10000     |
   165        | trader3b | ETH   | 10000     |
   166        | trader4  | ETH   | 10000     |
   167        | lpprov   | ETH   | 100000000 |
   168  
   169      When the parties submit the following liquidity provision:
   170        | id  | party  | market id | commitment amount | fee | lp type    |
   171        | lp1 | lpprov | ETH/DEC21 | 90000             | 0.1 | submission |
   172        | lp1 | lpprov | ETH/DEC21 | 90000             | 0.1 | submission |
   173  
   174      And the parties place the following pegged iceberg orders:
   175        | party  | market id | peak size | minimum visible size | side | pegged reference | volume | offset |
   176        | lpprov | ETH/DEC21 | 90        | 1                    | buy  | BID              | 90     | 10     |
   177        | lpprov | ETH/DEC21 | 90        | 1                    | sell | ASK              | 90     | 10     |
   178  
   179      Then the parties place the following orders:
   180        | party | market id | side | volume | price | resulting trades | type       | tif     |
   181        | aux1  | ETH/DEC21 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   182        | aux2  | ETH/DEC21 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   183        | aux1  | ETH/DEC21 | buy  | 1      | 900   | 0                | TYPE_LIMIT | TIF_GTC |
   184        | aux2  | ETH/DEC21 | sell | 1      | 1100  | 0                | TYPE_LIMIT | TIF_GTC |
   185  
   186      Then the opening auction period ends for market "ETH/DEC21"
   187      And the market data for the market "ETH/DEC21" should be:
   188        | mark price | trading mode            |
   189        | 1000       | TRADING_MODE_CONTINUOUS |
   190      When the parties place the following orders with ticks:
   191        | party    | market id | side | volume | price | resulting trades | type       | tif     |
   192        | trader3a | ETH/DEC21 | buy  | 2      | 1002  | 0                | TYPE_LIMIT | TIF_GTC |
   193        | trader3b | ETH/DEC21 | buy  | 1      | 1002  | 0                | TYPE_LIMIT | TIF_GTC |
   194  
   195      Then the parties should have the following account balances:
   196        | party    | asset | market id | margin | general |
   197        | trader3a | ETH   | ETH/DEC21 | 480    | 9520    |
   198        | trader3b | ETH   | ETH/DEC21 | 240    | 9760    |
   199  
   200      And the accumulated liquidity fees should be "0" for the market "ETH/DEC21"
   201      And the accumulated infrastructure fees should be "0" for the asset "ETH"
   202  
   203      Then the parties place the following orders with ticks:
   204        | party   | market id | side | volume | price | resulting trades | type       | tif     |
   205        | trader4 | ETH/DEC21 | sell | 4      | 1002  | 2                | TYPE_LIMIT | TIF_GTC |
   206  
   207      Then the market data for the market "ETH/DEC21" should be:
   208        | mark price | trading mode            |
   209        | 1002       | TRADING_MODE_CONTINUOUS |
   210  
   211      Then the following trades should be executed:
   212        | buyer    | price | size | seller  | aggressor side |
   213        | trader3a | 1002  | 2    | trader4 | sell           |
   214        | trader3b | 1002  | 1    | trader4 | sell           |
   215  
   216  # For trader3a-
   217  # trade_value_for_fee_purposes for trader3a = size_of_trade 0000000000000000000000000000000000000000000000000000000000000000 price_of_trade = 2 0000000000000000000000000000000000000000000000000000000000000000 1002 = 2004
   218  # infrastructure_fee = fee_factor[infrastructure] 0000000000000000000000000000000000000000000000000000000000000000 trade_value_for_fee_purposes = 0.002 0000000000000000000000000000000000000000000000000000000000000000 2004 = 4.008 = 5 (rounded up to nearest whole value)
   219  # maker_fee =  fee_factor[maker]  0000000000000000000000000000000000000000000000000000000000000000 trade_value_for_fee_purposes = 0.005 0000000000000000000000000000000000000000000000000000000000000000 2004 = 10.02 = 11 (rounded up to nearest whole value)
   220  # liquidity_fee = fee_factor[liquidity] 0000000000000000000000000000000000000000000000000000000000000000 trade_value_for_fee_purposes = 0 0000000000000000000000000000000000000000000000000000000000000000 3006 = 0
   221  
   222  # For trader3b -
   223  # trade_value_for_fee_purposes = size_of_trade 0000000000000000000000000000000000000000000000000000000000000000 price_of_trade = 1 0000000000000000000000000000000000000000000000000000000000000000 1002 = 1002
   224  # infrastructure_fee = fee_factor[infrastructure] 0000000000000000000000000000000000000000000000000000000000000000 trade_value_for_fee_purposes = 0.002 0000000000000000000000000000000000000000000000000000000000000000 1002 = 2.004 = 3 (rounded up to nearest whole value)
   225  # maker_fee =  fee_factor[maker]  0000000000000000000000000000000000000000000000000000000000000000 trade_value_for_fee_purposes = 0.005 0000000000000000000000000000000000000000000000000000000000000000 1002 = 5.01 = 6 (rounded up to nearest whole value)
   226  # liquidity_fee = fee_factor[liquidity] 0000000000000000000000000000000000000000000000000000000000000000 trade_value_for_fee_purposes = 0 0000000000000000000000000000000000000000000000000000000000000000 3006 = 0
   227  
   228      And the following transfers should happen:
   229        | from    | to       | from account            | to account                       | market id | amount | asset |
   230        | trader4 | market   | ACCOUNT_TYPE_GENERAL    | ACCOUNT_TYPE_FEES_MAKER          | ETH/DEC21 | 11     | ETH   |
   231        | trader4 | market   | ACCOUNT_TYPE_GENERAL    | ACCOUNT_TYPE_FEES_MAKER          | ETH/DEC21 | 6      | ETH   |
   232        | trader4 |          | ACCOUNT_TYPE_GENERAL    | ACCOUNT_TYPE_FEES_INFRASTRUCTURE |           | 8      | ETH   |
   233        | trader4 | market   | ACCOUNT_TYPE_GENERAL    | ACCOUNT_TYPE_FEES_LIQUIDITY      | ETH/DEC21 | 302    | ETH   |
   234        | market  | trader3a | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL             | ETH/DEC21 | 11     | ETH   |
   235        | market  | trader3b | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL             | ETH/DEC21 | 6      | ETH   |
   236  
   237  # total_fee = infrastructure_fee + maker_fee + liquidity_fee = 8 + 11 + 6 + 0 = 25 ??
   238  # Trader3a margin + general account balance = 10000 + 11 ( Maker fees) = 10011
   239  # Trader3b margin + general account balance = 10000 + 6 ( Maker fees) = 10006
   240  # Trader4  margin + general account balance = 10000 - (11+6) ( Maker fees) - 8 (Infra fee) = 99975
   241  
   242      Then the parties should have the following account balances:
   243        | party    | asset | market id | margin | general |
   244        | trader3a | ETH   | ETH/DEC21 | 1082   | 8929    |
   245        | trader3b | ETH   | ETH/DEC21 | 541    | 9465    |
   246        | trader4  | ETH   | ETH/DEC21 | 1383   | 8290    |
   247  
   248      And the accumulated infrastructure fees should be "8" for the asset "ETH"
   249      And the accumulated liquidity fees should be "302" for the market "ETH/DEC21"
   250  
   251      #complete the epoch for rewards to take place
   252      Then the network moves ahead "7" blocks
   253      # only trader3 received the maker fees so only they get the reward of 10k
   254      Then the parties should have the following account balances:
   255        | party    | asset | market id | margin | general |
   256        | trader3a | ETH   | ETH/DEC21 | 1082   | 8929    |
   257        | trader3b | ETH   | ETH/DEC21 | 541    | 9465    |
   258        | trader4  | ETH   | ETH/DEC21 | 1383   | 8290    |
   259  
   260  
   261      Then "trader3a" should have vesting account balance of "6470" for asset "VEGA"
   262      And "trader3b" should have vesting account balance of "3529" for asset "VEGA"
   263      And "trader4" should have vesting account balance of "1234" for asset "VEGA"
   264  
   265      #complete the epoch for rewards to take place
   266      Then the network moves ahead "7" blocks
   267      # expect no change to anyone
   268      Then the parties should have the following account balances:
   269        | party    | asset | market id | margin | general |
   270        | trader3a | ETH   | ETH/DEC21 | 1082   | 8929    |
   271        | trader3b | ETH   | ETH/DEC21 | 541    | 9465    |
   272        | trader4  | ETH   | ETH/DEC21 | 1383   | 8290    |
   273  
   274    Scenario: Testing fees in continuous trading with two trades and one liquidity providers with 10 and 0 s liquidity fee distribution timestep - test maker fee received, taker fee paid and lp fees rewards
   275      Given the fees configuration named "fees-config-1":
   276        | maker fee | infrastructure fee |
   277        | 0.005     | 0.002              |
   278      And the price monitoring named "price-monitoring":
   279        | horizon | probability | auction extension |
   280        | 1       | 0.99        | 3                 |
   281  
   282      When the simple risk model named "simple-risk-model-1":
   283        | long | short | max move up | min move down | probability of trading |
   284        | 0.2  | 0.1   | 100         | -100          | 0.1                    |
   285  
   286      And the liquidity sla params named "SLA":
   287        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
   288        | 1.0         | 0.5                          | 1                             | 1.0                    |
   289      And the following network parameters are set:
   290        | name                                               | value |
   291        | market.liquidity.providersFeeCalculationTimeStep   | 10s   |
   292  
   293      And the markets:
   294        | id        | quote name | asset | risk model          | margin calculator         | auction duration | fees          | price monitoring | data source config     | linear slippage factor | quadratic slippage factor | sla params |
   295        | ETH/DEC21 | ETH        | ETH   | simple-risk-model-1 | default-margin-calculator | 2                | fees-config-1 | price-monitoring | default-eth-for-future | 0.25                   | 0                         | SLA        |
   296      And the following network parameters are set:
   297        | name                                               | value |
   298        | market.liquidity.providersFeeCalculationTimeStep | 10s   |
   299  
   300      Given the parties deposit on asset's general account the following amount:
   301        | party                                                            | asset | amount   |
   302        | a3c024b4e23230c89884a54a813b1ecb4cb0f827a38641c66eeca466da6b2ddf | VEGA  | 10000000 |
   303  
   304      # setup accounts
   305      Given the parties deposit on asset's general account the following amount:
   306        | party    | asset | amount    |
   307        | aux1     | ETH   | 100000000 |
   308        | aux2     | ETH   | 100000000 |
   309        | trader3a | ETH   | 10000     |
   310        | trader3b | ETH   | 10000     |
   311        | trader4  | ETH   | 10000     |
   312  
   313      # transfer to the maker fee received reward account and the taker paid fee reward account
   314      Given the parties submit the following recurring transfers:
   315        | id | from                                                             | from_account_type    | to                                                               | to_account_type                         | asset | amount | start_epoch | end_epoch | factor | metric                              | metric_asset | markets   |
   316        | 1  | a3c024b4e23230c89884a54a813b1ecb4cb0f827a38641c66eeca466da6b2ddf | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES | VEGA  | 10000  | 1           |           | 0.5    | DISPATCH_METRIC_MAKER_FEES_RECEIVED | ETH          |           |
   317        | 2  | a3c024b4e23230c89884a54a813b1ecb4cb0f827a38641c66eeca466da6b2ddf | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES     | VEGA  | 1234   | 1           |           | 1      | DISPATCH_METRIC_MAKER_FEES_PAID     | ETH          | ETH/DEC21 |
   318        | 3  | a3c024b4e23230c89884a54a813b1ecb4cb0f827a38641c66eeca466da6b2ddf | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES    | VEGA  | 500    | 1           |           | 2      | DISPATCH_METRIC_LP_FEES_RECEIVED    | ETH          |           |
   319  
   320  
   321      Then the parties place the following orders:
   322        | party | market id | side | volume | price | resulting trades | type       | tif     |
   323        | aux1  | ETH/DEC21 | buy  | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   324        | aux2  | ETH/DEC21 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC |
   325        | aux1  | ETH/DEC21 | buy  | 1      | 920   | 0                | TYPE_LIMIT | TIF_GTC |
   326        | aux2  | ETH/DEC21 | sell | 1      | 1080  | 0                | TYPE_LIMIT | TIF_GTC |
   327  
   328      Given the parties submit the following liquidity provision:
   329        | id  | party | market id | commitment amount | fee   | lp type    |
   330        | lp1 | aux1  | ETH/DEC21 | 10000             | 0.001 | submission |
   331        | lp1 | aux1  | ETH/DEC21 | 10000             | 0.001 | amendment  |
   332  
   333      And the parties place the following pegged iceberg orders:
   334        | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset |
   335        | aux1  | ETH/DEC21 | 10        | 1                    | buy  | BID              | 10     | 10     |
   336        | aux1  | ETH/DEC21 | 10        | 1                    | sell | ASK              | 10     | 10     |
   337   
   338      Then the opening auction period ends for market "ETH/DEC21"
   339      And the market data for the market "ETH/DEC21" should be:
   340        | mark price | trading mode            |
   341        | 1000       | TRADING_MODE_CONTINUOUS |
   342  
   343      And the order book should have the following volumes for market "ETH/DEC21":
   344        | side | price | volume |
   345        | sell | 1080  | 1      |
   346        | buy  | 920   | 1      |
   347        | buy  | 910   | 10     |
   348        | sell | 1090  | 10     |
   349  
   350      When the parties place the following orders with ticks:
   351        | party    | market id | side | volume | price | resulting trades | type       | tif     |
   352        | trader3a | ETH/DEC21 | buy  | 2      | 1002  | 0                | TYPE_LIMIT | TIF_GTC |
   353        | trader3b | ETH/DEC21 | buy  | 1      | 1002  | 0                | TYPE_LIMIT | TIF_GTC |
   354        | trader4  | ETH/DEC21 | sell | 4      | 1002  | 2                | TYPE_LIMIT | TIF_GTC |
   355  
   356      And the liquidity fee factor should be "0.001" for the market "ETH/DEC21"
   357      And the accumulated liquidity fees should be "5" for the market "ETH/DEC21"
   358  
   359      Then the market data for the market "ETH/DEC21" should be:
   360        | mark price | trading mode            |
   361        | 1002       | TRADING_MODE_CONTINUOUS |
   362  
   363  # For trader3a-
   364  # trade_value_for_fee_purposes for trader3a = size_of_trade 0000000000000000000000000000000000000000000000000000000000000000 price_of_trade = 2 0000000000000000000000000000000000000000000000000000000000000000 1002 = 2004
   365  # infrastructure_fee = fee_factor[infrastructure] 0000000000000000000000000000000000000000000000000000000000000000 trade_value_for_fee_purposes = 0.002 0000000000000000000000000000000000000000000000000000000000000000 2004 = 4.008 = 5 (rounded up to nearest whole value)
   366  # maker_fee =  fee_factor[maker]  0000000000000000000000000000000000000000000000000000000000000000 trade_value_for_fee_purposes = 0.005 0000000000000000000000000000000000000000000000000000000000000000 2004 = 10.02 = 11 (rounded up to nearest whole value)
   367  # liquidity_fee = fee_factor[liquidity] 0000000000000000000000000000000000000000000000000000000000000000 trade_value_for_fee_purposes = 0.001 0000000000000000000000000000000000000000000000000000000000000000 2004 = 2.004 = 3 (rounded up to nearest whole value)
   368  
   369  # For trader3b -
   370  # trade_value_for_fee_purposes = size_of_trade 0000000000000000000000000000000000000000000000000000000000000000 price_of_trade = 1 0000000000000000000000000000000000000000000000000000000000000000 1002 = 1002
   371  # infrastructure_fee = fee_factor[infrastructure] 0000000000000000000000000000000000000000000000000000000000000000 trade_value_for_fee_purposes = 0.002 0000000000000000000000000000000000000000000000000000000000000000 1002 = 2.004 = 3 (rounded up to nearest whole value)
   372  # maker_fee =  fee_factor[maker]  0000000000000000000000000000000000000000000000000000000000000000 trade_value_for_fee_purposes = 0.005 0000000000000000000000000000000000000000000000000000000000000000 1002 = 5.01 = 6 (rounded up to nearest whole value)
   373  # liquidity_fee = fee_factor[liquidity] 0000000000000000000000000000000000000000000000000000000000000000 trade_value_for_fee_purposes = 0.001 0000000000000000000000000000000000000000000000000000000000000000 1002 = 1.002 = 2 (rounded up to nearest whole value)
   374  
   375      Then the following trades should be executed:
   376        | buyer    | price | size | seller  | aggressor side | buyer fee | seller fee | seller infrastructure fee | seller maker fee | seller liquidity fee |
   377        | trader3a | 1002  | 2    | trader4 | sell           | 0         | 19         | 5                  | 11        | 3             |
   378        | trader3b | 1002  | 1    | trader4 | sell           | 0         | 11         | 3                  | 6         | 2             |
   379  
   380      And the following transfers should happen:
   381        | from    | to       | from account            | to account                       | market id | amount | asset |
   382        | trader4 | market   | ACCOUNT_TYPE_GENERAL    | ACCOUNT_TYPE_FEES_MAKER          | ETH/DEC21 | 11     | ETH   |
   383        | trader4 | market   | ACCOUNT_TYPE_GENERAL    | ACCOUNT_TYPE_FEES_MAKER          | ETH/DEC21 | 6      | ETH   |
   384        | trader4 |          | ACCOUNT_TYPE_GENERAL    | ACCOUNT_TYPE_FEES_INFRASTRUCTURE |           | 8      | ETH   |
   385        | trader4 | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_LIQUIDITY | ETH/DEC21 | 5 | ETH |
   386        | market  | trader3a | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL             | ETH/DEC21 | 11     | ETH   |
   387        | market  | trader3b | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL             | ETH/DEC21 | 6      | ETH   |
   388  
   389  # total_fee = infrastructure_fee + maker_fee + liquidity_fee = 8 + 11 + 6 + 0 = 25
   390  
   391      And the accumulated infrastructure fees should be "8" for the asset "ETH"
   392      And the accumulated liquidity fees should be "5" for the market "ETH/DEC21"
   393  
   394      #complete the epoch for rewards to take place
   395      Then the network moves ahead "7" blocks
   396  
   397      # 11/17 x 10000 -> maker fee received reward
   398      Then "trader3a" should have vesting account balance of "6470" for asset "VEGA"
   399      # 6/17 x 10000 -> maker fee recevied reward
   400      And "trader3b" should have vesting account balance of "3529" for asset "VEGA"
   401      # 1234 = taker fee paid reward reward
   402      And "trader4" should have vesting account balance of "1234" for asset "VEGA"
   403  
   404      #complete the epoch for rewards to take place
   405      Then the network moves ahead "7" blocks
   406