code.vegaprotocol.io/vega@v0.79.0/core/integration/features/spot/liquidity_provision/0042-LIQF-marginal_cost.feature (about) 1 Feature: Marginal cost liquidity fee selection for spot markets 2 3 Background: 4 5 # Initialise the network and register assets 6 Given time is updated to "2024-01-01T00:00:00Z" 7 And the following network parameters are set: 8 | name | value | 9 | market.liquidity.earlyExitPenalty | 0 | 10 | market.liquidity.sla.nonPerformanceBondPenaltyMax | 0 | 11 And the following assets are registered: 12 | id | decimal places | quantum | 13 | USDT.0.1 | 0 | 1 | 14 | BTC.0.1 | 0 | 1 | 15 And the average block duration is "1" 16 17 # Initialise the zero and non-zero decimal places spot markets 18 And the spot markets: 19 | id | name | base asset | quote asset | risk model | auction duration | fees | price monitoring | decimal places | position decimal places | sla params | 20 | BTC/USDT | BTC/USDT | BTC.0.1 | USDT.0.1 | default-log-normal-risk-model | 1 | default-none | default-none | 0 | 0 | default-basic | 21 22 # Deposits for assets with zero decimal places 23 Given the parties deposit on asset's general account the following amount: 24 | party | asset | amount | 25 | lp1 | USDT.0.1 | 10000000 | 26 | lp2 | USDT.0.1 | 10000000 | 27 | lp3 | USDT.0.1 | 10000000 | 28 | aux1 | USDT.0.1 | 10000000 | 29 | aux2 | USDT.0.1 | 10000000 | 30 Given the parties deposit on asset's general account the following amount: 31 | party | asset | amount | 32 | aux1 | BTC.0.1 | 10000 | 33 | aux2 | BTC.0.1 | 10000 | 34 35 36 Scenario: An LP joining a market that is below the target stake with a higher fee bid than the current fee: their fee is used (0042-LIQF-073) 37 38 # Set the target stake time window to five epochs 39 Given the following network parameters are set: 40 | name | value | 41 | validators.epoch.length | 10s | 42 And the liquidity monitoring parameters: 43 | name | triggering ratio | scaling factor | time window | 44 | lqm-params | 1.0 | 1 | 50s | 45 And the spot markets are updated: 46 | id | liquidity monitoring | 47 | BTC/USDT | lqm-params | 48 49 Given the parties submit the following liquidity provision: 50 | id | party | market id | commitment amount | fee | lp type | 51 | lp1 | lp1 | BTC/USDT | 10000 | 0.01 | submission | 52 | lp2 | lp2 | BTC/USDT | 10000 | 0.02 | submission | 53 When the parties place the following orders: 54 | party | market id | side | volume | price | resulting trades | type | tif | 55 | aux1 | BTC/USDT | buy | 10 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | 56 | aux2 | BTC/USDT | sell | 10 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | 57 And the network moves ahead "2" blocks 58 Then the market data for the market "BTC/USDT" should be: 59 | trading mode | target stake | supplied stake | 60 | TRADING_MODE_CONTINUOUS | 20000 | 20000 | 61 62 Given the parties submit the following liquidity provision: 63 | id | party | market id | commitment amount | fee | lp type | 64 | lp1 | lp1 | BTC/USDT | 1000 | 0.01 | amendment | 65 | lp2 | lp2 | BTC/USDT | 1000 | 0.02 | amendment | 66 When the network moves ahead "1" epochs 67 Then the market data for the market "BTC/USDT" should be: 68 | trading mode | target stake | supplied stake | 69 | TRADING_MODE_CONTINUOUS | 20000 | 2000 | 70 And the liquidity fee factor should be "0.02" for the market "BTC/USDT" 71 72 Given the parties submit the following liquidity provision: 73 | id | party | market id | commitment amount | fee | lp type | 74 | lp3 | lp3 | BTC/USDT | 1000 | 0.03 | submission | 75 When the network moves ahead "1" epochs 76 Then the market data for the market "BTC/USDT" should be: 77 | trading mode | target stake | supplied stake | 78 | TRADING_MODE_CONTINUOUS | 20000 | 3000 | 79 And the liquidity fee factor should be "0.03" for the market "BTC/USDT" 80 81 82 Scenario: An LP joining a market that is below the target stake with a lower fee bid than the current fee: fee doesn't change (0042-LIQF-074) 83 84 # Set the target stake time window to five epochs 85 Given the following network parameters are set: 86 | name | value | 87 | validators.epoch.length | 10s | 88 And the liquidity monitoring parameters: 89 | name | triggering ratio | scaling factor | time window | 90 | lqm-params | 1.0 | 1 | 50s | 91 And the spot markets are updated: 92 | id | liquidity monitoring | 93 | BTC/USDT | lqm-params | 94 95 Given the parties submit the following liquidity provision: 96 | id | party | market id | commitment amount | fee | lp type | 97 | lp1 | lp1 | BTC/USDT | 10000 | 0.01 | submission | 98 | lp2 | lp2 | BTC/USDT | 10000 | 0.02 | submission | 99 When the parties place the following orders: 100 | party | market id | side | volume | price | resulting trades | type | tif | 101 | aux1 | BTC/USDT | buy | 10 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | 102 | aux2 | BTC/USDT | sell | 10 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | 103 And the network moves ahead "2" blocks 104 Then the market data for the market "BTC/USDT" should be: 105 | trading mode | target stake | supplied stake | 106 | TRADING_MODE_CONTINUOUS | 20000 | 20000 | 107 108 Given the parties submit the following liquidity provision: 109 | id | party | market id | commitment amount | fee | lp type | 110 | lp1 | lp1 | BTC/USDT | 1000 | 0.01 | amendment | 111 | lp2 | lp2 | BTC/USDT | 1000 | 0.02 | amendment | 112 When the network moves ahead "1" epochs 113 Then the market data for the market "BTC/USDT" should be: 114 | trading mode | target stake | supplied stake | 115 | TRADING_MODE_CONTINUOUS | 20000 | 2000 | 116 And the liquidity fee factor should be "0.02" for the market "BTC/USDT" 117 118 Given the parties submit the following liquidity provision: 119 | id | party | market id | commitment amount | fee | lp type | 120 | lp3 | lp3 | BTC/USDT | 1000 | 0 | submission | 121 When the network moves ahead "1" epochs 122 Then the market data for the market "BTC/USDT" should be: 123 | trading mode | target stake | supplied stake | 124 | TRADING_MODE_CONTINUOUS | 20000 | 3000 | 125 And the liquidity fee factor should be "0.02" for the market "BTC/USDT" 126 127 128 Scenario: An LP joining a market that is above the target stake with a sufficiently large commitment to push ALL higher bids above the target stake and a lower fee bid than the current fee: their fee is used (0042-LIQF-075) 129 130 # Set the target stake time window to five epochs 131 Given the following network parameters are set: 132 | name | value | 133 | validators.epoch.length | 10s | 134 And the liquidity monitoring parameters: 135 | name | triggering ratio | scaling factor | time window | 136 | lqm-params | 1.0 | 0.5 | 50s | 137 And the spot markets are updated: 138 | id | liquidity monitoring | 139 | BTC/USDT | lqm-params | 140 141 Given the parties submit the following liquidity provision: 142 | id | party | market id | commitment amount | fee | lp type | 143 | lp1 | lp1 | BTC/USDT | 10000 | 0.01 | submission | 144 | lp2 | lp2 | BTC/USDT | 10000 | 0.02 | submission | 145 When the parties place the following orders: 146 | party | market id | side | volume | price | resulting trades | type | tif | 147 | aux1 | BTC/USDT | buy | 10 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | 148 | aux2 | BTC/USDT | sell | 10 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | 149 And the network moves ahead "2" blocks 150 Then the market data for the market "BTC/USDT" should be: 151 | trading mode | target stake | supplied stake | 152 | TRADING_MODE_CONTINUOUS | 10000 | 20000 | 153 154 Given the parties submit the following liquidity provision: 155 | id | party | market id | commitment amount | fee | lp type | 156 | lp3 | lp3 | BTC/USDT | 30000 | 0 | submission | 157 When the network moves ahead "1" epochs 158 Then the market data for the market "BTC/USDT" should be: 159 | trading mode | target stake | supplied stake | 160 | TRADING_MODE_CONTINUOUS | 25000 | 50000 | 161 And the liquidity fee factor should be "0" for the market "BTC/USDT" 162 163 164 Scenario: An LP joining a market that is above the target stake with a commitment not large enough to push any higher bids above the target stake, and a lower fee bid than the current fee: the fee doesn't change (0042-LIQF-076) 165 166 # Set the target stake time window to five epochs 167 Given the following network parameters are set: 168 | name | value | 169 | validators.epoch.length | 10s | 170 And the liquidity monitoring parameters: 171 | name | triggering ratio | scaling factor | time window | 172 | lqm-params | 1.0 | 0.8 | 50s | 173 And the spot markets are updated: 174 | id | liquidity monitoring | 175 | BTC/USDT | lqm-params | 176 177 Given the parties submit the following liquidity provision: 178 | id | party | market id | commitment amount | fee | lp type | 179 | lp1 | lp1 | BTC/USDT | 10000 | 0.01 | submission | 180 | lp2 | lp2 | BTC/USDT | 10000 | 0.02 | submission | 181 When the parties place the following orders: 182 | party | market id | side | volume | price | resulting trades | type | tif | 183 | aux1 | BTC/USDT | buy | 10 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | 184 | aux2 | BTC/USDT | sell | 10 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | 185 And the network moves ahead "2" blocks 186 Then the market data for the market "BTC/USDT" should be: 187 | trading mode | target stake | supplied stake | 188 | TRADING_MODE_CONTINUOUS | 16000 | 20000 | 189 And the liquidity fee factor should be "0.02" for the market "BTC/USDT" 190 191 Given the parties submit the following liquidity provision: 192 | id | party | market id | commitment amount | fee | lp type | 193 | lp3 | lp3 | BTC/USDT | 10000 | 0 | submission | 194 When the network moves ahead "1" epochs 195 Then the market data for the market "BTC/USDT" should be: 196 | trading mode | target stake | supplied stake | 197 | TRADING_MODE_CONTINUOUS | 24000 | 30000 | 198 And the liquidity fee factor should be "0.02" for the market "BTC/USDT" 199 200 201 Scenario: An LP joining a market that is above the target stake with a commitment large enough to push one of two higher bids above the target stake, and a lower fee bid than the current fee: the fee changes to the other lower bid (0042-LIQF-077) 202 203 # Set the target stake time window to five epochs 204 Given the following network parameters are set: 205 | name | value | 206 | validators.epoch.length | 10s | 207 And the liquidity monitoring parameters: 208 | name | triggering ratio | scaling factor | time window | 209 | lqm-params | 1.0 | 0.6 | 50s | 210 And the spot markets are updated: 211 | id | liquidity monitoring | 212 | BTC/USDT | lqm-params | 213 214 Given the parties submit the following liquidity provision: 215 | id | party | market id | commitment amount | fee | lp type | 216 | lp1 | lp1 | BTC/USDT | 10000 | 0.01 | submission | 217 | lp2 | lp2 | BTC/USDT | 10000 | 0.02 | submission | 218 When the parties place the following orders: 219 | party | market id | side | volume | price | resulting trades | type | tif | 220 | aux1 | BTC/USDT | buy | 10 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | 221 | aux2 | BTC/USDT | sell | 10 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | 222 And the network moves ahead "2" blocks 223 Then the market data for the market "BTC/USDT" should be: 224 | trading mode | target stake | supplied stake | 225 | TRADING_MODE_CONTINUOUS | 12000 | 20000 | 226 And the liquidity fee factor should be "0.02" for the market "BTC/USDT" 227 228 Given the parties submit the following liquidity provision: 229 | id | party | market id | commitment amount | fee | lp type | 230 | lp3 | lp3 | BTC/USDT | 10000 | 0 | submission | 231 When the network moves ahead "1" epochs 232 Then the market data for the market "BTC/USDT" should be: 233 | trading mode | target stake | supplied stake | 234 | TRADING_MODE_CONTINUOUS | 18000 | 30000 | 235 And the liquidity fee factor should be "0.01" for the market "BTC/USDT" 236 237 238 Scenario: An LP joining a market that is above the target stake with a commitment large enough to push one of two higher bids above the target stake, and a higher fee bid than the current fee: the fee doesn't change (0042-LIQF-078) 239 240 # Set the target stake time window to five epochs 241 Given the following network parameters are set: 242 | name | value | 243 | validators.epoch.length | 10s | 244 And the liquidity monitoring parameters: 245 | name | triggering ratio | scaling factor | time window | 246 | lqm-params | 1.0 | 0.6 | 50s | 247 And the spot markets are updated: 248 | id | liquidity monitoring | 249 | BTC/USDT | lqm-params | 250 251 Given the parties submit the following liquidity provision: 252 | id | party | market id | commitment amount | fee | lp type | 253 | lp1 | lp1 | BTC/USDT | 10000 | 0.01 | submission | 254 | lp2 | lp2 | BTC/USDT | 10000 | 0.02 | submission | 255 When the parties place the following orders: 256 | party | market id | side | volume | price | resulting trades | type | tif | 257 | aux1 | BTC/USDT | buy | 10 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | 258 | aux2 | BTC/USDT | sell | 10 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | 259 And the network moves ahead "2" blocks 260 Then the market data for the market "BTC/USDT" should be: 261 | trading mode | target stake | supplied stake | 262 | TRADING_MODE_CONTINUOUS | 12000 | 20000 | 263 And the liquidity fee factor should be "0.02" for the market "BTC/USDT" 264 265 Given the parties submit the following liquidity provision: 266 | id | party | market id | commitment amount | fee | lp type | 267 | lp3 | lp3 | BTC/USDT | 10000 | 0.03 | submission | 268 When the network moves ahead "1" epochs 269 Then the market data for the market "BTC/USDT" should be: 270 | trading mode | target stake | supplied stake | 271 | TRADING_MODE_CONTINUOUS | 18000 | 30000 | 272 And the liquidity fee factor should be "0.02" for the market "BTC/USDT" 273 274 275 Scenario: An LP leaves a market that is above target stake when their fee bid is currently being used: fee changes to fee bid by the LP who takes their place in the bidding order (0042-LIQF-079) 276 277 # Set the target stake time window to five epochs 278 Given the following network parameters are set: 279 | name | value | 280 | validators.epoch.length | 10s | 281 And the liquidity monitoring parameters: 282 | name | triggering ratio | scaling factor | time window | 283 | lqm-params | 1.0 | 1 | 50s | 284 And the spot markets are updated: 285 | id | liquidity monitoring | 286 | BTC/USDT | lqm-params | 287 288 Given the parties submit the following liquidity provision: 289 | id | party | market id | commitment amount | fee | lp type | 290 | lp1 | lp1 | BTC/USDT | 10000 | 0.01 | submission | 291 | lp2 | lp2 | BTC/USDT | 10000 | 0.02 | submission | 292 | lp3 | lp3 | BTC/USDT | 10000 | 0.03 | submission | 293 294 When the parties place the following orders: 295 | party | market id | side | volume | price | resulting trades | type | tif | 296 | aux1 | BTC/USDT | buy | 10 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | 297 | aux2 | BTC/USDT | sell | 10 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | 298 And the network moves ahead "2" blocks 299 Then the market data for the market "BTC/USDT" should be: 300 | trading mode | target stake | supplied stake | 301 | TRADING_MODE_CONTINUOUS | 30000 | 30000 | 302 And the liquidity fee factor should be "0.03" for the market "BTC/USDT" 303 304 Given the parties submit the following liquidity provision: 305 | id | party | market id | commitment amount | fee | lp type | 306 | lp3 | lp3 | BTC/USDT | 10000 | 0.03 | cancellation | 307 When the network moves ahead "1" epochs 308 Then the market data for the market "BTC/USDT" should be: 309 | trading mode | target stake | supplied stake | 310 | TRADING_MODE_CONTINUOUS | 30000 | 20000 | 311 And the liquidity fee factor should be "0.02" for the market "BTC/USDT" 312 313 314 Scenario: An LP leaves a market that is above target stake when their fee bid is lower than the one currently being used and their commitment size changes the LP that meets the target stake: fee changes to fee bid by the LP that is now at the place in the bid order to provide the target stake (0042-LIQF-080) 315 316 # Set the target stake time window to five epochs 317 Given the following network parameters are set: 318 | name | value | 319 | validators.epoch.length | 10s | 320 And the liquidity monitoring parameters: 321 | name | triggering ratio | scaling factor | time window | 322 | lqm-params | 1.0 | 0.5 | 50s | 323 And the spot markets are updated: 324 | id | liquidity monitoring | 325 | BTC/USDT | lqm-params | 326 327 Given the parties submit the following liquidity provision: 328 | id | party | market id | commitment amount | fee | lp type | 329 | lp1 | lp1 | BTC/USDT | 10000 | 0.01 | submission | 330 | lp2 | lp2 | BTC/USDT | 10000 | 0.02 | submission | 331 | lp3 | lp3 | BTC/USDT | 10000 | 0.03 | submission | 332 333 When the parties place the following orders: 334 | party | market id | side | volume | price | resulting trades | type | tif | 335 | aux1 | BTC/USDT | buy | 10 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | 336 | aux2 | BTC/USDT | sell | 10 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | 337 And the network moves ahead "2" blocks 338 Then the market data for the market "BTC/USDT" should be: 339 | trading mode | target stake | supplied stake | 340 | TRADING_MODE_CONTINUOUS | 15000 | 30000 | 341 And the liquidity fee factor should be "0.02" for the market "BTC/USDT" 342 343 Given the parties submit the following liquidity provision: 344 | id | party | market id | commitment amount | fee | lp type | 345 | lp1 | lp1 | BTC/USDT | 10000 | 0.01 | cancellation | 346 When the network moves ahead "1" epochs 347 Then the market data for the market "BTC/USDT" should be: 348 | trading mode | target stake | supplied stake | 349 | TRADING_MODE_CONTINUOUS | 15000 | 20000 | 350 And the liquidity fee factor should be "0.03" for the market "BTC/USDT" 351 352 353 Scenario: An LP leaves a market that is above target stake when their fee bid is lower than the one currently being used. The loss of their commitment doesn't change which LP meets the target stake: fee doesn't change (0042-LIQF-081) 354 355 # Set the target stake time window to five epochs 356 Given the following network parameters are set: 357 | name | value | 358 | validators.epoch.length | 10s | 359 And the liquidity monitoring parameters: 360 | name | triggering ratio | scaling factor | time window | 361 | lqm-params | 1.0 | 0.4 | 50s | 362 And the spot markets are updated: 363 | id | liquidity monitoring | 364 | BTC/USDT | lqm-params | 365 366 Given the parties submit the following liquidity provision: 367 | id | party | market id | commitment amount | fee | lp type | 368 | lp1 | lp1 | BTC/USDT | 2000 | 0.01 | submission | 369 | lp2 | lp2 | BTC/USDT | 14000 | 0.02 | submission | 370 | lp3 | lp3 | BTC/USDT | 14000 | 0.03 | submission | 371 372 When the parties place the following orders: 373 | party | market id | side | volume | price | resulting trades | type | tif | 374 | aux1 | BTC/USDT | buy | 10 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | 375 | aux2 | BTC/USDT | sell | 10 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | 376 And the network moves ahead "2" blocks 377 Then the market data for the market "BTC/USDT" should be: 378 | trading mode | target stake | supplied stake | 379 | TRADING_MODE_CONTINUOUS | 12000 | 30000 | 380 And the liquidity fee factor should be "0.02" for the market "BTC/USDT" 381 382 Given the parties submit the following liquidity provision: 383 | id | party | market id | commitment amount | fee | lp type | 384 | lp1 | lp1 | BTC/USDT | 2000 | 0.01 | cancellation | 385 When the network moves ahead "1" epochs 386 Then the market data for the market "BTC/USDT" should be: 387 | trading mode | target stake | supplied stake | 388 | TRADING_MODE_CONTINUOUS | 12000 | 28000 | 389 And the liquidity fee factor should be "0.02" for the market "BTC/USDT" 390 391 392 Scenario: Given the fee setting method is marginal cost. An LP leaves a spot market that is above target stake when their fee bid is higher than the one currently being used: fee doesn't change (0042-LIQF-106) 393 394 # Set the target stake time window to five epochs 395 Given the following network parameters are set: 396 | name | value | 397 | validators.epoch.length | 10s | 398 And the liquidity monitoring parameters: 399 | name | triggering ratio | scaling factor | time window | 400 | lqm-params | 1.0 | 0.4 | 50s | 401 And the spot markets are updated: 402 | id | liquidity monitoring | 403 | BTC/USDT | lqm-params | 404 405 Given the parties submit the following liquidity provision: 406 | id | party | market id | commitment amount | fee | lp type | 407 | lp1 | lp1 | BTC/USDT | 2000 | 0.01 | submission | 408 | lp2 | lp2 | BTC/USDT | 14000 | 0.02 | submission | 409 | lp3 | lp3 | BTC/USDT | 14000 | 0.03 | submission | 410 411 When the parties place the following orders: 412 | party | market id | side | volume | price | resulting trades | type | tif | 413 | aux1 | BTC/USDT | buy | 10 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | 414 | aux2 | BTC/USDT | sell | 10 | 10000 | 0 | TYPE_LIMIT | TIF_GTC | 415 And the network moves ahead "2" blocks 416 Then the market data for the market "BTC/USDT" should be: 417 | trading mode | target stake | supplied stake | 418 | TRADING_MODE_CONTINUOUS | 12000 | 30000 | 419 And the liquidity fee factor should be "0.02" for the market "BTC/USDT" 420 421 Given the parties submit the following liquidity provision: 422 | id | party | market id | commitment amount | fee | lp type | 423 | lp3 | lp3 | BTC/USDT | 14000 | 0.01 | cancellation | 424 When the network moves ahead "1" epochs 425 Then the market data for the market "BTC/USDT" should be: 426 | trading mode | target stake | supplied stake | 427 | TRADING_MODE_CONTINUOUS | 12000 | 16000 | 428 And the liquidity fee factor should be "0.02" for the market "BTC/USDT"