code.vegaprotocol.io/vega@v0.79.0/core/integration/features/closeouts/1847-closeout-short.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 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/DEC19 | BTC        | BTC   | default-simple-risk-model-4 | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 1.5                    | 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          | 2     |
    13  
    14    Scenario: https://drive.google.com/file/d/1bYWbNJvG7E-tcqsK26JMu2uGwaqXqm0L/view
    15      # setup accounts
    16      Given the parties deposit on asset's general account the following amount:
    17        | party  | asset | amount    |
    18        | tt_12  | BTC   | 10000000  |
    19        | tt_13  | BTC   | 10000000  |
    20        | tt_14  | BTC   | 10000000  |
    21        | tt_15  | BTC   | 100       |
    22        | tt_16  | BTC   | 10000000  |
    23        | tt_aux | BTC   | 100000000 |
    24        | t2_aux | BTC   | 100000000 |
    25        | lpprov | BTC   | 100000000 |
    26  
    27      # place auxiliary orders so we always have best bid and best offer as to not trigger the liquidity auction
    28      Then the parties place the following orders:
    29        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    30        | tt_aux | ETH/DEC19 | buy  | 1      | 1     | 0                | TYPE_LIMIT | TIF_GTC | aux-b-1   |
    31        | tt_aux | ETH/DEC19 | sell | 1      | 200   | 0                | TYPE_LIMIT | TIF_GTC | aux-s-1   |
    32        | t2_aux | ETH/DEC19 | buy  | 1      | 20    | 0                | TYPE_LIMIT | TIF_GTC | aux-b-2   |
    33        | tt_aux | ETH/DEC19 | sell | 1      | 20    | 0                | TYPE_LIMIT | TIF_GTC | aux-s-2   |
    34      And the parties submit the following liquidity provision:
    35        | id  | party  | market id | commitment amount | fee | lp type    |
    36        | lp1 | lpprov | ETH/DEC19 | 90000             | 0.1 | submission |
    37        | lp1 | lpprov | ETH/DEC19 | 90000             | 0.1 | submission |
    38      And the parties place the following pegged iceberg orders:
    39        | party  | market id | peak size | minimum visible size | side | pegged reference | volume     | offset |
    40        | lpprov | ETH/DEC19 | 90000     | 1                    | buy  | BID              | 90000      | 0      |
    41        | lpprov | ETH/DEC19 | 448       | 1                    | sell | ASK              | 448        | 1      |
    42      Then the opening auction period ends for market "ETH/DEC19"
    43      And the insurance pool balance should be "0" for the market "ETH/DEC19"
    44  
    45      # place orders and generate trades
    46      When the parties place the following orders "1" blocks apart:
    47        | party | market id | side | volume | price | resulting trades | type       | tif     | reference | expires in |
    48        | tt_12 | ETH/DEC19 | buy  | 5      | 20    | 0                | TYPE_LIMIT | TIF_GTT | tt_12-1   | 3600       |
    49        | tt_13 | ETH/DEC19 | sell | 5      | 20    | 1                | TYPE_LIMIT | TIF_GTT | tt_13-1   | 3600       |
    50        | tt_14 | ETH/DEC19 | sell | 2      | 50    | 0                | TYPE_LIMIT | TIF_GTC | tt_14-1   |            |
    51        | tt_14 | ETH/DEC19 | sell | 2      | 50    | 0                | TYPE_LIMIT | TIF_GTC | tt_14-2   |            |
    52        | tt_15 | ETH/DEC19 | sell | 2      | 20    | 0                | TYPE_LIMIT | TIF_GTC | tt_15-1   |            |
    53        | tt_16 | ETH/DEC19 | buy  | 2      | 20    | 1                | TYPE_LIMIT | TIF_GTC | tt_16-1   |            |
    54        | tt_15 | ETH/DEC19 | sell | 2      | 20    | 0                | TYPE_LIMIT | TIF_GTC | tt_15-2   |            |
    55        | tt_16 | ETH/DEC19 | buy  | 2      | 20    | 1                | TYPE_LIMIT | TIF_GTC | tt_16-2   |            |
    56      And the network moves ahead "1" blocks
    57  
    58  
    59      And the mark price should be "20" for the market "ETH/DEC19"
    60  
    61      # checking margins
    62      Then the parties should have the following account balances:
    63        | party | asset | market id | margin | general |
    64        | tt_15 | BTC   | ETH/DEC19 | 0      | 0       |
    65  
    66      # the insurance pool will have received the distressed party collateral but will have
    67      # paid it straight out to the party who matched the closing out network trade.
    68      And the insurance pool balance should be "0" for the market "ETH/DEC19"
    69  
    70      #check positions
    71      Then the parties should have the following profit and loss:
    72        | party | volume | unrealised pnl | realised pnl |
    73        | tt_12 | 5      | 0              | 0            |
    74        | tt_13 | -5     | 0              | 0            |
    75        | tt_14 | -4     | 120            | -40          |
    76        | tt_15 | 0      | 0              | -100         |
    77        | tt_16 | 4      | 0              | 0            |