code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/overflow.feature (about)

     1  Feature: FCAP liquidations
     2  
     3      vega-market-sim fuzz testing shows parties being liquidated on
     4      fully collateralised capped future (FCAP) markets.
     5  
     6      For the following test cases, the margin requirements are checked
     7      and the price moved against the party to check for liquidations.
     8  
     9      - cross margin:
    10          - party opens short position
    11          - party reduces short position 
    12          - party increases short position
    13          - party opens long position
    14          - party reduces long position 
    15          - party increases long position
    16          - party switches from long to short position
    17          - party switches from short to long position
    18  
    19    Background:
    20  
    21      # Initialise the network and register the assets
    22      Given the average block duration is "1"
    23      And the following network parameters are set:
    24        | name                                    | value |
    25        | market.fee.factors.makerFee             | 0     |
    26        | market.fee.factors.infrastructureFee    | 0     |
    27        | network.markPriceUpdateMaximumFrequency | 0s    |
    28  
    29      And the following assets are registered:
    30        | id       | decimal places | quantum             |
    31        | USD-1-10 | 18             | 1000000000000000000 |
    32  
    33      # Initialise the parties and deposit assets
    34      Given the parties deposit on asset's general account the following amount:
    35        | party | asset    | amount                                                   |
    36        | lp    | USD-1-10 | 1000000000000000000000000000                             |
    37        | aux1  | USD-1-10 | 10000000000000000000000000000000000000000000000000000000 |
    38        | aux2  | USD-1-10 | 10000000000000000000000000000000000000000000000000000000 |
    39  
    40      # Setup the FCAP market in continuous trading
    41      Given the markets:
    42        | id            | quote name | asset    | risk model                    | margin calculator         | auction duration | fees         | price monitoring | data source config     | linear slippage factor | quadratic slippage factor | sla params      | decimal places | position decimal places | max price cap | binary | fully collateralised |
    43        | FCAP/USD-1-10 | ETH        | USD-1-10 | default-log-normal-risk-model | default-margin-calculator | 1                | default-none | default-none     | default-eth-for-future | 1e-3                   | 0                         | default-futures | 4              | 1                       | 10000         | true   | true                 |
    44      And the parties submit the following liquidity provision:
    45        | id  | party | market id     | commitment amount      | fee | lp type    |
    46        | lp1 | lp    | FCAP/USD-1-10 | 1000000000000000000000 | 0   | submission |
    47      And the parties place the following orders:
    48        | party | market id     | side | volume | price | resulting trades | type       | tif     |
    49        | aux1  | FCAP/USD-1-10 | buy  | 1      | 5000  | 0                | TYPE_LIMIT | TIF_GTC |
    50        | aux2  | FCAP/USD-1-10 | sell | 1      | 5000  | 0                | TYPE_LIMIT | TIF_GTC |
    51      When the opening auction period ends for market "FCAP/USD-1-10"
    52      And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "FCAP/USD-1-10"
    53  
    54    @NoPerp
    55    Scenario Outline: Simple test case, party opens long position, margin correctly taken and party never closed out.
    56  
    57      Given the parties deposit on asset's general account the following amount:
    58        | party  | asset    | amount  |
    59        | trader | USD-1-10 | <funds> |
    60  
    61      And the parties place the following orders:
    62        | party  | market id     | side | volume | price         | resulting trades | type       | tif     |
    63        | aux1   | FCAP/USD-1-10 | sell | <size> | <entry price> | 0                | TYPE_LIMIT | TIF_GTC |
    64        | trader | FCAP/USD-1-10 | buy  | <size> | <entry price> | 1                | TYPE_LIMIT | TIF_GTC |
    65      Then the network moves ahead "1" blocks
    66      Then the parties should have the following account balances:
    67        | party  | asset    | market id     | margin         |
    68        | trader | USD-1-10 | FCAP/USD-1-10 | <entry margin> |
    69  
    70      Then the parties place the following orders:
    71        | party | market id     | side | volume | price         | resulting trades | type       | tif     |
    72        | aux1  | FCAP/USD-1-10 | buy  | 1      | <final price> | 0                | TYPE_LIMIT | TIF_GTC |
    73        | aux2  | FCAP/USD-1-10 | sell | 1      | <final price> | 1                | TYPE_LIMIT | TIF_GTC |
    74      Then the network moves ahead "1" blocks
    75      Then the parties should have the following account balances:
    76        | party  | asset    | market id     | margin         |
    77        | trader | USD-1-10 | FCAP/USD-1-10 | <final margin> |
    78  
    79    Examples:
    80        | funds | size | entry price | entry margin | final price | final margin |
    81      #   | 25000000000000000000         | 1            | 2500        | 25000000000000000            | 1           | 10000000000000            |
    82      #   | 250000000000000000000        | 10           | 2500        | 250000000000000000           | 1           | 100000000000000           |
    83      #   | 75000000000000000000         | 1            | 7500        | 75000000000000000            | 1           | 10000000000000            |
    84      #   | 750000000000000000000        | 10           | 7500        | 750000000000000000           | 1           | 100000000000000           |
    85        | 50966286350000000000000 | 1075465 | 4739 | 50966286350000000000000 | 1 | 10754650000000000000 |