code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/0002-STTL-settlement-verified-loss-socialization-case2.feature (about) 1 Feature: Test loss socialization case 2 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-margin-calculator | 1 | default-none | default-none | default-eth-for-future | 0.25 | 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 Scenario: Case 2: trader1 has insufficient MTM & multiple traders socialise the losses (0002-STTL-009) 13 Description: Case 2 from https://docs.google.com/spreadsheets/d/1CIPH0aQmIKj6YeFW9ApP_l-jwB4OcsNQ/edit#gid=1555964910 14 15 # setup accounts 16 Given the parties deposit on asset's general account the following amount: 17 | party | asset | amount | 18 | sellSideProvider | BTC | 100000000 | 19 | buySideProvider | BTC | 100000000 | 20 | party1 | BTC | 2500 | 21 | party2 | BTC | 10000 | 22 | party3 | BTC | 10000 | 23 | party4 | BTC | 10000 | 24 | aux1 | BTC | 100000000 | 25 | aux2 | BTC | 100000000 | 26 # setup orderbook 27 When the parties place the following orders: 28 | party | market id | side | volume | price | resulting trades | type | tif | reference | 29 | sellSideProvider | ETH/DEC19 | sell | 1000 | 120 | 0 | TYPE_LIMIT | TIF_GTC | sell-provider-1 | 30 | buySideProvider | ETH/DEC19 | buy | 1000 | 80 | 0 | TYPE_LIMIT | TIF_GTC | buy-provider-1 | 31 | aux1 | ETH/DEC19 | sell | 1 | 120 | 0 | TYPE_LIMIT | TIF_GTC | aux-s-1 | 32 | aux2 | ETH/DEC19 | buy | 1 | 80 | 0 | TYPE_LIMIT | TIF_GTC | aux-b-1 | 33 | aux1 | ETH/DEC19 | sell | 1 | 100 | 0 | TYPE_LIMIT | TIF_GTC | aux-s-2 | 34 | aux2 | ETH/DEC19 | buy | 1 | 100 | 0 | TYPE_LIMIT | TIF_GTC | aux-b-2 | 35 Then the opening auction period ends for market "ETH/DEC19" 36 And the mark price should be "100" for the market "ETH/DEC19" 37 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" 38 # trade 1 occurs 39 When the parties place the following orders with ticks: 40 | party | market id | side | volume | price | resulting trades | type | tif | reference | 41 | party1 | ETH/DEC19 | sell | 25 | 100 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 42 | party2 | ETH/DEC19 | buy | 25 | 100 | 1 | TYPE_LIMIT | TIF_GTC | ref-2 | 43 # trade 2 occurs 44 When the parties place the following orders with ticks: 45 | party | market id | side | volume | price | resulting trades | type | tif | reference | 46 | party1 | ETH/DEC19 | sell | 75 | 100 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 47 | party3 | ETH/DEC19 | buy | 75 | 100 | 1 | TYPE_LIMIT | TIF_GTC | ref-2 | 48 49 # order book volume change 50 Then the parties cancel the following orders: 51 | party | reference | 52 | sellSideProvider | sell-provider-1 | 53 | buySideProvider | buy-provider-1 | 54 When the parties place the following orders with ticks: 55 | party | market id | side | volume | price | resulting trades | type | tif | reference | 56 | sellSideProvider | ETH/DEC19 | sell | 1000 | 300 | 0 | TYPE_LIMIT | TIF_GTC | sell-provider-2 | 57 | buySideProvider | ETH/DEC19 | buy | 1000 | 80 | 0 | TYPE_LIMIT | TIF_GTC | buy-provider-2 | 58 Then the parties cancel the following orders: 59 | party | reference | 60 | aux1 | aux-s-1 | 61 | aux2 | aux-b-1 | 62 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" 63 64 # trade 4 occurs 65 When the parties place the following orders with ticks: 66 | party | market id | side | volume | price | resulting trades | type | tif | reference | 67 | party2 | ETH/DEC19 | buy | 10 | 180 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 68 | party4 | ETH/DEC19 | sell | 10 | 180 | 1 | TYPE_LIMIT | TIF_GTC | ref-2 | 69 70 # check positions 71 Then the parties should have the following profit and loss: 72 | party | volume | unrealised pnl | realised pnl | 73 | party1 | 0 | 0 | -2500 | 74 | party2 | 35 | 2000 | -1362 | 75 | party3 | 75 | 6000 | -4083 | 76 | party4 | -10 | 0 | 0 | 77 78 And the insurance pool balance should be "0" for the market "ETH/DEC19"