code.vegaprotocol.io/vega@v0.79.0/core/integration/features/volume-rebate/0095-HVMR.feature (about) 1 Feature: Volume rebate program - contributions from trades 2 3 Volume rebate program rewards parties who comprise above a specified 4 fraction of the maker volume on the network in a window with an 5 extra rebate factor. 6 7 Tests check trades contribute towards a party's maker volume fraction 8 correctly and that volume across windows and markets is correctly 9 counted and scaled where necessary. 10 11 Background: 12 13 # Initialise the network and register the assets 14 Given the average block duration is "1" 15 And the following network parameters are set: 16 | name | value | 17 | market.fee.factors.makerFee | 0.01 | 18 | market.fee.factors.infrastructureFee | 0.01 | 19 | market.fee.factors.treasuryFee | 0.1 | 20 | market.fee.factors.buybackFee | 0.1 | 21 | network.markPriceUpdateMaximumFrequency | 0s | 22 | validators.epoch.length | 20s | 23 | market.auction.minimumDuration | 1 | 24 25 And the following assets are registered: 26 | id | decimal places | quantum | 27 | USD-0-1 | 0 | 1 | 28 | MXN-0-10 | 0 | 10 | 29 30 # Initialise the parties and deposit assets 31 Given the parties deposit on asset's general account the following amount: 32 | party | asset | amount | 33 | aux1 | USD-0-1 | 1000000 | 34 | aux2 | USD-0-1 | 1000000 | 35 | aux1 | MXN-0-10 | 10000000 | 36 | aux2 | MXN-0-10 | 10000000 | 37 38 # Setup the markets 39 Given the price monitoring named "price-monitoring": 40 | horizon | probability | auction extension | 41 | 3600 | 0.99 | 1 | 42 And the markets: 43 | id | quote name | asset | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | decimal places | position decimal places | 44 | BTC/USD-0-1 | USD | USD-0-1 | default-log-normal-risk-model | default-margin-calculator | 1 | default-none | price-monitoring | default-eth-for-future | 1e-3 | 0 | default-futures | 0 | 0 | 45 | BTC/MXN-0-10 | VND | MXN-0-10 | default-log-normal-risk-model | default-margin-calculator | 1 | default-none | price-monitoring | default-eth-for-future | 1e-3 | 0 | default-futures | 0 | 0 | 46 And the spot markets: 47 | id | name | base asset | quote asset | risk model | auction duration | fees | price monitoring | decimal places | position decimal places | sla params | 48 | MXN-0-10/USD-0-1 | MXN/USD | MXN-0-10 | USD-0-1 | default-log-normal-risk-model | 1 | default-none | price-monitoring | 0 | 0 | default-basic | 49 | USD-0-1/MXN-0-10 | MXN/USD | USD-0-1 | MXN-0-10 | default-log-normal-risk-model | 1 | default-none | price-monitoring | 0 | 0 | default-basic | 50 And the parties place the following orders: 51 | party | market id | side | volume | price | resulting trades | type | tif | 52 | aux1 | BTC/USD-0-1 | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | 53 | aux2 | BTC/USD-0-1 | sell | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | 54 And the parties place the following orders: 55 | party | market id | side | volume | price | resulting trades | type | tif | 56 | aux1 | BTC/MXN-0-10 | buy | 1 | 500000 | 0 | TYPE_LIMIT | TIF_GTC | 57 | aux2 | BTC/MXN-0-10 | sell | 1 | 500000 | 0 | TYPE_LIMIT | TIF_GTC | 58 And the parties place the following orders: 59 | party | market id | side | volume | price | resulting trades | type | tif | 60 | aux1 | MXN-0-10/USD-0-1 | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | 61 | aux2 | MXN-0-10/USD-0-1 | sell | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | 62 And the parties place the following orders: 63 | party | market id | side | volume | price | resulting trades | type | tif | 64 | aux1 | USD-0-1/MXN-0-10 | buy | 1 | 500000 | 0 | TYPE_LIMIT | TIF_GTC | 65 | aux2 | USD-0-1/MXN-0-10 | sell | 1 | 500000 | 0 | TYPE_LIMIT | TIF_GTC | 66 When the network moves ahead "2" blocks 67 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/USD-0-1" 68 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/MXN-0-10" 69 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "MXN-0-10/USD-0-1" 70 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "MXN-0-10/USD-0-1" 71 72 Given the parties deposit on asset's general account the following amount: 73 | party | asset | amount | 74 | party1 | USD-0-1 | 1000000 | 75 | party2 | USD-0-1 | 1000000 | 76 | party1 | MXN-0-10 | 10000000 | 77 | party2 | MXN-0-10 | 10000000 | 78 79 80 Scenario: Maker/taker volume does/does not contribute towards the maker volume fraction respectively (0095-HVMR-013)(0095-HVMR-014)(0095-HVMR-015)(0095-HVMR-016) 81 82 Given the volume rebate program tiers named "vrt": 83 | fraction | rebate | 84 | 0.0001 | 0.001 | 85 And the volume rebate program: 86 | id | tiers | closing timestamp | window length | 87 | id | vrt | 0 | 1 | 88 And the network moves ahead "1" epochs 89 90 Given the parties place the following orders: 91 | party | market id | side | volume | price | resulting trades | type | tif | error | 92 | party1 | <market> | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 93 | party2 | <market> | sell | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 94 When the network moves ahead "1" blocks 95 Then the following trades should be executed: 96 | buyer | seller | size | price | aggressor side | buyer maker fee | seller maker fee | 97 | party1 | party2 | 1 | 50000 | sell | 0 | 500 | 98 99 # In the following epoch, party1 and party2 are both the maker of a 100 # trade but only party1 recevieves a rebate. 101 Given the network moves ahead "1" epochs 102 And the parties place the following orders: 103 | party | market id | side | volume | price | resulting trades | type | tif | error | 104 | party1 | <market> | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 105 | party2 | <market> | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 106 | aux1 | <market> | sell | 2 | 50000 | 2 | TYPE_LIMIT | TIF_GTC | | 107 When the network moves ahead "1" blocks 108 Then the following trades should be executed: 109 | buyer | seller | size | price | aggressor side | buyer high volume maker fee | seller high volume maker fee | 110 | party1 | aux1 | 1 | 50000 | sell | 0 | 50 | 111 | party2 | aux1 | 1 | 50000 | sell | 0 | 0 | 112 Then the following transfers should happen: 113 | from | to | from account | to account | market id | amount | asset | type | 114 | | party1 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | <market> | 50 | USD-0-1 | TRANSFER_TYPE_HIGH_MAKER_FEE_REBATE_RECEIVE | 115 116 Examples: 117 | market | 118 | BTC/USD-0-1 | 119 | MXN-0-10/USD-0-1 | 120 121 122 Scenario Outline: Trades on auction uncrossing do not contribute towards the maker volume fraction (0095-HVMR-017)(0095-HVMR-018) 123 124 Given the volume rebate program tiers named "vrt": 125 | fraction | rebate | 126 | 0.0001 | 0.001 | 127 And the volume rebate program: 128 | id | tiers | closing timestamp | window length | 129 | id | vrt | 0 | 1 | 130 And the network moves ahead "1" epochs 131 132 Given the parties place the following orders: 133 | party | market id | side | volume | price | resulting trades | type | tif | error | reference | 134 | aux1 | <market> | buy | 1 | 1 | 0 | TYPE_LIMIT | TIF_GTC | | auction-order-aux1 | 135 | aux2 | <market> | sell | 1 | 1 | 0 | TYPE_LIMIT | TIF_GTC | | auction-order-aux2 | 136 And the parties cancel the following orders: 137 | party | reference | 138 | aux1 | auction-order-aux1 | 139 | aux2 | auction-order-aux2 | 140 Then the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market <market string> 141 142 # Exit the PM auction - volume should not contribute towards maker 143 # volume fraction of either party1 or party2 144 Given the parties place the following orders: 145 | party | market id | side | volume | price | resulting trades | type | tif | error | 146 | party1 | <market> | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 147 | party2 | <market> | sell | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 148 When the network moves ahead "2" blocks 149 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market <market string> 150 And the following trades should be executed: 151 | buyer | seller | size | price | aggressor side | buyer maker fee | seller maker fee | 152 | party1 | party2 | 1 | 50000 | | 0 | 0 | 153 154 # In the following epoch, party1 and party2 are both the maker of a 155 # trade but neither receive a rebate. 156 Given the network moves ahead "1" epochs 157 And the parties place the following orders: 158 | party | market id | side | volume | price | resulting trades | type | tif | error | 159 | party1 | <market> | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 160 | party2 | <market> | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 161 | aux1 | <market> | sell | 2 | 50000 | 2 | TYPE_LIMIT | TIF_GTC | | 162 When the network moves ahead "1" blocks 163 Then the following trades should be executed: 164 | buyer | seller | size | price | aggressor side | buyer high volume maker fee | seller high volume maker fee | 165 | party1 | aux1 | 1 | 50000 | sell | 0 | 0 | 166 | party2 | aux1 | 1 | 50000 | sell | 0 | 0 | 167 168 Examples: 169 | market | market string | 170 | BTC/USD-0-1 | "BTC/USD-0-1" | 171 | MXN-0-10/USD-0-1 | "MXN-0-10/USD-0-1" | 172 173 174 Scenario Outline: Volume made in previous window correctly contributes towards maker volume fraction (0095-HVMR-019)(0095-HVMR-020)(0095-HVMR-021)(0095-HVMR-022) 175 176 Given the volume rebate program tiers named "vrt": 177 | fraction | rebate | 178 | 0.0001 | 0.001 | 179 And the volume rebate program: 180 | id | tiers | closing timestamp | window length | 181 | id | vrt | 0 | <window length> | 182 And the network moves ahead "1" epochs 183 184 And the parties place the following orders: 185 | party | market id | side | volume | price | resulting trades | type | tif | error | 186 | party1 | <market> | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 187 | aux1 | <market> | sell | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 188 When the network moves ahead "1" blocks 189 Then the following trades should be executed: 190 | buyer | seller | size | price | aggressor side | buyer maker fee | seller maker fee | 191 | party1 | aux1 | 1 | 50000 | sell | 0 | 500 | 192 193 Given the network moves ahead <epochs between trades> epochs 194 When the parties place the following orders: 195 | party | market id | side | volume | price | resulting trades | type | tif | error | 196 | party2 | <market> | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 197 | aux1 | <market> | sell | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 198 When the network moves ahead "1" blocks 199 Then the following trades should be executed: 200 | buyer | seller | size | price | aggressor side | buyer maker fee | seller maker fee | 201 | party2 | aux1 | 1 | 50000 | sell | 0 | 500 | 202 203 When the network moves ahead "1" epochs 204 When the parties place the following orders: 205 | party | market id | side | volume | price | resulting trades | type | tif | error | 206 | party1 | <market> | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 207 | party2 | <market> | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 208 | aux1 | <market> | sell | 2 | 50000 | 2 | TYPE_LIMIT | TIF_GTC | | 209 When the network moves ahead "1" blocks 210 Then the following trades should be executed: 211 | buyer | seller | size | price | aggressor side | buyer high volume maker fee | seller high volume maker fee | 212 | party1 | aux1 | 1 | 50000 | sell | 0 | <party1 rebate> | 213 | party2 | aux1 | 1 | 50000 | sell | 0 | <party2 rebate> | 214 215 Examples: 216 | market | window length | epochs between trades | party1 rebate | party2 rebate | 217 | BTC/USD-0-1 | 2 | "0" | 50 | 50 | 218 | BTC/USD-0-1 | 2 | "1" | 50 | 50 | 219 | BTC/USD-0-1 | 2 | "2" | 0 | 50 | 220 | MXN-0-10/USD-0-1 | 2 | "0" | 50 | 50 | 221 | MXN-0-10/USD-0-1 | 2 | "1" | 50 | 50 | 222 | MXN-0-10/USD-0-1 | 2 | "2" | 0 | 50 | 223 224 225 Scenario Outline: Derivative and spot markets using assets with different quantums scale maker volume correctly (0095-HVMR-023)(0095-HVMR-024)(0095-HVMR-025) 226 227 Given the volume rebate program tiers named "vrt": 228 | fraction | rebate | 229 | 0.5 | 0.001 | 230 And the volume rebate program: 231 | id | tiers | closing timestamp | window length | 232 | id | vrt | 0 | 1 | 233 And the network moves ahead "1" epochs 234 235 Given the parties deposit on asset's general account the following amount: 236 | party | asset | amount | 237 | party1 | USD-0-1 | 1000000 | 238 | party2 | MXN-0-10 | 1000000 | 239 And the parties place the following orders: 240 | party | market id | side | volume | price | resulting trades | type | tif | error | 241 | party1 | BTC/USD-0-1 | buy | 1 | <usd price> | 0 | TYPE_LIMIT | TIF_GTC | | 242 | aux1 | BTC/USD-0-1 | sell | 1 | <usd price> | 1 | TYPE_LIMIT | TIF_GTC | | 243 | party2 | BTC/MXN-0-10 | buy | 1 | <mxn price> | 0 | TYPE_LIMIT | TIF_GTC | | 244 | aux1 | BTC/MXN-0-10 | sell | 1 | <mxn price> | 1 | TYPE_LIMIT | TIF_GTC | | 245 When the network moves ahead "1" blocks 246 Then the following trades should be executed: 247 | buyer | seller | size | price | aggressor side | 248 | party1 | aux1 | 1 | <usd price> | sell | 249 | party2 | aux1 | 1 | <mxn price> | sell | 250 251 # In the following epoch, party1 and party2 are both the maker of a 252 # trade but only party1 recevieves a rebate. 253 Given the network moves ahead "1" epochs 254 And the parties place the following orders: 255 | party | market id | side | volume | price | resulting trades | type | tif | error | 256 | party1 | BTC/USD-0-1 | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 257 | aux1 | BTC/USD-0-1 | sell | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 258 | party2 | BTC/MXN-0-10 | buy | 1 | 500000 | 0 | TYPE_LIMIT | TIF_GTC | | 259 | aux1 | BTC/MXN-0-10 | sell | 1 | 500000 | 1 | TYPE_LIMIT | TIF_GTC | | 260 Then debug trades 261 When the network moves ahead "1" blocks 262 Then the following trades should be executed: 263 | buyer | seller | size | price | aggressor side | buyer high volume maker fee | seller high volume maker fee | 264 | party1 | aux1 | 1 | 50000 | sell | 0 | <party1 rebate> | 265 | party2 | aux1 | 1 | 500000 | sell | 0 | <party2 rebate> | 266 267 Examples: 268 | usd market | mxn market | usd price | mxn price | party1 rebate | party2 rebate | 269 | BTC/USDT-0-1 | BTC/MXN-0-10 | 50001 | 500000 | 50 | 0 | 270 | BTC/USDT-0-1 | USD-0-1/MXN-0-10 | 50000 | 500000 | 50 | 500 | 271 | MXN-0-1/USD-0-10 | USD-0-1/MXN-0-10 | 50000 | 500001 | 0 | 500 | 272 273 274 Scenario: A party's rebate is fixed for the epoch and only increases on the next epoch (0095-HVMR-026)(0095-HVMR-027)(0095-HVMR-028) 275 276 Given the volume rebate program tiers named "vrt": 277 | fraction | rebate | 278 | 0.000000000001 | 0.001 | 279 | 0.500000000001 | 0.010 | 280 And the volume rebate program: 281 | id | tiers | closing timestamp | window length | 282 | id | vrt | 0 | 1 | 283 And the network moves ahead "1" epochs 284 285 # Place trades such that both parties have exactly half of the maker 286 # volume and therefore receive the lower rebate factor. 287 Given the parties place the following orders: 288 | party | market id | side | volume | price | resulting trades | type | tif | error | 289 | party1 | BTC/USD-0-1 | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 290 | aux1 | BTC/USD-0-1 | sell | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 291 | party2 | BTC/USD-0-1 | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 292 | aux1 | BTC/USD-0-1 | sell | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 293 Then the following trades should be executed: 294 | buyer | seller | size | price | aggressor side | seller maker fee | 295 | party1 | aux1 | 1 | 50000 | sell | 500 | 296 | party2 | aux1 | 1 | 50000 | sell | 500 | 297 298 # Place trades such that party2 has slightly more than half of the 299 # maker volume andt therefore will evently receive the higher rebate factor. 300 Given the network moves ahead "1" epochs 301 And the parties place the following orders: 302 | party | market id | side | volume | price | resulting trades | type | tif | error | 303 | party1 | BTC/USD-0-1 | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 304 | aux1 | BTC/USD-0-1 | sell | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 305 | party2 | BTC/USD-0-1 | buy | 1 | 50100 | 0 | TYPE_LIMIT | TIF_GTC | | 306 | aux1 | BTC/USD-0-1 | sell | 1 | 50100 | 1 | TYPE_LIMIT | TIF_GTC | | 307 When the network moves ahead "1" blocks 308 Then the following trades should be executed: 309 | buyer | seller | size | price | aggressor side | seller maker fee | seller high volume maker fee | 310 | party1 | aux1 | 1 | 50000 | sell | 500 | 50 | 311 | party2 | aux1 | 1 | 50100 | sell | 501 | 50 | 312 313 # Place more orders. The rebates are fixed for the epoch so party2 314 # should not yet receive the higher rebate factor. 315 Given the parties place the following orders: 316 | party | market id | side | volume | price | resulting trades | type | tif | error | 317 | party1 | BTC/USD-0-1 | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 318 | aux1 | BTC/USD-0-1 | sell | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 319 | party2 | BTC/USD-0-1 | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 320 | aux1 | BTC/USD-0-1 | sell | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 321 When the network moves ahead "1" blocks 322 Then the following trades should be executed: 323 | buyer | seller | size | price | aggressor side | seller maker fee | seller high volume maker fee | 324 | party1 | aux1 | 1 | 50000 | sell | 500 | 50 | 325 | party2 | aux1 | 1 | 50000 | sell | 500 | 50 | 326 327 # In the next epoch the rebate factors are updated and party2 now 328 # receives a larger high volume maker fee. 329 Given the network moves ahead "1" epochs 330 And the parties place the following orders: 331 | party | market id | side | volume | price | resulting trades | type | tif | error | 332 | party1 | BTC/USD-0-1 | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 333 | aux1 | BTC/USD-0-1 | sell | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 334 | party2 | BTC/USD-0-1 | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 335 | aux1 | BTC/USD-0-1 | sell | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 336 When the network moves ahead "1" blocks 337 Then the following trades should be executed: 338 | buyer | seller | size | price | aggressor side | seller maker fee | seller high volume maker fee | 339 | party1 | aux1 | 1 | 50000 | sell | 500 | 50 | 340 | party2 | aux1 | 1 | 50000 | sell | 500 | 500 | 341 342