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

     1  Feature: vAMM has the same ELS as liquidity provision with the same commitment amount
     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        | 0.5           | 0.6            | 1.0            |
     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 | 0              |
    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 markets:
    48        | 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 |
    49        | ETH/MAR22 | USD        | USD   | lqm-params           | log-normal-risk-model | margin-calculator-1 | 2                | fees-config-1 | default-none     | default-eth-for-future | 1e0                    | 0                         | SLA-22     |
    50  
    51      # 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
    52      Given the parties deposit on asset's general account the following amount:
    53        | party  | asset | amount  |
    54        | lp1    | USD   | 1000000 |
    55        | lp2    | USD   | 1000000 |
    56        | lp3    | USD   | 1000000 |
    57        | party1 | USD   | 1000000 |
    58        | party2 | USD   | 1000000 |
    59        | party3 | USD   | 1000000 |
    60        | party4 | USD   | 1000000 |
    61        | party5 | USD   | 1000000 |
    62        | vamm1  | USD   | 1000000 |
    63  
    64      When the parties submit the following liquidity provision:
    65        | id   | party | market id | commitment amount | fee   | lp type    |
    66        | lp_1 | lp1   | ETH/MAR22 | 10000             | 0.02  | submission |
    67  
    68      And the parties place the following orders:
    69        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    70        | lp1    | ETH/MAR22 | buy  | 20     | 40    | 0                | TYPE_LIMIT | TIF_GTC | lp1-b     |
    71        | party1 | ETH/MAR22 | buy  | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC |           |
    72        | party2 | ETH/MAR22 | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC |           |
    73        | lp1    | ETH/MAR22 | sell | 10     | 160   | 0                | TYPE_LIMIT | TIF_GTC | lp1-s     |
    74  
    75      When the opening auction period ends for market "ETH/MAR22"
    76      Then the following trades should be executed:
    77        | buyer  | price | size | seller |
    78        | party1 | 100   | 1    | party2 |
    79        
    80      Then the network moves ahead "1" epochs
    81      And the current epoch is "1"
    82  
    83    @VAMM
    84    Scenario: 0090-VAMM-016: A vAMM's virtual ELS should be equal to the ELS of a regular LP with the same committed volume on the book (i.e. if a vAMM has an average volume on each side of the book across the epoch of 10k USDT, their ELS should be equal to that of a regular LP who has a commitment which requires supplying 10k USDT who joined at the same time as them).
    85  
    86      And the market data for the market "ETH/MAR22" should be:
    87        | mark price | trading mode            | target stake | supplied stake | open interest | ref price | mid price | static mid price |
    88        | 100        | TRADING_MODE_CONTINUOUS | 39           | 10000          | 0             | 100       | 100       | 100              |
    89  
    90      When the parties submit the following liquidity provision:
    91        # Using 9788 instead of exactly 10,000 makes things easier because getting exactly 10,000 from an AMM pool as virtual stake can be tricky due to complex math.
    92        | id   | party | market id | commitment amount | fee   | lp type    |
    93        | lp_2 | lp2   | ETH/MAR22 | 9887              | 0.03  | submission |
    94  
    95      When the parties submit the following AMM:
    96        | party | market id | amount | slippage | base | lower bound | upper bound | lower leverage | upper leverage | proposed fee |
    97        | vamm1 | ETH/MAR22 | 10000  | 0.8      | 100  | 95          | 105         | 1.041          | 1.041          | 0.03         |
    98      Then the AMM pool status should be:
    99        | party | market id | amount | status        | base | lower bound | upper bound | lower leverage | upper leverage |
   100        | vamm1 | ETH/MAR22 | 10000  | STATUS_ACTIVE | 100  | 95          | 105         | 1.041          | 1.041          |
   101      
   102      And set the following AMM sub account aliases:
   103        | party | market id | alias    |
   104        | vamm1 | ETH/MAR22 | vamm1-id |
   105      And the following transfers should happen:
   106        | from  | from account         | to       | to account           | market id | amount | asset | is amm | type                  |
   107        | vamm1 | ACCOUNT_TYPE_GENERAL | vamm1-id | ACCOUNT_TYPE_GENERAL |           | 10000  | USD   | true   | TRANSFER_TYPE_AMM_LOW |
   108  
   109      Then the network moves ahead "1" epochs
   110      And the current epoch is "2"
   111      And the liquidity provider fee shares for the market "ETH/MAR22" should be:
   112        | party                                                            | equity like share  | virtual stake         | average entry valuation |
   113        | lp2                                                              | 0.3320682474642305 | 9887.0000000000000000 | 29774                   |
   114        | 137112507e25d3845a56c47db15d8ced0f28daa8498a0fd52648969c4b296aba | 0.3320682474642305 | 9887.0000000000000000 | 19887                   |  
   115    
   116    @VAMM
   117    Scenario: 0090-VAMM-017: A vAMM's virtual ELS should be equal to the ELS of a regular LP with the same committed volume on the book (i.e. if a vAMM has an average volume on each side of the book across the epoch of 10k USDT, their ELS should be equal to that of a regular LP who has a commitment which requires supplying 10k USDT who joined at the same time as them).
   118  
   119      And the market data for the market "ETH/MAR22" should be:
   120        | mark price | trading mode            | target stake | supplied stake | open interest | ref price | mid price | static mid price |
   121        | 100        | TRADING_MODE_CONTINUOUS | 39           | 10000          | 0             | 100       | 100       | 100              |
   122  
   123      When the parties submit the following liquidity provision:
   124        # Using 10,093 instead of exactly 10,000 makes things easier because getting exactly 10,000 from an AMM pool as virtual stake can be tricky due to complex math.
   125        | id   | party | market id | commitment amount | fee   | lp type    |
   126        | lp_2 | lp2   | ETH/MAR22 | 9887              | 0.03  | submission |
   127  
   128      And the parties place the following orders:
   129        | party | market id | side | volume | price | resulting trades | type       | tif   |
   130        | lp2   | ETH/MAR22 | buy  | 1000   | 100   | 0                | TYPE_LIMIT | TIF_GTC |
   131        | lp2   | ETH/MAR22 | sell | 1000   | 100   | 0                | TYPE_LIMIT | TIF_GTC |
   132  
   133      When the parties submit the following AMM:
   134        | party | market id | amount | slippage | base | lower bound | upper bound | lower leverage | upper leverage | proposed fee |
   135        | vamm1 | ETH/MAR22 | 10000  | 0.05     | 100  | 95          | 105         | 1.041          | 1.041          | 0.03         |
   136      Then the AMM pool status should be:
   137        | party | market id | amount | status        | base | lower bound | upper bound | lower leverage | upper leverage |
   138        | vamm1 | ETH/MAR22 | 10000  | STATUS_ACTIVE | 100  | 95          | 105         | 1.041          | 1.041          |
   139      
   140      And set the following AMM sub account aliases:
   141        | party | market id | alias    |
   142        | vamm1 | ETH/MAR22 | vamm1-id |
   143      And the following transfers should happen:
   144        | from  | from account         | to       | to account           | market id | amount | asset | is amm | type                  |
   145        | vamm1 | ACCOUNT_TYPE_GENERAL | vamm1-id | ACCOUNT_TYPE_GENERAL |           | 10000  | USD   | true   | TRANSFER_TYPE_AMM_LOW |
   146  
   147      Then the network moves ahead "1" epochs
   148      And the current epoch is "2"
   149      And the liquidity provider fee shares for the market "ETH/MAR22" should be:
   150        | party                                                            | equity like share  | virtual stake         | average entry valuation |
   151        | lp2                                                              | 0.3320682474642305 | 9887.0000000000000000 | 29774                   |
   152        | 137112507e25d3845a56c47db15d8ced0f28daa8498a0fd52648969c4b296aba | 0.3320682474642305 | 9887.0000000000000000 | 19887                   |
   153  
   154    Then the network moves ahead "2" epochs
   155    And the current epoch is "4"
   156  
   157    And the liquidity provider fee shares for the market "ETH/MAR22" should be:
   158      | party                                                            | equity like share  | virtual stake         | average entry valuation |
   159      | lp2                                                              | 0.3320682474642305 | 9887.0000000000000000 | 29774                   |
   160      | 137112507e25d3845a56c47db15d8ced0f28daa8498a0fd52648969c4b296aba | 0.3320682474642305 | 9887.0000000000000000 | 19887                   |