code.vegaprotocol.io/vega@v0.79.0/core/integration/features/closeouts/630-position-resolution-negative-insurance-pool.feature (about)

     1  Feature: Regression test for issue 630
     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 | 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        | network.markPriceUpdateMaximumFrequency | 0s    |
    11        | limits.markets.maxPeggedOrders          | 2     |
    12  
    13    @Liquidation
    14    Scenario: Trader is being closed out.
    15      # setup accounts
    16      Given the parties deposit on asset's general account the following amount:
    17        | party            | asset | amount   |
    18        | sellSideProvider | BTC   | 1000000  |
    19        | buySideProvider  | BTC   | 11000000 |
    20        | partyGuy         | BTC   | 240000   |
    21        | party1           | BTC   | 1000000  |
    22        | party2           | BTC   | 1000000  |
    23        | aux              | BTC   | 100000   |
    24        | lpprov           | BTC   | 1000000  |
    25        | closeout         | BTC   | 1000000  |
    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     |
    30        | aux   | ETH/DEC19 | buy  | 1      | 1     | 0                | TYPE_LIMIT | TIF_GTC |
    31        | aux   | ETH/DEC19 | sell | 1      | 10001 | 0                | TYPE_LIMIT | TIF_GTC |
    32  
    33      # Trigger an auction to set the mark price
    34      When the parties place the following orders:
    35        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    36        | party1 | ETH/DEC19 | buy  | 1      | 100   | 0                | TYPE_LIMIT | TIF_GFA | party1-2  |
    37        | party2 | ETH/DEC19 | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GFA | party2-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  | BID              | 50         | 100    |
    45        | lpprov | ETH/DEC19 | 2         | 1                    | sell | ASK              | 50         | 100    |
    46      Then the opening auction period ends for market "ETH/DEC19"
    47      And the mark price should be "100" for the market "ETH/DEC19"
    48  
    49      # setup orderbook
    50      When the parties place the following orders "1" blocks apart:
    51        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference |
    52        | sellSideProvider | ETH/DEC19 | sell | 200    | 10000 | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    53        | buySideProvider  | ETH/DEC19 | buy  | 200    | 1     | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |
    54      And the cumulated balance for all accounts should be worth "16340000"
    55      Then the parties should have the following margin levels:
    56        | party            | market id | maintenance | search | initial | release |
    57        | sellSideProvider | ETH/DEC19 | 2000        | 2200   | 2400    | 2800    |
    58      When the parties place the following orders "1" blocks apart:
    59        | party    | market id | side | volume | price | resulting trades | type       | tif     | reference |
    60        | partyGuy | ETH/DEC19 | buy  | 100    | 10000 | 1                | TYPE_LIMIT | TIF_GTC | ref-1     |
    61      Then the parties should have the following account balances:
    62        | party            | asset | market id | margin | general |
    63        | partyGuy         | BTC   | ETH/DEC19 | 0      | 0       |
    64        | sellSideProvider | BTC   | ETH/DEC19 | 540000 | 460000  |
    65      When the parties place the following orders:
    66        | party    | market id | side | volume | price | resulting trades | type       | tif     |
    67        | closeout | ETH/DEC19 | buy  | 100    | 105   | 0                | TYPE_LIMIT | TIF_GTC |
    68      And the network moves ahead "1" blocks
    69      Then the insurance pool balance should be "0" for the market "ETH/DEC19"
    70      And debug trades
    71      And the following trades should be executed:
    72        | buyer           | price | size | seller   |
    73        | network         | 10000 | 100  | partyGuy |
    74        | buySideProvider | 1     | 99   | network  |
    75        | aux             | 1     | 1    | network  |
    76      And the cumulated balance for all accounts should be worth "16340000"