code.vegaprotocol.io/vega@v0.79.0/core/integration/features/closeouts/1847-closeout-short-with-fees.feature (about) 1 Feature: Short close-out test (see ln 449 of system-tests/grpc/trading/tradesTests.py & https://github.com/vegaprotocol/scenario-runner/tree/develop/scenarios/QA/issues/86) 2 3 Background: 4 5 Given the fees configuration named "my-fees-config": 6 | maker fee | infrastructure fee | 7 | 0.00025 | 0.0005 | 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 | 10 | ETH/DEC19 | BTC | BTC | default-simple-risk-model-4 | default-margin-calculator | 1 | my-fees-config | default-none | default-eth-for-future | 1.5 | 0 | default-futures | 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 @Liquidation 18 Scenario: https://drive.google.com/file/d/1bYWbNJvG7E-tcqsK26JMu2uGwaqXqm0L/view 19 # setup accounts 20 Given the parties deposit on asset's general account the following amount: 21 | party | asset | amount | 22 | tt_12 | BTC | 100000000 | 23 | tt_13 | BTC | 100000000 | 24 | tt_14 | BTC | 100000000 | 25 | tt_15 | BTC | 100 | 26 | tt_16 | BTC | 100000000 | 27 | tt_aux | BTC | 100000000 | 28 | t2_aux | BTC | 100000000 | 29 | party-lp | BTC | 100000000 | 30 And the parties submit the following liquidity provision: 31 | id | party | market id | commitment amount | fee | lp type | 32 | lp1 | party-lp | ETH/DEC19 | 30000000 | 0.000 | submission | 33 | lp1 | party-lp | ETH/DEC19 | 30000000 | 0.000 | amendment | 34 # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction 35 Then the parties place the following orders: 36 | party | market id | side | volume | price | resulting trades | type | tif | reference | 37 | tt_aux | ETH/DEC19 | buy | 1 | 1 | 0 | TYPE_LIMIT | TIF_GTC | aux-b-1 | 38 | tt_aux | ETH/DEC19 | sell | 1 | 200 | 0 | TYPE_LIMIT | TIF_GTC | aux-s-1 | 39 | t2_aux | ETH/DEC19 | buy | 1 | 20 | 0 | TYPE_LIMIT | TIF_GTC | aux-b-2 | 40 | tt_aux | ETH/DEC19 | sell | 1 | 20 | 0 | TYPE_LIMIT | TIF_GTC | aux-s-2 | 41 Then the opening auction period ends for market "ETH/DEC19" 42 43 # place orders and generate trades 44 When the parties place the following orders "1" blocks apart: 45 | party | market id | side | volume | price | resulting trades | type | tif | reference | expires in | 46 | tt_12 | ETH/DEC19 | buy | 5 | 20 | 0 | TYPE_LIMIT | TIF_GTT | tt_12-1 | 3600 | 47 | tt_13 | ETH/DEC19 | sell | 5 | 20 | 1 | TYPE_LIMIT | TIF_GTT | tt_13-1 | 3600 | 48 | tt_14 | ETH/DEC19 | sell | 2 | 50 | 0 | TYPE_LIMIT | TIF_GTC | tt_14-1 | | 49 | tt_14 | ETH/DEC19 | sell | 2 | 50 | 0 | TYPE_LIMIT | TIF_GTC | tt_14-2 | | 50 | tt_15 | ETH/DEC19 | sell | 2 | 20 | 0 | TYPE_LIMIT | TIF_GTC | tt_15-1 | | 51 | tt_16 | ETH/DEC19 | buy | 2 | 20 | 1 | TYPE_LIMIT | TIF_GTC | tt_16-1 | | 52 53 Then the parties should have the following account balances: 54 | party | asset | market id | margin | general | 55 | tt_15 | BTC | ETH/DEC19 | 76 | 25 | 56 57 When the parties place the following orders "1" blocks apart: 58 | party | market id | side | volume | price | resulting trades | type | tif | reference | 59 | tt_15 | ETH/DEC19 | sell | 2 | 20 | 0 | TYPE_LIMIT | TIF_GTC | tt_15-2 | 60 | tt_16 | ETH/DEC19 | buy | 2 | 20 | 1 | TYPE_LIMIT | TIF_GTC | tt_16-2 | 61 62 And the mark price should be "20" for the market "ETH/DEC19" 63 64 When the network moves ahead "3" blocks 65 # checking margins 66 Then the parties should have the following account balances: 67 | party | asset | market id | margin | general | 68 | tt_15 | BTC | ETH/DEC19 | 0 | 0 | 69 70 And the insurance pool balance should be "0" for the market "ETH/DEC19" 71 72 #check positions 73 # Note that the realised pnl for tt_15 is -102 as additional 2 was made 74 # on top of initial deposit by earning maker fee on passive orders. 75 Then the parties should have the following profit and loss: 76 | party | volume | unrealised pnl | realised pnl | 77 | tt_12 | 5 | 0 | 0 | 78 | tt_13 | -5 | 0 | 0 | 79 | tt_14 | -4 | 120 | -22 | 80 | tt_15 | 0 | 0 | -102 | 81 | tt_16 | 4 | 0 | 0 |