code.vegaprotocol.io/vega@v0.79.0/core/integration/features/settlement/0053-PERP-funding-rate-modifiers2.feature (about)

     1  Feature: Test internal and external twap calculation
     2  
     3      Background:
     4          # epoch time is 1602806400
     5          Given time is updated to "2020-10-16T00:00:00Z"
     6  
     7          And the perpetual oracles from "0xCAFECAFE1":
     8              | name        | asset | settlement property | settlement type | schedule property | schedule type   | funding rate lower bound | funding rate upper bound | quote name | settlement decimals |
     9              | perp-oracle | USD   | perp.ETH.value      | TYPE_INTEGER    | perp.funding.cue  | TYPE_TIMESTAMP | -0.015                   | 0.005                    | ETH        | 18                  |
    10  
    11          And the liquidity sla params named "SLA":
    12              | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor |
    13              | 100.0       | 0.5                          | 1                             | 1.0                    |
    14          And the price monitoring named "my-price-monitoring":
    15              | horizon | probability | auction extension |
    16              | 43200   | 0.9999999   | 120               |
    17          And the log normal risk model named "my-log-normal-risk-model":
    18              | risk aversion | tau                    | mu | r     | sigma |
    19              | 0.000001      | 0.00011407711613050422 | 0  | 0.016 | 0.8   |
    20          And the markets:
    21              | id        | quote name | asset | risk model               | margin calculator         | auction duration | fees         | price monitoring    | data source config | linear slippage factor | quadratic slippage factor | position decimal places | market type | sla params |
    22              | ETH/DEC19 | ETH        | USD   | my-log-normal-risk-model | default-margin-calculator | 120              | default-none | my-price-monitoring | perp-oracle        | 0.25                   | 0                         | -3                      | perp        | SLA        |
    23          And the following network parameters are set:
    24              | name                                    | value |
    25              | network.markPriceUpdateMaximumFrequency | 0s    |
    26          And the average block duration is "1"
    27          When the parties deposit on asset's general account the following amount:
    28              | party  | asset | amount       |
    29              | party1 | USD   | 100000000000 |
    30              | party2 | USD   | 100000000000 |
    31              | party3 | USD   | 100000000000 |
    32              | aux    | USD   | 100000000000 |
    33              | aux2   | USD   | 100000000000 |
    34              | lpprov | USD   | 100000000000 |
    35          Then the parties submit the following liquidity provision:
    36              | id  | party  | market id | commitment amount | fee   | lp type    |
    37              | lp1 | lpprov | ETH/DEC19 | 100000            | 0.001 | submission |
    38          # move market to continuous
    39          And the parties place the following orders:
    40              | party  | market id | side | volume | price   | resulting trades | type       | tif     |
    41              | aux2   | ETH/DEC19 | buy  | 1      | 1       | 0                | TYPE_LIMIT | TIF_GTC |
    42              | lpprov | ETH/DEC19 | buy  | 100000 | 1       | 0                | TYPE_LIMIT | TIF_GTC |
    43              | aux2   | ETH/DEC19 | buy  | 1      | 1000    | 0                | TYPE_LIMIT | TIF_GTC |
    44              | aux    | ETH/DEC19 | sell | 1      | 1000    | 0                | TYPE_LIMIT | TIF_GTC |
    45              | aux    | ETH/DEC19 | sell | 1      | 3500    | 0                | TYPE_LIMIT | TIF_GTC |
    46              | lpprov | ETH/DEC19 | sell | 100000 | 3500    | 0                | TYPE_LIMIT | TIF_GTC |
    47          And the market data for the market "ETH/DEC19" should be:
    48              | target stake  | supplied stake |
    49              | 431500        | 100000         |
    50          And the opening auction period ends for market "ETH/DEC19"
    51  
    52      @Perpetual @funding-rate
    53      Scenario: 0053-PERP-031 Funding rate calculated correctly when the internel TWAP is greater than the external TWAP
    54          Given the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19"
    55          And time is updated to "2020-10-16T00:05:00Z"
    56          When the parties place the following orders:
    57              | party  | market id | side | volume | price | resulting trades | type       | tif     |
    58              | party1 | ETH/DEC19 | buy  | 1      | 1010  | 0                | TYPE_LIMIT | TIF_GTC |
    59              | party2 | ETH/DEC19 | sell | 1      | 1010  | 1                | TYPE_LIMIT | TIF_GTC |
    60          Then time is updated to "2020-10-16T00:10:00Z"
    61  
    62          # 1602806400 + 120s = 1602807000
    63          # funding period is ended with perp.funding.cue
    64          And the oracles broadcast data with block time signed with "0xCAFECAFE1":
    65              | name             | value                  | time offset |
    66              | perp.ETH.value   | 1000000000000000000000 | -1s         |
    67              | perp.funding.cue | 1602807000             | 0s          |
    68          And the mark price should be "1010" for the market "ETH/DEC19"
    69  
    70          Then the product data for the market "ETH/DEC19" should be:
    71              | internal twap | external twap  | funding payment | funding rate |
    72              | 1010          | 1000           | 5               | 0.005        |
    73  
    74         
    75  
    76