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

     1  Feature: vAMM with oracle driven base price
     2  
     3    Background:
     4      Background:
     5      Given the following assets are registered:
     6        | id  | decimal places |
     7        | ETH | 5             |
     8        | USD | 0              |
     9      And the perpetual oracles from "0xCAFECAFE1":
    10        | name        | asset | settlement property | settlement type | schedule property | schedule type  | margin funding factor | interest rate | clamp lower bound | clamp upper bound | quote name | settlement decimals | source weights | source staleness tolerance | spec id |
    11        | perp-oracle | ETH   | perp.ETH.value      | TYPE_INTEGER    | perp.funding.cue  | TYPE_TIMESTAMP | 0                     | 0             | 0                 | 0                 | ETH        | 5                   | 1,0,0,0        | 100s,0s,0s,0s              | 1234    |
    12      
    13      And the composite price oracles from "0xCAFECAFE2":
    14        | name    | price property  | price type   | price decimals |
    15        | oracle1 | price.USD.value | TYPE_INTEGER | 5              |
    16      
    17      And the liquidity sla params named "SLA":
    18        | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
    19        | 1.0         | 0.5                          | 1                             | 1.0                    |
    20      And the liquidity monitoring parameters:
    21        | name               | triggering ratio | time window | scaling factor |
    22        | lqm-params         | 0.01             | 10s         | 5              |  
    23  
    24      And the markets:
    25        | id        | quote name | asset | liquidity monitoring | risk model            | margin calculator         | auction duration | fees         | price monitoring | data source config | linear slippage factor | quadratic slippage factor | decimal places | position decimal places | market type | sla params | tick size | price type | decay weight | decay power | cash amount | source weights | source staleness tolerance | oracle1 |
    26        | ETH/MAR22 | ETH        | ETH   | lqm-params           | default-st-risk-model | default-margin-calculator | 1                | default-none | default-none     | perp-oracle        | 0.1                    | 0                         | 0              | 5                       | perp        | SLA        |     1     | weight     | 1            | 1           | 0           | 0,0,1,0        | 1m0s,1m0s,1m0s,1m0s        | oracle1 |
    27      And the following network parameters are set:
    28        | name                                             | value |
    29        | network.markPriceUpdateMaximumFrequency          | 0s    |
    30        | market.auction.minimumDuration                   | 1     |
    31        | market.fee.factors.infrastructureFee             | 0.001 |
    32        | market.fee.factors.makerFee                      | 0.004 |
    33        | market.value.windowLength                        | 60s   |
    34        | market.liquidity.bondPenaltyParameter            | 0.1   |
    35        | validators.epoch.length                          | 5s    |
    36        | limits.markets.maxPeggedOrders                   | 2     |
    37        | market.liquidity.providersFeeCalculationTimeStep | 5s    |
    38        | market.liquidity.stakeToCcyVolume                | 1     |
    39  
    40      And the average block duration is "1"
    41      # 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
    42      Given the parties deposit on asset's general account the following amount:
    43        | party  | asset | amount  |
    44        | lp1    | ETH   | 100000000000 |
    45        | lp2    | ETH   | 100000000000 |
    46        | lp3    | ETH   | 100000000000 |
    47        | party1 | ETH   | 100000000000 |
    48        | party2 | ETH   | 100000000000 |
    49        | party3 | ETH   | 100000000000 |
    50        | party4 | ETH   | 100000000000 |
    51        | party5 | ETH   | 100000000000 |
    52        | vamm1  | ETH   | 100000000000 |
    53        | vamm2  | ETH   | 100000000000 |
    54        | vamm3  | ETH   | 100000000000 |
    55  
    56  
    57      And the parties place the following orders:
    58        | party  | market id | side | volume | price | resulting trades | type       | tif     | reference |
    59        | party1 | ETH/MAR22 | buy  | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC |           |
    60        | party2 | ETH/MAR22 | sell | 1      | 100   | 0                | TYPE_LIMIT | TIF_GTC |           |
    61      When the opening auction period ends for market "ETH/MAR22"
    62      Then the following trades should be executed:
    63        | buyer  | price | size | seller |
    64        | party1 | 100   | 1    | party2 |
    65  
    66  
    67    @VAMM3
    68    Scenario: 0090-VAMM-038 It's possible to setup the vAMM so that it uses one of the oracles already available for the market in which it operates for its `base price`. In that case the deployment attempt should be deferred until the next value is received from the oracle.
    69  
    70     Then the parties submit the following AMM:
    71        | party | market id | amount  | slippage | base | lower bound | upper bound | proposed fee | data source id                                                   |
    72        | vamm1 | ETH/MAR22 | 100000  | 0.05     | 0    | 95          | 105         | 0.03         | 3dad1506c9130ae64a1f3ab8f9bea4339396c77cc85a0c952d9c704d963fff12 |
    73      Then the AMM pool status should be:
    74        | party | market id | amount | status         | base | lower bound | upper bound | 
    75        | vamm1 | ETH/MAR22 | 100000 | STATUS_PENDING | 0    | 95          | 105         | 
    76  
    77      And set the following AMM sub account aliases:
    78        | party | market id | alias    |
    79        | vamm1 | ETH/MAR22 | vamm1-id |
    80  
    81      And the market data for the market "ETH/MAR22" should be:
    82        | mark price | trading mode             | best bid price | best offer price | best bid volume | best offer volume |
    83        | 100        | TRADING_MODE_CONTINUOUS  | 0              | 0                | 0               | 0                 |
    84  
    85      # now oracle data comes in for the perp, but this isn't the one driving the AMM
    86      When the oracles broadcast data with block time signed with "0xCAFECAFE1":
    87        | name             | value      | time offset |
    88        | perp.ETH.value   | 10100000   | -2s         |
    89  
    90      Then the AMM pool status should be:
    91        | party | market id | amount | status         | base | lower bound | upper bound | 
    92        | vamm1 | ETH/MAR22 | 100000 | STATUS_PENDING | 0    | 95          | 105         | 
    93  
    94  
    95      # now oracle data comes in for the composite price source
    96      When the oracles broadcast data with block time signed with "0xCAFECAFE2":
    97        | name            | value   | time offset |
    98        | price.USD.value | 10000000 | -1s         |
    99  
   100  
   101      Then the AMM pool status should be:
   102        | party | market id | amount | status         | base | lower bound | upper bound | 
   103        | vamm1 | ETH/MAR22 | 100000 | STATUS_ACTIVE  | 100  | 95          | 105         | 
   104      
   105  
   106     
   107  
   108