code.vegaprotocol.io/vega@v0.79.0/core/integration/features/amm/0090-VAMM-rebase.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 | 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      And 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        | vamm2  | USD   | 1000000 |
    64  
    65      When the parties submit the following liquidity provision:
    66        | id   | party | market id | commitment amount | fee  | lp type    |
    67        | lp_1 | lp1   | ETH/MAR22 | 10000             | 0.02 | submission |
    68  
    69      And the parties place the following orders:
    70        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    71        | lp1    | ETH/MAR22 | buy  | 20     | 40    | 0                | TYPE_LIMIT | TIF_GTC | lp1-b     |
    72        | party1 | ETH/MAR22 | buy  | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC |           |
    73        | party2 | ETH/MAR22 | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC |           |
    74        | lp1    | ETH/MAR22 | sell | 10     | 160   | 0                | TYPE_LIMIT | TIF_GTC | lp1-s     |
    75  
    76      When the opening auction period ends for market "ETH/MAR22"
    77      Then the following trades should be executed:
    78        | buyer  | price | size | seller |
    79        | party1 | 100   | 1    | party2 |
    80        
    81      Then the network moves ahead "1" epochs
    82      And the current epoch is "1"
    83  
    84      Then the parties submit the following AMM:
    85        | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee |
    86        | vamm1 | ETH/MAR22 | 100000 | 0.05     | 100  | 90          | 110         | 0.03         |
    87      Then the AMM pool status should be:
    88        | party | market id | amount | status        | base | lower bound | upper bound |
    89        | vamm1 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 100  | 90          | 110         |
    90  
    91    @VAMM
    92    Scenario: a vAMM submits a rebasing order to SELL when its base is lower than an existing AMM's (0090-VAMM-033)
    93  
    94      When the parties submit the following AMM:
    95        | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee |
    96        | vamm2 | ETH/MAR22 | 100000 | 0.05     | 95   | 90          | 105         | 0.03         |
    97      Then the AMM pool status should be:
    98        | party | market id | amount | status        | base | lower bound | upper bound |
    99        | vamm2 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 95   | 90          | 105         |
   100      
   101      And set the following AMM sub account aliases:
   102        | party | market id | alias    |
   103        | vamm1 | ETH/MAR22 | vamm1-id |
   104        | vamm2 | ETH/MAR22 | vamm2-id |
   105  
   106      # second AMM has its base 5 away from the first AMM so it must submit a rebasing-order 
   107      And the following trades should be executed:
   108        | buyer    | price | size | seller   | is amm |
   109        | vamm1-id | 98    | 140  | vamm2-id | true   |
   110      Then the network moves ahead "1" blocks
   111  
   112      # and now the mid-price has shifted lower to a value between the two AMM's bases 95 < 97 < 100
   113      And the market data for the market "ETH/MAR22" should be:
   114        | mark price | trading mode            | mid price |
   115        | 98         | TRADING_MODE_CONTINUOUS | 97        |
   116  
   117  
   118    @VAMM
   119    Scenario: a vAMM submission cannot rebase because it exceeds slippage but exceeds slippage
   120  
   121      # sell rebase order
   122      When the parties submit the following AMM:
   123        | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | error                                  |
   124        | vamm2 | ETH/MAR22 | 100000 | 0.0005   | 95   | 90          | 105         | 0.03         | not enough liquidity for AMM to rebase |
   125      Then the AMM pool status should be:
   126        | party | market id | amount | status          | base | lower bound | upper bound | reason                      |
   127        | vamm2 | ETH/MAR22 | 100000 | STATUS_REJECTED | 95   | 90          | 105         | STATUS_REASON_CANNOT_REBASE |
   128      
   129      # buy rebase order
   130      When the parties submit the following AMM:
   131        | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | error                                  |
   132        | vamm2 | ETH/MAR22 | 100000 | 0.0005   | 105  | 100         | 110         | 0.03         | not enough liquidity for AMM to rebase |
   133      Then the AMM pool status should be:
   134        | party | market id | amount | status          | base | lower bound | upper bound | reason                      |
   135        | vamm2 | ETH/MAR22 | 100000 | STATUS_REJECTED | 105  | 100         | 110         | STATUS_REASON_CANNOT_REBASE |
   136  
   137    @VAMM
   138    Scenario: a vAMM submits a rebasing order to BUY when its base is lower than an existing AMM's (0090-VAMM-033)
   139  
   140      When the parties submit the following AMM:
   141        | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee |
   142        | vamm2 | ETH/MAR22 | 100000 | 0.05     | 105  | 100         | 110         | 0.03         |
   143      Then the AMM pool status should be:
   144        | party | market id | amount | status        | base | lower bound | upper bound |
   145        | vamm2 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 105  | 100         | 110         |
   146      
   147      And set the following AMM sub account aliases:
   148        | party | market id | alias    |
   149        | vamm1 | ETH/MAR22 | vamm1-id |
   150        | vamm2 | ETH/MAR22 | vamm2-id |
   151  
   152      # second AMM has its base 5 away from the first AMM so it must submit a rebasing-order 
   153      And the following trades should be executed:
   154        | buyer    | price | size | seller   | is amm |
   155        | vamm2-id | 101   | 176  | vamm1-id | true   |
   156      Then the network moves ahead "1" blocks
   157  
   158      # and now the mid-price has shifted lower to a value between the two AMM's bases 100 < 104 < 105
   159      And the market data for the market "ETH/MAR22" should be:
   160        | mark price | trading mode            | mid price | 
   161        | 101        | TRADING_MODE_CONTINUOUS | 103       |
   162    
   163  
   164  
   165    @VAMM
   166    Scenario: two aligned AMM's and one amends shifting its base lower and needs to submit a SELL rebasing order
   167  
   168      When the parties submit the following AMM:
   169        | party | market id | amount | slippage | base | lower bound | upper bound |  proposed fee |
   170        | vamm2 | ETH/MAR22 | 100000 | 0.05     | 100  | 95          | 105         |  0.03         |
   171      Then the AMM pool status should be:
   172        | party | market id | amount | status        | base | lower bound | upper bound |
   173        | vamm2 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 100  | 95          | 105         |
   174      
   175      And set the following AMM sub account aliases:
   176        | party | market id | alias    |
   177        | vamm1 | ETH/MAR22 | vamm1-id |
   178        | vamm2 | ETH/MAR22 | vamm2-id |
   179  
   180      Then the network moves ahead "1" blocks
   181      And the market data for the market "ETH/MAR22" should be:
   182        | mark price | trading mode            | mid price | 
   183        | 100        | TRADING_MODE_CONTINUOUS | 100       |
   184  
   185      When the parties amend the following AMM:
   186        | party | market id | slippage | base | lower bound | upper bound | 
   187        | vamm2 | ETH/MAR22 | 0.1      | 95   | 90          | 105         | 
   188      Then the AMM pool status should be:
   189        | party | market id | amount | status        | base | lower bound | upper bound |
   190        | vamm2 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 95   | 90          | 105         |
   191  
   192  
   193      # second AMM has its base 5 away from the first AMM so it must submit a rebasing-order 
   194      And the following trades should be executed:
   195        | buyer    | price | size | seller   | is amm |
   196        | vamm1-id | 98    | 140  | vamm2-id | true   |
   197      Then the network moves ahead "1" blocks
   198  
   199      # and now the mid-price has shifted lower to a value between the two AMM's bases 95 < 98 < 100
   200      And the market data for the market "ETH/MAR22" should be:
   201        | mark price | trading mode            | mid price |
   202        | 98         | TRADING_MODE_CONTINUOUS | 97        |
   203  
   204  
   205    @VAMM
   206    Scenario: two aligned AMM's and one amends shifting its base lower and needs to submit a BUY rebasing order
   207  
   208      When the parties submit the following AMM:
   209        | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee |
   210        | vamm2 | ETH/MAR22 | 100000 | 0.05     | 100  | 95          | 105         | 0.03         |
   211      Then the AMM pool status should be:
   212        | party | market id | amount | status        | base | lower bound | upper bound |
   213        | vamm2 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 100  | 95          | 105         |
   214      
   215      And set the following AMM sub account aliases:
   216        | party | market id | alias    |
   217        | vamm1 | ETH/MAR22 | vamm1-id |
   218        | vamm2 | ETH/MAR22 | vamm2-id |
   219  
   220      Then the network moves ahead "1" blocks
   221      And the market data for the market "ETH/MAR22" should be:
   222        | mark price | trading mode            | mid price | 
   223        | 100        | TRADING_MODE_CONTINUOUS | 100       |
   224  
   225      When the parties amend the following AMM:
   226        | party | market id | slippage | base | lower bound | upper bound |
   227        | vamm2 | ETH/MAR22 | 0.1      | 105  | 100         | 110         |
   228      Then the AMM pool status should be:
   229        | party | market id | amount | status        | base | lower bound | upper bound |
   230        | vamm2 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 105  | 100         | 110         |
   231  
   232  
   233      # second AMM has its base 5 away from the first AMM so it must submit a rebasing-order 
   234      And the following trades should be executed:
   235        | buyer    | price | size | seller   | is amm |
   236        | vamm2-id | 101   | 176  | vamm1-id | true   |
   237      Then the network moves ahead "1" blocks
   238  
   239      # and now the mid-price has shifted lower to a value between the two AMM's bases 100 < 104 < 105
   240      And the market data for the market "ETH/MAR22" should be:
   241        | mark price | trading mode            | mid price | 
   242        | 101        | TRADING_MODE_CONTINUOUS | 103       |
   243  
   244  
   245    @VAMM
   246    Scenario: One AMM exists and another on is submitted such that their ranges are disjoint and cross entirely (0090-VAMM-034)
   247  
   248      When the parties submit the following AMM:
   249        | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee |
   250        | vamm2 | ETH/MAR22 | 100000 | 0.50     | 200  | 195         | 205         | 0.03         |
   251      Then the AMM pool status should be:
   252        | party | market id | amount | status        | base | lower bound | upper bound |
   253        | vamm2 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 200  | 195         | 205         |
   254      
   255      And set the following AMM sub account aliases:
   256        | party | market id | alias    |
   257        | vamm1 | ETH/MAR22 | vamm1-id |
   258        | vamm2 | ETH/MAR22 | vamm2-id |
   259  
   260      Then the network moves ahead "1" blocks
   261  
   262      # second AMM has its base 5 away from the first AMM so it must submit a rebasing-order 
   263      And the following trades should be executed:
   264        | buyer    | price | size | seller   | is amm |
   265        | vamm2-id | 102   | 262  | vamm1-id | true   |
   266  
   267      Then the network moves ahead "1" blocks
   268  
   269      # and now the mid-price has shifted lower to a value between the two AMM's bases 100 < 104 < 105
   270      And the market data for the market "ETH/MAR22" should be:
   271        | mark price | trading mode            | mid price |
   272        | 102        | TRADING_MODE_CONTINUOUS | 107       |