code.vegaprotocol.io/vega@v0.79.0/core/integration/features/capped-futures/0019-MCAL-154.feature (about)

     1  Feature: Margin calculation on a fully collateralised capped future
     2  
     3    Background:
     4      Given time is updated to "2019-11-30T00:00:00Z"
     5      And the average block duration is "1"
     6  
     7      And the oracle spec for settlement data filtering data from "0xCAFECAFE1" named "ethDec21Oracle":
     8        | property         | type         | binding         |
     9        | prices.ETH.value | TYPE_INTEGER | settlement data |
    10  
    11      And the oracle spec for trading termination filtering data from "0xCAFECAFE1" named "ethDec21Oracle":
    12        | property           | type         | binding             |
    13        | trading.terminated | TYPE_BOOLEAN | trading termination |
    14  
    15      And the settlement data decimals for the oracle named "ethDec21Oracle" is given in "0" decimal places
    16  
    17      And the following network parameters are set:
    18        | name                                         | value |
    19        | market.auction.minimumDuration               | 1     |
    20        | network.markPriceUpdateMaximumFrequency      | 0s    |
    21        | market.liquidity.successorLaunchWindowLength | 1s    |
    22        | limits.markets.maxPeggedOrders               | 4     |
    23  
    24      And the fees configuration named "fees-config-1":
    25        | maker fee | infrastructure fee |
    26        | 0.005     | 0.02               |
    27      And the price monitoring named "price-monitoring-1":
    28        | horizon | probability | auction extension |
    29        | 3600000 | 0.99        | 300               |
    30      And the log normal risk model named "lognormal-risk-model-1":
    31        | risk aversion | tau  | mu | r   | sigma |
    32        | 0.0002        | 0.01 | 0  | 0.0 | 1.2   |
    33  
    34      And the markets:
    35        | 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 |
    36        | ETH/DEC21 | ETH        | USD   | lognormal-risk-model-1 | default-capped-margin-calculator | 1                | fees-config-1 | price-monitoring-1 | ethDec21Oracle     | 0.25                   | 0                         | default-futures | 100           | true                 | false  |
    37  
    38    @SLABug @NoPerp @Capped @CFC @CappedBug
    39    Scenario: 0019-MCAL-154: Party A posts an order to buy 10 contracts at a price of 30, there's no other volume in that price range so the order lands on the book and the maintenance and initial margin levels for the party and order margin account balance are all equal to 300.
    40      Given the initial insurance pool balance is "10000" for all the markets
    41      And the parties deposit on asset's general account the following amount:
    42        | party    | asset | amount    |
    43        | party1   | USD   | 10000     |
    44        | party2   | USD   | 10000     |
    45        | aux1     | USD   | 100000    |
    46        | aux2     | USD   | 100000    |
    47        | aux3     | USD   | 100000    |
    48        | aux4     | USD   | 100000    |
    49        | aux5     | USD   | 100000    |
    50        | party-lp | USD   | 100000000 |
    51  
    52      And the parties submit the following liquidity provision:
    53        | id  | party    | market id | commitment amount | fee | lp type    |
    54        | lp2 | party-lp | ETH/DEC21 | 30000             | 0   | submission |
    55  
    56      When the parties place the following orders:
    57        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference | error |
    58        | aux1   | ETH/DEC21 | buy  | 2      | 9     | 0                | TYPE_LIMIT | TIF_GTC | ref-1     |       |
    59        | aux2   | ETH/DEC21 | sell | 2      | 99    | 0                | TYPE_LIMIT | TIF_GTC | ref-2     |       |
    60        | party1 | ETH/DEC21 | buy  | 5      | 50    | 0                | TYPE_LIMIT | TIF_GTC | ref-3     |       |
    61        | party2 | ETH/DEC21 | sell | 5      | 50    | 0                | TYPE_LIMIT | TIF_GTC | ref-4     |       |
    62      And the network moves ahead "2" blocks
    63  
    64      Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC21"
    65      And the market state should be "STATE_ACTIVE" for the market "ETH/DEC21"
    66      And the mark price should be "50" for the market "ETH/DEC21"
    67      And the parties should have the following account balances:
    68        | party  | asset | market id | margin | general |
    69        | party1 | USD   | ETH/DEC21 | 250    | 9750    |
    70        | party2 | USD   | ETH/DEC21 | 250    | 9750    |
    71        | aux1   | USD   | ETH/DEC21 | 18     | 99982   |
    72  
    73      And the parties should have the following margin levels:
    74        | party  | market id | maintenance | search | initial | release | margin mode  |
    75        | party1 | ETH/DEC21 | 250         | 250    | 250     | 250     | cross margin |
    76        | party2 | ETH/DEC21 | 250         | 250    | 250     | 250     | cross margin |
    77        | aux1   | ETH/DEC21 | 18          | 18     | 18      | 18      | cross margin |
    78        | aux2   | ETH/DEC21 | 2           | 2      | 2       | 2       | cross margin |
    79  
    80      # The case the AC is actually about: buy 10@30
    81      When the parties place the following orders:
    82        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
    83        | aux3  | ETH/DEC21 | buy  | 10     | 30    | 0                | TYPE_LIMIT | TIF_GTC | aux3-1    |
    84      And the network moves ahead "2" blocks
    85      Then the parties should have the following account balances:
    86        | party  | asset | market id | margin | general |
    87        | party1 | USD   | ETH/DEC21 | 250    | 9750    |
    88        | party2 | USD   | ETH/DEC21 | 250    | 9750    |
    89        | aux1   | USD   | ETH/DEC21 | 18     | 99982   |
    90        | aux3   | USD   | ETH/DEC21 | 300    | 99700   |
    91      And the parties should have the following margin levels:
    92        | party  | market id | maintenance | search | initial | release | margin mode  |
    93        | party1 | ETH/DEC21 | 250         | 250    | 250     | 250     | cross margin |
    94        | party2 | ETH/DEC21 | 250         | 250    | 250     | 250     | cross margin |
    95        | aux1   | ETH/DEC21 | 18          | 18     | 18      | 18      | cross margin |
    96        | aux2   | ETH/DEC21 | 2           | 2      | 2       | 2       | cross margin |
    97        | aux3   | ETH/DEC21 | 300         | 300    | 300     | 300     | cross margin |
    98  
    99      #0019-MCAL-155
   100      When the parties place the following orders:
   101        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
   102        | aux4  | ETH/DEC21 | sell | 15     | 20    | 1                | TYPE_LIMIT | TIF_GTC | aux3-1    |
   103      And the network moves ahead "2" blocks
   104  
   105      And the following trades should be executed:
   106        | buyer | price | size | seller |
   107        | aux3  | 30    | 10   | aux4   |
   108  
   109      Then the parties should have the following account balances:
   110        | party  | asset | market id | margin | general |
   111        | party1 | USD   | ETH/DEC21 | 150    | 9750    |
   112        | party2 | USD   | ETH/DEC21 | 350    | 9750    |
   113        | aux1   | USD   | ETH/DEC21 | 18     | 99982   |
   114        | aux3   | USD   | ETH/DEC21 | 300    | 99702   |
   115        | aux4   | USD   | ETH/DEC21 | 1100   | 98892   |
   116      And the parties should have the following margin levels:
   117        | party  | market id | maintenance | search | initial | release | margin mode  |
   118        | party1 | ETH/DEC21 | 150         | 150    | 150     | 150     | cross margin |
   119        | party2 | ETH/DEC21 | 350         | 350    | 350     | 350     | cross margin |
   120        | aux1   | ETH/DEC21 | 18          | 18     | 18      | 18      | cross margin |
   121        | aux2   | ETH/DEC21 | 2           | 2      | 2       | 2       | cross margin |
   122        | aux3   | ETH/DEC21 | 300         | 300    | 300     | 300     | cross margin |
   123        | aux4   | ETH/DEC21 | 1100        | 1100   | 1100    | 1100    | cross margin |
   124  
   125      #0019-MCAL-156
   126      When the parties place the following orders:
   127        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
   128        | aux4  | ETH/DEC21 | buy  | 15     | 18    | 0                | TYPE_LIMIT | TIF_GTC | aux3-1    |
   129      And the network moves ahead "2" blocks
   130  
   131      Then the parties should have the following account balances:
   132        | party  | asset | market id | margin | general |
   133        | party1 | USD   | ETH/DEC21 | 150    | 9750    |
   134        | party2 | USD   | ETH/DEC21 | 350    | 9750    |
   135        | aux1   | USD   | ETH/DEC21 | 18     | 99982   |
   136        | aux3   | USD   | ETH/DEC21 | 300    | 99702   |
   137        | aux4   | USD   | ETH/DEC21 | 1100   | 98892   |
   138  
   139      #0019-MCAL-157
   140      When the parties place the following orders:
   141        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
   142        | aux4  | ETH/DEC21 | buy  | 30     | 16    | 0                | TYPE_LIMIT | TIF_GTC | aux3-1    |
   143      And the network moves ahead "2" blocks
   144  
   145      Then the parties should have the following account balances:
   146        | party  | asset | market id | margin | general |
   147        | party1 | USD   | ETH/DEC21 | 150    | 9750    |
   148        | party2 | USD   | ETH/DEC21 | 350    | 9750    |
   149        | aux1   | USD   | ETH/DEC21 | 18     | 99982   |
   150        | aux3   | USD   | ETH/DEC21 | 300    | 99702   |
   151        | aux4   | USD   | ETH/DEC21 | 1420   | 98572   |
   152  
   153      #0019-MCAL-158
   154      When the parties place the following orders:
   155        | party | market id | side | volume | price | resulting trades | type       | tif     | reference |
   156        | aux3  | ETH/DEC21 | sell | 20     | 17    | 1                | TYPE_LIMIT | TIF_GTC | aux3-1    |
   157      And the network moves ahead "2" blocks
   158  
   159      And the following trades should be executed:
   160        | buyer | price | size | seller |
   161        | aux4  | 18    | 15   | aux3   |
   162  
   163      Then the parties should have the following account balances:
   164        | party  | asset | market id | margin | general |
   165        | party1 | USD   | ETH/DEC21 | 90     | 9750    |
   166        | party2 | USD   | ETH/DEC21 | 410    | 9750    |
   167        | aux1   | USD   | ETH/DEC21 | 18     | 99982   |
   168        | aux3   | USD   | ETH/DEC21 | 825    | 99049   |
   169        | aux4   | USD   | ETH/DEC21 | 570    | 99544   |
   170