code.vegaprotocol.io/vega@v0.79.0/core/integration/features/perpetual-mark-and-index-price.feature (about) 1 Feature: Simple tests for perpetual market mark price. 2 3 Background: 4 Given the following assets are registered: 5 | id | decimal places | 6 | ETH | 5 | 7 And the liquidity sla params named "SLA": 8 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 9 | 1.0 | 0.5 | 1 | 1.0 | 10 And the liquidity monitoring parameters: 11 | name | triggering ratio | time window | scaling factor | 12 | lqm-params | 0.01 | 10s | 5 | 13 14 And the following network parameters are set: 15 | name | value | 16 | network.markPriceUpdateMaximumFrequency | 1s | 17 | network.internalCompositePriceUpdateFrequency | 1s | 18 | market.auction.minimumDuration | 1 | 19 | market.fee.factors.infrastructureFee | 0.001 | 20 | market.fee.factors.makerFee | 0.004 | 21 | market.value.windowLength | 60s | 22 | market.liquidity.bondPenaltyParameter | 0.1 | 23 | validators.epoch.length | 5s | 24 | limits.markets.maxPeggedOrders | 2 | 25 | market.liquidity.providersFeeCalculationTimeStep | 5s | 26 27 And the average block duration is "1" 28 29 # All parties have 1,000,000.000,000,000,000,000,000 30 # Add as many parties as needed here 31 And the parties deposit on asset's general account the following amount: 32 | party | asset | amount | 33 | lpprov | ETH | 10000000000000000000000000 | 34 | trader1 | ETH | 10000000000000000000000000 | 35 | trader2 | ETH | 10000000000000000000000000 | 36 37 Scenario: Use last trade for internal TWAP 38 When the perpetual oracles from "0xCAFECAFE1": 39 | 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 | price type | cash amount | source weights | source staleness tolerance | 40 | perp-oracle | ETH | perp.ETH.value | TYPE_INTEGER | perp.funding.cue | TYPE_TIMESTAMP | 0 | 0 | 0 | 0 | ETH | 5 | weight | 1000 | 1,0,0,0 | 0s,0s,0s,0s | 41 And the markets: 42 | 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 | price type | 43 | ETH/DEC19 | ETH | ETH | lqm-params | default-st-risk-model | default-margin-calculator | 1 | default-none | default-none | perp-oracle | 0.1 | 0 | 5 | 5 | perp | SLA | last trade | 44 Given the parties submit the following liquidity provision: 45 | id | party | market id | commitment amount | fee | lp type | 46 | lp1 | lpprov | ETH/DEC19 | 3905000000000000 | 0.3 | submission | 47 And the parties place the following pegged iceberg orders: 48 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference | 49 | lpprov | ETH/DEC19 | 4000000000000000 | 3905000000000000 | buy | BID | 4000000000000000 | 1 | lp-ice-buy | 50 | lpprov | ETH/DEC19 | 4000000000000000 | 3905000000000000 | sell | ASK | 4000000000000000 | 1 | lp-ice-sell | 51 And the parties place the following orders: 52 | party | market id | side | volume | price | resulting trades | type | tif | reference | 53 | trader1 | ETH/DEC19 | buy | 5 | 1001 | 0 | TYPE_LIMIT | TIF_GTC | t1-b-1 | 54 | trader1 | ETH/DEC19 | buy | 5 | 900 | 0 | TYPE_LIMIT | TIF_GTC | t1-b-2 | 55 | trader1 | ETH/DEC19 | buy | 1 | 100 | 0 | TYPE_LIMIT | TIF_GTC | t1-b-3 | 56 | trader2 | ETH/DEC19 | sell | 5 | 1200 | 0 | TYPE_LIMIT | TIF_GTC | t2-s-1 | 57 | trader2 | ETH/DEC19 | sell | 1 | 100000 | 0 | TYPE_LIMIT | TIF_GTC | t2-s-2 | 58 | trader2 | ETH/DEC19 | sell | 5 | 951 | 0 | TYPE_LIMIT | TIF_GTC | t2-s-3 | 59 When the opening auction period ends for market "ETH/DEC19" 60 Then the market data for the market "ETH/DEC19" should be: 61 | mark price | trading mode | 62 | 976 | TRADING_MODE_CONTINUOUS | 63 64 And the network moves ahead "2" blocks 65 Then the oracles broadcast data with block time signed with "0xCAFECAFE1": 66 | name | value | time offset | 67 | perp.ETH.value | 140 | -1s | 68 69 Then the product data for the market "ETH/DEC19" should be: 70 | internal twap | external twap | 71 | 976 | 140 | 72 73 Scenario: 0053-PERP-033 74 When the perpetual oracles from "0xCAFECAFE1": 75 | 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 | price type | cash amount | source weights | source staleness tolerance | 76 | perp-oracle | ETH | perp.ETH.value | TYPE_INTEGER | perp.funding.cue | TYPE_TIMESTAMP | 0 | 0 | 0 | 0 | ETH | 5 | weight | 1000 | 0,1,0,0 | 0s,100s,0s,0s | 77 And the markets: 78 | 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 | price type | 79 | ETH/DEC19 | ETH | ETH | lqm-params | default-st-risk-model | default-margin-calculator | 1 | default-none | default-none | perp-oracle | 0.1 | 0 | 5 | 5 | perp | SLA | last trade | 80 Given the parties submit the following liquidity provision: 81 | id | party | market id | commitment amount | fee | lp type | 82 | lp1 | lpprov | ETH/DEC19 | 3905000000000000 | 0.3 | submission | 83 And the parties place the following pegged iceberg orders: 84 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference | 85 | lpprov | ETH/DEC19 | 4000000000000000 | 3905000000000000 | buy | BID | 4000000000000000 | 1 | lp-ice-buy | 86 | lpprov | ETH/DEC19 | 4000000000000000 | 3905000000000000 | sell | ASK | 4000000000000000 | 1 | lp-ice-sell | 87 And the parties place the following orders: 88 | party | market id | side | volume | price | resulting trades | type | tif | reference | 89 | trader1 | ETH/DEC19 | buy | 5 | 1001 | 0 | TYPE_LIMIT | TIF_GTC | t1-b-1 | 90 | trader1 | ETH/DEC19 | buy | 5 | 900 | 0 | TYPE_LIMIT | TIF_GTC | t1-b-2 | 91 | trader1 | ETH/DEC19 | buy | 1 | 100 | 0 | TYPE_LIMIT | TIF_GTC | t1-b-3 | 92 | trader2 | ETH/DEC19 | sell | 5 | 1200 | 0 | TYPE_LIMIT | TIF_GTC | t2-s-1 | 93 | trader2 | ETH/DEC19 | sell | 1 | 100000 | 0 | TYPE_LIMIT | TIF_GTC | t2-s-2 | 94 | trader2 | ETH/DEC19 | sell | 5 | 951 | 0 | TYPE_LIMIT | TIF_GTC | t2-s-3 | 95 When the opening auction period ends for market "ETH/DEC19" 96 Then the market data for the market "ETH/DEC19" should be: 97 | mark price | trading mode | 98 | 976 | TRADING_MODE_CONTINUOUS | 99 100 And the network moves ahead "2" blocks 101 102 Then the oracles broadcast data with block time signed with "0xCAFECAFE1": 103 | name | value | time offset | 104 | perp.ETH.value | 140 | -1s | 105 106 Then the product data for the market "ETH/DEC19" should be: 107 | internal twap | external twap | 108 | 1050 | 140 | 109 110 Scenario: 0053-PERP-034 111 When the perpetual oracles from "0xCAFECAFE1": 112 | 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 | price type | cash amount | source weights | source staleness tolerance | 113 | perp-oracle | ETH | perp.ETH.value | TYPE_INTEGER | perp.funding.cue | TYPE_TIMESTAMP | 0 | 0 | 0 | 0 | ETH | 5 | weight | 1000 | 0,1,0,0 | 0s,100s,0s,0s | 114 And the composite price oracles from "0xCAFECAFE2": 115 | name | price property | price type | price decimals | 116 | oracle1 | prices.ETH.value | TYPE_INTEGER | 5 | 117 And the markets: 118 | 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 | price type | source weights | source staleness tolerance | oracle1 | 119 | ETH/DEC19 | ETH | ETH | lqm-params | default-st-risk-model | default-margin-calculator | 1 | default-none | default-none | perp-oracle | 0.1 | 0 | 5 | 5 | perp | SLA | weight | 0,0,1,0 | 0s,0s,24h0m0s,0s | oracle1 | 120 Given the parties submit the following liquidity provision: 121 | id | party | market id | commitment amount | fee | lp type | 122 | lp1 | lpprov | ETH/DEC19 | 3905000000000000 | 0.3 | submission | 123 And the parties place the following pegged iceberg orders: 124 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference | 125 | lpprov | ETH/DEC19 | 4000000000000000 | 3905000000000000 | buy | BID | 4000000000000000 | 1 | lp-ice-buy | 126 | lpprov | ETH/DEC19 | 4000000000000000 | 3905000000000000 | sell | ASK | 4000000000000000 | 1 | lp-ice-sell | 127 And the parties place the following orders: 128 | party | market id | side | volume | price | resulting trades | type | tif | reference | 129 | trader1 | ETH/DEC19 | buy | 5 | 1001 | 0 | TYPE_LIMIT | TIF_GTC | t1-b-1 | 130 | trader1 | ETH/DEC19 | buy | 5 | 900 | 0 | TYPE_LIMIT | TIF_GTC | t1-b-2 | 131 | trader1 | ETH/DEC19 | buy | 1 | 100 | 0 | TYPE_LIMIT | TIF_GTC | t1-b-3 | 132 | trader2 | ETH/DEC19 | sell | 5 | 1200 | 0 | TYPE_LIMIT | TIF_GTC | t2-s-1 | 133 | trader2 | ETH/DEC19 | sell | 1 | 100000 | 0 | TYPE_LIMIT | TIF_GTC | t2-s-2 | 134 | trader2 | ETH/DEC19 | sell | 5 | 951 | 0 | TYPE_LIMIT | TIF_GTC | t2-s-3 | 135 When the opening auction period ends for market "ETH/DEC19" 136 Then the market data for the market "ETH/DEC19" should be: 137 | mark price | trading mode | 138 | 976 | TRADING_MODE_CONTINUOUS | 139 140 And the network moves ahead "2" blocks 141 142 When the oracles broadcast data with block time signed with "0xCAFECAFE1": 143 | name | value | time offset | 144 | perp.ETH.value | 140 | -1s | 145 146 And the oracles broadcast data with block time signed with "0xCAFECAFE2": 147 | name | value | time offset | 148 | prices.ETH.value | 500 | -1s | 149 150 And the product data for the market "ETH/DEC19" should be: 151 | internal twap | external twap | 152 | 1050 | 140 | 153 154 And the network moves ahead "15" blocks 155 156 Then the market data for the market "ETH/DEC19" should be: 157 | mark price | trading mode | 158 | 500 | TRADING_MODE_CONTINUOUS | 159 160 And the product data for the market "ETH/DEC19" should be: 161 | internal twap | external twap | 162 | 1050 | 140 | 163 164 Scenario: 0053-PERP-035 165 When the perpetual oracles from "0xCAFECAFE1": 166 | 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 | price type | cash amount | source weights | source staleness tolerance | 167 | perp-oracle | ETH | perp.ETH.value | TYPE_INTEGER | perp.funding.cue | TYPE_TIMESTAMP | 0 | 0 | 0 | 0 | ETH | 5 | weight | 0 | 1,1,0,0 | 30s,100s,0s,0s | 168 And the composite price oracles from "0xCAFECAFE2": 169 | name | price property | price type | price decimals | 170 | oracle1 | prices.ETH.value | TYPE_INTEGER | 5 | 171 And the markets: 172 | 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 | price type | source weights | source staleness tolerance | oracle1 | 173 | ETH/DEC19 | ETH | ETH | lqm-params | default-st-risk-model | default-margin-calculator | 1 | default-none | default-none | perp-oracle | 0.1 | 0 | 5 | 5 | perp | SLA | weight | 0,0,1,0 | 0s,0s,24h0m0s,0s | oracle1 | 174 Given the parties submit the following liquidity provision: 175 | id | party | market id | commitment amount | fee | lp type | 176 | lp1 | lpprov | ETH/DEC19 | 3905000000000000 | 0.3 | submission | 177 And the parties place the following pegged iceberg orders: 178 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference | 179 | lpprov | ETH/DEC19 | 4000000000000000 | 3905000000000000 | buy | BID | 4000000000000000 | 1 | lp-ice-buy | 180 | lpprov | ETH/DEC19 | 4000000000000000 | 3905000000000000 | sell | ASK | 4000000000000000 | 1 | lp-ice-sell | 181 And the parties place the following orders: 182 | party | market id | side | volume | price | resulting trades | type | tif | reference | 183 | trader1 | ETH/DEC19 | buy | 5 | 1001 | 0 | TYPE_LIMIT | TIF_GTC | t1-b-1 | 184 | trader1 | ETH/DEC19 | buy | 5 | 900 | 0 | TYPE_LIMIT | TIF_GTC | t1-b-2 | 185 | trader1 | ETH/DEC19 | buy | 1 | 100 | 0 | TYPE_LIMIT | TIF_GTC | t1-b-3 | 186 | trader2 | ETH/DEC19 | sell | 5 | 1200 | 0 | TYPE_LIMIT | TIF_GTC | t2-s-1 | 187 | trader2 | ETH/DEC19 | sell | 1 | 100000 | 0 | TYPE_LIMIT | TIF_GTC | t2-s-2 | 188 | trader2 | ETH/DEC19 | sell | 5 | 951 | 0 | TYPE_LIMIT | TIF_GTC | t2-s-3 | 189 When the opening auction period ends for market "ETH/DEC19" 190 Then the market data for the market "ETH/DEC19" should be: 191 | mark price | trading mode | 192 | 976 | TRADING_MODE_CONTINUOUS | 193 194 And the network moves ahead "2" blocks 195 196 When the oracles broadcast data with block time signed with "0xCAFECAFE1": 197 | name | value | time offset | 198 | perp.ETH.value | 140 | -1s | 199 200 And the oracles broadcast data with block time signed with "0xCAFECAFE2": 201 | name | value | time offset | 202 | prices.ETH.value | 500 | -1s | 203 204 And the product data for the market "ETH/DEC19" should be: 205 | internal twap | external twap | 206 | 1013 | 140 | 207 208 And the network moves ahead "15" blocks 209 210 Then the market data for the market "ETH/DEC19" should be: 211 | mark price | trading mode | 212 | 500 | TRADING_MODE_CONTINUOUS | 213 214 And the product data for the market "ETH/DEC19" should be: 215 | internal twap | external twap | 216 | 1013 | 140 |