code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/0042-LIQF-fees_rewards_VirtualStake.feature (about) 1 Feature: Test liquidity provider reward distribution; Should also cover liquidity-fee-setting and equity-like-share calc and total stake. 2 # to look into and test: If an equity-like share is small and LP rewards are distributed immediately, then how do we round? (does a small share get rounded up or down, do they all add up?) 3 #Check what happens with time and distribution period (both in genesis and mid-market) 4 5 Background: 6 7 Given the simple risk model named "simple-risk-model-1": 8 | long | short | max move up | min move down | probability of trading | 9 | 0.1 | 0.1 | 500 | 500 | 0.1 | 10 And the fees configuration named "fees-config-1": 11 | maker fee | infrastructure fee | 12 | 0.0004 | 0.001 | 13 And the price monitoring named "price-monitoring": 14 | horizon | probability | auction extension | 15 | 3600 | 0.99 | 3 | 16 And the following network parameters are set: 17 | name | value | 18 | market.value.windowLength | 1h | 19 | network.markPriceUpdateMaximumFrequency | 0s | 20 | limits.markets.maxPeggedOrders | 12 | 21 Given the liquidity monitoring parameters: 22 | name | triggering ratio | time window | scaling factor | 23 | lqm-params | 0.0 | 24h | 1.0 | 24 25 And the liquidity sla params named "SLA": 26 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 27 | 1.0 | 0.5 | 1 | 1.0 | 28 And the markets: 29 | 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 | 30 | ETH/MAR22 | USD | USD | lqm-params | simple-risk-model-1 | default-margin-calculator | 2 | fees-config-1 | price-monitoring | default-eth-for-future | 0.2 | 0 | SLA | 31 And the following network parameters are set: 32 | name | value | 33 | market.liquidity.providersFeeCalculationTimeStep | 600s | 34 35 # block duration of 2 seconds 36 And the average block duration is "2" 37 38 @VirtStake 39 Scenario: 001 1 LP joining at start, checking liquidity rewards over 3 periods, 1 period with no trades (0042-LIQF-001) 40 # setup accounts 41 Given the parties deposit on asset's general account the following amount: 42 | party | asset | amount | 43 | lp1 | USD | 1000000000 | 44 | party1 | USD | 100000000 | 45 | party2 | USD | 100000000 | 46 47 And the parties submit the following liquidity provision: 48 | id | party | market id | commitment amount | fee | lp type | 49 | lp1 | lp1 | ETH/MAR22 | 10000 | 0.001 | submission | 50 | lp1 | lp1 | ETH/MAR22 | 10000 | 0.001 | amendment | 51 | lp1 | lp1 | ETH/MAR22 | 10000 | 0.001 | amendment | 52 | lp1 | lp1 | ETH/MAR22 | 10000 | 0.001 | amendment | 53 And the parties place the following pegged iceberg orders: 54 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 55 | lp1 | ETH/MAR22 | 12 | 1 | buy | BID | 12 | 2 | 56 | lp1 | ETH/MAR22 | 12 | 1 | buy | MID | 12 | 1 | 57 | lp1 | ETH/MAR22 | 12 | 1 | sell | ASK | 12 | 2 | 58 | lp1 | ETH/MAR22 | 12 | 1 | sell | MID | 12 | 1 | 59 60 When the parties place the following orders: 61 | party | market id | side | volume | price | resulting trades | type | tif | 62 | party1 | ETH/MAR22 | buy | 1 | 900 | 0 | TYPE_LIMIT | TIF_GTC | 63 | party1 | ETH/MAR22 | buy | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 64 | party2 | ETH/MAR22 | sell | 1 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | 65 | party2 | ETH/MAR22 | sell | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 66 67 Then the opening auction period ends for market "ETH/MAR22" 68 69 And the following trades should be executed: 70 | buyer | price | size | seller | 71 | party1 | 1000 | 10 | party2 | 72 73 And the market data for the market "ETH/MAR22" should be: 74 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 75 | 1000 | TRADING_MODE_CONTINUOUS | 3600 | 500 | 1500 | 1000 | 10000 | 10 | 76 77 And the liquidity provider fee shares for the market "ETH/MAR22" should be: 78 | party | equity like share | average entry valuation | 79 | lp1 | 1 | 10000 | 80 81 And the liquidity fee factor should be "0.001" for the market "ETH/MAR22" 82 83 # No fees in auction 84 And the accumulated liquidity fees should be "0" for the market "ETH/MAR22" 85 86 When the network moves ahead "1" blocks 87 88 And the parties place the following orders with ticks: 89 | party | market id | side | volume | price | resulting trades | type | tif | reference | 90 | party1 | ETH/MAR22 | sell | 20 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | party1-sell | 91 | party2 | ETH/MAR22 | buy | 20 | 1000 | 2 | TYPE_LIMIT | TIF_GTC | party2-buy | 92 93 Then the following trades should be executed: 94 | buyer | price | size | seller | 95 | party2 | 951 | 12 | lp1 | 96 | party2 | 1000 | 8 | party1 | 97 98 And the parties should have the following account balances: 99 | party | asset | market id | margin | general | bond | 100 | lp1 | USD | ETH/MAR22 | 5760 | 999983657 | 10000 | 101 102 And the accumulated liquidity fees should be "20" for the market "ETH/MAR22" 103 104 105 # Trigger distribution of liquidity fees 106 When the network moves ahead "301" blocks 107 108 And the accumulated liquidity fees should be "0" for the market "ETH/MAR22" 109 110 111 # Move to new block 112 When the network moves ahead "301" blocks 113 114 And the parties place the following orders: 115 | party | market id | side | volume | price | resulting trades | type | tif | reference | 116 | party2 | ETH/MAR22 | buy | 40 | 1100 | 2 | TYPE_LIMIT | TIF_GTC | party1-buy | 117 | party2 | ETH/MAR22 | sell | 40 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | party2-sell | 118 119 Then the following trades should be executed: 120 | buyer | price | size | seller | 121 | party2 | 1002 | 12 | lp1 | 122 123 And the accumulated liquidity fees should be "25" for the market "ETH/MAR22" 124 125 # Trigger distribution of liquidity fees 126 When the network moves ahead "301" blocks 127 And the accumulated liquidity fees should be "0" for the market "ETH/MAR22" 128 129 @VirtStake 130 Scenario: 002 2 LPs joining at start, equal commitments (0042-LIQF-002) 131 132 Given the parties deposit on asset's general account the following amount: 133 | party | asset | amount | 134 | lp1 | USD | 1000000000 | 135 | lp2 | USD | 1000000000 | 136 | party1 | USD | 100000000 | 137 | party2 | USD | 100000000 | 138 139 And the parties submit the following liquidity provision: 140 | id | party | market id | commitment amount | fee | lp type | 141 | lp1 | lp1 | ETH/MAR22 | 5000 | 0.001 | submission | 142 | lp1 | lp1 | ETH/MAR22 | 5000 | 0.001 | amendment | 143 | lp1 | lp1 | ETH/MAR22 | 5000 | 0.001 | amendment | 144 | lp1 | lp1 | ETH/MAR22 | 5000 | 0.001 | amendment | 145 And the parties place the following pegged iceberg orders: 146 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 147 | lp1 | ETH/MAR22 | 12 | 1 | buy | BID | 12 | 2 | 148 | lp1 | ETH/MAR22 | 12 | 1 | buy | MID | 12 | 1 | 149 | lp1 | ETH/MAR22 | 12 | 1 | sell | ASK | 12 | 2 | 150 | lp1 | ETH/MAR22 | 12 | 1 | sell | MID | 12 | 1 | 151 And the parties submit the following liquidity provision: 152 | id | party | market id | commitment amount | fee | lp type | 153 | lp2 | lp2 | ETH/MAR22 | 5000 | 0.002 | submission | 154 | lp2 | lp2 | ETH/MAR22 | 5000 | 0.002 | amendment | 155 | lp2 | lp2 | ETH/MAR22 | 5000 | 0.002 | amendment | 156 | lp2 | lp2 | ETH/MAR22 | 5000 | 0.002 | amendment | 157 And the parties place the following pegged iceberg orders: 158 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 159 | lp2 | ETH/MAR22 | 12 | 1 | buy | BID | 12 | 2 | 160 | lp2 | ETH/MAR22 | 12 | 1 | buy | MID | 12 | 1 | 161 | lp2 | ETH/MAR22 | 12 | 1 | sell | ASK | 12 | 2 | 162 | lp2 | ETH/MAR22 | 12 | 1 | sell | MID | 12 | 1 | 163 164 When the parties place the following orders: 165 | party | market id | side | volume | price | resulting trades | type | tif | 166 | party1 | ETH/MAR22 | buy | 1 | 900 | 0 | TYPE_LIMIT | TIF_GTC | 167 | party1 | ETH/MAR22 | buy | 90 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 168 | party2 | ETH/MAR22 | sell | 1 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | 169 | party2 | ETH/MAR22 | sell | 90 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 170 171 Then the opening auction period ends for market "ETH/MAR22" 172 173 And the following trades should be executed: 174 | buyer | price | size | seller | 175 | party1 | 1000 | 90 | party2 | 176 177 And the market data for the market "ETH/MAR22" should be: 178 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 179 | 1000 | TRADING_MODE_CONTINUOUS | 3600 | 500 | 1500 | 9000 | 10000 | 90 | 180 181 And the liquidity provider fee shares for the market "ETH/MAR22" should be: 182 | party | equity like share | average entry valuation | 183 | lp1 | 0.5 | 5000 | 184 | lp2 | 0.5 | 10000 | 185 186 And the liquidity fee factor should be "0.002" for the market "ETH/MAR22" 187 188 # No fees in auction 189 And the accumulated liquidity fees should be "0" for the market "ETH/MAR22" 190 191 When the parties place the following orders: 192 | party | market id | side | volume | price | resulting trades | type | tif | reference | 193 | party1 | ETH/MAR22 | sell | 20 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | party1-sell | 194 | party2 | ETH/MAR22 | buy | 20 | 1000 | 2 | TYPE_LIMIT | TIF_GTC | party2-buy | 195 When the network moves ahead "1" blocks 196 197 And the accumulated liquidity fees should be "39" for the market "ETH/MAR22" 198 199 # Trigger fee distribution 200 When the network moves ahead "301" blocks 201 202 And the accumulated liquidity fees should be "1" for the market "ETH/MAR22" 203 204 When the parties place the following orders: 205 | party | market id | side | volume | price | resulting trades | type | tif | reference | 206 | party1 | ETH/MAR22 | buy | 40 | 1100 | 1 | TYPE_LIMIT | TIF_GTC | party1-buy | 207 | party2 | ETH/MAR22 | sell | 40 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | party2-sell | 208 When the network moves ahead "1" blocks 209 210 And the accumulated liquidity fees should be "9" for the market "ETH/MAR22" 211 212 # Trigger fee distribution 213 When the network moves ahead "301" blocks 214 And the accumulated liquidity fees should be "1" for the market "ETH/MAR22" 215 216 @FeeRound 217 Scenario: 003 2 LPs joining at start, unequal commitments. Checking calculation of equity-like-shares and liquidity-fee-distribution in a shrinking market. (0042-LIQF-008 0042-LIQF-011) 218 219 # Scenario has 6 market periods: 220 221 # - 0th period (bootstrap period): no LP changes, no trades 222 # - 1st period: 1 LPs decrease commitment, some trades occur 223 # - 2nd period: 1 LPs increase commitment, some trades occur 224 # - 3rd period: 2 LPs decrease commitment, some trades occur 225 # - 4th period: 2 LPs increase commitment, some trades occur 226 # - 5th period: 1 LPs decrease commitment, 1 LPs increase commitment, some trades occur 227 228 229 # Scenario moves ahead to next market period by: 230 231 # - moving ahead "1" blocks to trigger the next liquidity distribution 232 # - moving ahead "1" blocks to trigger the next market period 233 234 235 # Following checks occur in each market where trades: 236 237 # - Check transfers from the price taker to the market-liquidity-pool are correct 238 # - Check accumulated-liquidity-fees are non-zero and correct 239 # - Check equity-like-shares are correct 240 # - Check transfers from the market-liquidity-pool to the liquidity-providers are correct 241 # - Check accumulated-liquidity-fees are zero 242 243 Given the average block duration is "1801" 244 245 And the parties deposit on asset's general account the following amount: 246 | party | asset | amount | 247 | lp1 | USD | 100000 | 248 | lp2 | USD | 100000 | 249 | party1 | USD | 100000 | 250 | party2 | USD | 100000 | 251 252 And the parties submit the following liquidity provision: 253 | id | party | market id | commitment amount | fee | lp type | 254 | lp1 | lp1 | ETH/MAR22 | 4000 | 0.001 | submission | 255 256 And the parties place the following pegged iceberg orders: 257 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 258 | lp1 | ETH/MAR22 | 2 | 1 | buy | BID | 1 | 2 | 259 | lp1 | ETH/MAR22 | 2 | 1 | buy | MID | 3 | 1 | 260 | lp1 | ETH/MAR22 | 2 | 1 | sell | ASK | 1 | 2 | 261 | lp1 | ETH/MAR22 | 2 | 1 | sell | MID | 3 | 1 | 262 263 And the parties submit the following liquidity provision: 264 | id | party | market id | commitment amount | fee | lp type | 265 | lp2 | lp2 | ETH/MAR22 | 6000 | 0.002 | submission | 266 267 And the parties place the following pegged iceberg orders: 268 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 269 | lp2 | ETH/MAR22 | 2 | 1 | buy | BID | 1 | 2 | 270 | lp2 | ETH/MAR22 | 2 | 1 | buy | MID | 3 | 1 | 271 | lp2 | ETH/MAR22 | 2 | 1 | sell | ASK | 1 | 2 | 272 | lp2 | ETH/MAR22 | 2 | 1 | sell | MID | 3 | 1 | 273 274 And the parties place the following orders: 275 | party | market id | side | volume | price | resulting trades | type | tif | 276 | party1 | ETH/MAR22 | buy | 1 | 900 | 0 | TYPE_LIMIT | TIF_GTC | 277 | party1 | ETH/MAR22 | buy | 50 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 278 | party2 | ETH/MAR22 | sell | 1 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | 279 | party2 | ETH/MAR22 | sell | 50 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 280 281 # 0th period (bootstrap period): no LP changes, no trades 282 Then the opening auction period ends for market "ETH/MAR22" 283 284 And the following trades should be executed: 285 | buyer | price | size | seller | 286 | party1 | 1000 | 50 | party2 | 287 288 And the market data for the market "ETH/MAR22" should be: 289 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 290 | 1000 | TRADING_MODE_CONTINUOUS | 3600 | 500 | 1500 | 5000 | 10000 | 50 | 291 292 And the liquidity provider fee shares for the market "ETH/MAR22" should be: 293 | party | equity like share | average entry valuation | 294 | lp1 | 0.4 | 4000 | 295 | lp2 | 0.6 | 10000 | 296 297 And the accumulated liquidity fees should be "0" for the market "ETH/MAR22" 298 299 300 # 1st period: 1 LPs decrease commitment, some trades occur: 301 When the network moves ahead "2" blocks: 302 303 And the parties submit the following liquidity provision: 304 | id | party | market id | commitment amount | fee | lp type | 305 | lp1 | lp1 | ETH/MAR22 | 3000 | 0.001 | amendment | 306 307 And the parties place the following pegged iceberg orders: 308 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 309 | lp1 | ETH/MAR22 | 2 | 1 | buy | BID | 1 | 2 | 310 | lp1 | ETH/MAR22 | 2 | 1 | sell | ASK | 1 | 2 | 311 312 And the parties place the following orders: 313 | party | market id | side | volume | price | resulting trades | type | tif | 314 | party1 | ETH/MAR22 | buy | 2 | 1001 | 1 | TYPE_LIMIT | TIF_GTC | 315 316 # liquidity_fee = ceil(volume * price * liquidity_fee_factor) = ceil(1001 * 2 * 0.002) = ceil(4.004) = 5 317 318 And the following transfers should happen: 319 | from | to | from account | to account | market id | amount | asset | 320 | party1 | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_LIQUIDITY | ETH/MAR22 | 5 | USD | 321 322 And the accumulated liquidity fees should be "5" for the market "ETH/MAR22" 323 324 And the market data for the market "ETH/MAR22" should be: 325 | mark price | last traded price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 326 | 1000 | 1001 | TRADING_MODE_CONTINUOUS | 3600 | 500 | 1500 | 5200 | 10000 | 52 | 327 328 # Trigger next liquidity fee distribution without triggering next period 329 When the network moves ahead "1" blocks: 330 331 Then the liquidity provider fee shares for the market "ETH/MAR22" should be: 332 | party | equity like share | average entry valuation | 333 | lp1 | 0.4 | 4000 | 334 | lp2 | 0.6 | 10000 | 335 336 And the accumulated liquidity fees should be "0" for the market "ETH/MAR22" 337 338 # 2nd period: 1 LPs increase commitment, some trades occur 339 When the network moves ahead "1" blocks: 340 341 And the parties submit the following liquidity provision: 342 | id | party | market id | commitment amount | fee | lp type | 343 | lp1 | lp1 | ETH/MAR22 | 4000 | 0.001 | amendment | 344 345 And the parties place the following pegged iceberg orders: 346 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 347 | lp1 | ETH/MAR22 | 2 | 1 | buy | BID | 1 | 2 | 348 | lp1 | ETH/MAR22 | 2 | 1 | sell | ASK | 1 | 2 | 349 350 And the parties place the following orders: 351 | party | market id | side | volume | price | resulting trades | type | tif | 352 | party1 | ETH/MAR22 | buy | 2 | 1001 | 1 | TYPE_LIMIT | TIF_GTC | 353 354 #liquidity_fee = ceil(volume * price * liquidity_fee_factor) = ceil(1001 * 2 * 0.002) = ceil(4.004) = 5 355 356 And the accumulated liquidity fees should be "5" for the market "ETH/MAR22" 357 358 And the market data for the market "ETH/MAR22" should be: 359 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 360 | 1001 | TRADING_MODE_CONTINUOUS | 3600 | 502 | 1500 | 5405 | 10000 | 54 | 361 362 # Trigger next liquidity fee distribution without triggering next period 363 When the network moves ahead "1" blocks: 364 365 Then the liquidity provider fee shares for the market "ETH/MAR22" should be: 366 | party | equity like share | average entry valuation | 367 | lp1 | 0.3333333333333333 | 4000 | 368 | lp2 | 0.6666666666666667 | 10000 | 369 370 And the accumulated liquidity fees should be "1" for the market "ETH/MAR22" 371 372 373 # 3rd period: 2 LPs decrease commitment, some trades occur 374 When the network moves ahead "1" blocks: 375 376 And the parties submit the following liquidity provision: 377 | id | party | market id | commitment amount | fee | lp type | 378 | lp1 | lp1 | ETH/MAR22 | 3000 | 0.001 | amendment | 379 380 And the parties submit the following liquidity provision: 381 | id | party | market id | commitment amount | fee | lp type | 382 | lp2 | lp2 | ETH/MAR22 | 5000 | 0.002 | amendment | 383 384 When the network moves ahead "1" blocks: 385 386 And the parties place the following orders: 387 | party | market id | side | volume | price | resulting trades | type | tif | 388 | party1 | ETH/MAR22 | buy | 3 | 1001 | 2 | TYPE_LIMIT | TIF_GTC | 389 390 # liquidity_fee = ceil(volume * price * liquidity_fee_factor) = ceil(1001 * 3 * 0.002) = ceil(6.006) = 7 391 392 And the accumulated liquidity fees should be "7" for the market "ETH/MAR22" 393 394 And the market data for the market "ETH/MAR22" should be: 395 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 396 | 1001 | TRADING_MODE_CONTINUOUS | 3600 | 502 | 1500 | 5605 | 10000 | 56 | 397 398 # Trigger next liquidity fee distribution without triggering next period 399 When the network moves ahead "1" blocks: 400 401 Then the liquidity provider fee shares for the market "ETH/MAR22" should be: 402 | party | equity like share | average entry valuation | 403 | lp1 | 0.375 | 5500 | 404 | lp2 | 0.625 | 10000 | 405 406 And the accumulated liquidity fees should be "1" for the market "ETH/MAR22" 407 408 # 4nd period: 2 LPs increase commitment, some trades occur 409 When the network moves ahead "2" blocks: 410 411 And the parties submit the following liquidity provision: 412 | id | party | market id | commitment amount | fee | lp type | 413 | lp1 | lp1 | ETH/MAR22 | 4000 | 0.001 | amendment | 414 415 And the parties submit the following liquidity provision: 416 | id | party | market id | commitment amount | fee | lp type | 417 | lp2 | lp2 | ETH/MAR22 | 6000 | 0.002 | amendment | 418 419 And the parties place the following orders: 420 | party | market id | side | volume | price | resulting trades | type | tif | 421 | party1 | ETH/MAR22 | sell | 4 | 1001 | 2 | TYPE_LIMIT | TIF_GTC | 422 423 #liquidity_fee = ceil(volume * price * liquidity_fee_factor) = ceil(1001 * 3 * 0.002) + ceil(1001 * 1 * 0.002) = ceil(6.006) + ceil(2.002)= 10 424 425 And the accumulated liquidity fees should be "11" for the market "ETH/MAR22" 426 427 And the market data for the market "ETH/MAR22" should be: 428 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 429 | 1001 | TRADING_MODE_CONTINUOUS | 3600 | 502 | 1500 | 5605 | 10000 | 52 | 430 431 # Trigger next liquidity fee distribution without triggering next period 432 When the network moves ahead "1" blocks: 433 434 Then the liquidity provider fee shares for the market "ETH/MAR22" should be: 435 | party | equity like share | average entry valuation | 436 | lp1 | 0.375 | 5500 | 437 | lp2 | 0.625 | 10000 | 438 439 And the accumulated liquidity fees should be "1" for the market "ETH/MAR22" 440 441 # 5th period: 1 LPs decrease commitment 1 LPs increase commitment, some trades occur 442 When the network moves ahead "1" blocks: 443 444 And the parties submit the following liquidity provision: 445 | id | party | market id | commitment amount | fee | lp type | 446 | lp1 | lp1 | ETH/MAR22 | 8000 | 0.001 | amendment | 447 448 And the parties submit the following liquidity provision: 449 | id | party | market id | commitment amount | fee | lp type | 450 | lp2 | lp2 | ETH/MAR22 | 7000 | 0.002 | amendment | 451 452 And the parties place the following pegged iceberg orders: 453 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 454 | lp1 | ETH/MAR22 | 2 | 1 | buy | BID | 10 | 10 | 455 | lp1 | ETH/MAR22 | 2 | 1 | sell | MID | 10 | 10 | 456 When the network moves ahead "1" blocks: 457 458 And the parties place the following orders: 459 | party | market id | side | volume | price | resulting trades | type | tif | 460 | party1 | ETH/MAR22 | sell | 2 | 1001 | 2 | TYPE_LIMIT | TIF_GTC | 461 462 # liquidity_fee = ceil(volume * price * liquidity_fee_factor) = ceil(1001 * 3 * 0.002) + ceil(1001 * 2 * 0.002) = ceil(6.006) + ceil(4.004)= 12 463 464 And the accumulated liquidity fees should be "7" for the market "ETH/MAR22" 465 466 And the market data for the market "ETH/MAR22" should be: 467 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 468 | 1050 | TRADING_MODE_CONTINUOUS | 3600 | 550 | 1550 | 5880 | 15000 | 50 | 469 470 # Trigger next liquidity fee distribution without triggering next period 471 When the network moves ahead "10" blocks: 472 473 Then the liquidity provider fee shares for the market "ETH/MAR22" should be: 474 | party | equity like share | average entry valuation | 475 | lp1 | 0.5333333333333333 | 10187.5 | 476 | lp2 | 0.4666666666666667 | 10714.2857142857142857 | 477 478 And the accumulated liquidity fees should be "1" for the market "ETH/MAR22" 479 480 @FeeRound @Liquidation 481 Scenario: 004 2 LPs joining at start, 1 LP forcibly closed out (0042-LIQF-008) 482 483 Given the average block duration is "601" 484 485 When the parties deposit on asset's general account the following amount: 486 | party | asset | amount | 487 | lp1 | USD | 10000 | 488 | lp2 | USD | 10000000 | 489 | party1 | USD | 10000000 | 490 | party2 | USD | 10000000 | 491 492 And the parties submit the following liquidity provision: 493 | id | party | market id | commitment amount | fee | lp type | 494 | lp1 | lp1 | ETH/MAR22 | 1000 | 0.001 | submission | 495 And the parties place the following pegged iceberg orders: 496 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 497 | lp1 | ETH/MAR22 | 2 | 1 | buy | BID | 1 | 51 | 498 | lp1 | ETH/MAR22 | 2 | 1 | sell | ASK | 1 | 51 | 499 And the parties submit the following liquidity provision: 500 | id | party | market id | commitment amount | fee | lp type | 501 | lp2 | lp2 | ETH/MAR22 | 9000 | 0.002 | submission | 502 And the parties place the following pegged iceberg orders: 503 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 504 | lp2 | ETH/MAR22 | 2 | 1 | buy | BID | 1 | 51 | 505 | lp2 | ETH/MAR22 | 2 | 1 | sell | ASK | 1 | 51 | 506 And the parties place the following orders: 507 | party | market id | side | volume | price | resulting trades | type | tif | reference | 508 | party1 | ETH/MAR22 | buy | 1 | 900 | 0 | TYPE_LIMIT | TIF_GTC | pa1-b1 | 509 | party1 | ETH/MAR22 | buy | 15 | 950 | 0 | TYPE_LIMIT | TIF_GTC | pa1-b2 | 510 | party2 | ETH/MAR22 | sell | 1 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | pa2-s1 | 511 | lp1 | ETH/MAR22 | sell | 15 | 950 | 0 | TYPE_LIMIT | TIF_GTC | lp1-s1 | 512 513 Then the opening auction period ends for market "ETH/MAR22" 514 515 Then the parties should have the following account balances: 516 | party | asset | market id | margin | general | bond | 517 | lp1 | USD | ETH/MAR22 | 5244 | 3756 | 1000 | 518 519 # 1st set of trades: market moves against lp1s position, margin-insufficient, margin topped up from general and bond 520 When the network moves ahead "1" blocks: 521 522 And the parties amend the following orders: 523 | party | reference | price | size delta | tif | 524 | party1 | pa1-b1 | 1050 | 0 | TIF_GTC | 525 | party2 | pa2-s1 | 1250 | 0 | TIF_GTC | 526 527 And the parties place the following orders with ticks: 528 | party | market id | side | volume | price | resulting trades | type | tif | 529 | party1 | ETH/MAR22 | buy | 30 | 1150 | 0 | TYPE_LIMIT | TIF_GTC | 530 | party2 | ETH/MAR22 | sell | 30 | 1150 | 1 | TYPE_LIMIT | TIF_GTC | 531 532 Then the following trades should be executed: 533 | buyer | price | size | seller | 534 | party1 | 1150 | 30 | party2 | 535 536 # liquidity_fee = ceil(volume * price * liquidity_fee_factor) = ceil(1150 * 30 * 0.002) = ceil(69) = 69 537 538 And the accumulated liquidity fees should be "69" for the market "ETH/MAR22" 539 540 Then the parties should have the following account balances: 541 | party | asset | market id | margin | general | bond | 542 | lp1 | USD | ETH/MAR22 | 6348 | 0 | 652 | 543 544 And the liquidity provider fee shares for the market "ETH/MAR22" should be: 545 | party | equity like share | average entry valuation | 546 | lp1 | 0.1 | 1000 | 547 | lp2 | 0.9 | 10000 | 548 549 # Trigger liquidity distribution 550 When the network moves ahead "1" blocks: 551 And the accumulated liquidity fees should be "1" for the market "ETH/MAR22" 552 553 # 2nd set of trades: market moves against LP1s position, margin-insufficient, margin topped up from general and bond 554 When the network moves ahead "1" blocks: 555 556 When the parties amend the following orders: 557 | party | reference | price | size delta | tif | 558 | party1 | pa1-b1 | 1200 | 0 | TIF_GTC | 559 | party2 | pa2-s1 | 1400 | 0 | TIF_GTC | 560 561 And the parties place the following orders with ticks: 562 | party | market id | side | volume | price | resulting trades | type | tif | 563 | party1 | ETH/MAR22 | buy | 30 | 1300 | 0 | TYPE_LIMIT | TIF_GTC | 564 | party2 | ETH/MAR22 | sell | 30 | 1300 | 1 | TYPE_LIMIT | TIF_GTC | 565 566 Then the following trades should be executed: 567 | buyer | price | size | seller | 568 | party1 | 1300 | 30 | party2 | 569 570 # liquidity_fee = ceil(volume * price * liquidity_fee_factor) = ceil(1300 * 30 * 0.002) = ceil(78) = 78 571 572 And the accumulated liquidity fees should be "82" for the market "ETH/MAR22" 573 574 Then the parties should have the following account balances: 575 | party | asset | market id | margin | general | bond | 576 | lp1 | USD | ETH/MAR22 | 0 | 0 | 0 | 577 When the network moves ahead "1" blocks: 578 579 And the liquidity provider fee shares for the market "ETH/MAR22" should be: 580 | party | equity like share | average entry valuation | 581 | lp2 | 0.9324492333195193 | 10000 | 582 583 # Trigger liquidity distribution 584 When the network moves ahead "1" blocks: 585 586 And the accumulated liquidity fees should be "0" for the market "ETH/MAR22" 587 588 589