code.vegaprotocol.io/vega@v0.79.0/core/integration/features/closeouts/position-resolution-after-auction.feature (about) 1 Feature: Set up a market with an opening auction, then uncross the book so that the part trading in auction becomes distressed 2 Background: 3 Given the markets: 4 | id | quote name | asset | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | 5 | ETH/DEC19 | BTC | BTC | default-simple-risk-model-4 | default-margin-calculator | 1 | default-none | default-none | default-eth-for-future | 0.1 | 0.1 | default-futures | 6 And the parties deposit on asset's general account the following amount: 7 | party | asset | amount | 8 | party1 | BTC | 20000 | 9 | party2a | BTC | 100000000 | 10 | party2b | BTC | 100000000 | 11 | party2c | BTC | 100000000 | 12 | party3 | BTC | 100000000 | 13 | party4 | BTC | 100000000 | 14 | lp | BTC | 100000000 | 15 And the following network parameters are set: 16 | name | value | 17 | limits.markets.maxPeggedOrders | 2 | 18 19 @Liquidation 20 Scenario: 21 When the parties place the following orders: 22 | party | market id | side | volume | price | resulting trades | type | tif | reference | 23 | party3 | ETH/DEC19 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | t3-b-1 | 24 | party4 | ETH/DEC19 | sell | 1 | 11000 | 0 | TYPE_LIMIT | TIF_GTC | t4-s-1 | 25 | party1 | ETH/DEC19 | buy | 5 | 10000 | 0 | TYPE_LIMIT | TIF_GFA | t1-b-1 | 26 | party2a | ETH/DEC19 | sell | 5 | 10000 | 0 | TYPE_LIMIT | TIF_GFA | t2a-s-1 | 27 | party1 | ETH/DEC19 | buy | 5 | 10000 | 0 | TYPE_LIMIT | TIF_GFA | t1-b-2 | 28 | party2b | ETH/DEC19 | sell | 5 | 10001 | 0 | TYPE_LIMIT | TIF_GFA | t2b-s-2 | 29 | party1 | ETH/DEC19 | buy | 4 | 3000 | 0 | TYPE_LIMIT | TIF_GFA | t1-b-3 | 30 | party2c | ETH/DEC19 | sell | 3 | 3000 | 0 | TYPE_LIMIT | TIF_GFA | t2c-s-3 | 31 And the parties submit the following liquidity provision: 32 | id | party | market id | commitment amount | fee | lp type | 33 | lp1 | lp | ETH/DEC19 | 160000 | 0.01 | submission | 34 | lp1 | lp | ETH/DEC19 | 160000 | 0.01 | submission | 35 And the parties place the following pegged iceberg orders: 36 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 37 | lp | ETH/DEC19 | 27 | 1 | buy | MID | 36 | 100 | 38 | lp | ETH/DEC19 | 27 | 1 | sell | MID | 27 | 100 | 39 Then the parties should have the following margin levels: 40 | party | market id | maintenance | 41 | party1 | ETH/DEC19 | 14000 | 42 And the parties should have the following account balances: 43 | party | asset | market id | margin | general | 44 | party1 | BTC | ETH/DEC19 | 16800 | 3200 | 45 When the opening auction period ends for market "ETH/DEC19" 46 Then the market data for the market "ETH/DEC19" should be: 47 | mark price | trading mode | auction trigger | extension trigger | target stake | supplied stake | open interest | 48 | 10000 | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | AUCTION_TRIGGER_UNSPECIFIED | 80000 | 160000 | 8 | 49 When the network moves ahead "1" blocks 50 And debug trades 51 And the following trades should be executed: 52 | buyer | price | size | seller | 53 | party1 | 10000 | 3 | party2a | 54 | party1 | 10000 | 2 | party2a | 55 | party1 | 10000 | 3 | party2c | 56 | network | 10000 | 8 | party1 | 57 | lp | 5900 | 8 | network | 58 Then the parties should have the following profit and loss: 59 | party | volume | unrealised pnl | realised pnl | 60 | party2a | -5 | 0 | 0 | 61 | party2c | -3 | 0 | 0 | 62 | party1 | 0 | 0 | -20000 | 63 And the accumulated liquidity fees should be "472" for the market "ETH/DEC19" 64 And the insurance pool balance should be "19528" for the market "ETH/DEC19" 65 And the parties should have the following account balances: 66 | party | asset | market id | margin | general | bond | 67 | party1 | BTC | ETH/DEC19 | 0 | 0 | | 68 | lp | BTC | ETH/DEC19 | 43200 | 99796800 | 160000 | 69 # sum of lp accounts = 100019528 70 # lp started with 100000000, should've made 8*(10000-5900)=32800 in MTM gains following the closeout, 71 # but party1 only had 20000, of which 472 has been put towards liquidity fees, 72 # so only the leftover 19528 was transferred to lp in MTM gains, hence the -13272 realised pnl