code.vegaprotocol.io/vega@v0.79.0/core/integration/features/closeouts/distressed-safe-event.feature (about) 1 Feature: Ensure distressed status events are correctly emitted, both for safe and distressed parties 2 3 Background: 4 5 Given the markets: 6 | id | quote name | asset | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | 7 | ETH/DEC19 | BTC | BTC | default-simple-risk-model-2 | default-overkill-margin-calculator | 1 | default-none | default-none | default-eth-for-future | 1e3 | 1e3 | default-futures | 8 And the following network parameters are set: 9 | name | value | 10 | market.auction.minimumDuration | 1 | 11 | network.markPriceUpdateMaximumFrequency | 0s | 12 13 @CloseOut @Liquidation 14 Scenario: Implement trade and order network 15 # setup accounts 16 Given the parties deposit on asset's general account the following amount: 17 | party | asset | amount | 18 | sellSideProvider | BTC | 1000000000000 | 19 | buySideProvider | BTC | 1000000000000 | 20 | designatedLoser | BTC | 12000 | 21 | aux | BTC | 1000000000000 | 22 | aux2 | BTC | 1000000000000 | 23 24 # insurance pool generation - setup orderbook 25 When the parties place the following orders: 26 | party | market id | side | volume | price | resulting trades | type | tif | reference | 27 | sellSideProvider | ETH/DEC19 | sell | 290 | 150 | 0 | TYPE_LIMIT | TIF_GTC | sell-provider-1 | 28 | buySideProvider | ETH/DEC19 | buy | 1 | 140 | 0 | TYPE_LIMIT | TIF_GTC | buy-provider-1 | 29 | aux | ETH/DEC19 | sell | 100 | 159 | 0 | TYPE_LIMIT | TIF_GTC | aux-s-1 | 30 | aux | ETH/DEC19 | sell | 1 | 149 | 0 | TYPE_LIMIT | TIF_GTC | aux-s-2 | 31 | aux2 | ETH/DEC19 | buy | 1 | 149 | 0 | TYPE_LIMIT | TIF_GTC | aux-b-1 | 32 | aux2 | ETH/DEC19 | buy | 100 | 140 | 0 | TYPE_LIMIT | TIF_GTC | aux-b-2 | 33 Then the opening auction period ends for market "ETH/DEC19" 34 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" 35 36 # insurance pool generation - trade 37 When the parties place the following orders "1" blocks apart: 38 | party | market id | side | volume | price | resulting trades | type | tif | reference | 39 | designatedLoser | ETH/DEC19 | buy | 290 | 150 | 1 | TYPE_LIMIT | TIF_GTC | ref-1 | 40 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" 41 And debug trades 42 43 # buy side provider provides insufficient volume on the book to zero out the network 44 And the parties place the following orders: 45 | party | market id | side | volume | price | resulting trades | type | tif | reference | 46 | buySideProvider | ETH/DEC19 | buy | 4 | 40 | 0 | TYPE_LIMIT | TIF_GTC | buy-provider-2 | 47 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" 48 49 # insurance pool generation - set new mark price (and trigger closeout) 50 When the parties place the following orders "1" blocks apart: 51 | party | market id | side | volume | price | resulting trades | type | tif | reference | 52 | sellSideProvider | ETH/DEC19 | sell | 1 | 120 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 53 | buySideProvider | ETH/DEC19 | buy | 1 | 120 | 1 | TYPE_LIMIT | TIF_GTC | ref-2 | 54 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" 55 # designatedLoser should've been closed out, but due to lack of volume on the book, they maintain their position 56 # however, their position status is flagged as being distressed 57 And the parties should have the following profit and loss: 58 | party | volume | unrealised pnl | realised pnl | status | 59 | designatedLoser | 0 | 0 | -12000 | POSITION_STATUS_CLOSED_OUT | 60