code.vegaprotocol.io/vega@v0.79.0/core/integration/features/margin/6202-release-excess-on-amend.feature (about)

     1  Feature: test margin during amending orders
     2  
     3    Background:
     4  
     5      Given the log normal risk model named "log-normal-risk-model-1":
     6        | risk aversion | tau | mu | r | sigma |
     7        | 0.000001      | 0.1 | 0  | 0 | 1.0   |
     8      And the fees configuration named "fees-config-1":
     9        | maker fee | infrastructure fee |
    10        | 0.004     | 0.001              |
    11      And the price monitoring named "price-monitoring-1":
    12        | horizon | probability | auction extension |
    13        | 1       | 0.99        | 300               |
    14      And the following network parameters are set:
    15        | name                                          | value |
    16        | market.liquidity.bondPenaltyParameter       | 0.2   |
    17      And the liquidity monitoring parameters:
    18        | name               | triggering ratio | time window | scaling factor |
    19        | lqm-params         | 0.10             | 24h         | 1              |
    20      And the markets:
    21        | 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      |
    22        | ETH/MAR22 | ETH        | USD   | lqm-params           | log-normal-risk-model-1 | default-margin-calculator | 1                | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.25                   | 0                         | default-futures |
    23      And the parties deposit on asset's general account the following amount:
    24        | party  | asset | amount    |
    25        | party0 | USD   | 500000    |
    26        | party1 | USD   | 100000000 |
    27        | party2 | USD   | 100000000 |
    28        | party3 | USD   | 100000000 |
    29        | party4 | USD   | 100000000 |
    30      And the following network parameters are set:
    31        | name                                    | value |
    32        | network.markPriceUpdateMaximumFrequency | 0s    |
    33        | limits.markets.maxPeggedOrders          | 2     |
    34  
    35    @ExcessAmend
    36    @MTMDelta
    37    Scenario: 001, reduce order size, 0011-MARA-004
    38  
    39      Given the average block duration is "1"
    40  
    41      And the parties submit the following liquidity provision:
    42        | id  | party  | market id | commitment amount | fee   | lp type    |
    43        | lp1 | party0 | ETH/MAR22 | 50000             | 0.001 | submission |
    44        | lp1 | party0 | ETH/MAR22 | 50000             | 0.001 | amendment  |
    45      And the parties place the following orders:
    46        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference  |
    47        | party1 | ETH/MAR22 | buy  | 20     | 900   | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-1  |
    48        | party2 | ETH/MAR22 | buy  | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | buy-ref-2  |
    49        | party3 | ETH/MAR22 | sell | 10     | 1000  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-3 |
    50        | party4 | ETH/MAR22 | sell | 20     | 1100  | 0                | TYPE_LIMIT | TIF_GTC | sell-ref-4 |
    51  
    52      When the opening auction period ends for market "ETH/MAR22"
    53      Then the auction ends with a traded volume of "10" at a price of "1000"
    54      # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1000 x 10 x 1 x 0.1
    55      And the insurance pool balance should be "0" for the market "ETH/MAR22"
    56      And the market data for the market "ETH/MAR22" should be:
    57        | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest |
    58        | 1000       | TRADING_MODE_CONTINUOUS | 1       | 1000      | 1000      | 35569        | 50000          | 10            |
    59  
    60      # check the requried balances
    61      And the parties should have the following account balances:
    62        | party  | asset | market id | margin | general  |
    63        | party1 | USD   | ETH/MAR22 | 19218  | 99980782 |
    64        | party4 | USD   | ETH/MAR22 | 93902  | 99906098 |
    65  
    66      #margin for party4: 20*1000*3.5569036=71139
    67  
    68      #check the margin levels
    69      Then the parties should have the following margin levels:
    70        | party  | market id | maintenance | search | initial | release |
    71        | party1 | ETH/MAR22 | 16015       | 17616  | 19218   | 22421   |
    72        | party4 | ETH/MAR22 | 71139       | 78252  | 85366   | 99594   |
    73  
    74      Then the parties amend the following orders:
    75        | party  | reference  | price | size delta | tif     |
    76        | party1 | buy-ref-1  | 900   | -18        | TIF_GTC |
    77        | party4 | sell-ref-4 | 1100  | 20         | TIF_GTC |
    78  
    79      And the parties should have the following account balances:
    80        | party  | asset | market id | margin | general  |
    81        | party1 | USD   | ETH/MAR22 | 1922   | 99998078 |
    82        | party4 | USD   | ETH/MAR22 | 170732 | 99829268 |
    83      #check the margin levels
    84      Then the parties should have the following margin levels:
    85        | party  | market id | maintenance | search | initial | release |
    86        | party1 | ETH/MAR22 | 1602        | 1762   | 1922    | 2242    |
    87        | party4 | ETH/MAR22 | 142277      | 156504 | 170732  | 199187  |
    88  
    89      And the parties cancel the following orders:
    90        | party  | reference  |
    91        | party1 | buy-ref-1  |
    92        | party4 | sell-ref-4 |
    93  
    94      And the network moves ahead "1" blocks
    95  
    96      And the parties should have the following account balances:
    97        | party  | asset | market id | margin | general   |
    98        | party1 | USD   | ETH/MAR22 | 0      | 100000000 |
    99        | party4 | USD   | ETH/MAR22 | 0      | 100000000 |