code.vegaprotocol.io/vega@v0.79.0/core/integration/features/amm/0090-VAMM-auction.feature (about) 1 Feature: vAMM rebasing when created or amended 2 3 Background: 4 Given the average block duration is "1" 5 And the margin calculator named "margin-calculator-1": 6 | search factor | initial factor | release factor | 7 | 1.2 | 1.5 | 1.7 | 8 And the log normal risk model named "log-normal-risk-model": 9 | risk aversion | tau | mu | r | sigma | 10 | 0.001 | 0.0011407711613050422 | 0 | 0.9 | 3.0 | 11 And the liquidity monitoring parameters: 12 | name | triggering ratio | time window | scaling factor | 13 | lqm-params | 1.00 | 20s | 1 | 14 15 And the following network parameters are set: 16 | name | value | 17 | market.value.windowLength | 60s | 18 | network.markPriceUpdateMaximumFrequency | 0s | 19 | limits.markets.maxPeggedOrders | 6 | 20 | market.auction.minimumDuration | 1 | 21 | market.fee.factors.infrastructureFee | 0.001 | 22 | market.fee.factors.makerFee | 0.004 | 23 | spam.protection.max.stopOrdersPerMarket | 5 | 24 | market.liquidity.equityLikeShareFeeFraction | 1 | 25 | market.amm.minCommitmentQuantum | 1 | 26 | market.liquidity.bondPenaltyParameter | 0.2 | 27 | market.liquidity.stakeToCcyVolume | 1 | 28 | market.liquidity.successorLaunchWindowLength | 1h | 29 | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0 | 30 | market.liquidity.sla.nonPerformanceBondPenaltyMax | 0.6 | 31 | validators.epoch.length | 10s | 32 | market.liquidity.earlyExitPenalty | 0.25 | 33 | market.liquidity.maximumLiquidityFeeFactorLevel | 0.25 | 34 #risk factor short:3.5569036 35 #risk factor long:0.801225765 36 And the following assets are registered: 37 | id | decimal places | 38 | USD | 0 | 39 And the fees configuration named "fees-config-1": 40 | maker fee | infrastructure fee | 41 | 0.0004 | 0.001 | 42 43 And the liquidity sla params named "SLA-22": 44 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 45 | 0.5 | 0.6 | 1 | 1.0 | 46 47 And the markets: 48 | 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 | 49 | ETH/MAR22 | USD | USD | lqm-params | log-normal-risk-model | margin-calculator-1 | 2 | fees-config-1 | default-none | default-eth-for-future | 1e0 | 0 | SLA-22 | 50 51 # Setting up the accounts and vAMM submission now is part of the background, because we'll be running scenarios 0090-VAMM-006 through 0090-VAMM-014 on this setup 52 Given the parties deposit on asset's general account the following amount: 53 | party | asset | amount | 54 | lp1 | USD | 1000000 | 55 | lp2 | USD | 1000000 | 56 | lp3 | USD | 1000000 | 57 | party1 | USD | 1000000 | 58 | party2 | USD | 1000000 | 59 | party3 | USD | 1000000 | 60 | party4 | USD | 1000000 | 61 | party5 | USD | 1000000 | 62 | vamm1 | USD | 1000000 | 63 | vamm2 | USD | 1000000 | 64 | vamm3 | USD | 1000000 | 65 | vamm4 | USD | 1000000 | 66 67 @VAMM 68 Scenario: two crossed AMMs at opening auction end 69 70 Then the parties submit the following AMM: 71 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 72 | vamm1 | ETH/MAR22 | 100000 | 0.05 | 102 | 92 | 112 | 0.03 | 73 Then the AMM pool status should be: 74 | party | market id | amount | status | base | lower bound | upper bound | 75 | vamm1 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 102 | 92 | 112 | 76 77 And the market data for the market "ETH/MAR22" should be: 78 | trading mode | indicative price | indicative volume | 79 | TRADING_MODE_OPENING_AUCTION | 0 | 0 | 80 81 Then the parties submit the following AMM: 82 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 83 | vamm2 | ETH/MAR22 | 100000 | 0.05 | 98 | 88 | 108 | 0.03 | 84 Then the AMM pool status should be: 85 | party | market id | amount | status | base | lower bound | upper bound | 86 | vamm2 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 98 | 88 | 108 | 87 88 89 And set the following AMM sub account aliases: 90 | party | market id | alias | 91 | vamm1 | ETH/MAR22 | vamm1-id | 92 | vamm2 | ETH/MAR22 | vamm2-id | 93 94 And the market data for the market "ETH/MAR22" should be: 95 | trading mode | indicative price | indicative volume | 96 | TRADING_MODE_OPENING_AUCTION | 100 | 91 | 97 98 When the opening auction period ends for market "ETH/MAR22" 99 Then the following trades should be executed: 100 | buyer | price | size | seller | is amm | 101 | vamm1-id | 100 | 91 | vamm2-id | true | 102 103 Then the network moves ahead "1" blocks 104 105 # two AMMs are now prices at ~100 which is between their base values 106 And the market data for the market "ETH/MAR22" should be: 107 | mark price | trading mode | best bid price | best offer price | 108 | 100 | TRADING_MODE_CONTINUOUS | 99 | 101 | 109 110 111 @VAMM 112 Scenario: two AMM's that cross at a single point i.e no overlap 113 114 Then the parties submit the following AMM: 115 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 116 | vamm1 | ETH/MAR22 | 100000 | 0.05 | 100 | 95 | 105 | 0.03 | 117 Then the AMM pool status should be: 118 | party | market id | amount | status | base | lower bound | upper bound | 119 | vamm1 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 100 | 95 | 105 | 120 121 And the market data for the market "ETH/MAR22" should be: 122 | trading mode | indicative price | indicative volume | 123 | TRADING_MODE_OPENING_AUCTION | 0 | 0 | 124 125 Then the parties submit the following AMM: 126 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 127 | vamm2 | ETH/MAR22 | 100000 | 0.05 | 102 | 97 | 107 | 0.03 | 128 Then the AMM pool status should be: 129 | party | market id | amount | status | base | lower bound | upper bound | 130 | vamm2 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 102 | 97 | 107 | 131 132 133 And set the following AMM sub account aliases: 134 | party | market id | alias | 135 | vamm1 | ETH/MAR22 | vamm1-id | 136 | vamm2 | ETH/MAR22 | vamm2-id | 137 138 And the market data for the market "ETH/MAR22" should be: 139 | trading mode | indicative price | indicative volume | 140 | TRADING_MODE_OPENING_AUCTION | 101 | 92 | 141 142 When the opening auction period ends for market "ETH/MAR22" 143 Then the following trades should be executed: 144 | buyer | price | size | seller | is amm | 145 | vamm2-id | 101 | 92 | vamm1-id | true | 146 147 Then the network moves ahead "1" blocks 148 149 # two AMMs are now prices at ~100 which is between their base values 150 And the market data for the market "ETH/MAR22" should be: 151 | mark price | trading mode | best bid price | best offer price | 152 | 101 | TRADING_MODE_CONTINUOUS | 100 | 102 | 153 154 @VAMM 155 Scenario: AMM crossed with SELL orders 156 157 Then the parties submit the following AMM: 158 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 159 | vamm1 | ETH/MAR22 | 100000 | 0.05 | 100 | 90 | 110 | 0.03 | 160 Then the AMM pool status should be: 161 | party | market id | amount | status | base | lower bound | upper bound | 162 | vamm1 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 100 | 90 | 110 | 163 164 165 And the parties place the following orders: 166 | party | market id | side | volume | price | resulting trades | type | tif | reference | 167 | lp1 | ETH/MAR22 | sell | 100 | 95 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 168 169 And set the following AMM sub account aliases: 170 | party | market id | alias | 171 | vamm1 | ETH/MAR22 | vamm1-id | 172 173 174 And the market data for the market "ETH/MAR22" should be: 175 | trading mode | indicative price | indicative volume | 176 | TRADING_MODE_OPENING_AUCTION | 96 | 100 | 177 178 When the opening auction period ends for market "ETH/MAR22" 179 Then the following trades should be executed: 180 | buyer | price | size | seller | is amm | 181 | vamm1-id | 96 | 100 | lp1 | true | 182 183 184 Then the network moves ahead "1" blocks 185 And the market data for the market "ETH/MAR22" should be: 186 | mark price | trading mode | best bid price | best offer price | 187 | 96 | TRADING_MODE_CONTINUOUS | 97 | 99 | 188 189 @VAMM 190 Scenario: AMM crossed with BUY orders 191 192 Then the parties submit the following AMM: 193 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 194 | vamm1 | ETH/MAR22 | 100000 | 0.05 | 100 | 90 | 110 | 0.03 | 195 Then the AMM pool status should be: 196 | party | market id | amount | status | base | lower bound | upper bound | 197 | vamm1 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 100 | 90 | 110 | 198 199 And the parties place the following orders: 200 | party | market id | side | volume | price | resulting trades | type | tif | reference | 201 | lp1 | ETH/MAR22 | buy | 100 | 105 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 202 203 And set the following AMM sub account aliases: 204 | party | market id | alias | 205 | vamm1 | ETH/MAR22 | vamm1-id | 206 207 208 And the market data for the market "ETH/MAR22" should be: 209 | trading mode | indicative price | indicative volume | 210 | TRADING_MODE_OPENING_AUCTION | 104 | 100 | 211 212 When the opening auction period ends for market "ETH/MAR22" 213 Then the following trades should be executed: 214 | buyer | price | size | seller | is amm | 215 | lp1 | 104 | 100 | vamm1-id | true | 216 217 218 Then the network moves ahead "1" blocks 219 And the market data for the market "ETH/MAR22" should be: 220 | mark price | trading mode | best bid price | best offer price | 221 | 104 | TRADING_MODE_CONTINUOUS | 102 | 104 | 222 223 224 @VAMM 225 Scenario: AMM's crossed with orders and AMMs 226 227 Then the parties submit the following AMM: 228 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 229 | vamm1 | ETH/MAR22 | 100000 | 0.05 | 100 | 90 | 110 | 0.03 | 230 Then the AMM pool status should be: 231 | party | market id | amount | status | base | lower bound | upper bound | 232 | vamm1 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 100 | 90 | 110 | 233 234 Then the parties submit the following AMM: 235 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 236 | vamm2 | ETH/MAR22 | 100000 | 0.05 | 98 | 88 | 108 | 0.03 | 237 Then the AMM pool status should be: 238 | party | market id | amount | status | base | lower bound | upper bound | 239 | vamm2 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 98 | 88 | 108 | 240 241 And the parties place the following orders: 242 | party | market id | side | volume | price | resulting trades | type | tif | reference | 243 | lp1 | ETH/MAR22 | buy | 50 | 105 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 244 | lp1 | ETH/MAR22 | buy | 50 | 102 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 245 | lp2 | ETH/MAR22 | sell | 50 | 95 | 0 | TYPE_LIMIT | TIF_GTC | lp2-b | 246 | lp2 | ETH/MAR22 | sell | 50 | 98 | 0 | TYPE_LIMIT | TIF_GTC | lp2-b | 247 248 And set the following AMM sub account aliases: 249 | party | market id | alias | 250 | vamm1 | ETH/MAR22 | vamm1-id | 251 | vamm2 | ETH/MAR22 | vamm2-id | 252 253 254 And the market data for the market "ETH/MAR22" should be: 255 | trading mode | indicative price | indicative volume | 256 | TRADING_MODE_OPENING_AUCTION | 99 | 146 | 257 258 When the opening auction period ends for market "ETH/MAR22" 259 Then the following trades should be executed: 260 | buyer | price | size | seller | is amm | 261 | lp1 | 99 | 46 | vamm2-id | true | 262 | lp1 | 99 | 4 | lp2 | false | 263 | lp1 | 99 | 46 | lp2 | false | 264 | lp1 | 99 | 4 | lp2 | false | 265 | vamm1-id | 99 | 46 | lp2 | true | 266 267 268 Then the network moves ahead "1" blocks 269 And the market data for the market "ETH/MAR22" should be: 270 | mark price | trading mode | best bid price | best offer price | 271 | 99 | TRADING_MODE_CONTINUOUS | 98 | 100 | 272 273 274 @VAMM 275 Scenario: Crossed orders then AMM submitted 276 277 When the parties place the following orders: 278 | party | market id | side | volume | price | resulting trades | type | tif | reference | 279 | lp1 | ETH/MAR22 | buy | 50 | 105 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 280 | lp1 | ETH/MAR22 | buy | 50 | 102 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 281 | lp2 | ETH/MAR22 | sell | 50 | 95 | 0 | TYPE_LIMIT | TIF_GTC | lp2-b | 282 #| lp2 | ETH/MAR22 | sell | 50 | 98 | 0 | TYPE_LIMIT | TIF_GTC | lp2-b | 283 284 And the market data for the market "ETH/MAR22" should be: 285 | trading mode | indicative price | indicative volume | 286 | TRADING_MODE_OPENING_AUCTION | 100 | 50 | 287 288 Then the parties submit the following AMM: 289 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 290 | vamm1 | ETH/MAR22 | 100000 | 0.05 | 100 | 90 | 110 | 0.03 | 291 Then the AMM pool status should be: 292 | party | market id | amount | status | base | lower bound | upper bound | 293 | vamm1 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 100 | 90 | 110 | 294 295 296 And set the following AMM sub account aliases: 297 | party | market id | alias | 298 | vamm1 | ETH/MAR22 | vamm1-id | 299 300 301 And the market data for the market "ETH/MAR22" should be: 302 | trading mode | indicative price | indicative volume | 303 | TRADING_MODE_OPENING_AUCTION | 102 | 100 | 304 305 When the opening auction period ends for market "ETH/MAR22" 306 #Then the following trades should be executed: 307 # | buyer | price | size | seller | is amm | 308 # | vamm1-id | 96 | 100 | lp1 | true | 309 310 311 Then the network moves ahead "1" blocks 312 And the market data for the market "ETH/MAR22" should be: 313 | mark price | trading mode | best bid price | best offer price | 314 | 102 | TRADING_MODE_CONTINUOUS | 101 | 103 | 315 316 @VAMM 317 Scenario: AMM cancelled and amending when in auction 318 319 Then the parties submit the following AMM: 320 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 321 | vamm1 | ETH/MAR22 | 100000 | 0.05 | 100 | 90 | 110 | 0.03 | 322 Then the AMM pool status should be: 323 | party | market id | amount | status | base | lower bound | upper bound | 324 | vamm1 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 100 | 90 | 110 | 325 326 And the market data for the market "ETH/MAR22" should be: 327 | trading mode | indicative price | indicative volume | 328 | TRADING_MODE_OPENING_AUCTION | 0 | 0 | 329 330 331 When the parties submit the following AMM: 332 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 333 | vamm2 | ETH/MAR22 | 100000 | 0.05 | 95 | 85 | 105 | 0.03 | 334 Then the AMM pool status should be: 335 | party | market id | amount | status | base | lower bound | upper bound | 336 | vamm2 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 95 | 85 | 105 | 337 338 And the market data for the market "ETH/MAR22" should be: 339 | trading mode | indicative price | indicative volume | 340 | TRADING_MODE_OPENING_AUCTION | 98 | 104 | 341 342 343 And set the following AMM sub account aliases: 344 | party | market id | alias | 345 | vamm1 | ETH/MAR22 | vamm1-id | 346 | vamm2 | ETH/MAR22 | vamm2-id | 347 348 349 # amend so that its not crossed 350 When the parties amend the following AMM: 351 | party | market id | slippage | base | lower bound | upper bound | 352 | vamm2 | ETH/MAR22 | 0.1 | 100 | 90 | 110 | 353 Then the AMM pool status should be: 354 | party | market id | amount | status | base | lower bound | upper bound | 355 | vamm2 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 100 | 90 | 110 | 356 357 And the market data for the market "ETH/MAR22" should be: 358 | trading mode | indicative price | indicative volume | 359 | TRADING_MODE_OPENING_AUCTION | 0 | 0 | 360 361 362 # amend so that its more crossed again at a different point 363 When the parties amend the following AMM: 364 | party | market id | slippage | base | lower bound | upper bound | 365 | vamm2 | ETH/MAR22 | 0.1 | 98 | 88 | 108 | 366 Then the AMM pool status should be: 367 | party | market id | amount | status | base | lower bound | upper bound | 368 | vamm2 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 98 | 88 | 108 | 369 370 And the market data for the market "ETH/MAR22" should be: 371 | trading mode | indicative price | indicative volume | 372 | TRADING_MODE_OPENING_AUCTION | 99 | 46 | 373 374 # then the second AMM is cancels 375 When the parties cancel the following AMM: 376 | party | market id | method | 377 | vamm2 | ETH/MAR22 | METHOD_IMMEDIATE | 378 379 And the market data for the market "ETH/MAR22" should be: 380 | trading mode | indicative price | indicative volume | 381 | TRADING_MODE_OPENING_AUCTION | 0 | 0 | 382 383 384 # then amend the first AMM and re-create the second 385 When the parties amend the following AMM: 386 | party | market id | slippage | base | lower bound | upper bound | 387 | vamm1 | ETH/MAR22 | 0.1 | 98 | 88 | 108 | 388 Then the AMM pool status should be: 389 | party | market id | amount | status | base | lower bound | upper bound | 390 | vamm1 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 98 | 88 | 108 | 391 392 When the parties submit the following AMM: 393 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 394 | vamm2 | ETH/MAR22 | 100000 | 0.05 | 102 | 92 | 112 | 0.03 | 395 Then the AMM pool status should be: 396 | party | market id | amount | status | base | lower bound | upper bound | 397 | vamm2 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 102 | 92 | 112 | 398 399 400 And the market data for the market "ETH/MAR22" should be: 401 | trading mode | indicative price | indicative volume | 402 | TRADING_MODE_OPENING_AUCTION | 100 | 91 | 403 404 405 # now uncross 406 When the opening auction period ends for market "ETH/MAR22" 407 Then the following trades should be executed: 408 | buyer | price | size | seller | is amm | 409 | vamm2-id | 100 | 91 | vamm1-id | true | 410 411 412 Then the network moves ahead "1" blocks 413 And the market data for the market "ETH/MAR22" should be: 414 | mark price | trading mode | best bid price | best offer price | 415 | 100 | TRADING_MODE_CONTINUOUS | 99 | 101 | 416 417 Scenario: Stagnet auction uncrossing panic where uncrossing side has both AMM and orderbook volume at the same level but we only need the orderbook volume 418 Then the parties submit the following AMM: 419 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 420 | vamm1 | ETH/MAR22 | 100000 | 0.05 | 100 | 90 | 110 | 0.03 | 421 Then the AMM pool status should be: 422 | party | market id | amount | status | base | lower bound | upper bound | 423 | vamm1 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 100 | 90 | 110 | 424 425 426 And the parties place the following orders: 427 | party | market id | side | volume | price | resulting trades | type | tif | reference | 428 | lp1 | ETH/MAR22 | sell | 10 | 99 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 429 | lp1 | ETH/MAR22 | sell | 160 | 95 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 430 | lp2 | ETH/MAR22 | buy | 2 | 98 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 431 432 And the market data for the market "ETH/MAR22" should be: 433 | trading mode | indicative price | indicative volume | best bid price | best offer price | 434 | TRADING_MODE_OPENING_AUCTION | 96 | 160 | 99 | 95 | 435 436 437 When the opening auction period ends for market "ETH/MAR22" 438 Then the network moves ahead "1" blocks 439 And the market data for the market "ETH/MAR22" should be: 440 | mark price | trading mode | best bid price | best offer price | 441 | 96 | TRADING_MODE_CONTINUOUS | 96 | 98 | 442 443 @VAMM 444 Scenario: complicated AMM's crossed with orders and pegged orders 445 446 # these are buys 447 And the parties place the following orders: 448 | party | market id | side | volume | price | resulting trades | type | tif | reference | 449 | lp1 | ETH/MAR22 | buy | 50 | 105 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 450 | lp1 | ETH/MAR22 | buy | 50 | 103 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 451 | lp1 | ETH/MAR22 | buy | 50 | 101 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 452 | lp1 | ETH/MAR22 | buy | 50 | 99 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 453 | lp1 | ETH/MAR22 | buy | 50 | 98 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 454 455 # these are sells 456 And the parties place the following orders: 457 | party | market id | side | volume | price | resulting trades | type | tif | reference | 458 | lp2 | ETH/MAR22 | sell | 50 | 102 | 0 | TYPE_LIMIT | TIF_GTC | lp2-b | 459 | lp2 | ETH/MAR22 | sell | 50 | 98 | 0 | TYPE_LIMIT | TIF_GTC | lp2-b | 460 | lp2 | ETH/MAR22 | sell | 50 | 95 | 0 | TYPE_LIMIT | TIF_GTC | lp2-b | 461 462 463 Then the parties submit the following AMM: 464 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 465 | vamm1 | ETH/MAR22 | 100000 | 0.05 | 100 | 90 | 110 | 0.03 | 466 Then the AMM pool status should be: 467 | party | market id | amount | status | base | lower bound | upper bound | 468 | vamm1 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 100 | 90 | 110 | 469 470 Then the parties submit the following AMM: 471 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 472 | vamm2 | ETH/MAR22 | 100000 | 0.05 | 90 | 85 | 95 | 0.03 | 473 Then the AMM pool status should be: 474 | party | market id | amount | status | base | lower bound | upper bound | 475 | vamm2 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 90 | 85 | 95 | 476 477 478 Then the parties submit the following AMM: 479 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 480 | vamm3 | ETH/MAR22 | 100000 | 0.05 | 90 | 85 | 95 | 0.03 | 481 Then the AMM pool status should be: 482 | party | market id | amount | status | base | lower bound | upper bound | 483 | vamm3 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 90 | 85 | 95 | 484 485 486 487 # now place some pegged orders which will cause a panic if the uncrossing is crossed 488 When the parties place the following pegged orders: 489 | party | market id | side | volume | pegged reference | offset | 490 | lp3 | ETH/MAR22 | buy | 100 | BID | 1 | 491 | lp3 | ETH/MAR22 | sell | 100 | ASK | 1 | 492 493 And set the following AMM sub account aliases: 494 | party | market id | alias | 495 | vamm1 | ETH/MAR22 | vamm1-id | 496 | vamm2 | ETH/MAR22 | vamm2-id | 497 498 499 And the market data for the market "ETH/MAR22" should be: 500 | trading mode | indicative price | indicative volume | 501 | TRADING_MODE_OPENING_AUCTION | 93 | 602 | 502 503 504 When the opening auction period ends for market "ETH/MAR22" 505 And the market data for the market "ETH/MAR22" should be: 506 | mark price | trading mode | best bid price | best offer price | 507 | 93 | TRADING_MODE_CONTINUOUS | 92 | 94 | 508 509 510 @VAMM 511 Scenario: AMM crossed with limit order, AMM pushed to boundary 512 513 514 And the parties place the following orders: 515 | party | market id | side | volume | price | resulting trades | type | tif | reference | 516 | lp1 | ETH/MAR22 | buy | 423 | 200 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 517 518 Then the parties submit the following AMM: 519 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 520 | vamm1 | ETH/MAR22 | 100000 | 0.05 | 100 | 90 | 110 | 0.03 | 521 Then the AMM pool status should be: 522 | party | market id | amount | status | base | lower bound | upper bound | 523 | vamm1 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 100 | 90 | 110 | 524 525 526 # now place some pegged orders which will cause a panic if the uncrossing is crossed 527 When the parties place the following pegged orders: 528 | party | market id | side | volume | pegged reference | offset | 529 | lp3 | ETH/MAR22 | buy | 100 | BID | 1 | 530 | lp3 | ETH/MAR22 | sell | 100 | ASK | 1 | 531 532 And set the following AMM sub account aliases: 533 | party | market id | alias | 534 | vamm1 | ETH/MAR22 | vamm1-id | 535 536 537 And the market data for the market "ETH/MAR22" should be: 538 | trading mode | indicative price | indicative volume | 539 | TRADING_MODE_OPENING_AUCTION | 155 | 423 | 540 541 542 When the opening auction period ends for market "ETH/MAR22" 543 544 # the volume of this trade should be the entire volume of the AMM's sell curve 545 Then the following trades should be executed: 546 | buyer | price | size | seller | is amm | 547 | lp1 | 155 | 423 | vamm1-id | true | 548 549 And the market data for the market "ETH/MAR22" should be: 550 | mark price | trading mode | best bid price | best offer price | 551 | 155 | TRADING_MODE_CONTINUOUS | 109 | 0 | 552 553 @VAMM 554 Scenario: Two AMMs crossed with large order expansion 555 556 Then the parties submit the following AMM: 557 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 558 | vamm1 | ETH/MAR22 | 1000000 | 0.05 | 150 | 100 | 200 | 0.03 | 559 Then the AMM pool status should be: 560 | party | market id | amount | status | base | lower bound | upper bound | 561 | vamm1 | ETH/MAR22 | 1000000 | STATUS_ACTIVE | 150 | 100 | 200 | 562 563 And the market data for the market "ETH/MAR22" should be: 564 | trading mode | indicative price | indicative volume | 565 | TRADING_MODE_OPENING_AUCTION | 0 | 0 | 566 567 Then the parties submit the following AMM: 568 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 569 | vamm2 | ETH/MAR22 | 1000000 | 0.05 | 250 | 200 | 300 | 0.03 | 570 Then the AMM pool status should be: 571 | party | market id | amount | status | base | lower bound | upper bound | 572 | vamm2 | ETH/MAR22 | 1000000 | STATUS_ACTIVE | 250 | 200 | 300 | 573 574 575 And set the following AMM sub account aliases: 576 | party | market id | alias | 577 | vamm1 | ETH/MAR22 | vamm1-id | 578 | vamm2 | ETH/MAR22 | vamm2-id | 579 580 And the market data for the market "ETH/MAR22" should be: 581 | trading mode | indicative price | indicative volume | 582 | TRADING_MODE_OPENING_AUCTION | 201 | 2238 | 583 584 When the opening auction period ends for market "ETH/MAR22" 585 586 # note that this is one big order instead of a hundred small orders 587 Then the following trades should be executed: 588 | buyer | price | size | seller | is amm | 589 | vamm2-id | 201 | 2238 | vamm1-id | true | 590 591 Then the network moves ahead "1" blocks 592 593 # two AMMs are now prices at ~100 which is between their base values 594 And the market data for the market "ETH/MAR22" should be: 595 | mark price | trading mode | best bid price | best offer price | 596 | 201 | TRADING_MODE_CONTINUOUS | 202 | 204 |