code.vegaprotocol.io/vega@v0.79.0/core/integration/features/0084-VDPR-012.feature (about) 1 Feature: At the start of an epoch, each parties volume_discount_factor is reevaluated and fixed for the epoch (0084-VDPR-012). 2 3 Background: 4 5 Given the margin calculator named "margin-calculator-1": 6 | search factor | initial factor | release factor | 7 | 1.2 | 1.5 | 1.7 | 8 Given the log normal risk model named "log-normal-risk-model": 9 | risk aversion | tau | mu | r | sigma | 10 | 0.000001 | 0.1 | 0 | 0 | 1.0 | 11 12 Given the liquidity monitoring parameters: 13 | name | triggering ratio | time window | scaling factor | 14 | lqm-params | 1.0 | 20s | 1.0 | 15 16 And the following network parameters are set: 17 | name | value | 18 | market.value.windowLength | 60s | 19 | network.markPriceUpdateMaximumFrequency | 0s | 20 | limits.markets.maxPeggedOrders | 6 | 21 | market.auction.minimumDuration | 1 | 22 23 24 #risk factor short:3.5569036 25 #risk factor long:0.801225765 26 And the volume discount program tiers named "VDP-01": 27 | volume | infra factor | liquidity factor | maker factor | 28 | 1000 | 0.001 | 0.002 | 0.003 | 29 | 2000 | 0.005 | 0.006 | 0.007 | 30 | 3000 | 0.010 | 0.012 | 0.014 | 31 And the volume discount program: 32 | id | tiers | closing timestamp | window length | 33 | id1 | VDP-01 | 0 | 4 | 34 35 And the following assets are registered: 36 | id | decimal places | 37 | ETH | 0 | 38 And the fees configuration named "fees-config-1": 39 | maker fee | infrastructure fee | liquidity fee method | liquidity fee constant | 40 | 0.0004 | 0.001 | METHOD_CONSTANT | 0 | 41 42 And the fees configuration named "fees-config-2": 43 | maker fee | infrastructure fee | liquidity fee method | liquidity fee constant | buy back fee | treasury fee | 44 | 0 | 0 | METHOD_CONSTANT | 0.1 | 0.001 | 0.002 | 45 46 And the price monitoring named "price-monitoring": 47 | horizon | probability | auction extension | 48 | 3600 | 0.99 | 3 | 49 50 And the liquidity sla params named "SLA-22": 51 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 52 | 0.5 | 0.6 | 1 | 1.0 | 53 54 And the following network parameters are set: 55 | name | value | 56 | market.liquidity.bondPenaltyParameter | 0.2 | 57 | validators.epoch.length | 5s | 58 | market.liquidity.stakeToCcyVolume | 1 | 59 | market.liquidity.successorLaunchWindowLength | 1h | 60 | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0.7 | 61 | market.liquidity.sla.nonPerformanceBondPenaltyMax | 0.6 | 62 | validators.epoch.length | 10s | 63 | market.liquidity.earlyExitPenalty | 0.25 | 64 65 Given the average block duration is "1" 66 @Now 67 Scenario: 001: Check that the volume discount factor is updated after each epoch 68 Given the markets: 69 | id | quote name | asset | liquidity monitoring | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | 70 | ETH/MAR24 | ETH | ETH | lqm-params | log-normal-risk-model | margin-calculator-1 | 2 | fees-config-1 | price-monitoring | default-eth-for-future | 1e0 | 0 | SLA-22 | 71 72 Given the parties deposit on asset's general account the following amount: 73 | party | asset | amount | 74 | lp1 | ETH | 10000000 | 75 | party1 | ETH | 10000000 | 76 | party2 | ETH | 10000000 | 77 | party3 | ETH | 10000000 | 78 79 And the parties submit the following liquidity provision: 80 | id | party | market id | commitment amount | fee | lp type | 81 | lp_1 | lp1 | ETH/MAR24 | 100000 | 0.02 | submission | 82 83 Then the parties place the following orders: 84 | party | market id | side | volume | price | resulting trades | type | tif | 85 | party1 | ETH/MAR24 | buy | 10 | 900 | 0 | TYPE_LIMIT | TIF_GTC | 86 | party1 | ETH/MAR24 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 87 | lp1 | ETH/MAR24 | buy | 100 | 990 | 0 | TYPE_LIMIT | TIF_GTC | 88 | lp1 | ETH/MAR24 | sell | 100 | 1010 | 0 | TYPE_LIMIT | TIF_GTC | 89 | party2 | ETH/MAR24 | sell | 10 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | 90 | party2 | ETH/MAR24 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 91 92 Then the opening auction period ends for market "ETH/MAR24" 93 And the following trades should be executed: 94 | buyer | price | size | seller | 95 | party1 | 1000 | 1 | party2 | 96 And the market data for the market "ETH/MAR24" should be: 97 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 98 | 1000 | TRADING_MODE_CONTINUOUS | 3600 | 973 | 1027 | 3556 | 100000 | 1 | 99 And the party "party3" has the following discount infra factor "0" 100 101 Then the parties place the following orders: 102 | party | market id | side | volume | price | resulting trades | type | tif | 103 | party3 | ETH/MAR24 | buy | 1 | 0 | 1 | TYPE_MARKET | TIF_IOC | 104 | party3 | ETH/MAR24 | sell | 1 | 0 | 1 | TYPE_MARKET | TIF_IOC | 105 When the network moves ahead "1" epochs 106 And the party "party3" has the following discount infra factor "0.005" 107 And the party "party3" has the following discount liquidity factor "0.006" 108 And the party "party3" has the following discount maker factor "0.007" 109 110 Then the parties place the following orders: 111 | party | market id | side | volume | price | resulting trades | type | tif | 112 | party3 | ETH/MAR24 | buy | 20 | 0 | 1 | TYPE_MARKET | TIF_IOC | 113 | party3 | ETH/MAR24 | sell | 20 | 0 | 1 | TYPE_MARKET | TIF_IOC | 114 When the network moves ahead "1" epochs 115 And the party "party3" has the following discount infra factor "0.01" 116 And the party "party3" has the following discount liquidity factor "0.012" 117 And the party "party3" has the following discount maker factor "0.014" 118 119 # when trade_value_for_fee_purposes>0, then total fee should be maker_fee_after_referral_discount+ treasury_fee + buyback_fee when fee_factor[infrastructure] = 0, fee_factor[liquidity] = 0 (0083-RFPR-053) 120 # now lets reset the infra fee to 0 and do a trade with party 3: 121 And the following network parameters are set: 122 | name | value | 123 | market.fee.factors.makerFee | 0.1 | 124 | market.fee.factors.infrastructureFee | 0 | 125 | market.fee.factors.buybackFee | 0.001 | 126 | market.fee.factors.treasuryFee | 0.002 | 127 128 Then the parties place the following orders: 129 | party | market id | side | volume | price | resulting trades | type | tif | 130 | party3 | ETH/MAR24 | sell | 11 | 0 | 1 | TYPE_MARKET | TIF_IOC | 131 132 # trade value is 11*990 = 10,890 133 # infra fee is set to 0 134 # liquidity fee is set to 0 135 # maker fee before discount = 10,890 * 0.1 => 1089 136 # maker fee discount = 1089*0.014 => 15 137 # maker fee after discount = 1089-15=1074 138 # buyback = 11 139 # treasury = 22 140 # total = 1074 + 33 141 And the following trades should be executed: 142 | seller | price | size | buyer | seller fee | seller infrastructure fee | seller liquidity fee | seller maker fee | seller infrastructure fee volume discount | seller liquidity fee volume discount | seller maker fee volume discount | 143 | party3 | 990 | 11 | lp1 | 1107 | 0 | 0 | 1074 | 0 | 0 | 15 | 144 145 # when trade_value_for_fee_purposes>0, then total fee should be infrastructure_fee_after_referral_discount+ treasury_fee + buyback_fee when fee_factor[maker] = 0, fee_factor[liquidity] = 0 (0083-RFPR-055) 146 # now lets reset the maker fee to 0 and do a trade with party 3: 147 And the following network parameters are set: 148 | name | value | 149 | market.fee.factors.makerFee | 0 | 150 | market.fee.factors.infrastructureFee | 0.2 | 151 152 # trade value is 11*990 = 10,890 153 # maker fee is set to 0 154 # liquidity fee is set to 0 155 # infra fee before discount = 10,890 * 0.2 => 2178 156 # infra fee discount = 2178*0.01 => 21 157 # infra fee after discount = 2178-21=2157 158 # buyback = 11 159 # treasury = 22 160 # total = 2157 + 33 161 Then the parties place the following orders: 162 | party | market id | side | volume | price | resulting trades | type | tif | 163 | party3 | ETH/MAR24 | sell | 11 | 0 | 1 | TYPE_MARKET | TIF_IOC | 164 165 And the following trades should be executed: 166 | seller | price | size | buyer | seller fee | seller infrastructure fee | seller liquidity fee | seller maker fee | seller infrastructure fee volume discount | seller liquidity fee volume discount | seller maker fee volume discount | 167 | party3 | 990 | 11 | lp1 | 2190 | 2157 | 0 | 0 | 21 | 0 | 0 | 168 169 170 @Now 171 Scenario: when trade_value_for_fee_purposes>0, then total fee should be liquidity_fee_after_referral_discount+ treasury_fee + buyback_fee when fee_factor[maker] = 0, fee_factor[infrastructure] = 0 (0083-RFPR-054) 172 Given the markets: 173 | id | quote name | asset | liquidity monitoring | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | 174 | ETH/MAR24 | ETH | ETH | lqm-params | log-normal-risk-model | margin-calculator-1 | 2 | fees-config-2 | price-monitoring | default-eth-for-future | 1e0 | 0 | SLA-22 | 175 176 Given the parties deposit on asset's general account the following amount: 177 | party | asset | amount | 178 | lp1 | ETH | 10000000 | 179 | party1 | ETH | 10000000 | 180 | party2 | ETH | 10000000 | 181 | party3 | ETH | 10000000 | 182 183 And the parties submit the following liquidity provision: 184 | id | party | market id | commitment amount | fee | lp type | 185 | lp_1 | lp1 | ETH/MAR24 | 100000 | 0.02 | submission | 186 187 Then the parties place the following orders: 188 | party | market id | side | volume | price | resulting trades | type | tif | 189 | party1 | ETH/MAR24 | buy | 10 | 900 | 0 | TYPE_LIMIT | TIF_GTC | 190 | party1 | ETH/MAR24 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 191 | lp1 | ETH/MAR24 | buy | 100 | 990 | 0 | TYPE_LIMIT | TIF_GTC | 192 | lp1 | ETH/MAR24 | sell | 100 | 1010 | 0 | TYPE_LIMIT | TIF_GTC | 193 | party2 | ETH/MAR24 | sell | 10 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | 194 | party2 | ETH/MAR24 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 195 196 Then the opening auction period ends for market "ETH/MAR24" 197 And the following trades should be executed: 198 | buyer | price | size | seller | 199 | party1 | 1000 | 1 | party2 | 200 And the market data for the market "ETH/MAR24" should be: 201 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 202 | 1000 | TRADING_MODE_CONTINUOUS | 3600 | 973 | 1027 | 3556 | 100000 | 1 | 203 And the party "party3" has the following discount infra factor "0" 204 205 Then the parties place the following orders: 206 | party | market id | side | volume | price | resulting trades | type | tif | 207 | party3 | ETH/MAR24 | buy | 1 | 0 | 1 | TYPE_MARKET | TIF_IOC | 208 | party3 | ETH/MAR24 | sell | 1 | 0 | 1 | TYPE_MARKET | TIF_IOC | 209 When the network moves ahead "1" epochs 210 And the party "party3" has the following discount infra factor "0.005" 211 And the party "party3" has the following discount liquidity factor "0.006" 212 And the party "party3" has the following discount maker factor "0.007" 213 214 Then the parties place the following orders: 215 | party | market id | side | volume | price | resulting trades | type | tif | 216 | party3 | ETH/MAR24 | buy | 20 | 0 | 1 | TYPE_MARKET | TIF_IOC | 217 | party3 | ETH/MAR24 | sell | 20 | 0 | 1 | TYPE_MARKET | TIF_IOC | 218 When the network moves ahead "1" epochs 219 And the party "party3" has the following discount infra factor "0.01" 220 And the party "party3" has the following discount liquidity factor "0.012" 221 And the party "party3" has the following discount maker factor "0.014" 222 223 Then the parties place the following orders: 224 | party | market id | side | volume | price | resulting trades | type | tif | 225 | party3 | ETH/MAR24 | sell | 11 | 0 | 1 | TYPE_MARKET | TIF_IOC | 226 227 # trade value is 11*990 = 10,890 228 # infra fee is set to 0 229 # maker fee is set to 0 230 # liquidity fee before discount = 10,890 * 0.1 => 1089 231 # liquidity fee discount = 1089*0.012 => 13 232 # liquidity fee after discount = 1089-15=1076 233 # buyback = 11 234 # treasury = 22 235 # total = 1076 + 33 236 And the following trades should be executed: 237 | seller | price | size | buyer | seller fee | seller infrastructure fee | seller liquidity fee | seller maker fee | seller infrastructure fee volume discount | seller liquidity fee volume discount | seller maker fee volume discount | 238 | party3 | 990 | 11 | lp1 | 1109 | 0 | 1076 | 0 | 0 | 13 | 0 | 239