code.vegaprotocol.io/vega@v0.79.0/core/integration/features/liquidation/0012-POSR-012.feature (about) 1 Feature: 0012-POSR-012 Update the liquidation strategy through market update 2 3 Background: 4 Given the liquidation strategies: 5 | name | disposal step | disposal fraction | full disposal size | max fraction consumed | disposal slippage range | 6 | fast-liquidation | 10 | 0.1 | 20 | 0.05 | 0.5 | 7 8 And the markets: 9 | id | quote name | asset | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | liquidation strategy | 10 | ETH/DEC19 | BTC | BTC | default-simple-risk-model-4 | default-margin-calculator | 1 | default-none | default-none | default-eth-for-future | 0.25 | 0 | default-futures | slow-liquidation-strat | 11 And the following network parameters are set: 12 | name | value | 13 | market.auction.minimumDuration | 1 | 14 | network.markPriceUpdateMaximumFrequency | 0s | 15 | limits.markets.maxPeggedOrders | 2 | 16 17 @LiquidationUpdate 18 Scenario: Update liquidation strategy through market update 19 # setup accounts 20 Given the parties deposit on asset's general account the following amount: 21 | party | asset | amount | 22 | tt_4 | BTC | 500000 | 23 | tt_5 | BTC | 100 | 24 | tt_6 | BTC | 100000000 | 25 | tt_10 | BTC | 10000000 | 26 | tt_11 | BTC | 10000000 | 27 | tt_aux | BTC | 100000000 | 28 | t2_aux | BTC | 100000000 | 29 | lpprov | BTC | 100000000 | 30 31 # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction 32 Then the parties place the following orders: 33 | party | market id | side | volume | price | resulting trades | type | tif | reference | 34 | tt_aux | ETH/DEC19 | buy | 1 | 1 | 0 | TYPE_LIMIT | TIF_GTC | aux-b-1 | 35 | tt_aux | ETH/DEC19 | sell | 1 | 200 | 0 | TYPE_LIMIT | TIF_GTC | aux-s-1 | 36 | t2_aux | ETH/DEC19 | buy | 1 | 100 | 0 | TYPE_LIMIT | TIF_GTC | aux-b-2 | 37 | tt_aux | ETH/DEC19 | sell | 1 | 100 | 0 | TYPE_LIMIT | TIF_GTC | aux-s-2 | 38 And the parties submit the following liquidity provision: 39 | id | party | market id | commitment amount | fee | lp type | 40 | lp1 | lpprov | ETH/DEC19 | 90000 | 0.1 | submission | 41 | lp1 | lpprov | ETH/DEC19 | 90000 | 0.1 | submission | 42 And the parties place the following pegged iceberg orders: 43 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 44 | lpprov | ETH/DEC19 | 2 | 1 | buy | MID | 50 | 100 | 45 | lpprov | ETH/DEC19 | 2 | 1 | sell | MID | 50 | 100 | 46 Then the opening auction period ends for market "ETH/DEC19" 47 48 # place orders and generate trades 49 When the parties place the following orders "1" blocks apart: 50 | party | market id | side | volume | price | resulting trades | type | tif | reference | expires in | 51 | tt_10 | ETH/DEC19 | buy | 5 | 100 | 0 | TYPE_LIMIT | TIF_GTT | tt_10-1 | 3600 | 52 | tt_11 | ETH/DEC19 | sell | 5 | 100 | 1 | TYPE_LIMIT | TIF_GTT | tt_11-1 | 3600 | 53 | tt_4 | ETH/DEC19 | buy | 2 | 150 | 0 | TYPE_LIMIT | TIF_GTC | tt_4-1 | | 54 | tt_4 | ETH/DEC19 | buy | 2 | 150 | 0 | TYPE_LIMIT | TIF_GTC | tt_4-2 | | 55 | tt_5 | ETH/DEC19 | buy | 2 | 150 | 0 | TYPE_LIMIT | TIF_GTC | tt_5-1 | | 56 | tt_6 | ETH/DEC19 | sell | 2 | 150 | 1 | TYPE_LIMIT | TIF_GTC | tt_6-1 | | 57 | tt_5 | ETH/DEC19 | buy | 2 | 150 | 0 | TYPE_LIMIT | TIF_GTC | tt_5-2 | | 58 | tt_6 | ETH/DEC19 | sell | 2 | 150 | 1 | TYPE_LIMIT | TIF_GTC | tt_6-2 | | 59 | tt_10 | ETH/DEC19 | buy | 25 | 100 | 0 | TYPE_LIMIT | TIF_GTC | tt_10-2 | | 60 | tt_11 | ETH/DEC19 | sell | 25 | 0 | 3 | TYPE_MARKET | TIF_FOK | tt_11-2 | | 61 And the network moves ahead "1" blocks 62 63 And the mark price should be "100" for the market "ETH/DEC19" 64 65 # checking margins 66 Then the parties should have the following account balances: 67 | party | asset | market id | margin | general | 68 | tt_5 | BTC | ETH/DEC19 | 0 | 0 | 69 70 # then we make sure the insurance pool collected the funds 71 And the insurance pool balance should be "0" for the market "ETH/DEC19" 72 73 #check positions 74 Then the parties should have the following profit and loss: 75 | party | volume | unrealised pnl | realised pnl | 76 | tt_4 | 4 | -200 | 0 | 77 | tt_5 | 0 | 0 | -100 | 78 | tt_6 | -4 | 200 | -27 | 79 | tt_10 | 26 | 0 | 0 | 80 | tt_11 | -30 | 200 | -65 | 81 | network | 4 | 0 | 0 | 82 And the following trades should be executed: 83 | buyer | price | size | seller | 84 | network | 100 | 4 | tt_5 | 85 86 When the parties place the following orders: 87 | party | market id | side | volume | price | resulting trades | type | tif | reference | 88 | tt_10 | ETH/DEC19 | buy | 50 | 100 | 0 | TYPE_LIMIT | TIF_GTC | tt_10-n | 89 And the network moves ahead "101" blocks 90 Then the parties should have the following profit and loss: 91 | party | volume | unrealised pnl | realised pnl | 92 | tt_4 | 4 | -200 | 0 | 93 | tt_5 | 0 | 0 | -100 | 94 | tt_6 | -4 | 200 | -27 | 95 | tt_10 | 27 | 0 | 0 | 96 | tt_11 | -30 | 200 | -65 | 97 | network | 3 | 0 | 0 | 98 # Network trades with good party for a size of 1 99 And the following trades should be executed: 100 | buyer | price | size | seller | 101 | tt_10 | 100 | 1 | network | 102 # Now update the market 103 When the markets are updated: 104 | id | linear slippage factor | quadratic slippage factor | liquidation strategy | 105 | ETH/DEC19 | 0.25 | 0 | fast-liquidation | 106 # Now the network should dispose of its entire position 107 When the network moves ahead "11" blocks 108 Then the parties should have the following profit and loss: 109 | party | volume | unrealised pnl | realised pnl | 110 | tt_4 | 4 | -200 | 0 | 111 | tt_5 | 0 | 0 | -100 | 112 | tt_6 | -4 | 200 | -27 | 113 | tt_10 | 30 | 0 | 0 | 114 | tt_11 | -30 | 200 | -65 | 115 | network | 0 | 0 | 0 | 116 # Network has been closed out entirely now 117 And the following trades should be executed: 118 | buyer | price | size | seller | 119 | tt_10 | 100 | 3 | network |