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

     1  Feature: Test loss socialization case 1
     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 1: trader1 has insufficient MTM & only trader2 socialises the losses (0002-STTL-009)
    13      Description : Case 1 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   | 5000      |
    21        | party2           | BTC   | 50000     |
    22        | party3           | BTC   | 50000     |
    23        | aux1             | BTC   | 100000000 |
    24        | aux2             | BTC   | 100000000 |
    25      # setup order book
    26      When the parties place the following orders:
    27        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference       |
    28        | sellSideProvider | ETH/DEC19 | sell | 1000   | 120   | 0                | TYPE_LIMIT | TIF_GTC | sell-provider-1 |
    29        | buySideProvider  | ETH/DEC19 | buy  | 1000   | 80    | 0                | TYPE_LIMIT | TIF_GTC | buy-provider-1  |
    30        | aux1             | ETH/DEC19 | sell | 1      | 120   | 0                | TYPE_LIMIT | TIF_GTC | aux-s-1         |
    31        | aux2             | ETH/DEC19 | buy  | 1      | 80    | 0                | TYPE_LIMIT | TIF_GTC | aux-b-1         |
    32        | aux1             | ETH/DEC19 | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC | aux-s-2         |
    33        | aux2             | ETH/DEC19 | buy  | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC | aux-b-2         |
    34      Then the opening auction period ends for market "ETH/DEC19"
    35      And the mark price should be "100" for the market "ETH/DEC19"
    36      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
    37      # party 1 place an order + we check margins
    38      When the parties place the following orders with ticks:
    39        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    40        | party1 | ETH/DEC19 | sell | 100    | 100   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    41      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
    42      # then party2 place an order, and we calculate the margins again
    43      When the parties place the following orders with ticks:
    44        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    45        | party2 | ETH/DEC19 | buy  | 100    | 100   | 1                | TYPE_LIMIT | TIF_GTC | ref-1     |
    46      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
    47      # then we change the volume in the book
    48      Then the parties cancel the following orders:
    49        | party            | reference       |
    50        | sellSideProvider | sell-provider-1 |
    51        | buySideProvider  | buy-provider-1  |
    52      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
    53      When the parties place the following orders with ticks:
    54        | party            | market id | side | volume | price | resulting trades | type       | tif     | reference       |
    55        | sellSideProvider | ETH/DEC19 | sell | 1000   | 200   | 0                | TYPE_LIMIT | TIF_GTC | sell-provider-2 |
    56        | buySideProvider  | ETH/DEC19 | buy  | 1000   | 80    | 0                | TYPE_LIMIT | TIF_GTC | buy-provider-2  |
    57      Then the parties cancel the following orders:
    58        | party | reference |
    59        | aux1  | aux-s-1   |
    60        | aux2  | aux-b-1   |
    61      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
    62      When the parties place the following orders with ticks:
    63        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    64        | party2 | ETH/DEC19 | buy  | 100    | 180   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |
    65        | party3 | ETH/DEC19 | sell | 100    | 180   | 1                | TYPE_LIMIT | TIF_GTC | ref-2     |
    66      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
    67      Then the parties should have the following profit and loss:
    68        | party  | volume | unrealised pnl | realised pnl |
    69        | party1 | 0      | 0              | -5000        |
    70        | party2 | 200    | 8000           | -2970        |
    71        | party3 | -100   | 0              | 0            |
    72      And the insurance pool balance should be "0" for the market "ETH/DEC19"
    73      And the cumulated balance for all accounts should be worth "400105000"