code.vegaprotocol.io/vega@v0.79.0/core/integration/features/capped-futures/11453-closeout.feature (about)

     1  Feature: Issue 11453: incorrect closeout due to decimals in mark price
     2  
     3    Background:
     4      Given time is updated to "2019-11-30T00:00:00Z"
     5      And the average block duration is "1"
     6      And the following assets are registered:
     7        | id  | decimal places |
     8        | USD | 6              |
     9  
    10      And the oracle spec for settlement data filtering data from "0xCAFECAFE1" named "ethDec21Oracle":
    11        | property         | type         | binding         |
    12        | prices.ETH.value | TYPE_INTEGER | settlement data |
    13  
    14      And the oracle spec for trading termination filtering data from "0xCAFECAFE1" named "ethDec21Oracle":
    15        | property           | type         | binding             |
    16        | trading.terminated | TYPE_BOOLEAN | trading termination |
    17  
    18      And the settlement data decimals for the oracle named "ethDec21Oracle" is given in "2" decimal places
    19  
    20      And the following network parameters are set:
    21        | name                                         | value  |
    22        | market.auction.minimumDuration               | 1      |
    23        | network.markPriceUpdateMaximumFrequency      | 1s     |
    24        | market.liquidity.successorLaunchWindowLength | 1s     |
    25        | limits.markets.maxPeggedOrders               | 4      |
    26        | market.fee.factors.makerFee                  | 0.0002 |
    27        | market.fee.factors.infrastructureFee         | 0.0005 |
    28  
    29      And the fees configuration named "fees-config-1":
    30        | maker fee | infrastructure fee |
    31        | 0.0002    | 0.0005             |
    32      And the price monitoring named "price-monitoring-1":
    33        | horizon | probability | auction extension |
    34        | 3600000 | 0.99        | 300               |
    35      And the log normal risk model named "lognormal-risk-model-1":
    36        | risk aversion | tau             | mu | r     | sigma |
    37        | 0.00001       | 0.0001140771161 | 0  | 0.016 | 0.15  |
    38  
    39      And the markets:
    40        | id        | quote name | asset | risk model             | margin calculator                | auction duration | fees          | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params      | max price cap | fully collateralised | binary | price type | decay weight | decay power | cash amount | source weights | source staleness tolerance | decimal places | position decimal places |
    41        | ETH/DEC21 | ETH        | USD   | lognormal-risk-model-1 | default-capped-margin-calculator | 1                | fees-config-1 | default-none     | ethDec21Oracle     | 0.001                  | 0                         | default-futures | 1000          | true                 | true   | weight     | 1            | 1           | 5000000     | 0,1,0,0        | 1m,1m,1m,1m                | 1              | 1                       |
    42  
    43    @CappedBug
    44    Scenario: Replicate bug where MTM happens at strange price
    45      Given the initial insurance pool balance is "10000" for all the markets
    46      And the parties deposit on asset's general account the following amount:
    47        | party    | asset | amount        |
    48        | party1   | USD   | 100000000000  |
    49        | party2   | USD   | 100000000000  |
    50        | party3   | USD   | 100000000000  |
    51        | aux1     | USD   | 100000000000  |
    52        | aux2     | USD   | 100000000000  |
    53        | aux3     | USD   | 100000000000  |
    54        | aux4     | USD   | 1000000000    |
    55        | aux5     | USD   | 100000000000  |
    56        | party-lp | USD   | 1000000000000 |
    57  
    58      And the parties submit the following liquidity provision:
    59        | id  | party    | market id | commitment amount | fee | lp type    |
    60        | lp2 | party-lp | ETH/DEC21 | 300000000         | 0   | submission |
    61  
    62      When the parties place the following orders:
    63        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference | error |
    64        | aux1   | ETH/DEC21 | buy  | 1000   | 350   | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |       |
    65        | aux2   | ETH/DEC21 | sell | 1000   | 450   | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |       |
    66        | party1 | ETH/DEC21 | buy  | 1      | 400   | 0                | TYPE_LIMIT | TIF_GTC | ref-3     |       |
    67        | party2 | ETH/DEC21 | sell | 1      | 400   | 0                | TYPE_LIMIT | TIF_GTC | ref-4     |       |
    68        | party2 | ETH/DEC21 | sell | 1000   | 500   | 0                | TYPE_LIMIT | TIF_GTC | ref-4     |       |
    69        | party3 | ETH/DEC21 | buy  | 1000   | 300   | 0                | TYPE_LIMIT | TIF_GTC | ref-4     |       |
    70      And the network moves ahead "2" blocks
    71  
    72      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC21"
    73      And the market state should be "STATE_ACTIVE" for the market "ETH/DEC21"
    74      And the mark price should be "400" for the market "ETH/DEC21"
    75      And the parties should have the following account balances:
    76        | party  | asset | market id | margin     | general     |
    77        | party1 | USD   | ETH/DEC21 | 4000000    | 99996000000 |
    78        | party2 | USD   | ETH/DEC21 | 5006000000 | 94994000000 |
    79        | aux1   | USD   | ETH/DEC21 | 3500000000 | 96500000000 |
    80  
    81      And the parties should have the following margin levels:
    82        | party  | market id | maintenance | search     | initial    | release    | margin mode  |
    83        | party1 | ETH/DEC21 | 4000000     | 4000000    | 4000000    | 4000000    | cross margin |
    84        | party2 | ETH/DEC21 | 5006000000  | 5006000000 | 5006000000 | 5006000000 | cross margin |
    85        | aux1   | ETH/DEC21 | 3500000000  | 3500000000 | 3500000000 | 3500000000 | cross margin |
    86        | aux2   | ETH/DEC21 | 5500000000  | 5500000000 | 5500000000 | 5500000000 | cross margin |
    87  
    88      When the network moves ahead "2" blocks
    89      Then the parties place the following orders:
    90        | party | market id | side | volume | price | resulting trades | type       | tif     | reference | error |
    91        | aux4  | ETH/DEC21 | sell | 150    | 350   | 1                | TYPE_LIMIT | TIF_GTC | ref-4     |       |
    92      When the network moves ahead "2" blocks
    93      Then the mark price should be "400" for the market "ETH/DEC21"
    94      And the parties should have the following account balances:
    95        | party | asset | market id | margin    | general  |
    96        | aux4  | USD   | ETH/DEC21 | 900000000 | 24632500 |
    97      #And debug transfers
    98      #And debug detailed orderbook volumes for market "ETH/DEC21"
    99      #And debug trades