code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/enactment_RFPR.feature (about) 1 Feature: Referral program - program enactment 2 3 Referral program rewards sets who comprise above a specified 4 taker volume with a discount on all of their members fees. 5 6 Tests check on program enactment party benefit factors are updated 7 correctly and applied in the next epoch. 8 9 Background: 10 11 # Initialise the network and register the assets 12 Given the average block duration is "1" 13 And the following network parameters are set: 14 | name | value | 15 | market.fee.factors.makerFee | 0.01 | 16 | market.fee.factors.infrastructureFee | 0.01 | 17 | market.fee.factors.treasuryFee | 0.1 | 18 | market.fee.factors.buybackFee | 0.1 | 19 | network.markPriceUpdateMaximumFrequency | 0s | 20 | validators.epoch.length | 20s | 21 | market.auction.minimumDuration | 1 | 22 | referralProgram.maxPartyNotionalVolumeByQuantumPerEpoch | 1000000000 | 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 | referrer | USD-0-1 | 10000000 | 69 | referrer | USD-0-1 | 10000000 | 70 | party1 | USD-0-1 | 10000000 | 71 | party1 | MXN-0-1 | 10000000 | 72 And the parties create the following referral codes: 73 | party | code | is_team | team | 74 | referrer | referral-code-1 | true | team1 | 75 And the parties apply the following referral codes: 76 | party | code | is_team | team | 77 | party1 | referral-code-1 | true | team1 | 78 79 80 Scenario: No program currently active, new program enacted, benefit factors applied from the start of the next epoch. 81 82 # First generate some taker volume, so in the next epoch after the program is created party1 will qualify for benefit factors 83 Given the parties place the following orders: 84 | party | market id | side | volume | price | resulting trades | type | tif | error | 85 | aux1 | <market> | sell | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 86 | party1 | <market> | buy | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 87 When the network moves ahead "1" blocks 88 Then the following trades should be executed: 89 | buyer | seller | size | price | aggressor side | buyer maker fee | buyer infrastructure fee | 90 | party1 | aux1 | 1 | 50000 | buy | 500 | 500 | 91 92 # Enact the new referral program 93 Given the referral benefit tiers "rbt": 94 | minimum running notional taker volume | minimum epochs | referral reward infra factor | referral reward maker factor | referral reward liquidity factor | referral discount infra factor | referral discount maker factor | referral discount liquidity factor | 95 | 1 | 0 | 0.1 | 0.1 | 0.1 | 0.1 | 0.1 | 0.1 | 96 And the referral staking tiers "rst": 97 | minimum staked tokens | referral reward multiplier | 98 | 1 | 1 | 99 And the referral program: 100 | end of program | window length | benefit tiers | staking tiers | 101 | 2023-12-12T12:12:12Z | 10 | rbt | rst | 102 103 # Move ahead to the first epoch after enactment, check party1 is receiving discounts proportional to the benefit factors 104 Given the network moves ahead "1" epochs 105 And the parties place the following orders: 106 | party | market id | side | volume | price | resulting trades | type | tif | error | 107 | aux1 | <market> | sell | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 108 | party1 | <market> | buy | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 109 When the network moves ahead "1" blocks 110 Then the following trades should be executed: 111 | buyer | seller | size | price | aggressor side | buyer maker fee | buyer infrastructure fee | buyer maker fee referrer discount | buyer infrastructure fee referrer discount | 112 | party1 | aux1 | 1 | 50000 | buy | 450 | 450 | 50 | 50 | 113 114 Examples: 115 # Check the above scenario for a derivative and spot market 116 | market | 117 | BTC/USD-0-1 | 118 | MXN-0-1/USD-0-1 | 119 120 121 Scenario: Program currently active, program update enacted, benefit factors applied from the start of the next epoch. 122 123 # Enact the original referral program and move to the first epoch after enactment 124 Given the referral benefit tiers "rbt": 125 | minimum running notional taker volume | minimum epochs | referral reward infra factor | referral reward maker factor | referral reward liquidity factor | referral discount infra factor | referral discount maker factor | referral discount liquidity factor | 126 | 2000 | 1 | 0.1 | 0.1 | 0.1 | 0.1 | 0.1 | 0.1 | 127 And the referral staking tiers "rst": 128 | minimum staked tokens | referral reward multiplier | 129 | 1 | 1 | 130 And the referral program: 131 | end of program | window length | benefit tiers | staking tiers | 132 | 2023-12-12T12:12:12Z | 7 | rbt | rst | 133 And the network moves ahead "1" epochs 134 135 # First generate some taker volume, so in the next epoch party1 will qualify for the benefit factors 136 Given the parties place the following orders: 137 | party | market id | side | volume | price | resulting trades | type | tif | error | 138 | aux1 | <market> | sell | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 139 | party1 | <market> | buy | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 140 When the network moves ahead "1" blocks 141 Then the following trades should be executed: 142 | buyer | seller | size | price | aggressor side | buyer maker fee | buyer infrastructure fee | 143 | party1 | aux1 | 1 | 50000 | buy | 500 | 500 | 144 145 # Move ahead an epoch so factors updated, check party1 is receiving discounts proportional to the benefit factors 146 Given the network moves ahead "2" epochs 147 And the parties place the following orders: 148 | party | market id | side | volume | price | resulting trades | type | tif | error | 149 | aux1 | <market> | sell | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 150 | party1 | <market> | buy | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 151 When the network moves ahead "1" blocks 152 Then the following trades should be executed: 153 | buyer | seller | size | price | aggressor side | buyer maker fee | buyer infrastructure fee | buyer maker fee referrer discount | buyer infrastructure fee referrer discount | 154 | party1 | aux1 | 1 | 50000 | buy | 450 | 450 | 50 | 50 | 155 156 # Enact an update to the referral program - doubling the discounts 157 Given the referral benefit tiers "rbt": 158 | minimum running notional taker volume | minimum epochs | referral reward infra factor | referral reward maker factor | referral reward liquidity factor | referral discount infra factor | referral discount maker factor | referral discount liquidity factor | 159 | 1 | 0 | 0.2 | 0.2 | 0.2 | 0.2 | 0.2 | 0.2 | 160 And the referral staking tiers "rst": 161 | minimum staked tokens | referral reward multiplier | 162 | 1 | 1 | 163 And the referral program: 164 | end of program | window length | benefit tiers | staking tiers | 165 | 2023-12-12T12:12:12Z | 1 | rbt | rst | 166 167 # Before moving to the next epoch, check party1 is still receiving discounts proportional to the original benefit factor 168 Given the parties place the following orders: 169 | party | market id | side | volume | price | resulting trades | type | tif | error | 170 | aux1 | <market> | sell | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 171 | party1 | <market> | buy | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 172 When the network moves ahead "1" blocks 173 Then the following trades should be executed: 174 | buyer | seller | size | price | aggressor side | buyer maker fee | buyer infrastructure fee | buyer maker fee referrer discount | buyer infrastructure fee referrer discount | 175 | party1 | aux1 | 1 | 50000 | buy | 450 | 450 | 50 | 50 | 176 177 # Move to the first epoch after program update, check party1 is now receiving discounts proportional to the updated benefit factor 178 Given the network moves ahead "1" epochs 179 And the parties place the following orders: 180 | party | market id | side | volume | price | resulting trades | type | tif | error | 181 | aux1 | <market> | sell | 1 | 50000 | 0 | TYPE_LIMIT | TIF_GTC | | 182 | party1 | <market> | buy | 1 | 50000 | 1 | TYPE_LIMIT | TIF_GTC | | 183 When the network moves ahead "1" blocks 184 And the following trades should be executed: 185 | buyer | seller | size | price | aggressor side | buyer maker fee | buyer infrastructure fee | buyer maker fee referrer discount | buyer infrastructure fee referrer discount | 186 | party1 | aux1 | 1 | 50000 | buy | 400 | 400 | 100 | 100 | 187 188 Examples: 189 # Check the above scenario for a derivative and spot market 190 | market | 191 | BTC/USD-0-1 | 192 | MXN-0-1/USD-0-1 |