code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/0002-STTL-settlement-verified-loss-socialization-case3.feature (about)

     1  Feature: Test loss socialization case 3
     2  
     3    Background:
     4      Given the markets:
     5        | id        | quote name | asset | risk model                  | margin calculator         | auction duration | fees         | price monitoring | data source config     | linear slippage factor | quadratic slippage factor | sla params      |
     6        | ETH/DEC19 | BTC        | BTC   | default-simple-risk-model-2 | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 0.25                   | 0                         | default-futures |
     7      And the following network parameters are set:
     8        | name                                    | value |
     9        | market.auction.minimumDuration          | 1     |
    10        | network.markPriceUpdateMaximumFrequency | 0s    |
    11  
    12    Scenario: Case 3: multiple traders have insufficient MTM & multiple traders socialise the losses (no funds in insurance pool) (0002-STTL-009)
    13      Description: Case 3 from https://docs.google.com/spreadsheets/d/1CIPH0aQmIKj6YeFW9ApP_l-jwB4OcsNQ/edit#gid=1555964910
    14  
    15      # setup accounts
    16      Given the parties deposit on asset's general account the following amount:
    17        | party            | asset | amount    |
    18        | sellSideProvider | BTC   | 100000000 |
    19        | buySideProvider  | BTC   | 100000000 |
    20        | party1           | BTC   | 2000      |
    21        | party2           | BTC   | 10000     |
    22        | party3           | BTC   | 3000      |
    23        | party4           | BTC   | 10000     |
    24        | party5           | BTC   | 100000000 |
    25        | party6           | BTC   | 100000000 |
    26        | aux1             | BTC   | 100000000 |
    27        | aux2             | BTC   | 100000000 |
    28  
    29      # setup order book
    30      When the parties place the following orders:
    31        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference       |
    32        | sellSideProvider | ETH/DEC19 | sell | 1000   | 120   | 0                | TYPE_LIMIT | TIF_GTC | sell-provider-1 |
    33        | buySideProvider  | ETH/DEC19 | buy  | 1000   | 80    | 0                | TYPE_LIMIT | TIF_GTC | buy-provider-1  |
    34        | party5           | ETH/DEC19 | buy  | 10     | 100   | 0                | TYPE_LIMIT | TIF_GFA | buy-provider-t5 |
    35        | party6           | ETH/DEC19 | sell | 10     | 100   | 0                | TYPE_LIMIT | TIF_GFA | buy-provider-t6 |
    36        | aux1             | ETH/DEC19 | sell | 1      | 120   | 0                | TYPE_LIMIT | TIF_GTC | aux-s-1         |
    37        | aux2             | ETH/DEC19 | buy  | 1      | 80    | 0                | TYPE_LIMIT | TIF_GTC | aux-b-1         |
    38  
    39      Then the opening auction period ends for market "ETH/DEC19"
    40      And the mark price should be "100" for the market "ETH/DEC19"
    41      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
    42  
    43      # trade 1 occur
    44      When the parties place the following orders with ticks:
    45        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    46        | party1 | ETH/DEC19 | sell | 30     | 100   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    47        | party2 | ETH/DEC19 | buy  | 30     | 100   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
    48      # trade 2 occur
    49      When the parties place the following orders with ticks:
    50        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    51        | party3 | ETH/DEC19 | sell | 60     | 100   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    52        | party2 | ETH/DEC19 | buy  | 60     | 100   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
    53      # trade 3 occur
    54      When the parties place the following orders with ticks:
    55        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    56        | party3 | ETH/DEC19 | sell | 10     | 100   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    57        | party4 | ETH/DEC19 | buy  | 10     | 100   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
    58  
    59      # order book volume change
    60      Then the parties cancel the following orders:
    61        | party            | reference       |
    62        | sellSideProvider | sell-provider-1 |
    63        | buySideProvider  | buy-provider-1  |
    64      When the parties place the following orders with ticks:
    65        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference       |
    66        | sellSideProvider | ETH/DEC19 | sell | 1000   | 300   | 0                | TYPE_LIMIT | TIF_GTC | sell-provider-2 |
    67        | buySideProvider  | ETH/DEC19 | buy  | 1000   | 80    | 0                | TYPE_LIMIT | TIF_GTC | buy-provider-2  |
    68      Then the parties cancel the following orders:
    69        | party | reference |
    70        | aux1  | aux-s-1   |
    71        | aux2  | aux-b-1   |
    72      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
    73  
    74      # trade 4 occur
    75      When the parties place the following orders with ticks:
    76        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    77        | party2 | ETH/DEC19 | buy  | 10     | 180   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    78        | party4 | ETH/DEC19 | sell | 10     | 180   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
    79  
    80      # check positions
    81      Then the parties should have the following profit and loss:
    82        | party  | volume | unrealised pnl | realised pnl |
    83        | party1 | 0      | 0              | -2000        |
    84        | party2 | 100    | 7200           | -2455        |
    85        | party3 | 0      | 0              | -3000        |
    86        | party4 | 0      | 0              | 528          |
    87      And the insurance pool balance should be "0" for the market "ETH/DEC19"