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