code.vegaprotocol.io/vega@v0.79.0/core/integration/features/amm/0090-VAMM-market-dp.feature (about)

     1  Feature: vAMM rebasing when created or amended
     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        
    15      And the following network parameters are set:
    16        | name                                                | value |
    17        | market.value.windowLength                           | 60s   |
    18        | network.markPriceUpdateMaximumFrequency             | 0s    |
    19        | limits.markets.maxPeggedOrders                      | 6     |
    20        | market.auction.minimumDuration                      | 1     |
    21        | market.fee.factors.infrastructureFee                | 0.001 |
    22        | market.fee.factors.makerFee                         | 0.004 |
    23        | spam.protection.max.stopOrdersPerMarket             | 5     |
    24        | market.liquidity.equityLikeShareFeeFraction         | 1     |
    25  	    | market.amm.minCommitmentQuantum                     | 1     |
    26        | market.liquidity.bondPenaltyParameter               | 0.2   |
    27        | market.liquidity.stakeToCcyVolume                   | 1     |
    28        | market.liquidity.successorLaunchWindowLength        | 1h    |
    29        | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0   |
    30        | market.liquidity.sla.nonPerformanceBondPenaltyMax   | 0.6   |
    31        | validators.epoch.length                             | 10s   |
    32        | market.liquidity.earlyExitPenalty                   | 0.25  |
    33        | market.liquidity.maximumLiquidityFeeFactorLevel     | 0.25  |
    34      #risk factor short:3.5569036
    35      #risk factor long:0.801225765
    36      And the following assets are registered:
    37        | id  | decimal places |
    38        | USD | 2              |
    39      And the fees configuration named "fees-config-1":
    40        | maker fee | infrastructure fee |
    41        | 0.0004    | 0.001              |
    42  
    43      And the liquidity sla params named "SLA-22":
    44        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
    45        | 0.5         | 0.6                          | 1                             | 1.0                    |
    46  
    47      And the oracle spec for settlement data filtering data from "0xCAFECAFE19" named "termination-oracle":
    48        | property         | type         | binding         | decimals |
    49        | prices.ETH.value | TYPE_INTEGER | settlement data | 0        |
    50  
    51      And the oracle spec for trading termination filtering data from "0xCAFECAFE19" named "termination-oracle":
    52        | property           | type         | binding             |
    53        | trading.terminated | TYPE_BOOLEAN | trading termination |
    54  
    55      And the markets:
    56        | 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 | decimal places | position decimal places |
    57        | ETH/MAR22 | USD        | USD   | lqm-params           | log-normal-risk-model | margin-calculator-1 | 2                | fees-config-1 | default-none     | termination-oracle     | 1e0                    | 0                         | SLA-22     | 3              | -1                      |       
    58  
    59      # 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
    60      Given the parties deposit on asset's general account the following amount:
    61        | party  | asset | amount   |
    62        | lp1    | USD   | 10000000 |
    63        | lp2    | USD   | 10000000 |
    64        | lp3    | USD   | 10000000 |
    65        | party1 | USD   | 10000000 |
    66        | party2 | USD   | 10000000 |
    67        | party3 | USD   | 10000000 |
    68        | party4 | USD   | 10000000 |
    69        | party5 | USD   | 10000000 |
    70        | vamm1  | USD   | 1000000000 |
    71        | vamm2  | USD   | 1000000000 |
    72  
    73  
    74      And the parties place the following orders:
    75        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    76        | lp1    | ETH/MAR22 | buy  | 20     | 400    | 0                | TYPE_LIMIT | TIF_GTC | lp1-b     |
    77        | party5 | ETH/MAR22 | buy  | 20     | 900    | 0                | TYPE_LIMIT | TIF_GTC | lp1-b     |
    78        | party1 | ETH/MAR22 | buy  | 1      | 1000   | 0                | TYPE_LIMIT | TIF_GTC |           |
    79        | party2 | ETH/MAR22 | sell | 1      | 1000   | 0                | TYPE_LIMIT | TIF_GTC |           |
    80        | party3 | ETH/MAR22 | sell | 10     | 1100   | 0                | TYPE_LIMIT | TIF_GTC |           |
    81        | lp1    | ETH/MAR22 | sell | 10     | 1600   | 0                | TYPE_LIMIT | TIF_GTC | lp1-s     |
    82      When the opening auction period ends for market "ETH/MAR22"
    83      Then the following trades should be executed:
    84        | buyer  | price  | size | seller |
    85        | party1 | 1000   | 1    | party2 |
    86  
    87  
    88      Then the parties submit the following AMM:
    89        | party | market id | amount | slippage | base  | lower bound  | upper bound  | proposed fee |
    90        | vamm1 | ETH/MAR22 | 100000  | 0.05    | 1000  | 900          | 1100         | 0.03         |
    91      Then the AMM pool status should be:
    92        | party | market id | amount | status        | base | lower bound | upper bound | 
    93        | vamm1 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 1000 | 900         | 1100        | 
    94  
    95      And set the following AMM sub account aliases:
    96        | party | market id | alias    |
    97        | vamm1 | ETH/MAR22 | vamm1-id |
    98  
    99      And the market data for the market "ETH/MAR22" should be:
   100        | mark price | trading mode              | best bid price | best offer price | best bid volume | best offer volume |
   101        | 1000        | TRADING_MODE_CONTINUOUS  | 990            | 1010             | 5               | 4                 |
   102  
   103    @VAMM
   104    Scenario: Incoming order at AMM best price
   105  
   106    # AMM's has a BUY at 99 so a SELL at that price should match
   107    When the parties place the following orders:
   108        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   109        | party1 | ETH/MAR22 | sell | 1      | 990   | 1                | TYPE_LIMIT | TIF_GTC |           |
   110    Then the following trades should be executed:
   111        | buyer     | price | size | seller    | is amm |
   112        | vamm1-id  | 990   | 1    | party1    | true   |
   113  
   114    @VAMM
   115    Scenario: Incoming order at AMM best price and orderbook volume exists at that price
   116  
   117    # AMM's has a BUY at 99 so a SELL at that price should match
   118    When the parties place the following orders:
   119        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   120        | party2 | ETH/MAR22 | buy  | 150    | 990    | 0               | TYPE_LIMIT | TIF_GTC |           |
   121        | party1 | ETH/MAR22 | sell | 150    | 990    | 2               | TYPE_LIMIT | TIF_GTC |           |
   122  
   123    # incoming move AMM to a fair-price of 990, then we take the orderbook volume at 990
   124    Then the following trades should be executed:
   125        | buyer     | price | size | seller    | is amm |
   126        | vamm1-id  | 990   | 5    | party1    | true   |
   127        | party2    | 990   | 145  | party1    | true   |
   128  
   129  
   130    @VAMM
   131    Scenario: Incoming order at AMM best price and orderbook volume exists at FAIR PRICE
   132  
   133    # AMM's has a BUY at 99 so a SELL at that price should match
   134    When the parties place the following orders:
   135        | party  | market id | side | volume | price  | resulting trades | type       | tif     | reference |
   136        | party2 | ETH/MAR22 | buy  | 146    | 1000   | 0                | TYPE_LIMIT | TIF_GTC |           |
   137        | party1 | ETH/MAR22 | sell | 150    | 990    | 2                | TYPE_LIMIT | TIF_GTC |           |
   138  
   139    # incoming absorbs order at fair price, then we take volume from AMM
   140    Then the following trades should be executed:
   141        | buyer     | price  | size | seller    | is amm |
   142        | party2    | 1000   | 146  | party1    | true   |
   143        | vamm1-id  | 990    | 4    | party1    | true   |
   144  
   145  
   146    @VAMM
   147    Scenario: Incoming order at AMM fair price and orderbook volume exists at FAIR PRICE
   148  
   149    # AMM's has a BUY at 99 so a SELL at 100 should not match
   150    When the parties place the following orders:
   151        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
   152        | party2 | ETH/MAR22 | buy  | 100    | 1000   | 0                | TYPE_LIMIT | TIF_GTC |           |
   153        | party1 | ETH/MAR22 | sell | 150    | 1000   | 1                | TYPE_LIMIT | TIF_GTC |           |
   154  
   155    # incoming absorbs order at fair price, then we take volume from AMM
   156    Then the following trades should be executed:
   157        | buyer     | price  | size | seller    | is amm |
   158        | party2    | 1000   | 100  | party1    | true   |
   159  
   160    @VAMM
   161    Scenario: Incoming order at AMM fair price and orderbook volume exists at FAIR PRICE and at AMM best price
   162    When the parties place the following orders:
   163        | party  | market id | side | volume | price  | resulting trades | type       | tif     | reference |
   164        | party2 | ETH/MAR22 | buy  | 50     | 1000   | 0                | TYPE_LIMIT | TIF_GTC |           |
   165        | party2 | ETH/MAR22 | buy  | 50     | 990    | 0                | TYPE_LIMIT | TIF_GTC |           |
   166        | party1 | ETH/MAR22 | sell | 60     | 990    | 3                | TYPE_LIMIT | TIF_GTC |           |
   167  
   168    # incoming absorbs order at fair price, then we take volume from AMM
   169    Then the following trades should be executed:
   170        | buyer     | price | size | seller    | is amm |
   171        | party2    | 1000  | 50   | party1    | true   |
   172        | vamm1-id  | 990   | 5    | party1    | true   |
   173        | party2    | 990   | 5    | party1    | true   |
   174  
   175    When the network moves ahead "1" blocks