code.vegaprotocol.io/vega@v0.79.0/core/integration/features/closeouts/0012-POSR-009.feature (about)

     1  Feature: When a party is distressed and gets closed out the network's position gets modified to reflect that it's now the network party that holds that volume. (0012-POSR-009)
     2  
     3    Background:
     4      Given the liquidation strategies:
     5        | name           | disposal step | disposal fraction | full disposal size | max fraction consumed | disposal slippage range |
     6        | disposal-strat | 10            | 1.0               | 1000               | 1.0                   | 0.1                     |
     7  
     8      Given 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-2 | default-overkill-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 1e3                    | 1e3                       | default-futures | disposal-strat       |
    11      And the following network parameters are set:
    12        | name                                    | value |
    13        | market.auction.minimumDuration          | 1     |
    14        | network.markPriceUpdateMaximumFrequency | 0s    |
    15  
    16    Scenario: Implement trade and order network
    17      # setup accounts
    18      Given the parties deposit on asset's general account the following amount:
    19        | party            | asset | amount        |
    20        | sellSideProvider | BTC   | 1000000000000 |
    21        | buySideProvider  | BTC   | 1000000000000 |
    22        | designatedLoser  | BTC   | 12000         |
    23        | aux              | BTC   | 1000000000000 |
    24        | aux2             | BTC   | 1000000000000 |
    25  
    26      # insurance pool generation - setup orderbook
    27      When the parties place the following orders:
    28        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference       |
    29        | sellSideProvider | ETH/DEC19 | sell | 290    | 150   | 0                | TYPE_LIMIT | TIF_GTC | sell-provider-1 |
    30        | buySideProvider  | ETH/DEC19 | buy  | 1      | 140   | 0                | TYPE_LIMIT | TIF_GTC | buy-provider-1  |
    31        | aux              | ETH/DEC19 | sell | 100    | 159   | 0                | TYPE_LIMIT | TIF_GTC | aux-s-1         |
    32        | aux              | ETH/DEC19 | sell | 1      | 149   | 0                | TYPE_LIMIT | TIF_GTC | aux-s-2         |
    33        | aux2             | ETH/DEC19 | buy  | 1      | 149   | 0                | TYPE_LIMIT | TIF_GTC | aux-b-1         |
    34        | aux2             | ETH/DEC19 | buy  | 100    | 140   | 0                | TYPE_LIMIT | TIF_GTC | aux-b-2         |
    35      Then the opening auction period ends for market "ETH/DEC19"
    36      When the network moves ahead "1" blocks
    37      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
    38  
    39      Then the parties should have the following account balances:
    40        | party           | asset | market id | general |
    41        | designatedLoser | BTC   | ETH/DEC19 | 12000   |
    42  
    43      # insurance pool generation - trade
    44      When the parties place the following orders "1" blocks apart:
    45        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference |
    46        | designatedLoser  | ETH/DEC19 | buy  | 105    | 150   | 1                | TYPE_LIMIT | TIF_GTC | ref-1     |
    47      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
    48  
    49      # The designatedLoser will be closed out and have all their funds moved to the insurance pool
    50      Then the parties should have the following account balances:
    51        | party           | asset | market id | general | margin |
    52        | designatedLoser | BTC   | ETH/DEC19 | 0       | 0      |
    53  
    54      And the global insurance pool balance should be "0" for the asset "BTC"
    55      And the insurance pool balance should be "12000" for the market "ETH/DEC19"    
    56  
    57      # check the network trades happened and the network party holds the volume
    58      Then the following network trades should be executed:
    59        | party           | aggressor side | volume |
    60        | designatedLoser | buy            | 105    |