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

     1  Feature: Test vAMM submission works as expected (invalid submission)
     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                     | 1000  |
    26        | market.liquidity.bondPenaltyParameter               | 0.2   |
    27        | market.liquidity.stakeToCcyVolume                   | 1     |
    28        | market.liquidity.successorLaunchWindowLength        | 1h    |
    29        | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0.1   |
    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 | 0              |
    39      And the fees configuration named "fees-config-1":
    40        | maker fee | infrastructure fee |
    41        | 0.0004    | 0.001              |
    42      And the price monitoring named "price-monitoring":
    43        | horizon | probability | auction extension |
    44        | 3600    | 0.95        | 3                 |
    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 markets:
    51        | 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 |
    52        | ETH/MAR22 | USD        | USD   | lqm-params           | log-normal-risk-model | margin-calculator-1 | 2                | fees-config-1 | price-monitoring | default-eth-for-future | 1e0                    | 0                         | SLA-22     |
    53  
    54     @VAMM
    55     Scenario: 0090-VAMM-005:  When market.amm.minCommitmentQuantum is 1000, mid price of the market 100, a user with 1000 USDT is able to create a vAMM with commitment 100, and any other combination of settings.
    56       Given the parties deposit on asset's general account the following amount:
    57         | party  | asset | amount |
    58         | lp1    | USD   | 100000 |
    59         | lp2    | USD   | 100000 |
    60         | lp3    | USD   | 100000 |
    61         | party1 | USD   | 100000 |
    62         | party2 | USD   | 100000 |
    63         | party3 | USD   | 100000 |
    64         | vamm1  | USD   | 100000 |
    65         | vamm2  | USD   | 100000 |
    66         | vamm3  | USD   | 100000 |
    67         | vamm4  | USD   | 100000 |
    68         | vamm5  | USD   | 100000 |
    69         | vamm6  | USD   | 100000 |
    70         | vamm7  | USD   | 100000 |
    71  
    72       When the parties submit the following liquidity provision:
    73         | id   | party | market id | commitment amount | fee   | lp type    |
    74         | lp_1 | lp1   | ETH/MAR22 | 600               | 0.02  | submission |
    75         | lp_2 | lp2   | ETH/MAR22 | 400               | 0.015 | submission |
    76       Then the network moves ahead "4" blocks
    77       And the current epoch is "0"
    78  
    79       And the parties place the following orders:
    80         | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    81         | party3 | ETH/MAR22 | buy  | 10     | 85    | 0                | TYPE_LIMIT | TIF_GTC |           |
    82         | party1 | ETH/MAR22 | buy  | 10     | 90    | 0                | TYPE_LIMIT | TIF_GTC |           |
    83         | party1 | ETH/MAR22 | buy  | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC |           |
    84         | party2 | ETH/MAR22 | sell | 10     | 110   | 0                | TYPE_LIMIT | TIF_GTC |           |
    85         | party2 | ETH/MAR22 | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC |           |
    86         | party3 | ETH/MAR22 | sell | 1      | 120   | 0                | TYPE_LIMIT | TIF_GTC |           |
    87         | lp1    | ETH/MAR22 | buy  | 10     | 95    | 0                | TYPE_LIMIT | TIF_GTC | lp1-b     |
    88         | lp1    | ETH/MAR22 | sell | 10     | 105   | 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 | 100   | 1    | party2 |
    93  
    94       And the market data for the market "ETH/MAR22" should be:
    95         | mark price | trading mode            | horizon | min bound | max bound | target stake | supplied stake | open interest | ref price | mid price | static mid price |
    96         | 100        | TRADING_MODE_CONTINUOUS | 3600    | 94        | 106       | 39           | 1000           | 1             | 100       | 100       | 100              |
    97  
    98       When the parties submit the following AMM:
    99         | party | market id | amount | slippage | base | lower bound | upper bound | lower leverage | upper leverage | proposed fee |
   100         | vamm1 | ETH/MAR22 | 100000 | 0.1      | 100  | 85          | 150         | 0.25           | 0.25           | 0.01         |
   101       Then the AMM pool status should be:
   102         | party | market id | amount | status        | base | lower bound | lower leverage | upper bound | upper leverage |
   103         | vamm1 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 100  | 85          | 0.25           | 150         | 0.25           |
   104  
   105      When the parties submit the following AMM:
   106        | party | market id | amount | slippage | base | lower bound | lower leverage | error                        | proposed fee |
   107        | vamm2 | ETH/MAR22 | 100000 | 0.1      | 90   | 85          | 0.25           | rebase target outside bounds | 0.01         |
   108      # can't rebase because the target is 100 and thats outside of its bounds given there is no upper
   109      Then the AMM pool status should be:
   110        | party | market id | amount | status        | base | lower bound | lower leverage |
   111        | vamm2 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 90   | 85          | 0.25           |
   112  
   113      When the parties submit the following AMM:
   114        | party | market id | amount | slippage | base | upper bound | upper leverage | error                        | proposed fee |
   115        | vamm3 | ETH/MAR22 | 100000 | 0.1      | 110  | 150         | 0.25           | rebase target outside bounds | 0.01         |
   116      Then the AMM pool status should be:
   117        | party | market id | amount | status        | base | upper bound | upper leverage |
   118        | vamm3 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 110  | 150         | 0.25           |
   119  
   120       When the parties submit the following AMM:
   121         | party | market id | amount | slippage | base | lower bound | lower leverage | proposed fee |
   122         | vamm4 | ETH/MAR22 | 100000 | 0.1      | 100  | 99          | 0.1            | 0.01         |
   123       Then the AMM pool status should be:
   124         | party | market id | amount | status         | base | lower bound | lower leverage |
   125         | vamm4 | ETH/MAR22 | 100000  | STATUS_ACTIVE | 100  | 99          | 0.1            |
   126  
   127       When the parties submit the following AMM:
   128         | party | market id | amount | slippage | base | upper bound | upper leverage | proposed fee |
   129         | vamm5 | ETH/MAR22 | 100000  | 0.1      | 99   | 101        | 0.02           |  0.01        |
   130       Then the AMM pool status should be:
   131         | party | market id | amount | status          | base | upper bound | upper leverage |
   132         | vamm5 | ETH/MAR22 | 100000  | STATUS_ACTIVE   | 99  | 101         | 0.02           |
   133  
   134       When the parties submit the following AMM:
   135         | party | market id | amount | slippage | base | lower bound | upper bound | lower leverage | upper leverage | proposed fee | error |
   136         | vamm6 | ETH/MAR22 | 100000 | 0.001    | 101  | 95          | 105         | 0.01           | 0.01           | 0.01         | blah  |
   137       Then the AMM pool status should be:
   138         | party | market id | amount | status        | base | lower bound | lower leverage | upper bound | upper leverage |
   139         | vamm6 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 101  | 95          | 0.01           | 105         | 0.01           |
   140  
   141       When the parties submit the following AMM:
   142         | party | market id | amount | slippage | base | lower bound | lower leverage | proposed fee |
   143         | vamm7 | ETH/MAR22 | 100000 | 0.01     | 101  | 99          | 0.1            | 0.01         |
   144       Then the AMM pool status should be:
   145         | party | market id | amount | status          | base | lower bound | lower leverage | 
   146         | vamm7 | ETH/MAR22 | 100000  | STATUS_ACTIVE  | 101  | 99          | 0.1            | 
   147  
   148       And set the following AMM sub account aliases:
   149         | party | market id | alias     |
   150         | vamm1 | ETH/MAR22 | vamm1-acc |
   151         | vamm2 | ETH/MAR22 | vamm2-acc |
   152         | vamm3 | ETH/MAR22 | vamm3-acc |
   153         | vamm4 | ETH/MAR22 | vamm4-acc |
   154         | vamm5 | ETH/MAR22 | vamm5-acc |
   155         | vamm6 | ETH/MAR22 | vamm6-acc |
   156       And the following transfers should happen:
   157         | from  | from account         | to        | to account           | market id | amount   | asset | is amm | type                  |
   158         | vamm1 | ACCOUNT_TYPE_GENERAL | vamm1-acc | ACCOUNT_TYPE_GENERAL |           | 100000   | USD   | true   | TRANSFER_TYPE_AMM_LOW |
   159         | vamm2 | ACCOUNT_TYPE_GENERAL | vamm2-acc | ACCOUNT_TYPE_GENERAL |           | 100000   | USD   | true   | TRANSFER_TYPE_AMM_LOW |
   160         | vamm3 | ACCOUNT_TYPE_GENERAL | vamm3-acc | ACCOUNT_TYPE_GENERAL |           | 100000   | USD   | true   | TRANSFER_TYPE_AMM_LOW |
   161         | vamm4 | ACCOUNT_TYPE_GENERAL | vamm4-acc | ACCOUNT_TYPE_GENERAL |           | 100000   | USD   | true   | TRANSFER_TYPE_AMM_LOW |
   162         | vamm5 | ACCOUNT_TYPE_GENERAL | vamm5-acc | ACCOUNT_TYPE_GENERAL |           | 100000   | USD   | true   | TRANSFER_TYPE_AMM_LOW |
   163         | vamm6 | ACCOUNT_TYPE_GENERAL | vamm6-acc | ACCOUNT_TYPE_GENERAL |           | 100000   | USD   | true   | TRANSFER_TYPE_AMM_LOW |
   164