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

     1  Feature: Test loss socialization case 4
     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  
    13    Scenario: Case 4: multiple traders have insufficient MTM & multiple traders socialise the losses (insurance pool partially covers the losses) (0002-STTL-009)
    14      Description: Case 4 from https://docs.google.com/spreadsheets/d/1CIPH0aQmIKj6YeFW9ApP_l-jwB4OcsNQ/edit#gid=1555964910
    15  
    16      # setup accounts
    17      Given the initial insurance pool balance is "2900" for all the markets
    18      Given the parties deposit on asset's general account the following amount:
    19        | party            | asset | amount    |
    20        | sellSideProvider | BTC   | 100000000 |
    21        | buySideProvider  | BTC   | 100000000 |
    22        | party1           | BTC   | 2000      |
    23        | party2           | BTC   | 10000     |
    24        | party3           | BTC   | 3000      |
    25        | party4           | BTC   | 10000     |
    26        | party5           | BTC   | 100000000 |
    27        | party6           | BTC   | 100000000 |
    28        | aux1             | BTC   | 100000000 |
    29        | aux2             | BTC   | 100000000 |
    30  
    31      # Trigger an auction to set the mark price
    32      When the parties place the following orders:
    33        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    34        | aux1   | ETH/DEC19 | buy  | 1      | 10    | 0                | TYPE_LIMIT | TIF_GTC | party5-1  |
    35        | aux2   | ETH/DEC19 | sell | 1      | 1000  | 0                | TYPE_LIMIT | TIF_GTC | party6-1  |
    36        | party5 | ETH/DEC19 | buy  | 1      | 100   | 0                | TYPE_LIMIT | TIF_GFA | party5-2  |
    37        | party6 | ETH/DEC19 | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GFA | party6-2  |
    38      Then the opening auction period ends for market "ETH/DEC19"
    39      And the mark price should be "100" for the market "ETH/DEC19"
    40  
    41      # setup orderbook
    42      When the parties place the following orders with ticks:
    43        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference       |
    44        | sellSideProvider | ETH/DEC19 | sell | 1000   | 120   | 0                | TYPE_LIMIT | TIF_GTC | sell-provider-1 |
    45        | buySideProvider  | ETH/DEC19 | buy  | 1000   | 80    | 0                | TYPE_LIMIT | TIF_GTC | buy-provider-1  |
    46      # trade 1 occur
    47      When the parties place the following orders with ticks:
    48        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    49        | party1 | ETH/DEC19 | sell | 30     | 100   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    50        | party2 | ETH/DEC19 | buy  | 30     | 100   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
    51      # trade 2 occur
    52      When the parties place the following orders with ticks:
    53        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    54        | party3 | ETH/DEC19 | sell | 60     | 100   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    55        | party2 | ETH/DEC19 | buy  | 60     | 100   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
    56      # trade 3 occur
    57      When the parties place the following orders with ticks:
    58        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    59        | party3 | ETH/DEC19 | sell | 10     | 100   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    60        | party4 | ETH/DEC19 | buy  | 10     | 100   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
    61  
    62      # order book volume change
    63      Then the parties cancel the following orders:
    64        | party            | reference       |
    65        | sellSideProvider | sell-provider-1 |
    66        | buySideProvider  | buy-provider-1  |
    67      When the parties place the following orders with ticks:
    68        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference       |
    69        | sellSideProvider | ETH/DEC19 | sell | 1000   | 300   | 0                | TYPE_LIMIT | TIF_GTC | sell-provider-2 |
    70        | buySideProvider  | ETH/DEC19 | buy  | 1000   | 80    | 0                | TYPE_LIMIT | TIF_GTC | buy-provider-2  |
    71      Then the parties cancel the following orders:
    72        | party | reference |
    73        | aux1  | party5-1  |
    74        | aux2  | party6-1  |
    75  
    76      # trade 4 occur
    77      When the parties place the following orders with ticks:
    78        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    79        | party2 | ETH/DEC19 | buy  | 10     | 180   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    80        | party4 | ETH/DEC19 | sell | 10     | 180   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
    81  
    82      # check positions
    83      Then the parties should have the following profit and loss:
    84        | party  | volume | unrealised pnl | realised pnl |
    85        | party1 | 0      | 0              | -2400        |
    86        | party2 | 100    | 7200           | -90          |
    87        | party3 | 0      | 0              | -5500        |
    88        | party4 | 0      | 0              | 791          |
    89      And the insurance pool balance should be "0" for the market "ETH/DEC19"