code.vegaprotocol.io/vega@v0.79.0/core/integration/features/closeouts/1847-closeout-long-with-fees.feature (about)

     1  Feature: Long close-out test (see ln 293 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         | fees           | auction duration | 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 | my-fees-config | 1                | default-none     | default-eth-for-future | 0.25                   | 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_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  
    62      And the mark price should be "100" for the market "ETH/DEC19"
    63  
    64      # Ensure the network position is closed out
    65      When the network moves ahead "2" blocks
    66      # checking margins
    67      Then the parties should have the following account balances:
    68        | party | asset | market id | margin | general |
    69        | tt_5  | BTC   | ETH/DEC19 | 0      | 0       |
    70      And debug trades
    71      And the following trades should be executed:
    72        | buyer   | price | size | seller  |
    73        | network | 100   | 4    | tt_5    |
    74        | tt_10   | 100   | 4    | network |
    75  
    76      # then we make sure the insurance pool collected the funds
    77      And the insurance pool balance should be "0" for the market "ETH/DEC19"
    78  
    79      #check positions
    80      #   Note that the realised pnl for tt_15 is -102 as additional 2 was made
    81      #   on top of initial deposit by earning maker fee on passive orders.
    82      #   That same income was used to pay up a higher portion of the 200 owed in MTM
    83      #   settlement by tt_15, hence lower realised pnl loss for tt_11 compared to
    84      #   the no fees case. The benefit for tt_6 is not visible due to rounding.
    85      Then the parties should have the following profit and loss:
    86        | party | volume | unrealised pnl | realised pnl |
    87        | tt_4  | 4      | -200           | 0            |
    88        | tt_5  | 0      | 0              | -102         |
    89        | tt_6  | -4     | 200            | -28          |
    90        | tt_10 | 30     | 0              | 0            |
    91        | tt_11 | -30    | 200            | -63          |