code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/verified-positions-resolution-3.feature (about) 1 Feature: Position resolution case 3 2 3 Background: 4 Given the markets: 5 | id | quote name | asset | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | 6 | ETH/DEC19 | BTC | BTC | default-simple-risk-model-2 | default-overkill-margin-calculator | 1 | default-none | default-none | default-eth-for-future | 0.5349 | 0 | default-futures | 7 And the following network parameters are set: 8 | name | value | 9 | market.auction.minimumDuration | 1 | 10 | network.markPriceUpdateMaximumFrequency | 0s | 11 12 @Liquidation 13 Scenario: close out when there is enough orders on the orderbook to cover the position (0008-TRAD-002,0008-TRAD-003, 0008-TRAD-006) 14 # setup accounts 15 Given the parties deposit on asset's general account the following amount: 16 | party | asset | amount | 17 | sellSideProvider | BTC | 1000000000000 | 18 | buySideProvider | BTC | 1000000000000 | 19 | designatedLooser | BTC | 12000 | 20 | aux | BTC | 1000000000000 | 21 | aux2 | BTC | 1000000000000 | 22 23 # insurance pool generation - setup orderbook 24 When the parties place the following orders: 25 | party | market id | side | volume | price | resulting trades | type | tif | reference | 26 | sellSideProvider | ETH/DEC19 | sell | 291 | 150 | 0 | TYPE_LIMIT | TIF_GTC | sell-provider-1 | 27 | buySideProvider | ETH/DEC19 | buy | 1 | 140 | 0 | TYPE_LIMIT | TIF_GTC | buy-provider-1 | 28 | aux | ETH/DEC19 | sell | 1 | 155 | 0 | TYPE_LIMIT | TIF_GTC | aux-s-1 | 29 | aux2 | ETH/DEC19 | buy | 1 | 150 | 0 | TYPE_LIMIT | TIF_GTC | aux-b-1 | 30 | aux2 | ETH/DEC19 | buy | 1 | 140 | 0 | TYPE_LIMIT | TIF_GTC | aux-b-2 | 31 Then the opening auction period ends for market "ETH/DEC19" 32 And the mark price should be "150" for the market "ETH/DEC19" 33 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" 34 35 # insurance pool generation - trade 36 When the parties place the following orders with ticks: 37 | party | market id | side | volume | price | resulting trades | type | tif | reference | 38 | designatedLooser | ETH/DEC19 | buy | 290 | 150 | 1 | TYPE_LIMIT | TIF_GTC | ref-1 | 39 40 And the parties should have the following margin levels: 41 | party | market id | maintenance | search | initial | release | 42 | designatedLooser | ETH/DEC19 | 0 | 0 | 0 | 0 | 43 44 Then the parties should have the following account balances: 45 | party | asset | market id | margin | general | 46 | designatedLooser | BTC | ETH/DEC19 | 0 | 0 | 47 48 Then the parties should have the following margin levels: 49 | party | market id | maintenance | search | initial | release | 50 | designatedLooser | ETH/DEC19 | 0 | 0 | 0 | 0 | 51 52 When the parties place the following orders with ticks: 53 | party | market id | side | volume | price | resulting trades | type | tif | reference | 54 | buySideProvider | ETH/DEC19 | buy | 300 | 40 | 0 | TYPE_LIMIT | TIF_GTC | buy-provider-2 | 55 56 # check the party accounts 57 Then the parties should have the following account balances: 58 | party | asset | market id | margin | general | 59 | designatedLooser | BTC | ETH/DEC19 | 0 | 0 | 60 61 # insurance pool generation - set new mark price (and trigger closeout) 62 When the parties place the following orders with ticks: 63 | party | market id | side | volume | price | resulting trades | type | tif | reference | 64 | buySideProvider | ETH/DEC19 | buy | 1 | 120 | 0 | TYPE_LIMIT | TIF_GTC | ref-2 | 65 | sellSideProvider | ETH/DEC19 | sell | 1 | 120 | 1 | TYPE_LIMIT | TIF_GTC | ref-1 | 66 67 # check positions 68 Then the parties should have the following profit and loss: 69 | party | volume | unrealised pnl | realised pnl | 70 | designatedLooser | 0 | 0 | -12000 | 71 72 # checking margins 73 Then the parties should have the following account balances: 74 | party | asset | market id | margin | general | 75 | designatedLooser | BTC | ETH/DEC19 | 0 | 0 | 76 77 #And debug transfers 78 # Insurance pool collected 12000 which was then paid out in MTM settlements 79 And the insurance pool balance should be "0" for the market "ETH/DEC19" 80 81