code.vegaprotocol.io/vega@v0.79.0/core/integration/features/settlement/0053-PERP-funding-rate-modifiers.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 And the perpetual oracles from "0xCAFECAFE1": 7 | name | asset | settlement property | settlement type | schedule property | schedule type | funding rate scaling factor | quote name | settlement decimals | 8 | perp-oracle | USD | perp.ETH.value | TYPE_INTEGER | perp.funding.cue | TYPE_TIMESTAMP | 2.5 | ETH | 18 | 9 10 And the perpetual oracles from "0xCAFECAFE1": 11 | name | asset | settlement property | settlement type | schedule property | schedule type | funding rate lower bound | funding rate upper bound | quote name | settlement decimals | 12 | perp-oracle2 | USD | perp.ETH.value | TYPE_INTEGER | perp.funding.cue | TYPE_TIMESTAMP | -0.005 | 0.005 | ETH | 18 | 13 14 And the liquidity sla params named "SLA": 15 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 16 | 100.0 | 0.5 | 1 | 1.0 | 17 And the price monitoring named "my-price-monitoring": 18 | horizon | probability | auction extension | 19 | 43200 | 0.9999999 | 120 | 20 And the log normal risk model named "my-log-normal-risk-model": 21 | risk aversion | tau | mu | r | sigma | 22 | 0.000001 | 0.00011407711613050422 | 0 | 0.016 | 0.8 | 23 And the markets: 24 | 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 | 25 | 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 | 26 And the following network parameters are set: 27 | name | value | 28 | network.markPriceUpdateMaximumFrequency | 0s | 29 And the average block duration is "1" 30 When the parties deposit on asset's general account the following amount: 31 | party | asset | amount | 32 | party1 | USD | 100000000000 | 33 | party2 | USD | 100000000000 | 34 | party3 | USD | 100000000000 | 35 | aux | USD | 100000000000 | 36 | aux2 | USD | 100000000000 | 37 | lpprov | USD | 100000000000 | 38 Then the parties submit the following liquidity provision: 39 | id | party | market id | commitment amount | fee | lp type | 40 | lp1 | lpprov | ETH/DEC19 | 100000 | 0.001 | submission | 41 # move market to continuous 42 And the parties place the following orders: 43 | party | market id | side | volume | price | resulting trades | type | tif | 44 | aux2 | ETH/DEC19 | buy | 1 | 1 | 0 | TYPE_LIMIT | TIF_GTC | 45 | lpprov | ETH/DEC19 | buy | 100000 | 1 | 0 | TYPE_LIMIT | TIF_GTC | 46 | aux2 | ETH/DEC19 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 47 | aux | ETH/DEC19 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 48 | aux | ETH/DEC19 | sell | 1 | 3500 | 0 | TYPE_LIMIT | TIF_GTC | 49 | lpprov | ETH/DEC19 | sell | 100000 | 3500 | 0 | TYPE_LIMIT | TIF_GTC | 50 And the market data for the market "ETH/DEC19" should be: 51 | target stake | supplied stake | 52 | 431500 | 100000 | 53 And the opening auction period ends for market "ETH/DEC19" 54 55 @Perpetual @funding-rate 56 Scenario: 0053-PERP-029, 0053-PERP-030 Funding rate modified by perpetual parameters 57 Given the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" 58 And time is updated to "2020-10-16T00:05:00Z" 59 When the parties place the following orders: 60 | party | market id | side | volume | price | resulting trades | type | tif | 61 | party1 | ETH/DEC19 | buy | 1 | 990 | 0 | TYPE_LIMIT | TIF_GTC | 62 | party2 | ETH/DEC19 | sell | 1 | 990 | 1 | TYPE_LIMIT | TIF_GTC | 63 Then time is updated to "2020-10-16T00:10:00Z" 64 65 # 1602806400 + 120s = 1602807000 66 # funding period is ended with perp.funding.cue 67 And the oracles broadcast data with block time signed with "0xCAFECAFE1": 68 | name | value | time offset | 69 | perp.ETH.value | 1000000000000000000000 | -1s | 70 | perp.funding.cue | 1602807000 | 0s | 71 And the mark price should be "990" for the market "ETH/DEC19" 72 73 # 0053-PERP-029 funding rate will be 2.5 times what it would normally be given funding-rate-scaling-factor 74 Then the product data for the market "ETH/DEC19" should be: 75 | internal twap | external twap | funding payment | funding rate | 76 | 990 | 1000 | -25 | -0.025 | 77 78 # update to the perp spec with the lower bound on the funding rate 79 And the markets are updated: 80 | id | data source config | linear slippage factor | quadratic slippage factor | 81 | ETH/DEC19 | perp-oracle2 | 1e-3 | 0 | 82 83 Then time is updated to "2020-10-16T00:10:01Z" 84 85 # 0053-PERP-030 funding rate will be snapped to -0.005 since it should *really* be -0.01, but thats lower than funding-rate-lower-bound 86 Then the product data for the market "ETH/DEC19" should be: 87 | internal twap | external twap | funding payment | funding rate | 88 | 990 | 1000 | -5 | -0.005 | 89 90 91 92