code.vegaprotocol.io/vega@v0.79.0/core/integration/features/margin/order-margin-account-balance.feature (about)

     1  Feature: Test funds are transferred from general account when margin factor decreases and released back to it when it increases
     2    Background:
     3      Given the following network parameters are set:
     4        | name                                    | value |
     5        | network.markPriceUpdateMaximumFrequency | 0s    |
     6      And the liquidity monitoring parameters:
     7        | name       | triggering ratio | time window | scaling factor |
     8        | lqm-params | 0.00             | 24h         | 1e-9           |
     9      And the simple risk model named "simple-risk-model":
    10        | long | short | max move up | min move down | probability of trading |
    11        | 0.1  | 0.1   | 100         | -100          | 0.2                    |
    12      And the markets:
    13        | id        | quote name | asset | liquidity monitoring | risk model        | margin calculator         | auction duration | fees         | price monitoring | data source config     | linear slippage factor | quadratic slippage factor | sla params      |
    14        | ETH/FEB23 | ETH        | USD   | lqm-params           | simple-risk-model | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 0.25                   | 0                         | default-futures |
    15  
    16    Scenario: Parties with same funds, trades, orders and margin factors must have same account balances irrespective of any interim margin factor changes
    17      Given the parties deposit on asset's general account the following amount:
    18        | party            | asset | amount       |
    19        | buySideProvider  | USD   | 100000000000 |
    20        | sellSideProvider | USD   | 100000000000 |
    21        | party1           | USD   | 1000000      |
    22        | party2           | USD   | 1000000      |
    23      And the parties place the following orders:
    24        | party            | market id | side | volume | price  | resulting trades | type       | tif     |
    25        | buySideProvider  | ETH/FEB23 | buy  | 10     | 14900  | 0                | TYPE_LIMIT | TIF_GTC |
    26        | buySideProvider  | ETH/FEB23 | buy  | 6      | 15900  | 0                | TYPE_LIMIT | TIF_GTC |
    27        | party1           | ETH/FEB23 | sell | 3      | 15900  | 0                | TYPE_LIMIT | TIF_GTC |
    28        | party2           | ETH/FEB23 | sell | 3      | 15900  | 0                | TYPE_LIMIT | TIF_GTC |
    29        | party1           | ETH/FEB23 | sell | 3      | 16100  | 0                | TYPE_LIMIT | TIF_GTC |
    30        | party2           | ETH/FEB23 | sell | 3      | 16100  | 0                | TYPE_LIMIT | TIF_GTC |
    31        | sellSideProvider | ETH/FEB23 | sell | 1      | 100000 | 0                | TYPE_LIMIT | TIF_GTC |
    32  
    33      When the network moves ahead "2" blocks
    34      Then the market data for the market "ETH/FEB23" should be:
    35        | mark price | trading mode            |
    36        | 15900      | TRADING_MODE_CONTINUOUS |
    37  
    38      When the parties submit update margin mode:
    39        | party  | market    | margin_mode     | margin_factor |
    40        | party1 | ETH/FEB23 | isolated margin | 2             |
    41        | party2 | ETH/FEB23 | isolated margin | 2             |
    42      And the network moves ahead "2" blocks
    43      Then the parties should have the following margin levels:
    44        | party  | market id | maintenance | search | initial | release | margin mode     | margin factor | order |
    45        | party1 | ETH/FEB23 | 16695       | 0      | 20034   | 0       | isolated margin | 2             | 96600 |
    46        | party2 | ETH/FEB23 | 16695       | 0      | 20034   | 0       | isolated margin | 2             | 96600 |
    47      And the parties should have the following account balances:
    48        | party  | asset | market id | margin | general | order margin |
    49        | party1 | USD   | ETH/FEB23 | 95400  | 808000  | 96600        |
    50        | party2 | USD   | ETH/FEB23 | 95400  | 808000  | 96600        |
    51  
    52      When the parties submit update margin mode:
    53        | party  | market    | margin_mode     | margin_factor |
    54        | party2 | ETH/FEB23 | isolated margin | 0.5           |
    55      And the network moves ahead "2" blocks
    56      Then the parties should have the following margin levels:
    57        | party  | market id | maintenance | search | initial | release | margin mode     | margin factor | order |
    58        | party1 | ETH/FEB23 | 16695       | 0      | 20034   | 0       | isolated margin | 2             | 96600 |
    59        | party2 | ETH/FEB23 | 16695       | 0      | 20034   | 0       | isolated margin | 0.5           | 24150 |
    60      And the parties should have the following account balances:
    61        | party  | asset | market id | margin | general | order margin |
    62        | party1 | USD   | ETH/FEB23 | 95400  | 808000  | 96600        |
    63        | party2 | USD   | ETH/FEB23 | 23850  | 952000  | 24150        |
    64  
    65      When the parties submit update margin mode:
    66        | party  | market    | margin_mode     | margin_factor |
    67        | party2 | ETH/FEB23 | isolated margin | 2             |
    68      And the network moves ahead "2" blocks
    69      # Expecting equal margin levels and balances at this stage
    70      Then the parties should have the following margin levels:
    71        | party  | market id | maintenance | search | initial | release | margin mode     | margin factor | order |
    72        | party1 | ETH/FEB23 | 16695       | 0      | 20034   | 0       | isolated margin | 2             | 96600 |
    73        | party2 | ETH/FEB23 | 16695       | 0      | 20034   | 0       | isolated margin | 2             | 96600 |
    74      And the parties should have the following account balances:
    75        | party  | asset | market id | margin | general | order margin |
    76        | party1 | USD   | ETH/FEB23 | 95400  | 808000  | 96600        |
    77        | party2 | USD   | ETH/FEB23 | 95400  | 808000  | 96600        |