code.vegaprotocol.io/vega@v0.79.0/core/integration/features/accounts/2943-distressed-trader-has-general-balance.feature (about) 1 Feature: Distressed parties should not have general balance left 2 3 Background: 4 Given time is updated to "2020-10-16T00:00:00Z" 5 And 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/DEC20 | ETH | ETH | default-simple-risk-model-3 | default-margin-calculator | 1 | default-none | default-none | default-eth-for-future | 0.25 | 0 | default-futures | 8 And the following network parameters are set: 9 | name | value | 10 | market.auction.minimumDuration | 1 | 11 | network.markPriceUpdateMaximumFrequency | 0s | 12 | limits.markets.maxPeggedOrders | 4 | 13 | market.liquidity.providersFeeCalculationTimeStep | 1s | 14 | market.liquidity.equityLikeShareFeeFraction | 1 | 15 16 Scenario: Upper bound breached 17 Given the parties deposit on asset's general account the following amount: 18 | party | asset | amount | 19 | party1 | ETH | 10000000000000 | 20 | party2 | ETH | 10000000000000 | 21 | party3 | ETH | 24000 | 22 | party4 | ETH | 10000000000000 | 23 | party5 | ETH | 10000000000000 | 24 | auxiliary | ETH | 100000000000 | 25 | aux2 | ETH | 100000000000 | 26 | lpprov | ETH | 10000000000000 | 27 28 # Provide LP so market can leave opening auction 29 When the parties submit the following liquidity provision: 30 | id | party | market id | commitment amount | fee | lp type | 31 | lp1 | lpprov | ETH/DEC20 | 10000 | 0.1 | submission | 32 And the parties place the following pegged iceberg orders: 33 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference | 34 | lpprov | ETH/DEC20 | 2 | 1 | buy | BID | 50 | 10 | lp1-ice-buy | 35 | lpprov | ETH/DEC20 | 2 | 1 | sell | ASK | 50 | 10 | lp1-ice-sell | 36 37 # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction 38 Then the parties place the following orders: 39 | party | market id | side | volume | price | resulting trades | type | tif | 40 | auxiliary | ETH/DEC20 | buy | 1 | 1 | 0 | TYPE_LIMIT | TIF_GTC | 41 | auxiliary | ETH/DEC20 | sell | 1 | 200 | 0 | TYPE_LIMIT | TIF_GTC | 42 | aux2 | ETH/DEC20 | buy | 1 | 100 | 0 | TYPE_LIMIT | TIF_GTC | 43 | auxiliary | ETH/DEC20 | sell | 1 | 100 | 0 | TYPE_LIMIT | TIF_GTC | 44 Then the opening auction period ends for market "ETH/DEC20" 45 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20" 46 47 When the parties place the following orders "1" blocks apart: 48 | party | market id | side | volume | price | resulting trades | type | tif | 49 | party1 | ETH/DEC20 | sell | 1 | 100 | 0 | TYPE_LIMIT | TIF_GTC | 50 | party2 | ETH/DEC20 | buy | 1 | 100 | 1 | TYPE_LIMIT | TIF_GTC | 51 | party1 | ETH/DEC20 | sell | 20 | 120 | 0 | TYPE_LIMIT | TIF_GTC | 52 | party2 | ETH/DEC20 | buy | 20 | 80 | 0 | TYPE_LIMIT | TIF_GTC | 53 54 And the mark price should be "100" for the market "ETH/DEC20" 55 56 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC20" 57 58 # T0 + 1min - this causes the price for comparison of the bounds to be 567 59 Then time is updated to "2020-10-16T00:01:00Z" 60 61 When the parties place the following orders "1" blocks apart: 62 | party | market id | side | volume | price | resulting trades | type | tif | 63 | party4 | ETH/DEC20 | sell | 10 | 100 | 0 | TYPE_LIMIT | TIF_GTC | 64 | party5 | ETH/DEC20 | buy | 10 | 100 | 1 | TYPE_LIMIT | TIF_FOK | 65 | party3 | ETH/DEC20 | buy | 10 | 110 | 0 | TYPE_LIMIT | TIF_GTC | 66 | party3 | ETH/DEC20 | sell | 40 | 120 | 0 | TYPE_LIMIT | TIF_GTC | 67 68 Then the parties should have the following account balances: 69 | party | asset | market id | margin | general | 70 | party4 | ETH | ETH/DEC20 | 420 | 9999999999580 | 71 | party5 | ETH | ETH/DEC20 | 432 | 9999999999468 | 72 Then the parties submit the following liquidity provision: 73 | id | party | market id | commitment amount | fee | lp type | 74 | lp2 | party3 | ETH/DEC20 | 20000 | 0.1 | submission | 75 And the parties place the following pegged iceberg orders: 76 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference | 77 | party3 | ETH/DEC20 | 189 | 1 | buy | BID | 189 | 10 | lp2-ice-buy | 78 | party3 | ETH/DEC20 | 117 | 1 | sell | ASK | 117 | 10 | lp2-ice-sell | 79 80 Then the liquidity provisions should have the following states: 81 | id | party | market | commitment amount | status | 82 | lp2 | party3 | ETH/DEC20 | 20000 | STATUS_PENDING | 83 84 When the network moves ahead "1" blocks 85 Then the liquidity provisions should have the following states: 86 | id | party | market | commitment amount | status | 87 | lp2 | party3 | ETH/DEC20 | 20000 | STATUS_ACTIVE | 88 89 Then the orders should have the following states: 90 | party | market id | side | volume | remaining | price | status | 91 | party3 | ETH/DEC20 | buy | 189 | 189 | 100 | STATUS_ACTIVE | 92 | party3 | ETH/DEC20 | sell | 117 | 117 | 130 | STATUS_ACTIVE | 93 ## The sum of the margin + general account == 24000 - 10000 (commitment amount) 94 Then the parties should have the following account balances: 95 | party | asset | market id | margin | general | 96 | party3 | ETH | ETH/DEC20 | 2626 | 1374 | 97 98 ## Now let's increase the mark price so party3 gets distressed 99 When the parties place the following orders "1" blocks apart: 100 | party | market id | side | volume | price | resulting trades | type | tif | reference | 101 | party5 | ETH/DEC20 | buy | 40 | 165 | 2 | TYPE_LIMIT | TIF_GTC | ref-1 | 102 | party1 | ETH/DEC20 | sell | 20 | 1850 | 0 | TYPE_LIMIT | TIF_GTC | ref-3 | 103 Then the mark price should be "120" for the market "ETH/DEC20" 104 Then the liquidity provider fee shares for the market "ETH/DEC20" should be: 105 | party | equity like share | average entry valuation | 106 | lpprov | 0.6428571428571429 | 10000 | 107 | party3 | 0.3571428571428571 | 60000.0000000000000556 | 108 109 And the following trades should be executed: 110 | buyer | price | size | seller | 111 | party5 | 120 | 20 | party1 | 112 | party5 | 120 | 20 | party3 | 113 Then the parties should have the following account balances: 114 | party | asset | market id | margin | general | 115 | party3 | ETH | ETH/DEC20 | 3152 | 1040 | 116 Then the parties cancel the following orders: 117 | party | reference | 118 | party3 | lp2-ice-sell | 119 | party3 | lp2-ice-buy | 120 121 And the parties place the following pegged iceberg orders: 122 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 123 | party3 | ETH/DEC20 | 189 | 1 | buy | BID | 189 | 10 | 124 | party3 | ETH/DEC20 | 136 | 1 | sell | ASK | 136 | 10 | 125 126 Then the network moves ahead "10" blocks 127 128 And the parties should have the following account balances: 129 | party | asset | market id | margin | general | 130 | party3 | ETH | ETH/DEC20 | 3254 | 938 | 131 | party4 | ETH | ETH/DEC20 | 504 | 9999999999296 | 132 133 ## Now let's increase the mark price so party3 gets distressed 134 When the parties place the following orders "1" blocks apart: 135 | party | market id | side | volume | price | resulting trades | type | tif | reference | 136 | party4 | ETH/DEC20 | sell | 30 | 165 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 137 | party5 | ETH/DEC20 | buy | 30 | 165 | 3 | TYPE_LIMIT | TIF_GTC | ref-1 | 138 Then the mark price should be "130" for the market "ETH/DEC20" 139 140 And the parties should have the following account balances: 141 | party | asset | market id | margin | general | 142 | party3 | ETH | ETH/DEC20 | 4617 | 0 |