code.vegaprotocol.io/vega@v0.79.0/core/integration/features/rewards/infra_fees.feature (about) 1 Feature: Fees calculations 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 And the validators: 22 | id | staking account balance | 23 | node1 | 1000000 | 24 | node2 | 1000000 | 25 | node3 | 1000000 | 26 | node4 | 1000000 | 27 | node5 | 1000000 | 28 | node6 | 1000000 | 29 | node7 | 1000000 | 30 | node8 | 1000000 | 31 | node9 | 1000000 | 32 | node10 | 1000000 | 33 | node11 | 1000000 | 34 | node12 | 1000000 | 35 | node13 | 1000000 | 36 37 #set up the self delegation of the validators 38 Then the parties submit the following delegations: 39 | party | node id | amount | 40 | node1 | node1 | 10000 | 41 | node2 | node2 | 10000 | 42 | node3 | node3 | 10000 | 43 | node4 | node4 | 10000 | 44 | node5 | node5 | 10000 | 45 | node6 | node6 | 10000 | 46 | node7 | node7 | 10000 | 47 | node8 | node8 | 10000 | 48 | node9 | node9 | 10000 | 49 | node10 | node10 | 10000 | 50 | node11 | node11 | 10000 | 51 | node12 | node12 | 10000 | 52 | node13 | node13 | 10000 | 53 54 And the parties deposit on staking account the following amount: 55 | party | asset | amount | 56 | party1 | VEGA | 10000 | 57 58 Then the parties submit the following delegations: 59 | party | node id | amount | 60 | party1 | node1 | 100 | 61 | party1 | node2 | 200 | 62 | party1 | node3 | 300 | 63 64 And the parties deposit on asset's general account the following amount: 65 | party | asset | amount | 66 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | VEGA | 50000 | 67 And the parties submit the following one off transfers: 68 | id | from | from_account_type | to | to_account_type | asset | amount | delivery_time | 69 | 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_GLOBAL_REWARD | VEGA | 50000 | 2021-08-26T00:00:01Z | 70 71 #complete the first epoch for the self delegation to take effect 72 Then the network moves ahead "7" blocks 73 74 Scenario: Testing fees when network parameters are changed (in continuous trading with one trade and no liquidity providers) 75 Description : Changing net params does change the fees being collected appropriately even if the market is already running 76 77 Given the fees configuration named "fees-config-1": 78 | maker fee | infrastructure fee | 79 | 0.005 | 0.002 | 80 And the price monitoring named "price-monitoring": 81 | horizon | probability | auction extension | 82 | 1 | 0.99 | 3 | 83 84 And the simple risk model named "simple-risk-model-1": 85 | long | short | max move up | min move down | probability of trading | 86 | 0.2 | 0.1 | 100 | -100 | 0.1 | 87 88 And the markets: 89 | id | quote name | asset | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | 90 | 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 | 91 92 # setup accounts 93 Given the parties deposit on asset's general account the following amount: 94 | party | asset | amount | 95 | aux1 | ETH | 100000000 | 96 | aux2 | ETH | 100000000 | 97 | trader3 | ETH | 10000 | 98 | trader4 | ETH | 10000 | 99 | lpprov | ETH | 1000000000 | 100 101 When the parties submit the following liquidity provision: 102 | id | party | market id | commitment amount | fee | lp type | 103 | lp1 | lpprov | ETH/DEC21 | 90000 | 0.1 | submission | 104 | lp1 | lpprov | ETH/DEC21 | 90000 | 0.1 | submission | 105 And the parties place the following pegged iceberg orders: 106 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 107 | lpprov | ETH/DEC21 | 2 | 1 | buy | BID | 50 | 100 | 108 | lpprov | ETH/DEC21 | 2 | 1 | sell | ASK | 50 | 100 | 109 Then the parties place the following orders: 110 | party | market id | side | volume | price | resulting trades | type | tif | 111 | aux1 | ETH/DEC21 | buy | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 112 | aux2 | ETH/DEC21 | sell | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 113 | aux1 | ETH/DEC21 | buy | 1 | 900 | 0 | TYPE_LIMIT | TIF_GTC | 114 | aux2 | ETH/DEC21 | sell | 1 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | 115 116 Then the opening auction period ends for market "ETH/DEC21" 117 And the market data for the market "ETH/DEC21" should be: 118 | mark price | trading mode | 119 | 1000 | TRADING_MODE_CONTINUOUS | 120 When the parties place the following orders with ticks: 121 | party | market id | side | volume | price | resulting trades | type | tif | 122 | trader3 | ETH/DEC21 | buy | 3 | 1002 | 0 | TYPE_LIMIT | TIF_GTC | 123 124 Then the parties should have the following account balances: 125 | party | asset | market id | margin | general | 126 | trader3 | ETH | ETH/DEC21 | 720 | 9280 | 127 128 And the accumulated liquidity fees should be "0" for the market "ETH/DEC21" 129 And the accumulated infrastructure fees should be "0" for the asset "ETH" 130 131 # Changing net params fees factors 132 And the following network parameters are set: 133 | name | value | 134 | market.fee.factors.makerFee | 0.05 | 135 | market.fee.factors.infrastructureFee | 0.5 | 136 137 Then the parties place the following orders with ticks: 138 | party | market id | side | volume | price | resulting trades | type | tif | 139 | trader4 | ETH/DEC21 | sell | 4 | 1002 | 1 | TYPE_LIMIT | TIF_GTC | 140 141 And the market data for the market "ETH/DEC21" should be: 142 | mark price | trading mode | 143 | 1002 | TRADING_MODE_CONTINUOUS | 144 145 Then the following trades should be executed: 146 | buyer | price | size | seller | 147 | trader3 | 1002 | 3 | trader4 | 148 149 # trade_value_for_fee_purposes = size_of_trade * price_of_trade = 3 *1002 = 3006 150 # infrastructure_fee = fee_factor[infrastructure] * trade_value_for_fee_purposes = 0.5 * 3006 = 1503 151 # maker_fee = fee_factor[maker] * trade_value_for_fee_purposes = 0.05 * 3006 = 150.30 = 151 (rounded up to nearest whole value) 152 # liquidity_fee = fee_factor[liquidity] * trade_value_for_fee_purposes = 0 * 3006 = 0 153 And the following transfers should happen: 154 | from | to | from account | to account | market id | amount | asset | 155 | trader4 | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_MAKER | ETH/DEC21 | 151 | ETH | 156 | trader4 | | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_INFRASTRUCTURE | | 1503 | ETH | 157 | trader4 | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_LIQUIDITY | ETH/DEC21 | 301 | ETH | 158 | market | trader3 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | ETH/DEC21 | 151 | ETH | 159 160 # total_fee = infrastructure_fee + maker_fee + liquidity_fee = 1503 + 151 + 0 = 1654 161 162 And the accumulated infrastructure fees should be "1503" for the asset "ETH" 163 And the accumulated liquidity fees should be "301" for the market "ETH/DEC21" 164 Then the network moves ahead "7" blocks 165 166 #verify validator score 167 Then the validators should have the following val scores for epoch 1: 168 | node id | validator score | normalised score | 169 | node1 | 0.07734 | 0.07734 | 170 | node2 | 0.07810 | 0.07810 | 171 | node3 | 0.07887 | 0.07887 | 172 | node4 | 0.07657 | 0.07657 | 173 174 #staking and delegation rewards - 50k 175 #node1 has 10k self delegation + 100 from party1 176 #node2 has 10k self delegation + 200 from party2 177 #node3 has 10k self delegation + 300 from party3 178 #all other nodes have 10k self delegation 179 #party1 gets 0.07734 * 50000 * 0.883 * 100/10100 + 0.07810 * 50000 * 0.883 * 200/10200 + 0.07887 * 50000 * 0.883 * 300/10300 180 #node1 gets: (1 - 0.883 * 100/10100) * 0.07734 * 50000 181 #node2 gets: (1 - 0.883 * 200/10200) * 0.07810 * 50000 182 #node3 gets: (1 - 0.883 * 300/10300) * 0.07887 * 50000 183 #node4 - node13 gets: 0.07657 * 50000 184 #infrastructure fees rewards -> 1503 185 #party1 gets 0.07734 * 1503 * 0.883 * 100/10100 + 0.07810 * 1503 * 0.883 * 200/10200 + 0.07887 * 1503 * 0.883 * 300/10300 186 #node1 gets: (1 - 0.883 * 100/10100) * 0.07734 * 1503 187 #node2 gets: (1 - 0.883 * 200/10200) * 0.07810 * 1503 188 #node3 gets: (1 - 0.883 * 300/10300) * 0.07887 * 1503 189 #node4 - node13 gets: 0.07657 * 1503 190 191 And the parties receive the following reward for epoch 1: 192 | party | asset | amount | 193 | party1 | ETH | 6 | 194 | node1 | ETH | 115 | 195 | node2 | ETH | 115 | 196 | node3 | ETH | 115 | 197 | node4 | ETH | 115 | 198 | node5 | ETH | 115 | 199 | node6 | ETH | 115 | 200 | node8 | ETH | 115 | 201 | node10 | ETH | 115 | 202 | node11 | ETH | 115 | 203 | node12 | ETH | 115 | 204 | node13 | ETH | 115 | 205 | party1 | VEGA | 201 | 206 | node1 | VEGA | 3832 | 207 | node2 | VEGA | 3837 | 208 | node3 | VEGA | 3841 | 209 | node4 | VEGA | 3828 | 210 | node5 | VEGA | 3828 | 211 | node6 | VEGA | 3828 | 212 | node8 | VEGA | 3828 | 213 | node10 | VEGA | 3828 | 214 | node11 | VEGA | 3828 | 215 | node12 | VEGA | 3828 | 216 | node13 | VEGA | 3828 | 217 218 219 220