code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/enactment_HVMR.feature (about) 1 Feature: Volume rebate program - program enactment 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 on program enactment party benefit factors are updated 8 correctly and applied in the next epoch. 9 10 Background: 11 12 # Initialise the network and register the assets 13 Given the average block duration is "1" 14 And the following network parameters are set: 15 | name | value | 16 | market.fee.factors.makerFee | 0.01 | 17 | market.fee.factors.infrastructureFee | 0.01 | 18 | market.fee.factors.treasuryFee | 0.1 | 19 | market.fee.factors.buybackFee | 0.1 | 20 | network.markPriceUpdateMaximumFrequency | 0s | 21 | validators.epoch.length | 20s | 22 | market.auction.minimumDuration | 1 | 23 24 And the following assets are registered: 25 | id | decimal places | quantum | 26 | USD-0-1 | 0 | 1 | 27 | MXN-0-1 | 0 | 1 | 28 29 # Initialise the parties and deposit assets 30 Given the parties deposit on asset's general account the following amount: 31 | party | asset | amount | 32 | aux1 | USD-0-1 | 1000000 | 33 | aux2 | USD-0-1 | 1000000 | 34 | aux1 | MXN-0-1 | 10000000 | 35 | aux2 | MXN-0-1 | 10000000 | 36 37 # Setup the markets 38 And the markets: 39 | 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 | 40 | BTC/USD-0-1 | USD | USD-0-1 | default-log-normal-risk-model | default-margin-calculator | 1 | default-none | default-none | default-eth-for-future | 1e-3 | 0 | default-futures | 0 | 0 | 41 | BTC/MXN-0-1 | VND | MXN-0-1 | default-log-normal-risk-model | default-margin-calculator | 1 | default-none | default-none | default-eth-for-future | 1e-3 | 0 | default-futures | 0 | 0 | 42 And the spot markets: 43 | id | name | base asset | quote asset | risk model | auction duration | fees | price monitoring | decimal places | position decimal places | sla params | 44 | MXN-0-1/USD-0-1 | MXN/USD | MXN-0-1 | USD-0-1 | default-log-normal-risk-model | 1 | default-none | default-none | 0 | 0 | default-basic | 45 | USD-0-1/MXN-0-1 | MXN/USD | USD-0-1 | MXN-0-1 | default-log-normal-risk-model | 1 | default-none | default-none | 0 | 0 | default-basic | 46 And the parties place the following orders: 47 | party | market id | side | volume | price | resulting trades | type | tif | 48 | aux1 | BTC/USD-0-1 | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | 49 | aux2 | BTC/USD-0-1 | sell | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | 50 And the parties place the following orders: 51 | party | market id | side | volume | price | resulting trades | type | tif | 52 | aux1 | BTC/MXN-0-1 | buy | 1 | 500000 | 0 | TYPE_LIMIT | TIF_GTC | 53 | aux2 | BTC/MXN-0-1 | sell | 1 | 500000 | 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 | MXN-0-1/USD-0-1 | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | 57 | aux2 | MXN-0-1/USD-0-1 | sell | 1 | 50000 | 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 | USD-0-1/MXN-0-1 | buy | 1 | 500000 | 0 | TYPE_LIMIT | TIF_GTC | 61 | aux2 | USD-0-1/MXN-0-1 | sell | 1 | 500000 | 0 | TYPE_LIMIT | TIF_GTC | 62 When the network moves ahead "2" blocks 63 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "BTC/USD-0-1" 64 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "MXN-0-1/USD-0-1" 65 66 Given the parties deposit on asset's general account the following amount: 67 | party | asset | amount | 68 | party1 | USD-0-1 | 1000000 | 69 | party2 | USD-0-1 | 1000000 | 70 | party1 | MXN-0-1 | 10000000 | 71 | party2 | MXN-0-1 | 10000000 | 72 73 74 Scenario: No program currently active, new program enacted, rebate factors applied from the start of the next epoch. 75 76 # First generate some maker volume, so in the next epoch after the program is created party1 will qualify for the rebate factor 77 Given the parties place the following orders: 78 | party | market id | side | volume | price | resulting trades | type | tif | error | 79 | party1 | <market> | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 80 | aux1 | <market> | sell | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 81 When the network moves ahead "1" blocks 82 Then the following trades should be executed: 83 | buyer | seller | size | price | aggressor side | buyer maker fee | seller maker fee | 84 | party1 | aux1 | 1 | 50000 | sell | 0 | 500 | 85 86 # Enact the new rebate program 87 Given the volume rebate program tiers named "vrt": 88 | fraction | rebate | 89 | 0.0001 | 0.001 | 90 And the volume rebate program: 91 | id | tiers | closing timestamp | window length | 92 | id | vrt | 0 | 1 | 93 94 # Move ahead to the first epoch after enactment, check party1 is receiving rebates proportional to the rebate factor 95 Given the network moves ahead "1" epochs 96 And the parties place the following orders: 97 | party | market id | side | volume | price | resulting trades | type | tif | error | 98 | party1 | <market> | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 99 | aux1 | <market> | sell | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 100 When the network moves ahead "1" blocks 101 Then the following trades should be executed: 102 | buyer | seller | size | price | aggressor side | buyer high volume maker fee | seller high volume maker fee | 103 | party1 | aux1 | 1 | 50000 | sell | 0 | 50 | 104 And the following transfers should happen: 105 | from | to | from account | to account | market id | amount | asset | type | 106 | | party1 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | <market> | 50 | USD-0-1 | TRANSFER_TYPE_HIGH_MAKER_FEE_REBATE_RECEIVE | 107 108 Examples: 109 # Check the above scenario for a derivative and spot market 110 | market | 111 | BTC/USD-0-1 | 112 | MXN-0-1/USD-0-1 | 113 114 115 Scenario: Program currently active, program update enacted, rebate factors applied from the start of the next epoch. 116 117 # Enact the original referral program and move to the first epoch after enactment 118 Given the volume rebate program tiers named "vrt": 119 | fraction | rebate | 120 | 0.0001 | 0.001 | 121 And the volume rebate program: 122 | id | tiers | closing timestamp | window length | 123 | id | vrt | 0 | 1 | 124 And the network moves ahead "1" epochs 125 126 # First generate some maker volume, so in the next epoch party1 will qualify for the rebate factor 127 Given the parties place the following orders: 128 | party | market id | side | volume | price | resulting trades | type | tif | error | 129 | party1 | <market> | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 130 | aux1 | <market> | sell | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 131 When the network moves ahead "1" blocks 132 Then the following trades should be executed: 133 | buyer | seller | size | price | aggressor side | buyer maker fee | seller maker fee | 134 | party1 | aux1 | 1 | 50000 | sell | 0 | 500 | 135 136 # Move ahead an epoch so factors updated, check party1 is receiving rebates proportional to the rebate factor 137 Given the network moves ahead "1" epochs 138 And the parties place the following orders: 139 | party | market id | side | volume | price | resulting trades | type | tif | error | 140 | party1 | <market> | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 141 | aux1 | <market> | sell | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 142 When the network moves ahead "1" blocks 143 Then the following trades should be executed: 144 | buyer | seller | size | price | aggressor side | buyer high volume maker fee | seller high volume maker fee | 145 | party1 | aux1 | 1 | 50000 | sell | 0 | 50 | 146 And the following transfers should happen: 147 | from | to | from account | to account | market id | amount | asset | type | 148 | | party1 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | <market> | 50 | USD-0-1 | TRANSFER_TYPE_HIGH_MAKER_FEE_REBATE_RECEIVE | 149 150 # Enact an update to the rebate program - doubling the rebates 151 Given the volume rebate program tiers named "vrt": 152 | fraction | rebate | 153 | 0.0001 | 0.002 | 154 And the volume rebate program: 155 | id | tiers | closing timestamp | window length | 156 | id | vrt | 0 | 1 | 157 158 # Before moving to the next epoch, check party1 is still receiving rebates proportional to the original rebate factor 159 Given the parties place the following orders: 160 | party | market id | side | volume | price | resulting trades | type | tif | error | 161 | party1 | <market> | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 162 | aux1 | <market> | sell | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 163 When the network moves ahead "1" blocks 164 Then the following trades should be executed: 165 | buyer | seller | size | price | aggressor side | buyer high volume maker fee | seller high volume maker fee | 166 | party1 | aux1 | 1 | 50000 | sell | 0 | 50 | 167 And the following transfers should happen: 168 | from | to | from account | to account | market id | amount | asset | type | 169 | | party1 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | <market> | 50 | USD-0-1 | TRANSFER_TYPE_HIGH_MAKER_FEE_REBATE_RECEIVE | 170 171 # Move to the first epoch after program update, check party1 is now receiving rebates proportional to the updated rebate factor 172 Given the network moves ahead "1" epochs 173 And the parties place the following orders: 174 | party | market id | side | volume | price | resulting trades | type | tif | error | 175 | party1 | <market> | buy | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 176 | aux1 | <market> | sell | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 177 When the network moves ahead "1" blocks 178 Then the following trades should be executed: 179 | buyer | seller | size | price | aggressor side | buyer high volume maker fee | seller high volume maker fee | 180 | party1 | aux1 | 1 | 50000 | sell | 0 | 100 | 181 And the following transfers should happen: 182 | from | to | from account | to account | market id | amount | asset | type | 183 | | party1 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | <market> | 100 | USD-0-1 | TRANSFER_TYPE_HIGH_MAKER_FEE_REBATE_RECEIVE | 184 185 Examples: 186 # Check the above scenario for a derivative and spot market 187 | market | 188 | BTC/USD-0-1 | 189 | MXN-0-1/USD-0-1 |