code.vegaprotocol.io/vega@v0.79.0/core/integration/features/capped-futures/0016-PFUT-020-ignore.feature (about) 1 Feature: When binary settlement is enabled, the market ignored oracle data that is neither 0 nor max price. 2 3 Background: 4 Given time is updated to "2019-11-30T00:00:00Z" 5 And the average block duration is "1" 6 7 And the oracle spec for settlement data filtering data from "0xCAFECAFE1" named "ethDec21Oracle": 8 | property | type | binding | 9 | prices.ETH.value | TYPE_INTEGER | settlement data | 10 11 And the oracle spec for trading termination filtering data from "0xCAFECAFE1" named "ethDec21Oracle": 12 | property | type | binding | 13 | trading.terminated | TYPE_BOOLEAN | trading termination | 14 15 And the settlement data decimals for the oracle named "ethDec21Oracle" is given in "0" decimal places 16 17 And the oracle spec for settlement data filtering data from "0xCAFECAFE2" named "ethDec22Oracle": 18 | property | type | binding | 19 | prices.ETH.value | TYPE_INTEGER | settlement data | 20 And the oracle spec for trading termination filtering data from "0xCAFECAFE2" named "ethDec22Oracle": 21 | property | type | binding | 22 | trading.terminated | TYPE_BOOLEAN | trading termination | 23 24 And the settlement data decimals for the oracle named "ethDec22Oracle" is given in "0" decimal places 25 26 And the following network parameters are set: 27 | name | value | 28 | market.auction.minimumDuration | 1 | 29 | network.markPriceUpdateMaximumFrequency | 1s | 30 | market.liquidity.successorLaunchWindowLength | 1s | 31 | limits.markets.maxPeggedOrders | 4 | 32 33 And the fees configuration named "fees-config-1": 34 | maker fee | infrastructure fee | 35 | 0.005 | 0.02 | 36 And the price monitoring named "price-monitoring-1": 37 | horizon | probability | auction extension | 38 | 3600000 | 0.99 | 300 | 39 And the log normal risk model named "lognormal-risk-model-1": 40 | risk aversion | tau | mu | r | sigma | 41 | 0.0002 | 0.01 | 0 | 0.0 | 1.2 | 42 And the simple risk model named "simple-risk-model-1": 43 | long | short | max move up | min move down | probability of trading | 44 | 0.2 | 0.1 | 100 | -100 | 0.1 | 45 46 And the markets: 47 | id | quote name | asset | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | max price cap | fully collateralised | binary | 48 | ETH/DEC21 | ETH | USD | lognormal-risk-model-1 | default-margin-calculator | 1 | fees-config-1 | price-monitoring-1 | ethDec21Oracle | 0.25 | 0 | default-futures | 1500 | true | true | 49 | ETH/DEC22 | ETH | USD | simple-risk-model-1 | default-margin-calculator | 1 | fees-config-1 | price-monitoring-1 | ethDec22Oracle | 0.25 | 0 | default-futures | 1500 | false | true | 50 | ETH/DEC23 | ETH | USD | lognormal-risk-model-1 | default-margin-calculator | 1 | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.25 | 0 | default-futures | 1500 | true | true | 51 52 @NoPerp @Capped @CBin @CappedBug 53 Scenario: 0016-PFUT-020: Pass in settlement prices that are neither 0 nor max price, then settle at valid prices. 54 Given the initial insurance pool balance is "10000" for all the markets 55 And the parties deposit on asset's general account the following amount: 56 | party | asset | amount | 57 | party1 | USD | 10000 | 58 | party2 | USD | 10000 | 59 | party3 | USD | 10000 | 60 | party4 | USD | 10000 | 61 | party5 | USD | 10000 | 62 | party6 | USD | 10000 | 63 | aux1 | USD | 100000 | 64 | aux2 | USD | 100000 | 65 | aux3 | USD | 100000 | 66 | aux4 | USD | 100000 | 67 | aux5 | USD | 100000 | 68 | aux6 | USD | 100000 | 69 | aux7 | USD | 100000 | 70 | party-lp1 | USD | 100000000 | 71 | party-lp2 | USD | 100000000 | 72 | party-lp3 | USD | 100000000 | 73 74 And the parties submit the following liquidity provision: 75 | id | party | market id | commitment amount | fee | lp type | 76 | lp1 | party-lp1 | ETH/DEC21 | 30000 | 0 | submission | 77 | lp2 | party-lp2 | ETH/DEC22 | 30000 | 0 | submission | 78 | lp3 | party-lp3 | ETH/DEC23 | 30000 | 0 | submission | 79 80 When the parties place the following orders: 81 | party | market id | side | volume | price | resulting trades | type | tif | reference | error | 82 | aux1 | ETH/DEC21 | buy | 2 | 999 | 0 | TYPE_LIMIT | TIF_GTC | ref-1-1 | | 83 | aux5 | ETH/DEC22 | buy | 2 | 999 | 0 | TYPE_LIMIT | TIF_GTC | ref-5-1 | | 84 | aux3 | ETH/DEC23 | buy | 2 | 999 | 0 | TYPE_LIMIT | TIF_GTC | ref-3-1 | | 85 | party1 | ETH/DEC21 | buy | 5 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-p1-1 | | 86 | party3 | ETH/DEC22 | buy | 5 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-p3-1 | | 87 | party5 | ETH/DEC23 | buy | 5 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-p5-1 | | 88 | party2 | ETH/DEC21 | sell | 5 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-p2-1 | | 89 | party4 | ETH/DEC22 | sell | 5 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-p4-1 | | 90 | party6 | ETH/DEC23 | sell | 5 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-p6-1 | | 91 | aux2 | ETH/DEC21 | sell | 2 | 1499 | 0 | TYPE_LIMIT | TIF_GTC | ref-2-1 | | 92 | aux4 | ETH/DEC23 | sell | 2 | 1499 | 0 | TYPE_LIMIT | TIF_GTC | ref-4-1 | | 93 | aux6 | ETH/DEC22 | sell | 2 | 1499 | 0 | TYPE_LIMIT | TIF_GTC | ref-6-1 | | 94 And the network moves ahead "2" blocks 95 96 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC21" 97 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC22" 98 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC23" 99 And the market state should be "STATE_ACTIVE" for the market "ETH/DEC21" 100 And the market state should be "STATE_ACTIVE" for the market "ETH/DEC22" 101 And the market state should be "STATE_ACTIVE" for the market "ETH/DEC23" 102 And the mark price should be "1000" for the market "ETH/DEC21" 103 And the mark price should be "1000" for the market "ETH/DEC22" 104 And the mark price should be "1000" for the market "ETH/DEC23" 105 And the parties should have the following account balances: 106 | party | asset | market id | margin | general | 107 | party1 | USD | ETH/DEC21 | 5000 | 5000 | 108 | party2 | USD | ETH/DEC21 | 2500 | 7500 | 109 | party3 | USD | ETH/DEC22 | 2700 | 7300 | 110 | party4 | USD | ETH/DEC22 | 2100 | 7900 | 111 | party5 | USD | ETH/DEC23 | 5000 | 5000 | 112 | party6 | USD | ETH/DEC23 | 2500 | 7500 | 113 114 #order margin for aux1: limit price * size = 999*2=1998 115 #order margin for aux2: (max price - limit price) * size = (1500-1301)*2=398 116 # party1 maintenance margin level: position size * average entry price = 5*1000=5000 117 # party2 maintenance margin level: position size * (max price - average entry price)=5*(1500-1000)=2500 118 # Aux1: potential position * average price on book = 2 * 999 = 1998, but due to the MTM settlement the margin level 119 And the parties should have the following margin levels: 120 | party | market id | maintenance | search | initial | release | margin mode | 121 | party1 | ETH/DEC21 | 5000 | 5000 | 5000 | 5000 | cross margin | 122 | party2 | ETH/DEC21 | 2500 | 2500 | 2500 | 2500 | cross margin | 123 | aux2 | ETH/DEC21 | 2 | 2 | 2 | 2 | cross margin | 124 | aux1 | ETH/DEC21 | 1998 | 1998 | 1998 | 1998 | cross margin | 125 | party3 | ETH/DEC22 | 2250 | 2475 | 2700 | 3150 | cross margin | 126 | party4 | ETH/DEC22 | 1750 | 1925 | 2100 | 2450 | cross margin | 127 | aux5 | ETH/DEC22 | 400 | 440 | 480 | 560 | cross margin | 128 | aux6 | ETH/DEC22 | 200 | 220 | 240 | 280 | cross margin | 129 | party5 | ETH/DEC23 | 5000 | 5000 | 5000 | 5000 | cross margin | 130 | party6 | ETH/DEC23 | 2500 | 2500 | 2500 | 2500 | cross margin | 131 | aux4 | ETH/DEC23 | 2 | 2 | 2 | 2 | cross margin | 132 | aux3 | ETH/DEC23 | 1998 | 1998 | 1998 | 1998 | cross margin | 133 134 #update mark price 135 When the parties place the following orders: 136 | party | market id | side | volume | price | resulting trades | type | tif | reference | 137 | aux1 | ETH/DEC21 | buy | 1 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | aux1-2 | 138 | aux2 | ETH/DEC21 | sell | 1 | 1100 | 1 | TYPE_LIMIT | TIF_GTC | aux2-2 | 139 | aux5 | ETH/DEC22 | buy | 1 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | aux5-2 | 140 | aux6 | ETH/DEC22 | sell | 1 | 1100 | 1 | TYPE_LIMIT | TIF_GTC | aux6-2 | 141 | aux3 | ETH/DEC23 | buy | 1 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | aux3-2 | 142 | aux4 | ETH/DEC23 | sell | 1 | 1100 | 1 | TYPE_LIMIT | TIF_GTC | aux4-2 | 143 144 And the network moves ahead "2" blocks 145 Then the mark price should be "1100" for the market "ETH/DEC21" 146 And the mark price should be "1100" for the market "ETH/DEC22" 147 And the mark price should be "1100" for the market "ETH/DEC23" 148 149 When the oracles broadcast data signed with "0xCAFECAFE1": 150 | name | value | 151 | trading.terminated | true | 152 And the oracles broadcast data signed with "0xCAFECAFE2": 153 | name | value | 154 | trading.terminated | true | 155 Then the network moves ahead "2" blocks 156 And the market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC21" 157 And the market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC22" 158 And the parties should have the following account balances: 159 | party | asset | market id | margin | general | 160 | party1 | USD | ETH/DEC21 | 5500 | 5000 | 161 | party2 | USD | ETH/DEC21 | 2000 | 7500 | 162 | party3 | USD | ETH/DEC22 | 3200 | 7300 | 163 | party4 | USD | ETH/DEC22 | 2310 | 7190 | 164 | aux1 | USD | ETH/DEC21 | 3098 | 96908 | 165 | aux2 | USD | ETH/DEC21 | 402 | 99570 | 166 | aux5 | USD | ETH/DEC22 | 1122 | 98884 | 167 | aux6 | USD | ETH/DEC22 | 726 | 99246 | 168 | party5 | USD | ETH/DEC23 | 5500 | 5000 | 169 | party6 | USD | ETH/DEC23 | 2000 | 7500 | 170 | aux3 | USD | ETH/DEC23 | 3098 | 96908 | 171 | aux4 | USD | ETH/DEC23 | 402 | 99570 | 172 173 # First, try settling a market via governance, providing an incorrect price. 174 When the market states are updated through governance: 175 | market id | state | settlement price | error | 176 | ETH/DEC23 | MARKET_STATE_UPDATE_TYPE_TERMINATE | 123 | settlement data is outside of the price cap | 177 | ETH/DEC23 | MARKET_STATE_UPDATE_TYPE_TERMINATE | 123456789 | settlement data is outside of the price cap | 178 Then the network moves ahead "1" blocks 179 And the market state should be "STATE_ACTIVE" for the market "ETH/DEC23" 180 # now provide a valid price 181 When the market states are updated through governance: 182 | market id | state | settlement price | error | 183 | ETH/DEC23 | MARKET_STATE_UPDATE_TYPE_TERMINATE | 0 | | 184 Then the network moves ahead "1" blocks 185 And the last market state should be "STATE_CLOSED" for the market "ETH/DEC23" 186 # Now we can try to settle the markets with invalid data, making sure it doesn't settle. 187 # In range, but not valid for binary settlements 188 When the oracles broadcast data signed with "0xCAFECAFE1": 189 | name | value | 190 | prices.ETH.value | 100 | 191 # Out of range, so should be ignored 192 When the oracles broadcast data signed with "0xCAFECAFE2": 193 | name | value | 194 | prices.ETH.value | 90000 | 195 And the network moves ahead "2" blocks 196 Then the market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC21" 197 And the market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC22" 198 # Make sure terminated is indeed the LAST state, rather than settled 199 And the last market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC21" 200 And the last market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC22" 201 202 # Now one market will settle with a valid price of 0 203 When the oracles broadcast data signed with "0xCAFECAFE1": 204 | name | value | 205 | prices.ETH.value | 0 | 206 And the network moves ahead "2" blocks 207 Then the market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC22" 208 And the last market state should be "STATE_SETTLED" for the market "ETH/DEC21" 209 210 # Now settle the remaining market using the max price. 211 When the oracles broadcast data signed with "0xCAFECAFE2": 212 | name | value | 213 | prices.ETH.value | 1500 | 214 And the network moves ahead "2" blocks 215 Then the last market state should be "STATE_SETTLED" for the market "ETH/DEC22" 216 And the last market state should be "STATE_SETTLED" for the market "ETH/DEC21" 217 # the margin balances should be empty 218 And the parties should have the following account balances: 219 | party | asset | market id | margin | general | 220 | party1 | USD | ETH/DEC21 | 0 | 5000 | 221 | party2 | USD | ETH/DEC21 | 0 | 15000 | 222 | party3 | USD | ETH/DEC22 | 0 | 12500 | 223 | party4 | USD | ETH/DEC22 | 0 | 7500 | 224 | aux1 | USD | ETH/DEC21 | 0 | 98906 | 225 | aux2 | USD | ETH/DEC21 | 0 | 101072 | 226 | aux5 | USD | ETH/DEC22 | 0 | 100406 | 227 | aux6 | USD | ETH/DEC22 | 0 | 99572 | 228 | party5 | USD | ETH/DEC23 | 0 | 5000 | 229 | party6 | USD | ETH/DEC23 | 0 | 15000 | 230 | aux3 | USD | ETH/DEC23 | 0 | 98906 | 231 | aux4 | USD | ETH/DEC23 | 0 | 101072 |