code.vegaprotocol.io/vega@v0.79.0/core/integration/features/amm/0090-VAMM-021.feature (about) 1 Feature: Test vAMM cancellation by reduce-only from short. 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.1 | 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 64 When the parties submit the following liquidity provision: 65 | id | party | market id | commitment amount | fee | lp type | 66 | lp_1 | lp1 | ETH/MAR22 | 600 | 0.02 | submission | 67 | lp_2 | lp2 | ETH/MAR22 | 400 | 0.015 | submission | 68 Then the network moves ahead "4" blocks 69 And the current epoch is "0" 70 71 And the parties place the following orders: 72 | party | market id | side | volume | price | resulting trades | type | tif | reference | 73 | lp1 | ETH/MAR22 | buy | 20 | 40 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 74 | party1 | ETH/MAR22 | buy | 1 | 100 | 0 | TYPE_LIMIT | TIF_GTC | | 75 | party2 | ETH/MAR22 | sell | 1 | 100 | 0 | TYPE_LIMIT | TIF_GTC | | 76 | lp1 | ETH/MAR22 | sell | 10 | 160 | 0 | TYPE_LIMIT | TIF_GTC | lp1-s | 77 When the opening auction period ends for market "ETH/MAR22" 78 Then the following trades should be executed: 79 | buyer | price | size | seller | 80 | party1 | 100 | 1 | party2 | 81 82 And the market data for the market "ETH/MAR22" should be: 83 | mark price | trading mode | target stake | supplied stake | open interest | ref price | mid price | static mid price | 84 | 100 | TRADING_MODE_CONTINUOUS | 39 | 1000 | 1 | 100 | 100 | 100 | 85 When the parties submit the following AMM: 86 | party | market id | amount | slippage | base | lower bound | upper bound | lower leverage | upper leverage | proposed fee | 87 | vamm1 | ETH/MAR22 | 100000 | 0.1 | 100 | 85 | 150 | 4 | 4 | 0.01 | 88 Then the AMM pool status should be: 89 | party | market id | amount | status | base | lower bound | upper bound | lower leverage | upper leverage | 90 | vamm1 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 100 | 85 | 150 | 4 | 4 | 91 92 And set the following AMM sub account aliases: 93 | party | market id | alias | 94 | vamm1 | ETH/MAR22 | vamm1-id | 95 And the following transfers should happen: 96 | from | from account | to | to account | market id | amount | asset | is amm | type | 97 | vamm1 | ACCOUNT_TYPE_GENERAL | vamm1-id | ACCOUNT_TYPE_GENERAL | | 100000 | USD | true | TRANSFER_TYPE_AMM_LOW | 98 99 100 @VAMM 101 Scenario: 0090-VAMM-021: If a vAMM is cancelled and set in Reduce-Only mode when it is currently short, then it creates no further sell orders even if the current price is below the configured upper price. When one of it's buy orders is executed it still does not produce sell orders, and correctly quotes buy orders from a lower price. When the position reaches 0 the vAMM is closed and all funds are released to the user after the next mark to market. 102 # based on 0090-VAMM-008: vAMM creates a position, has some general balance left in general and margin accounts. 103 When the parties place the following orders: 104 | party | market id | side | volume | price | resulting trades | type | tif | reference | 105 | party4 | ETH/MAR22 | buy | 500 | 155 | 1 | TYPE_LIMIT | TIF_GTC | p4-first | 106 # see the trades that make the vAMM go short 107 Then the following trades should be executed: 108 | buyer | price | size | seller | is amm | 109 | party4 | 122 | 291 | vamm1-id | true | 110 And the market data for the market "ETH/MAR22" should be: 111 | mark price | trading mode | mid price | static mid price | best offer price | best bid price | 112 | 100 | TRADING_MODE_CONTINUOUS | 157 | 157 | 160 | 155 | 113 114 # trying to trade again causes no trades because the AMM has no more volume 115 When the parties place the following orders: 116 | party | market id | side | volume | price | resulting trades | type | tif | reference | 117 | party4 | ETH/MAR22 | buy | 500 | 150 | 0 | TYPE_LIMIT | TIF_GTC | p4-second | 118 119 # the AMM's mid price has moved to 150, but it has no volume +150 so that best offer comes from the orderbook of 160 120 Then the market data for the market "ETH/MAR22" should be: 121 | mark price | trading mode | mid price | static mid price | best offer price | best bid price | 122 | 100 | TRADING_MODE_CONTINUOUS | 157 | 157 | 160 | 155 | 123 124 When the network moves ahead "1" blocks 125 Then the parties should have the following profit and loss: 126 | party | volume | unrealised pnl | realised pnl | is amm | 127 | party4 | 291 | 0 | 0 | | 128 | vamm1-id | -291 | 0 | 0 | true | 129 # Notional value therefore is 291 * 122 130 And the market data for the market "ETH/MAR22" should be: 131 | mark price | trading mode | mid price | static mid price | best offer price | best bid price | 132 | 122 | TRADING_MODE_CONTINUOUS | 157 | 157 | 160 | 155 | 133 134 # vAMM receives fees, but loses out in the MTM settlement 135 And the following transfers should happen: 136 | from | from account | to | to account | market id | amount | asset | is amm | type | 137 | | ACCOUNT_TYPE_FEES_MAKER | vamm1-id | ACCOUNT_TYPE_GENERAL | ETH/MAR22 | 143 | USD | true | TRANSFER_TYPE_MAKER_FEE_RECEIVE | 138 | vamm1-id | ACCOUNT_TYPE_GENERAL | vamm1-id | ACCOUNT_TYPE_MARGIN | ETH/MAR22 | 74548 | USD | true | TRANSFER_TYPE_MARGIN_LOW | 139 And the parties should have the following account balances: 140 | party | asset | market id | general | margin | is amm | 141 | vamm1 | USD | | 900000 | | | 142 | vamm1-id | USD | ETH/MAR22 | 25595 | 74548 | true | 143 144 # Reduce only cancellation: vAMM only trades to reduce its position. 145 When the parties cancel the following AMM: 146 | party | market id | method | 147 | vamm1 | ETH/MAR22 | METHOD_REDUCE_ONLY | 148 Then the AMM pool status should be: 149 | party | market id | amount | status | base | lower bound | upper bound | lower leverage | upper leverage | 150 | vamm1 | ETH/MAR22 | 100000 | STATUS_REDUCE_ONLY | 100 | 85 | 150 | 4 | 4 | 151 # Cancel the remaining order from the start of the test 152 When the parties cancel the following orders: 153 | party | reference | 154 | party4 | p4-first | 155 | party4 | p4-second | 156 # Ensure the vAMM cancellation works as expected: a short position should not increase. 157 # Place buy orders at mid price, current mark price, and best bid. 158 Then the parties place the following orders: 159 | party | market id | side | volume | price | resulting trades | type | tif | 160 | party4 | ETH/MAR22 | buy | 10 | 122 | 0 | TYPE_LIMIT | TIF_GTC | 161 | party4 | ETH/MAR22 | buy | 10 | 149 | 0 | TYPE_LIMIT | TIF_GTC | 162 | party4 | ETH/MAR22 | buy | 10 | 154 | 0 | TYPE_LIMIT | TIF_GTC | 163 And the market data for the market "ETH/MAR22" should be: 164 | mark price | trading mode | mid price | static mid price | best offer price | best bid price | 165 | 122 | TRADING_MODE_CONTINUOUS | 157 | 157 | 160 | 154 | 166 167 # Now bring in another party that will trade with the buy orders we've just placed, and reduce the exposure of the vAMM 168 When the parties place the following orders: 169 | party | market id | side | volume | price | resulting trades | type | tif | 170 | party5 | ETH/MAR22 | sell | 172 | 121 | 6 | TYPE_LIMIT | TIF_GTC | 171 Then the following trades should be executed: 172 | buyer | price | size | seller | is amm | 173 | party4 | 154 | 10 | party5 | | 174 | party4 | 149 | 10 | party5 | | 175 | party4 | 122 | 10 | party5 | | 176 | vamm1-id | 149 | 4 | party5 | true | 177 | vamm1-id | 134 | 137 | party5 | true | 178 | vamm1-id | 121 | 1 | party5 | true | 179 180 When the network moves ahead "1" blocks 181 Then the parties should have the following profit and loss: 182 | party | volume | unrealised pnl | realised pnl | is amm | 183 | party4 | 321 | -911 | 0 | | 184 | party5 | -172 | 2513 | 0 | | 185 | vamm1-id | -149 | 149 | -1751 | true | 186 And the following transfers should happen: 187 | from | from account | to | to account | market id | amount | asset | is amm | type | 188 | | ACCOUNT_TYPE_FEES_MAKER | vamm1-id | ACCOUNT_TYPE_GENERAL | ETH/MAR22 | 74 | USD | true | TRANSFER_TYPE_MAKER_FEE_RECEIVE | 189 | vamm1-id | ACCOUNT_TYPE_MARGIN | | ACCOUNT_TYPE_SETTLEMENT | ETH/MAR22 | 1602 | USD | true | TRANSFER_TYPE_MTM_LOSS | 190 | vamm1-id | ACCOUNT_TYPE_MARGIN | vamm1-id | ACCOUNT_TYPE_GENERAL | ETH/MAR22 | 35088 | USD | true | TRANSFER_TYPE_MARGIN_HIGH | 191 And the parties should have the following account balances: 192 | party | asset | market id | general | margin | is amm | 193 | vamm1 | USD | | 900000 | | | 194 | vamm1-id | USD | ETH/MAR22 | 60761 | 37858 | true | 195 # vAMM isn't quoting on its offer side due to being in reduce only, so best offer comes from an order 196 And the market data for the market "ETH/MAR22" should be: 197 | mark price | trading mode | mid price | static mid price | best offer price | best bid price | 198 | 121 | TRADING_MODE_CONTINUOUS | 140 | 140 | 160 | 121 | 199 200 # Cool, now close the position a little bit vamm completely 201 When the parties place the following orders: 202 | party | market id | side | volume | price | resulting trades | type | tif | 203 | party5 | ETH/MAR22 | sell | 40 | 115 | 1 | TYPE_LIMIT | TIF_GTC | 204 Then the following trades should be executed: 205 | buyer | price | size | seller | is amm | 206 | vamm1-id | 118 | 40 | party5 | true | 207 When the network moves ahead "1" blocks 208 Then the parties should have the following profit and loss: 209 | party | volume | unrealised pnl | realised pnl | is amm | 210 | party4 | 321 | -1874 | 0 | | 211 | party5 | -212 | 3029 | 0 | | 212 | vamm1-id | -109 | 436 | -1591 | true | 213 And the following transfers should happen: 214 | from | from account | to | to account | market id | amount | asset | is amm | type | 215 | | ACCOUNT_TYPE_FEES_MAKER | vamm1-id | ACCOUNT_TYPE_GENERAL | ETH/MAR22 | 19 | USD | true | TRANSFER_TYPE_MAKER_FEE_RECEIVE | 216 | vamm1-id | ACCOUNT_TYPE_MARGIN | vamm1-id | ACCOUNT_TYPE_GENERAL | ETH/MAR22 | 11296 | USD | true | TRANSFER_TYPE_MARGIN_HIGH | 217 And the parties should have the following account balances: 218 | party | asset | market id | general | margin | is amm | 219 | vamm1 | USD | | 900000 | | | 220 | vamm1-id | USD | ETH/MAR22 | 72076 | 27009 | true | 221 And the market data for the market "ETH/MAR22" should be: 222 | mark price | trading mode | mid price | static mid price | best offer price | best bid price | 223 | 118 | TRADING_MODE_CONTINUOUS | 137 | 137 | 160 | 115 | 224 225 # OK, zero-out the vAMM 226 When the parties place the following orders: 227 | party | market id | side | volume | price | resulting trades | type | tif | 228 | party5 | ETH/MAR22 | sell | 109 | 100 | 1 | TYPE_LIMIT | TIF_GTC | 229 Then the following trades should be executed: 230 | buyer | price | size | seller | is amm | 231 | vamm1-id | 107 | 109 | party5 | true | 232 233 When the network moves ahead "1" blocks 234 Then the parties should have the following profit and loss: 235 | party | volume | unrealised pnl | realised pnl | is amm | 236 | party4 | 321 | -5405 | 0 | | 237 | party5 | -321 | 5361 | 0 | | 238 | vamm1-id | 0 | 0 | 44 | true | 239 And the AMM pool status should be: 240 | party | market id | amount | status | base | lower bound | upper bound | lower leverage | upper leverage | 241 | vamm1 | ETH/MAR22 | 100000 | STATUS_CANCELLED | 100 | 85 | 150 | 4 | 4 | 242 And the following transfers should happen: 243 | from | from account | to | to account | market id | amount | asset | is amm | type | 244 | | ACCOUNT_TYPE_FEES_MAKER | vamm1-id | ACCOUNT_TYPE_GENERAL | ETH/MAR22 | 47 | USD | true | TRANSFER_TYPE_MAKER_FEE_RECEIVE | 245 | vamm1-id | ACCOUNT_TYPE_MARGIN | vamm1-id | ACCOUNT_TYPE_GENERAL | ETH/MAR22 | 28208 | USD | true | TRANSFER_TYPE_MARGIN_HIGH | 246 | vamm1-id | ACCOUNT_TYPE_GENERAL | vamm1 | ACCOUNT_TYPE_GENERAL | ETH/MAR22 | 100331 | USD | true | TRANSFER_TYPE_AMM_RELEASE | 247 And the parties should have the following account balances: 248 | party | asset | market id | general | margin | is amm | 249 | vamm1 | USD | | 1000331 | | | 250 | vamm1-id | USD | ETH/MAR22 | 0 | 0 | true | 251 And the market data for the market "ETH/MAR22" should be: 252 | mark price | trading mode | mid price | static mid price | best offer price | best bid price | 253 | 107 | TRADING_MODE_CONTINUOUS | 100 | 100 | 160 | 40 | 254 255 @VAMM 256 Scenario: 0090-VAMM-021: Same as the test above, only this time, the final order that closes the vAMM position is bigger than the remaining volume, so we check if the vAMM is cancelled instead of going long. 257 # based on 0090-VAMM-008: vAMM creates a position, has some general balance left in general and margin accounts. 258 When the parties place the following orders: 259 | party | market id | side | volume | price | resulting trades | type | tif | reference | 260 | party4 | ETH/MAR22 | buy | 500 | 155 | 1 | TYPE_LIMIT | TIF_GTC | p4-first | 261 # see the trades that make the vAMM go short 262 Then the following trades should be executed: 263 | buyer | price | size | seller | is amm | 264 | party4 | 122 | 291 | vamm1-id | true | 265 And the market data for the market "ETH/MAR22" should be: 266 | mark price | trading mode | mid price | static mid price | best offer price | best bid price | 267 | 100 | TRADING_MODE_CONTINUOUS | 157 | 157 | 160 | 155 | 268 269 # trying to trade again causes no trades because the AMM has no more volume 270 When the parties place the following orders: 271 | party | market id | side | volume | price | resulting trades | type | tif | reference | 272 | party4 | ETH/MAR22 | buy | 500 | 150 | 0 | TYPE_LIMIT | TIF_GTC | p4-second | 273 274 # the AMM's mid price has moved to 150, but it has no volume +150 so that best offer comes from the orderbook of 160 275 Then the market data for the market "ETH/MAR22" should be: 276 | mark price | trading mode | mid price | static mid price | best offer price | best bid price | 277 | 100 | TRADING_MODE_CONTINUOUS | 157 | 157 | 160 | 155 | 278 279 When the network moves ahead "1" blocks 280 Then the parties should have the following profit and loss: 281 | party | volume | unrealised pnl | realised pnl | is amm | 282 | party4 | 291 | 0 | 0 | | 283 | vamm1-id | -291 | 0 | 0 | true | 284 # Notional value therefore is 291 * 122 285 And the market data for the market "ETH/MAR22" should be: 286 | mark price | trading mode | mid price | static mid price | best offer price | best bid price | 287 | 122 | TRADING_MODE_CONTINUOUS | 157 | 157 | 160 | 155 | 288 289 # vAMM receives fees, but loses out in the MTM settlement 290 And the following transfers should happen: 291 | from | from account | to | to account | market id | amount | asset | is amm | type | 292 | | ACCOUNT_TYPE_FEES_MAKER | vamm1-id | ACCOUNT_TYPE_GENERAL | ETH/MAR22 | 143 | USD | true | TRANSFER_TYPE_MAKER_FEE_RECEIVE | 293 | vamm1-id | ACCOUNT_TYPE_GENERAL | vamm1-id | ACCOUNT_TYPE_MARGIN | ETH/MAR22 | 74548 | USD | true | TRANSFER_TYPE_MARGIN_LOW | 294 And the parties should have the following account balances: 295 | party | asset | market id | general | margin | is amm | 296 | vamm1 | USD | | 900000 | | | 297 | vamm1-id | USD | ETH/MAR22 | 25595 | 74548 | true | 298 299 # Reduce only cancellation: vAMM only trades to reduce its position. 300 When the parties cancel the following AMM: 301 | party | market id | method | 302 | vamm1 | ETH/MAR22 | METHOD_REDUCE_ONLY | 303 Then the AMM pool status should be: 304 | party | market id | amount | status | base | lower bound | upper bound | lower leverage | upper leverage | 305 | vamm1 | ETH/MAR22 | 100000 | STATUS_REDUCE_ONLY | 100 | 85 | 150 | 4 | 4 | 306 # Cancel the remaining order from the start of the test 307 When the parties cancel the following orders: 308 | party | reference | 309 | party4 | p4-first | 310 | party4 | p4-second | 311 # Ensure the vAMM cancellation works as expected: a short position should not increase. 312 # Place buy orders at mid price, current mark price, and best bid. 313 Then the parties place the following orders: 314 | party | market id | side | volume | price | resulting trades | type | tif | 315 | party4 | ETH/MAR22 | buy | 10 | 122 | 0 | TYPE_LIMIT | TIF_GTC | 316 | party4 | ETH/MAR22 | buy | 10 | 149 | 0 | TYPE_LIMIT | TIF_GTC | 317 | party4 | ETH/MAR22 | buy | 10 | 154 | 0 | TYPE_LIMIT | TIF_GTC | 318 And the market data for the market "ETH/MAR22" should be: 319 | mark price | trading mode | mid price | static mid price | best offer price | best bid price | 320 | 122 | TRADING_MODE_CONTINUOUS | 157 | 157 | 160 | 154 | 321 322 And clear trade events 323 # Now bring in another party that will trade with the buy orders we've just placed, and reduce the exposure of the vAMM 324 When the parties place the following orders: 325 | party | market id | side | volume | price | resulting trades | type | tif | 326 | party5 | ETH/MAR22 | sell | 172 | 121 | 6 | TYPE_LIMIT | TIF_GTC | 327 Then the following trades should be executed: 328 | buyer | price | size | seller | is amm | 329 | party4 | 154 | 10 | party5 | | 330 | party4 | 149 | 10 | party5 | | 331 | party4 | 122 | 10 | party5 | | 332 | vamm1-id | 149 | 4 | party5 | true | 333 | vamm1-id | 134 | 137 | party5 | true | 334 | vamm1-id | 121 | 1 | party5 | true | 335 336 When the network moves ahead "1" blocks 337 Then the parties should have the following profit and loss: 338 | party | volume | unrealised pnl | realised pnl | is amm | 339 | party4 | 321 | -911 | 0 | | 340 | party5 | -172 | 2513 | 0 | | 341 | vamm1-id | -149 | 149 | -1751 | true | 342 And the following transfers should happen: 343 | from | from account | to | to account | market id | amount | asset | is amm | type | 344 | | ACCOUNT_TYPE_FEES_MAKER | vamm1-id | ACCOUNT_TYPE_GENERAL | ETH/MAR22 | 74 | USD | true | TRANSFER_TYPE_MAKER_FEE_RECEIVE | 345 | vamm1-id | ACCOUNT_TYPE_MARGIN | | ACCOUNT_TYPE_SETTLEMENT | ETH/MAR22 | 1602 | USD | true | TRANSFER_TYPE_MTM_LOSS | 346 | vamm1-id | ACCOUNT_TYPE_MARGIN | vamm1-id | ACCOUNT_TYPE_GENERAL | ETH/MAR22 | 35088 | USD | true | TRANSFER_TYPE_MARGIN_HIGH | 347 And the parties should have the following account balances: 348 | party | asset | market id | general | margin | is amm | 349 | vamm1 | USD | | 900000 | | | 350 | vamm1-id | USD | ETH/MAR22 | 60761 | 37858 | true | 351 # vAMM isn't quoting on its offer side due to being in reduce only, so best offer comes from an order 352 And the market data for the market "ETH/MAR22" should be: 353 | mark price | trading mode | mid price | static mid price | best offer price | best bid price | 354 | 121 | TRADING_MODE_CONTINUOUS | 140 | 140 | 160 | 121 | 355 356 # Cool, now close the position a little bit vamm completely 357 When the parties place the following orders: 358 | party | market id | side | volume | price | resulting trades | type | tif | 359 | party5 | ETH/MAR22 | sell | 40 | 115 | 1 | TYPE_LIMIT | TIF_GTC | 360 Then the following trades should be executed: 361 | buyer | price | size | seller | is amm | 362 | vamm1-id | 118 | 40 | party5 | true | 363 When the network moves ahead "1" blocks 364 Then the parties should have the following profit and loss: 365 | party | volume | unrealised pnl | realised pnl | is amm | 366 | party4 | 321 | -1874 | 0 | | 367 | party5 | -212 | 3029 | 0 | | 368 | vamm1-id | -109 | 436 | -1591 | true | 369 And the following transfers should happen: 370 | from | from account | to | to account | market id | amount | asset | is amm | type | 371 | | ACCOUNT_TYPE_FEES_MAKER | vamm1-id | ACCOUNT_TYPE_GENERAL | ETH/MAR22 | 19 | USD | true | TRANSFER_TYPE_MAKER_FEE_RECEIVE | 372 | vamm1-id | ACCOUNT_TYPE_MARGIN | vamm1-id | ACCOUNT_TYPE_GENERAL | ETH/MAR22 | 11296 | USD | true | TRANSFER_TYPE_MARGIN_HIGH | 373 And the parties should have the following account balances: 374 | party | asset | market id | general | margin | is amm | 375 | vamm1 | USD | | 900000 | | | 376 | vamm1-id | USD | ETH/MAR22 | 72076 | 27009 | true | 377 And the market data for the market "ETH/MAR22" should be: 378 | mark price | trading mode | mid price | static mid price | best offer price | best bid price | 379 | 118 | TRADING_MODE_CONTINUOUS | 137 | 137 | 160 | 115 | 380 381 # OK, zero-out the vAMM 382 When the parties place the following orders: 383 | party | market id | side | volume | price | resulting trades | type | tif | 384 | party5 | ETH/MAR22 | sell | 129 | 100 | 1 | TYPE_LIMIT | TIF_GTC | 385 Then the following trades should be executed: 386 | buyer | price | size | seller | is amm | 387 | vamm1-id | 107 | 109 | party5 | true | 388 389 When the network moves ahead "1" blocks 390 Then the parties should have the following profit and loss: 391 | party | volume | unrealised pnl | realised pnl | is amm | 392 | party4 | 321 | -5405 | 0 | | 393 | party5 | -321 | 5361 | 0 | | 394 | vamm1-id | 0 | 0 | 44 | true | 395 And the AMM pool status should be: 396 | party | market id | amount | status | base | lower bound | upper bound | lower leverage | upper leverage | 397 | vamm1 | ETH/MAR22 | 100000 | STATUS_CANCELLED | 100 | 85 | 150 | 4 | 4 | 398 And the following transfers should happen: 399 | from | from account | to | to account | market id | amount | asset | is amm | type | 400 | | ACCOUNT_TYPE_FEES_MAKER | vamm1-id | ACCOUNT_TYPE_GENERAL | ETH/MAR22 | 47 | USD | true | TRANSFER_TYPE_MAKER_FEE_RECEIVE | 401 | vamm1-id | ACCOUNT_TYPE_MARGIN | vamm1-id | ACCOUNT_TYPE_GENERAL | ETH/MAR22 | 28208 | USD | true | TRANSFER_TYPE_MARGIN_HIGH | 402 | vamm1-id | ACCOUNT_TYPE_GENERAL | vamm1 | ACCOUNT_TYPE_GENERAL | ETH/MAR22 | 100331 | USD | true | TRANSFER_TYPE_AMM_RELEASE | 403 And the parties should have the following account balances: 404 | party | asset | market id | general | margin | is amm | 405 | vamm1 | USD | | 1000331 | | | 406 | vamm1-id | USD | ETH/MAR22 | 0 | 0 | true | 407 And the market data for the market "ETH/MAR22" should be: 408 | mark price | trading mode | mid price | static mid price | best offer price | best bid price | 409 | 107 | TRADING_MODE_CONTINUOUS | 70 | 70 | 100 | 40 |