code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/0042-LIQF-fees_rewards.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 | 1 | 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 | 8 | 21 | validators.epoch.length | 24h | 22 | market.liquidity.equityLikeShareFeeFraction | 1 | 23 | market.liquidity.providersFeeCalculationTimeStep | 600s | 24 Given the liquidity monitoring parameters: 25 | name | triggering ratio | time window | scaling factor | 26 | lqm-params | 0.0 | 24h | 1.0 | 27 28 And the liquidity sla params named "SLA": 29 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 30 | 1.0 | 0.5 | 1 | 1.0 | 31 And the markets: 32 | 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 | 33 | ETH/MAR22 | USD | USD | lqm-params | simple-risk-model-1 | default-margin-calculator | 2 | fees-config-1 | price-monitoring | default-eth-for-future | 0.5 | 0 | SLA | 34 35 Given the average block duration is "2" 36 37 Scenario: 001: basic test case, 1 LP joining at start, checking liquidity rewards over 3 periods, 1 period with no trades 38 # setup accounts 39 Given the parties deposit on asset's general account the following amount: 40 | party | asset | amount | 41 | lp1 | USD | 1000000000 | 42 | party1 | USD | 100000000 | 43 | party2 | USD | 100000000 | 44 45 And the parties submit the following liquidity provision: 46 | id | party | market id | commitment amount | fee | lp type | 47 | lp1 | lp1 | ETH/MAR22 | 10000 | 0.001 | submission | 48 And the parties place the following pegged iceberg orders: 49 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 50 | lp1 | ETH/MAR22 | 4 | 1 | buy | BID | 4 | 2 | 51 | lp1 | ETH/MAR22 | 7 | 1 | buy | MID | 7 | 1 | 52 | lp1 | ETH/MAR22 | 4 | 1 | sell | ASK | 4 | 2 | 53 | lp1 | ETH/MAR22 | 7 | 1 | sell | MID | 7 | 1 | 54 55 Then the parties place the following orders: 56 | party | market id | side | volume | price | resulting trades | type | tif | 57 | party1 | ETH/MAR22 | buy | 1 | 900 | 0 | TYPE_LIMIT | TIF_GTC | 58 | party1 | ETH/MAR22 | buy | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 59 | party2 | ETH/MAR22 | sell | 1 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | 60 | party2 | ETH/MAR22 | sell | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 61 62 Then the opening auction period ends for market "ETH/MAR22" 63 64 And the following trades should be executed: 65 | buyer | price | size | seller | 66 | party1 | 1000 | 10 | party2 | 67 68 And the market data for the market "ETH/MAR22" should be: 69 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 70 | 1000 | TRADING_MODE_CONTINUOUS | 1 | 500 | 1500 | 1000 | 10000 | 10 | 71 # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1000 x 10 x 1 x 0.1 72 # max_oi: max open interest 73 74 Then the order book should have the following volumes for market "ETH/MAR22": 75 | side | price | volume | 76 | buy | 898 | 4 | 77 | buy | 900 | 1 | 78 | buy | 999 | 7 | 79 | sell | 1001 | 7 | 80 | sell | 1100 | 1 | 81 | sell | 1102 | 4 | 82 83 And the liquidity provider fee shares for the market "ETH/MAR22" should be: 84 | party | equity like share | average entry valuation | 85 | lp1 | 1 | 10000 | 86 87 And the parties should have the following account balances: 88 | party | asset | market id | margin | general | bond | 89 | lp1 | USD | ETH/MAR22 | 1320 | 999988680 | 10000 | 90 91 Then the network moves ahead "1" blocks 92 93 And the price monitoring bounds for the market "ETH/MAR22" should be: 94 | min bound | max bound | 95 | 500 | 1500 | 96 97 And the liquidity fee factor should be "0.001" for the market "ETH/MAR22" 98 99 And the parties place the following pegged iceberg orders: 100 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 101 | lp1 | ETH/MAR22 | 1 | 1 | sell | MID | 1 | 1 | 102 | lp1 | ETH/MAR22 | 1 | 1 | buy | MID | 1 | 1 | 103 104 Then the parties place the following orders with ticks: 105 | party | market id | side | volume | price | resulting trades | type | tif | reference | 106 | party1 | ETH/MAR22 | sell | 20 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | party1-sell | 107 | party2 | ETH/MAR22 | buy | 20 | 1000 | 3 | TYPE_LIMIT | TIF_GTC | party2-buy | 108 109 Then the parties should have the following profit and loss: 110 | party | volume | unrealised pnl | realised pnl | 111 | lp1 | -8 | -392 | 0 | 112 | party1 | -2 | 0 | 0 | 113 | party2 | 10 | 0 | 392 | 114 115 And the parties place the following pegged iceberg orders: 116 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 117 | lp1 | ETH/MAR22 | 8 | 1 | sell | MID | 8 | 1 | 118 | lp1 | ETH/MAR22 | 1 | 1 | buy | MID | 1 | 1 | 119 120 And the parties should have the following account balances: 121 | party | asset | market id | margin | general | bond | 122 | lp1 | USD | ETH/MAR22 | 7200 | 999982412 | 10000 | 123 124 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR22" 125 And the accumulated liquidity fees should be "20" for the market "ETH/MAR22" 126 127 # opening auction + time window 128 Then time is updated to "2019-11-30T00:10:05Z" 129 130 Then the following transfers should happen: 131 | from | to | from account | to account | market id | amount | asset | 132 | market | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/MAR22 | 20 | USD | 133 134 And the accumulated liquidity fees should be "0" for the market "ETH/MAR22" 135 136 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR22" 137 Then time is updated to "2019-11-30T00:20:05Z" 138 139 When the parties place the following orders with ticks: 140 | party | market id | side | volume | price | resulting trades | type | tif | reference | 141 | party1 | ETH/MAR22 | buy | 40 | 1100 | 1 | TYPE_LIMIT | TIF_GTC | party1-buy | 142 | party2 | ETH/MAR22 | sell | 40 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | party2-sell | 143 144 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR22" 145 146 # here we get only a trade for a volume of 8 as it's what was on the LP 147 # order, then the 32 remaining from party1 are cancelled for self trade 148 And the following trades should be executed: 149 | buyer | price | size | seller | 150 | party1 | 951 | 8 | lp1 | 151 152 # this is slightly different than expected, as the trades happen against the LP, 153 # which is probably not what you expected initially 154 And the accumulated liquidity fees should be "8" for the market "ETH/MAR22" 155 156 Then time is updated to "2019-11-30T00:30:05Z" 157 158 Then the following transfers should happen: 159 | from | to | from account | to account | market id | amount | asset | 160 | market | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/MAR22 | 8 | USD | 161 162 And the accumulated liquidity fees should be "0" for the market "ETH/MAR22" 163 164 # Move beyond the end of the current epoch to trigger distribution to general account 165 When time is updated to "2019-12-04T00:30:05Z" 166 And the network moves ahead "1" blocks 167 Then the following transfers should happen: 168 | from | to | from account | to account | market id | amount | asset | 169 | lp1 | lp1 | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ACCOUNT_TYPE_GENERAL | ETH/MAR22 | 28 | USD | 170 171 Scenario: 002: The resulting liquidity-fee-factor is always equal to one of the liquidity provider's individually nominated fee factors (0042-LIQF-002) 172 173 Given the parties deposit on asset's general account the following amount: 174 | party | asset | amount | 175 | lp1 | USD | 1000000000 | 176 | lp2 | USD | 1000000000 | 177 | party1 | USD | 100000000 | 178 | party2 | USD | 100000000 | 179 180 And the parties submit the following liquidity provision: 181 | id | party | market id | commitment amount | fee | lp type | 182 | lp1 | lp1 | ETH/MAR22 | 5000 | 0.001 | submission | 183 And the parties place the following pegged iceberg orders: 184 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 185 | lp1 | ETH/MAR22 | 4 | 1 | buy | MID | 4 | 1 | 186 | lp1 | ETH/MAR22 | 4 | 1 | sell | MID | 4 | 1 | 187 And the parties submit the following liquidity provision: 188 | id | party | market id | commitment amount | fee | lp type | 189 | lp2 | lp2 | ETH/MAR22 | 5000 | 0.002 | submission | 190 And the parties place the following pegged iceberg orders: 191 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 192 | lp2 | ETH/MAR22 | 4 | 1 | buy | MID | 4 | 1 | 193 | lp2 | ETH/MAR22 | 4 | 1 | sell | MID | 4 | 1 | 194 195 Then the parties place the following orders: 196 | party | market id | side | volume | price | resulting trades | type | tif | 197 | party1 | ETH/MAR22 | buy | 1 | 900 | 0 | TYPE_LIMIT | TIF_GTC | 198 | party1 | ETH/MAR22 | buy | 90 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 199 | party2 | ETH/MAR22 | sell | 1 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | 200 | party2 | ETH/MAR22 | sell | 90 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 201 202 Then the opening auction period ends for market "ETH/MAR22" 203 204 And the following trades should be executed: 205 | buyer | price | size | seller | 206 | party1 | 1000 | 90 | party2 | 207 208 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR22" 209 And the mark price should be "1000" for the market "ETH/MAR22" 210 And the open interest should be "90" for the market "ETH/MAR22" 211 And the target stake should be "9000" for the market "ETH/MAR22" 212 And the supplied stake should be "10000" for the market "ETH/MAR22" 213 214 And the liquidity provider fee shares for the market "ETH/MAR22" should be: 215 | party | equity like share | average entry valuation | 216 | lp1 | 0.5 | 5000 | 217 | lp2 | 0.5 | 10000 | 218 219 And the price monitoring bounds for the market "ETH/MAR22" should be: 220 | min bound | max bound | 221 | 500 | 1500 | 222 223 And the liquidity fee factor should be "0.002" for the market "ETH/MAR22" 224 225 # no fees in auction 226 And the accumulated liquidity fees should be "0" for the market "ETH/MAR22" 227 228 Then the parties place the following orders with ticks: 229 | party | market id | side | volume | price | resulting trades | type | tif | reference | 230 | party1 | ETH/MAR22 | sell | 20 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | party1-sell | 231 | party2 | ETH/MAR22 | buy | 20 | 1000 | 3 | TYPE_LIMIT | TIF_GTC | party2-buy | 232 233 And the following trades should be executed: 234 | buyer | price | size | seller | 235 | party2 | 951 | 4 | lp1 | 236 | party2 | 951 | 4 | lp2 | 237 | party2 | 1000 | 12 | party1 | 238 239 And the accumulated liquidity fees should be "40" for the market "ETH/MAR22" 240 241 # opening auction + time window 242 Then time is updated to "2019-11-30T00:10:05Z" 243 244 # these are different from the tests, but again, we end up with a 2/3 vs 1/3 fee share here. 245 Then the following transfers should happen: 246 | from | to | from account | to account | market id | amount | asset | 247 | market | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/MAR22 | 20 | USD | 248 | market | lp2 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/MAR22 | 20 | USD | 249 When the parties place the following pegged iceberg orders: 250 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 251 | lp1 | ETH/MAR22 | 4 | 1 | buy | MID | 4 | 1 | 252 | lp1 | ETH/MAR22 | 4 | 1 | sell | MID | 4 | 1 | 253 | lp2 | ETH/MAR22 | 4 | 1 | buy | MID | 4 | 1 | 254 | lp2 | ETH/MAR22 | 4 | 1 | sell | MID | 4 | 1 | 255 And the parties place the following orders with ticks: 256 | party | market id | side | volume | price | resulting trades | type | tif | reference | 257 | party1 | ETH/MAR22 | buy | 40 | 1100 | 2 | TYPE_LIMIT | TIF_GTC | party1-buy | 258 | party2 | ETH/MAR22 | sell | 40 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | party2-sell | 259 Then the following trades should be executed: 260 | buyer | price | size | seller | 261 | party1 | 951 | 4 | lp1 | 262 | party1 | 951 | 4 | lp2 | 263 And the accumulated liquidity fees should be "16" for the market "ETH/MAR22" 264 265 When time is updated to "2019-11-30T00:20:08Z" 266 # these are different from the tests, but again, we end up with a 2/3 vs 1/3 fee share here. 267 Then the following transfers should happen: 268 | from | to | from account | to account | market id | amount | asset | 269 | market | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/MAR22 | 8 | USD | 270 | market | lp2 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/MAR22 | 8 | USD | 271 272 Scenario: 003: The resulting liquidity-fee-factor is never less than zero (0042-LIQF-003) 273 274 Given the parties deposit on asset's general account the following amount: 275 | party | asset | amount | 276 | lp1 | USD | 1000000000 | 277 | lp2 | USD | 1000000000 | 278 | party1 | USD | 100000000 | 279 | party2 | USD | 100000000 | 280 281 And the parties submit the following liquidity provision: 282 | id | party | market id | commitment amount | fee | lp type | error | 283 | lp1 | lp1 | ETH/MAR22 | 8000 | -0.001 | submission | invalid liquidity provision fee | 284 285 And the parties submit the following liquidity provision: 286 | id | party | market id | commitment amount | fee | lp type | 287 | lp1 | lp1 | ETH/MAR22 | 8000 | 0 | submission | 288 289 And the parties submit the following liquidity provision: 290 | id | party | market id | commitment amount | fee | lp type | 291 | lp1 | lp1 | ETH/MAR22 | 8000 | 0.001 | amendment | 292 293 And the parties place the following pegged iceberg orders: 294 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 295 | lp1 | ETH/MAR22 | 2 | 1 | buy | MID | 2 | 1 | 296 | lp1 | ETH/MAR22 | 2 | 1 | sell | MID | 2 | 1 | 297 And the parties submit the following liquidity provision: 298 | id | party | market id | commitment amount | fee | lp type | 299 | lp2 | lp2 | ETH/MAR22 | 2000 | 0.002 | submission | 300 | lp2 | lp2 | ETH/MAR22 | 2000 | 0.002 | submission | 301 | lp2 | lp2 | ETH/MAR22 | 2000 | 0.002 | submission | 302 | lp2 | lp2 | ETH/MAR22 | 2000 | 0.002 | submission | 303 And the parties place the following pegged iceberg orders: 304 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 305 | lp2 | ETH/MAR22 | 2 | 1 | buy | MID | 2 | 1 | 306 | lp2 | ETH/MAR22 | 2 | 1 | sell | MID | 2 | 1 | 307 308 Then the parties place the following orders: 309 | party | market id | side | volume | price | resulting trades | type | tif | 310 | party1 | ETH/MAR22 | buy | 1 | 900 | 0 | TYPE_LIMIT | TIF_GTC | 311 | party1 | ETH/MAR22 | buy | 60 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 312 | party2 | ETH/MAR22 | sell | 1 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | 313 | party2 | ETH/MAR22 | sell | 60 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 314 315 Then the opening auction period ends for market "ETH/MAR22" 316 317 And the following trades should be executed: 318 | buyer | price | size | seller | 319 | party1 | 1000 | 60 | party2 | 320 321 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR22" 322 And the mark price should be "1000" for the market "ETH/MAR22" 323 And the open interest should be "60" for the market "ETH/MAR22" 324 And the target stake should be "6000" for the market "ETH/MAR22" 325 And the supplied stake should be "10000" for the market "ETH/MAR22" 326 327 And the liquidity provider fee shares for the market "ETH/MAR22" should be: 328 | party | equity like share | average entry valuation | 329 | lp1 | 0.8 | 8000 | 330 | lp2 | 0.2 | 10000 | 331 332 And the price monitoring bounds for the market "ETH/MAR22" should be: 333 | min bound | max bound | 334 | 500 | 1500 | 335 336 And the liquidity fee factor should be "0.001" for the market "ETH/MAR22" 337 338 # no fees in auction 339 And the accumulated liquidity fees should be "0" for the market "ETH/MAR22" 340 341 Then the parties place the following orders with ticks: 342 | party | market id | side | volume | price | resulting trades | type | tif | reference | 343 | party1 | ETH/MAR22 | sell | 20 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | party1-sell | 344 | party2 | ETH/MAR22 | buy | 20 | 1000 | 3 | TYPE_LIMIT | TIF_GTC | party2-buy | 345 346 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR22" 347 348 And the accumulated liquidity fees should be "20" for the market "ETH/MAR22" 349 350 # opening auction + time window 351 Then time is updated to "2019-11-30T00:10:05Z" 352 353 # these are different from the tests, but again, we end up with a 0.8 vs 0.2 fee share here. 354 Then the following transfers should happen: 355 | from | to | from account | to account | market id | amount | asset | 356 | market | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/MAR22 | 16 | USD | 357 | market | lp2 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/MAR22 | 4 | USD | 358 359 And the accumulated liquidity fees should be "0" for the market "ETH/MAR22" 360 361 And the parties place the following pegged iceberg orders: 362 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 363 | lp1 | ETH/MAR22 | 2 | 1 | buy | MID | 6 | 1 | 364 | lp1 | ETH/MAR22 | 2 | 1 | sell | MID | 6 | 1 | 365 | lp2 | ETH/MAR22 | 2 | 1 | buy | MID | 2 | 1 | 366 | lp2 | ETH/MAR22 | 2 | 1 | sell | MID | 2 | 1 | 367 368 Then the parties place the following orders with ticks: 369 | party | market id | side | volume | price | resulting trades | type | tif | reference | 370 | party1 | ETH/MAR22 | buy | 40 | 1000 | 2 | TYPE_LIMIT | TIF_GTC | party1-buy | 371 | party2 | ETH/MAR22 | sell | 40 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | party2-sell | 372 373 And the following trades should be executed: 374 | buyer | price | size | seller | 375 | party1 | 951 | 6 | lp1 | 376 | party1 | 951 | 2 | lp2 | 377 378 And the accumulated liquidity fees should be "8" for the market "ETH/MAR22" 379 380 # opening auction + time window 381 Then time is updated to "2019-11-30T00:20:06Z" 382 383 # these are different from the tests, but again, we end up with a 0.8 vs 0.2 fee share here. 384 Then the following transfers should happen: 385 | from | to | from account | to account | market id | amount | asset | 386 | market | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/MAR22 | 6 | USD | 387 | market | lp2 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/MAR22 | 1 | USD | 388 389 And the accumulated liquidity fees should be "1" for the market "ETH/MAR22" 390 391 @FeeRound 392 Scenario: 004 2 LPs joining at start, unequal commitments, lp2's equity like share is very small, check the rounding of equity like share (round to 16 decimal places in this case)(0042-LIQF-004, 0042-LIQF-015) 393 394 Given the parties deposit on asset's general account the following amount: 395 | party | asset | amount | 396 | lp1 | USD | 1000000000 | 397 | lp2 | USD | 1000000000 | 398 | lp3 | USD | 1000000000 | 399 | party1 | USD | 100000000 | 400 | party2 | USD | 100000000 | 401 402 And the parties submit the following liquidity provision: 403 | id | party | market id | commitment amount | fee | lp type | 404 | lp1 | lp1 | ETH/MAR22 | 8000000 | 0.001 | submission | 405 And the parties place the following pegged iceberg orders: 406 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 407 | lp1 | ETH/MAR22 | 2970 | 1 | buy | BID | 2970 | 2 | 408 | lp1 | ETH/MAR22 | 5339 | 1 | buy | MID | 5339 | 1 | 409 | lp1 | ETH/MAR22 | 2420 | 1 | sell | ASK | 2420 | 2 | 410 | lp1 | ETH/MAR22 | 5329 | 1 | sell | MID | 5329 | 1 | 411 And the parties submit the following liquidity provision: 412 | id | party | market id | commitment amount | fee | lp type | 413 | lp2 | lp2 | ETH/MAR22 | 1 | 0.002 | submission | 414 And the parties place the following pegged iceberg orders: 415 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 416 | lp2 | ETH/MAR22 | 1 | 1 | buy | BID | 1 | 2 | 417 | lp2 | ETH/MAR22 | 1 | 1 | buy | MID | 1 | 1 | 418 | lp2 | ETH/MAR22 | 1 | 1 | sell | ASK | 1 | 2 | 419 | lp2 | ETH/MAR22 | 1 | 1 | sell | MID | 1 | 1 | 420 421 Then the parties place the following orders with ticks: 422 | party | market id | side | volume | price | resulting trades | type | tif | 423 | party1 | ETH/MAR22 | buy | 1 | 900 | 0 | TYPE_LIMIT | TIF_GTC | 424 | party1 | ETH/MAR22 | buy | 60 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 425 | party2 | ETH/MAR22 | sell | 1 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | 426 | party2 | ETH/MAR22 | sell | 60 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 427 428 Then the opening auction period ends for market "ETH/MAR22" 429 430 And the following trades should be executed: 431 | buyer | price | size | seller | 432 | party1 | 1000 | 60 | party2 | 433 434 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR22" 435 And the mark price should be "1000" for the market "ETH/MAR22" 436 And the open interest should be "60" for the market "ETH/MAR22" 437 And the target stake should be "6000" for the market "ETH/MAR22" 438 And the supplied stake should be "8000001" for the market "ETH/MAR22" 439 440 And the liquidity provider fee shares for the market "ETH/MAR22" should be: 441 | party | equity like share | average entry valuation | 442 | lp1 | 0.9999998750000156 | 8000000 | 443 | lp2 | 0.0000001249999844 | 8000001 | 444 445 And the price monitoring bounds for the market "ETH/MAR22" should be: 446 | min bound | max bound | 447 | 500 | 1500 | 448 449 And the liquidity fee factor should be "0.001" for the market "ETH/MAR22" 450 451 # no fees in auction 452 And the accumulated liquidity fees should be "0" for the market "ETH/MAR22" 453 454 Then the parties place the following orders with ticks: 455 | party | market id | side | volume | price | resulting trades | type | tif | reference | 456 | party1 | ETH/MAR22 | sell | 20 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | party1-sell | 457 | party2 | ETH/MAR22 | buy | 20 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | party2-buy | 458 And the liquidity fee factor should be "0.001" for the market "ETH/MAR22" 459 #liquidity fee: 20*1000*0.001=20 460 And the accumulated liquidity fees should be "20" for the market "ETH/MAR22" 461 462 # check lp fee distribution 463 Then time is updated to "2019-11-30T00:10:05Z" 464 465 Then the following transfers should happen: 466 | from | to | from account | to account | market id | amount | asset | 467 | market | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/MAR22 | 19 | USD | 468 | market | lp2 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/MAR22 | 0 | USD | 469 470 @FeeRound @NoPerp 471 Scenario: 005: 2 LP distribution at settlement 472 473 Given the parties deposit on asset's general account the following amount: 474 | party | asset | amount | 475 | lp1 | USD | 1000000000 | 476 | lp2 | USD | 1000000000 | 477 | lp3 | USD | 1000000000 | 478 | party1 | USD | 100000000 | 479 | party2 | USD | 100000000 | 480 481 And the parties submit the following liquidity provision: 482 | id | party | market id | commitment amount | fee | lp type | 483 | lp1 | lp1 | ETH/MAR22 | 8000000 | 0.001 | submission | 484 And the parties place the following pegged iceberg orders: 485 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 486 | lp1 | ETH/MAR22 | 2970 | 1 | buy | BID | 2970 | 2 | 487 | lp1 | ETH/MAR22 | 5339 | 1 | buy | MID | 5339 | 1 | 488 | lp1 | ETH/MAR22 | 2420 | 1 | sell | ASK | 2420 | 2 | 489 | lp1 | ETH/MAR22 | 5609 | 1 | sell | MID | 5609 | 1 | 490 And the parties submit the following liquidity provision: 491 | id | party | market id | commitment amount | fee | lp type | 492 | lp2 | lp2 | ETH/MAR22 | 1 | 0.002 | submission | 493 And the parties place the following pegged iceberg orders: 494 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 495 | lp2 | ETH/MAR22 | 1 | 1 | buy | BID | 1 | 2 | 496 | lp2 | ETH/MAR22 | 1 | 1 | buy | MID | 1 | 1 | 497 | lp2 | ETH/MAR22 | 1 | 1 | sell | ASK | 1 | 2 | 498 | lp2 | ETH/MAR22 | 1 | 1 | sell | MID | 1 | 1 | 499 500 Then the parties place the following orders: 501 | party | market id | side | volume | price | resulting trades | type | tif | 502 | party1 | ETH/MAR22 | buy | 1 | 900 | 0 | TYPE_LIMIT | TIF_GTC | 503 | party1 | ETH/MAR22 | buy | 60 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 504 | party2 | ETH/MAR22 | sell | 1 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | 505 | party2 | ETH/MAR22 | sell | 60 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 506 507 Then the opening auction period ends for market "ETH/MAR22" 508 509 And the following trades should be executed: 510 | buyer | price | size | seller | 511 | party1 | 1000 | 60 | party2 | 512 513 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/MAR22" 514 And the mark price should be "1000" for the market "ETH/MAR22" 515 And the open interest should be "60" for the market "ETH/MAR22" 516 And the target stake should be "6000" for the market "ETH/MAR22" 517 And the supplied stake should be "8000001" for the market "ETH/MAR22" 518 519 And the liquidity provider fee shares for the market "ETH/MAR22" should be: 520 | party | equity like share | average entry valuation | 521 | lp1 | 0.9999998750000156 | 8000000 | 522 | lp2 | 0.0000001249999844 | 8000001 | 523 524 And the price monitoring bounds for the market "ETH/MAR22" should be: 525 | min bound | max bound | 526 | 500 | 1500 | 527 528 And the liquidity fee factor should be "0.001" for the market "ETH/MAR22" 529 530 # no fees in auction 531 And the accumulated liquidity fees should be "0" for the market "ETH/MAR22" 532 533 Then the parties place the following orders: 534 | party | market id | side | volume | price | resulting trades | type | tif | reference | 535 | party1 | ETH/MAR22 | sell | 20 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | party1-sell | 536 537 Then the parties place the following orders: 538 | party | market id | side | volume | price | resulting trades | type | tif | reference | 539 | party2 | ETH/MAR22 | buy | 20 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | party2-buy | 540 541 And the accumulated liquidity fees should be "20" for the market "ETH/MAR22" 542 543 # settle the market 544 When the oracles broadcast data signed with "0xDEADBEEF": 545 | name | value | 546 | trading.terminated | true | 547 548 Then the oracles broadcast data signed with "0xDEADBEEF": 549 | name | value | 550 | prices.ETH.value | 1200 | 551 552 And the accumulated liquidity fees should be "0" for the market "ETH/MAR22" 553 554 Then the following transfers should happen: 555 | from | to | from account | to account | market id | amount | asset | 556 | market | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/MAR22 | 19 | USD | 557 | market | lp2 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/MAR22 | 0 | USD | 558 559 Scenario: 007 3 LPs joining at start, unequal commitments, check Liquidity fee factors are recalculated every time the liquidity demand estimate changes.(0042-LIQF-001, 0042-LIQF-005) 560 561 Given the parties deposit on asset's general account the following amount: 562 | party | asset | amount | 563 | lp1 | USD | 1000000000 | 564 | lp2 | USD | 1000000000 | 565 | lp3 | USD | 1000000000 | 566 | party1 | USD | 100000000 | 567 | party2 | USD | 100000000 | 568 569 And the parties submit the following liquidity provision: 570 | id | party | market id | commitment amount | fee | lp type | 571 | lp1 | lp1 | ETH/MAR22 | 2000 | 0.002 | submission | 572 | lp1 | lp1 | ETH/MAR22 | 2000 | 0.002 | amendment | 573 And the parties place the following pegged iceberg orders: 574 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 575 | lp1 | ETH/MAR22 | 2 | 1 | sell | ASK | 1 | 2 | 576 | lp1 | ETH/MAR22 | 2 | 1 | buy | BID | 1 | 1 | 577 578 And the parties submit the following liquidity provision: 579 | id | party | market id | commitment amount | fee | lp type | 580 | lp2 | lp2 | ETH/MAR22 | 3000 | 0.003 | submission | 581 | lp2 | lp2 | ETH/MAR22 | 3000 | 0.003 | amendment | 582 And the parties place the following pegged iceberg orders: 583 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 584 | lp2 | ETH/MAR22 | 2 | 1 | sell | ASK | 1 | 2 | 585 | lp2 | ETH/MAR22 | 2 | 1 | buy | BID | 1 | 1 | 586 587 And the parties submit the following liquidity provision: 588 | id | party | market id | commitment amount | fee | lp type | 589 | lp3 | lp3 | ETH/MAR22 | 4000 | 0.004 | submission | 590 | lp3 | lp3 | ETH/MAR22 | 4000 | 0.004 | amendment | 591 And the parties place the following pegged iceberg orders: 592 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 593 | lp3 | ETH/MAR22 | 2 | 1 | sell | ASK | 1 | 2 | 594 | lp3 | ETH/MAR22 | 2 | 1 | buy | BID | 1 | 1 | 595 596 Then the parties place the following orders with ticks: 597 | party | market id | side | volume | price | resulting trades | type | tif | 598 | party1 | ETH/MAR22 | buy | 1 | 900 | 0 | TYPE_LIMIT | TIF_GTC | 599 | party1 | ETH/MAR22 | buy | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 600 | party2 | ETH/MAR22 | sell | 1 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | 601 | party2 | ETH/MAR22 | sell | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 602 603 Then the opening auction period ends for market "ETH/MAR22" 604 And the liquidity fee factor should be "0.002" for the market "ETH/MAR22" 605 And the accumulated liquidity fees should be "0" for the market "ETH/MAR22" 606 # no fees in auction 607 608 Then the parties place the following orders with ticks: 609 | party | market id | side | volume | price | resulting trades | type | tif | 610 | party1 | ETH/MAR22 | buy | 25 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 611 | party2 | ETH/MAR22 | sell | 25 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | 612 And the accumulated liquidity fees should be "50" for the market "ETH/MAR22" 613 #liquidity fee: 25*1000*0.002=50 614 And the liquidity fee factor should be "0.003" for the market "ETH/MAR22" 615 616 Then the parties place the following orders with ticks: 617 | party | market id | side | volume | price | resulting trades | type | tif | 618 | party1 | ETH/MAR22 | buy | 25 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 619 | party2 | ETH/MAR22 | sell | 25 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | 620 And the accumulated liquidity fees should be "125" for the market "ETH/MAR22" 621 #liquidity fee: 25*1000*0.003=75 622 And the liquidity fee factor should be "0.004" for the market "ETH/MAR22" 623 624 And the following trades should be executed: 625 | buyer | price | size | seller | 626 | party1 | 1000 | 25 | party2 | 627 628 And the market data for the market "ETH/MAR22" should be: 629 | mark price | trading mode | auction trigger | extension trigger | target stake | supplied stake | open interest | 630 | 1000 | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | AUCTION_TRIGGER_UNSPECIFIED | 6000 | 9000 | 60 | 631 632 And the liquidity provider fee shares for the market "ETH/MAR22" should be: 633 | party | equity like share | average entry valuation | 634 | lp1 | 0.2222222222222222 | 2000 | 635 | lp2 | 0.3333333333333333 | 5000 | 636 | lp3 | 0.4444444444444444 | 9000 | 637 638 And the price monitoring bounds for the market "ETH/MAR22" should be: 639 | min bound | max bound | 640 | 500 | 1500 | 641 642 Then the parties place the following orders with ticks: 643 | party | market id | side | volume | price | resulting trades | type | tif | reference | 644 | party1 | ETH/MAR22 | sell | 50 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | party1-sell | 645 | party2 | ETH/MAR22 | buy | 50 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | party2-buy | 646 647 And the liquidity fee factor should be "0.004" for the market "ETH/MAR22" 648 And the accumulated liquidity fees should be "325" for the market "ETH/MAR22" 649 #liquidity fee: 50*1000*0.004=200, accumulated liquidity fee: 200+125=325 650 651 And the market data for the market "ETH/MAR22" should be: 652 | mark price | trading mode | auction trigger | extension trigger | target stake | supplied stake | open interest | 653 | 1000 | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | AUCTION_TRIGGER_UNSPECIFIED | 6000 | 9000 | 10 | 654 655 Then the parties place the following orders with ticks: 656 | party | market id | side | volume | price | resulting trades | type | tif | reference | 657 | party1 | ETH/MAR22 | buy | 200 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | party1-sell | 658 | party2 | ETH/MAR22 | sell | 200 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | party2-buy | 659 660 And the liquidity fee factor should be "0.004" for the market "ETH/MAR22" 661 And the accumulated liquidity fees should be "1125" for the market "ETH/MAR22" 662 #liquidity fee: 200*1000*0.004=800, accumulated liquidity fee: 800+325=1125 663 664 And the market data for the market "ETH/MAR22" should be: 665 | mark price | trading mode | auction trigger | extension trigger | target stake | supplied stake | open interest | 666 | 1000 | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | AUCTION_TRIGGER_UNSPECIFIED | 21000 | 9000 | 210 | 667 668