code.vegaprotocol.io/vega@v0.79.0/core/integration/features/amm/0012-POSR-032.feature (about)

     1  Feature: A network disposal order which crosses with volume implied by an vAMM should trade with the vAMM volume. (0012-POSR-032)
     2  
     3    Background:
     4      Given the average block duration is "1"
     5      And the margin calculator named "margin-calculator-1":
     6        | search factor | initial factor | release factor |
     7        | 1.2           | 1.5            | 1.7            |
     8      And the log normal risk model named "log-normal-risk-model":
     9        | risk aversion | tau                   | mu | r   | sigma |
    10        | 0.001         | 0.0011407711613050422 | 0  | 0.9 | 3.0   |
    11      And the liquidity monitoring parameters:
    12        | name       | triggering ratio | time window | scaling factor |
    13        | lqm-params | 1.00             | 20s         | 1              |
    14      And the liquidation strategies:
    15        | name             | disposal step | disposal fraction | full disposal size | max fraction consumed | disposal slippage range |
    16        | disposal-strat-1 | 5             | 0.2               | 10                 | 0.5                   | 0.1                     |
    17        
    18      And the following network parameters are set:
    19        | name                                                | value |
    20        | market.value.windowLength                           | 60s   |
    21        | network.markPriceUpdateMaximumFrequency             | 0s    |
    22        | limits.markets.maxPeggedOrders                      | 6     |
    23        | market.auction.minimumDuration                      | 1     |
    24        | market.fee.factors.infrastructureFee                | 0.001 |
    25        | market.fee.factors.makerFee                         | 0.004 |
    26        | spam.protection.max.stopOrdersPerMarket             | 5     |
    27        | market.liquidity.equityLikeShareFeeFraction         | 1     |
    28        | market.amm.minCommitmentQuantum                     | 1     |
    29        | market.liquidity.bondPenaltyParameter               | 0.2   |
    30        | market.liquidity.stakeToCcyVolume                   | 1     |
    31        | market.liquidity.successorLaunchWindowLength        | 1h    |
    32        | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0.1   |
    33        | market.liquidity.sla.nonPerformanceBondPenaltyMax   | 0.6   |
    34        | validators.epoch.length                             | 10s   |
    35        | market.liquidity.earlyExitPenalty                   | 0.25  |
    36        | market.liquidity.maximumLiquidityFeeFactorLevel     | 0.25  |
    37      #risk factor short:3.5569036
    38      #risk factor long:0.801225765
    39      And the following assets are registered:
    40        | id  | decimal places |
    41        | USD | 0              |
    42      And the fees configuration named "fees-config-1":
    43        | maker fee | infrastructure fee |
    44        | 0.0004    | 0.001              |
    45  
    46      And the liquidity sla params named "SLA-22":
    47        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
    48        | 0.5         | 0.6                          | 1                             | 1.0                    |
    49  
    50      And the oracle spec for settlement data filtering data from "0xCAFECAFE" named "ethMar22Oracle":
    51        | property         | type         | binding         |
    52        | prices.ETH.value | TYPE_INTEGER | settlement data |
    53      And the oracle spec for trading termination filtering data from "0xCAFECAFE" named "ethMar22Oracle":
    54        | property           | type         | binding             |
    55        | trading.terminated | TYPE_BOOLEAN | trading termination |
    56      And the settlement data decimals for the oracle named "ethMar22Oracle" is given in "0" decimal places
    57  
    58      And the markets:
    59        | 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 | liquidation strategy |
    60        | ETH/MAR22 | USD        | USD   | lqm-params           | log-normal-risk-model | margin-calculator-1 | 2                | fees-config-1 | default-none     | ethMar22Oracle     | 1e0                    | 0                         | SLA-22     | disposal-strat-1     |
    61  
    62      # Setting up the accounts and vAMM submission now is part of the background, because we'll be running scenarios 0090-VAMM-006 through 0090-VAMM-014 on this setup
    63      Given the parties deposit on asset's general account the following amount:
    64        | party  | asset | amount  |
    65        | lp1    | USD   | 1000000 |
    66        | lp2    | USD   | 1000000 |
    67        | lp3    | USD   | 1000000 |
    68        | party1 | USD   | 1000000 |
    69        | party2 | USD   | 1000000 |
    70        | party3 | USD   | 1000000 |
    71        | party4 | USD   | 1000000 |
    72        | party5 | USD   | 1000000 |
    73        | partyX | USD   | 100     |
    74        | vamm1  | USD   | 100000  |
    75  
    76      When the parties submit the following liquidity provision:
    77        | id   | party | market id | commitment amount | fee   | lp type    |
    78        | lp_1 | lp1   | ETH/MAR22 | 600               | 0.02  | submission |
    79        | lp_2 | lp2   | ETH/MAR22 | 400               | 0.015 | submission |
    80      Then the network moves ahead "4" blocks
    81      And the current epoch is "0"
    82  
    83      And the parties place the following orders:
    84        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    85        | lp1    | ETH/MAR22 | buy  | 20     | 4     | 0                | TYPE_LIMIT | TIF_GTC | lp1-b     |
    86        | party1 | ETH/MAR22 | buy  | 1      | 5     | 0                | TYPE_LIMIT | TIF_GTC |           |
    87        | partyX | ETH/MAR22 | sell | 1      | 5     | 0                | TYPE_LIMIT | TIF_GTC |           |
    88        | lp1    | ETH/MAR22 | sell | 10     | 16    | 0                | TYPE_LIMIT | TIF_GTC | lp1-s     |
    89      When the opening auction period ends for market "ETH/MAR22"
    90      Then the following trades should be executed:
    91        | buyer  | price | size | seller |
    92        | party1 | 5     | 1    | partyX |
    93      And the parties cancel the following orders:
    94        | party | reference |
    95        | lp1   | lp1-b     |
    96        | lp1   | lp1-s     |
    97  
    98      When the parties place the following orders:
    99        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   100        | lp1    | ETH/MAR22 | buy  | 20     | 40    | 0                | TYPE_LIMIT | TIF_GTC | lp1-b     |
   101        | party1 | ETH/MAR22 | buy  | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC |           |
   102        | party2 | ETH/MAR22 | sell | 1      | 100   | 1                | TYPE_LIMIT | TIF_GTC |           |
   103        | lp1    | ETH/MAR22 | sell | 10     | 160   | 0                | TYPE_LIMIT | TIF_GTC | lp1-s     |
   104      Then the network moves ahead "1" blocks
   105      And the following trades should be executed:
   106        | buyer  | price | size | seller  |
   107        | party1 | 100   | 1    | party2  |
   108        | partyX | 100   | 1    | network |
   109      And the market data for the market "ETH/MAR22" should be:
   110        | mark price | trading mode            | target stake | supplied stake | open interest | ref price | mid price | static mid price |
   111        | 100        | TRADING_MODE_CONTINUOUS | 79           | 1000           | 2             | 100       | 100       | 100              |
   112      When the parties submit the following AMM:
   113        | party | market id | amount  | slippage | base | lower bound | upper bound | lower leverage | upper leverage | proposed fee |
   114        | vamm1 | ETH/MAR22 | 100000  | 0.1      | 100  | 85          | 150         | 4              | 4              | 0.01         |
   115      Then the AMM pool status should be:
   116        | party | market id | amount  | status        | base | lower bound | upper bound | lower leverage | upper leverage |
   117        | vamm1 | ETH/MAR22 | 100000  | STATUS_ACTIVE | 100  | 85          | 150         | 4              | 4              |
   118  
   119      And set the following AMM sub account aliases:
   120        | party | market id | alias    |
   121        | vamm1 | ETH/MAR22 | vamm1-id |
   122      And the following transfers should happen:
   123        | from  | from account         | to       | to account           | market id | amount  | asset | is amm | type                             |
   124        | vamm1 | ACCOUNT_TYPE_GENERAL | vamm1-id | ACCOUNT_TYPE_GENERAL |           | 100000  | USD   | true   | TRANSFER_TYPE_AMM_LOW |
   125  
   126    @VAMM
   127    Scenario: the distressed party uncrosses with the vAMM orders
   128      # move to ahead to the disposal time step
   129      When the network moves ahead "5" blocks
   130      Then the following trades should be executed:
   131        | buyer   | price | size | seller   | is amm |
   132        | network | 100   | 1    | vamm1-id | true   |