code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/0002-STTL-settlement_at_expiry.feature (about) 1 Feature: Test settlement at expiry (0016-PFUT-012) 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 "0xCAFECAFE" named "ethDec20Oracle": 8 | property | type | binding | 9 | prices.ETH.value | TYPE_INTEGER | settlement data | 10 11 And the oracle spec for trading termination filtering data from "0xCAFECAFE" named "ethDec20Oracle": 12 | property | type | binding | 13 | trading.terminated | TYPE_BOOLEAN | trading termination | 14 15 And the oracle spec for settlement data filtering data from "0xCAFECAFE1" named "ethDec21Oracle": 16 | property | type | binding | 17 | prices.ETH.value | TYPE_INTEGER | settlement data | 18 19 And the oracle spec for trading termination filtering data from "0xCAFECAFE1" named "ethDec21Oracle": 20 | property | type | binding | 21 | trading.terminated | TYPE_BOOLEAN | trading termination | 22 23 And the settlement data decimals for the oracle named "ethDec20Oracle" is given in "0" decimal places 24 And the settlement data decimals for the oracle named "ethDec21Oracle" 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 | 0s | 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 | 1 | 0.99 | 300 | 39 And the simple risk model named "simple-risk-model-1": 40 | long | short | max move up | min move down | probability of trading | 41 | 0.2 | 0.1 | 100 | -100 | 0.1 | 42 43 And the markets: 44 | id | quote name | asset | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | 45 | ETH/DEC19 | ETH | ETH | default-simple-risk-model-3 | default-margin-calculator | 1 | default-none | default-none | ethDec20Oracle | 0.25 | 0 | default-futures | 46 | ETH/DEC21 | ETH | ETH | simple-risk-model-1 | default-margin-calculator | 1 | fees-config-1 | price-monitoring-1 | ethDec21Oracle | 0.25 | 0 | default-futures | 47 48 Scenario: Order cannot be placed once the market is expired (0002-STTL-001) 49 Given the parties deposit on asset's general account the following amount: 50 | party | asset | amount | 51 | party1 | ETH | 10000 | 52 | aux1 | ETH | 100000 | 53 | aux2 | ETH | 100000 | 54 | lpprov | ETH | 100000 | 55 56 When the parties submit the following liquidity provision: 57 | id | party | market id | commitment amount | fee | lp type | 58 | lp1 | lpprov | ETH/DEC19 | 90000 | 0.1 | submission | 59 | lp1 | lpprov | ETH/DEC19 | 90000 | 0.1 | submission | 60 And the parties place the following pegged iceberg orders: 61 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 62 | lpprov | ETH/DEC19 | 2 | 1 | buy | BID | 50 | 10 | 63 | lpprov | ETH/DEC19 | 2 | 1 | sell | ASK | 50 | 10 | 64 65 When the parties place the following orders: 66 | party | market id | side | volume | price | resulting trades | type | tif | reference | 67 | aux1 | ETH/DEC19 | buy | 1 | 999 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 68 | aux2 | ETH/DEC19 | sell | 1 | 1001 | 0 | TYPE_LIMIT | TIF_GTC | ref-2 | 69 | aux1 | ETH/DEC19 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-3 | 70 | aux2 | ETH/DEC19 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-4 | 71 Then the opening auction period ends for market "ETH/DEC19" 72 And the mark price should be "1000" for the market "ETH/DEC19" 73 74 When the oracles broadcast data signed with "0xCAFECAFE": 75 | name | value | 76 | trading.terminated | true | 77 And time is updated to "2020-01-01T01:01:01Z" 78 Then the market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC19" 79 Then the oracles broadcast data signed with "0xCAFECAFE": 80 | name | value | 81 | prices.ETH.value | 42 | 82 Then time is updated to "2020-01-01T01:01:02Z" 83 84 When the parties place the following orders: 85 | party | market id | side | volume | price | resulting trades | type | tif | reference | error | 86 | party1 | ETH/DEC19 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-7 | OrderError: Invalid Market ID | 87 88 @SLABug 89 Scenario: Settlement happened when market is being closed - no loss socialisation needed - no insurance taken (0002-STTL-002, 0002-STTL-007, 0005-COLL-002, 0015-INSR-002) 90 Given the initial insurance pool balance is "10000" for all the markets 91 Given the parties deposit on asset's general account the following amount: 92 | party | asset | amount | 93 | party1 | ETH | 10000 | 94 | party2 | ETH | 1000 | 95 | party3 | ETH | 5000 | 96 | aux1 | ETH | 100000 | 97 | aux2 | ETH | 100000 | 98 | party-lp | ETH | 100000000 | 99 100 And the cumulated balance for all accounts should be worth "100236000" 101 102 And the parties submit the following liquidity provision: 103 | id | party | market id | commitment amount | fee | lp type | 104 | lp1 | party-lp | ETH/DEC19 | 30000000 | 0 | submission | 105 | lp1 | party-lp | ETH/DEC19 | 30000000 | 0 | amendment | 106 | lp2 | party-lp | ETH/DEC21 | 30000000 | 0 | submission | 107 | lp2 | party-lp | ETH/DEC21 | 30000000 | 0 | amendment | 108 And the parties place the following pegged iceberg orders: 109 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 110 | party-lp | ETH/DEC19 | 2 | 1 | buy | BID | 50 | 10 | 111 | party-lp | ETH/DEC19 | 2 | 1 | sell | ASK | 50 | 10 | 112 | party-lp | ETH/DEC21 | 2 | 1 | buy | BID | 50 | 10 | 113 | party-lp | ETH/DEC21 | 2 | 1 | sell | ASK | 50 | 10 | 114 115 When the parties place the following orders: 116 | party | market id | side | volume | price | resulting trades | type | tif | reference | 117 | aux1 | ETH/DEC19 | buy | 2 | 999 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 118 | aux2 | ETH/DEC19 | sell | 2 | 1001 | 0 | TYPE_LIMIT | TIF_GTC | ref-2 | 119 | aux1 | ETH/DEC19 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-3 | 120 | aux2 | ETH/DEC19 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-4 | 121 122 # Other market 123 And the parties place the following orders: 124 | party | market id | side | volume | price | resulting trades | type | tif | reference | 125 | aux1 | ETH/DEC21 | buy | 2 | 999 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 126 | aux2 | ETH/DEC21 | sell | 2 | 1001 | 0 | TYPE_LIMIT | TIF_GTC | ref-2 | 127 | aux1 | ETH/DEC21 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-3 | 128 | aux2 | ETH/DEC21 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-4 | 129 130 When the network moves ahead "2" blocks 131 132 Then the mark price should be "1000" for the market "ETH/DEC19" 133 134 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" 135 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC21" 136 137 And the market state should be "STATE_ACTIVE" for the market "ETH/DEC19" 138 And the market state should be "STATE_ACTIVE" for the market "ETH/DEC21" 139 140 When the network moves ahead "2" blocks 141 142 # The market considered here ("ETH/DEC19") relies on "0xCAFECAFE" oracle, checking that broadcasting events from "0xCAFECAFE1" should have no effect on it apart from insurance pool transfer 143 And the oracles broadcast data signed with "0xCAFECAFE1": 144 | name | value | 145 | trading.terminated | true | 146 147 And the network moves ahead "2" blocks 148 149 Then the market state should be "STATE_ACTIVE" for the market "ETH/DEC19" 150 Then the market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC21" 151 152 When the oracles broadcast data signed with "0xCAFECAFE1": 153 | name | value | 154 | prices.ETH.value | 2000 | 155 156 And the network moves ahead "2" blocks 157 158 Then the market state should be "STATE_ACTIVE" for the market "ETH/DEC19" 159 160 When the parties place the following orders with ticks: 161 | party | market id | side | volume | price | resulting trades | type | tif | reference | 162 | party1 | ETH/DEC19 | sell | 2 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 163 | party2 | ETH/DEC19 | buy | 1 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | ref-2 | 164 | party3 | ETH/DEC19 | buy | 1 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | ref-3 | 165 166 And the following trades should be executed: 167 | buyer | price | size | seller | 168 | party2 | 1000 | 1 | party1 | 169 | party3 | 1000 | 1 | party1 | 170 171 Then the parties should have the following account balances: 172 | party | asset | market id | margin | general | 173 | party1 | ETH | ETH/DEC19 | 840 | 9160 | 174 | party2 | ETH | ETH/DEC19 | 432 | 568 | 175 | party3 | ETH | ETH/DEC19 | 432 | 4568 | 176 And the settlement account should have a balance of "0" for the market "ETH/DEC19" 177 And the cumulated balance for all accounts should be worth "100236000" 178 179 #Close positions by aux parties 180 When the parties place the following orders with ticks: 181 | party | market id | side | volume | price | resulting trades | type | tif | 182 | aux1 | ETH/DEC19 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 183 | aux2 | ETH/DEC19 | buy | 1 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | 184 185 186 Then the parties should have the following profit and loss: 187 | party | volume | unrealised pnl | realised pnl | 188 | party1 | -2 | 0 | 0 | 189 | party2 | 1 | 0 | 0 | 190 | party3 | 1 | 0 | 0 | 191 192 When the oracles broadcast data signed with "0xCAFECAFE": 193 | name | value | 194 | trading.terminated | true | 195 196 # Order can't be placed after oracle data is received (expecting party positions to remain unchanged) 197 When the parties place the following orders with ticks: 198 | party | market id | side | volume | price | resulting trades | type | tif | error | 199 | party3 | ETH/DEC19 | buy | 1 | 2000 | 0 | TYPE_LIMIT | TIF_GTC | trading not allowed | 200 201 And time is updated to "2020-01-01T01:01:01Z" 202 203 Then the parties should have the following profit and loss: 204 | party | volume | unrealised pnl | realised pnl | 205 | party1 | -2 | 0 | 0 | 206 | party2 | 1 | 0 | 0 | 207 | party3 | 1 | 0 | 0 | 208 209 Then the market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC19" 210 Then the oracles broadcast data signed with "0xCAFECAFE": 211 | name | value | 212 | prices.ETH.value | 42 | 213 214 Then time is updated to "2020-01-01T01:01:02Z" 215 216 Then the parties place the following orders: 217 | party | market id | side | volume | price | resulting trades | type | tif | reference | error | 218 | party1 | ETH/DEC19 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | OrderError: Invalid Market ID | 219 220 And the parties should have the following account balances: 221 | party | asset | market id | margin | general | 222 | party1 | ETH | ETH/DEC19 | 0 | 11916 | 223 | party2 | ETH | ETH/DEC19 | 0 | 42 | 224 | party3 | ETH | ETH/DEC19 | 0 | 4042 | 225 226 When the network moves ahead "2" blocks 227 Then the cumulated balance for all accounts should be worth "100236000" 228 And the insurance pool balance should be "0" for the market "ETH/DEC19" 229 And the global insurance pool balance should be "20000" for the asset "ETH" 230 And the insurance pool balance should be "0" for the market "ETH/DEC21" 231 232 Scenario: Same as above, but the other market already terminated before the end of scenario, expecting 0 balances in per market insurance pools - all should go to per asset insurance pool (0002-STTL-additional-tests, 0005-COLL-002, 0015-INSR-002) 233 234 Given the initial insurance pool balance is "10000" for all the markets 235 Given the parties deposit on asset's general account the following amount: 236 | party | asset | amount | 237 | party1 | ETH | 10000 | 238 | party2 | ETH | 1000 | 239 | party3 | ETH | 5000 | 240 | aux1 | ETH | 100000 | 241 | aux2 | ETH | 100000 | 242 | party-lp | ETH | 100000000 | 243 | lpprov | ETH | 100000000 | 244 245 And the cumulated balance for all accounts should be worth "200236000" 246 247 And the parties submit the following liquidity provision: 248 | id | party | market id | commitment amount | fee | lp type | 249 | lp1 | party-lp | ETH/DEC19 | 30000000 | 0 | submission | 250 | lp1 | party-lp | ETH/DEC19 | 30000000 | 0 | amendment | 251 | lp2 | lpprov | ETH/DEC21 | 30000000 | 0 | submission | 252 | lp2 | lpprov | ETH/DEC21 | 30000000 | 0 | submission | 253 And the parties place the following pegged iceberg orders: 254 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 255 | party-lp | ETH/DEC19 | 2 | 1 | buy | BID | 50 | 10 | 256 | party-lp | ETH/DEC19 | 2 | 1 | sell | ASK | 50 | 10 | 257 | lpprov | ETH/DEC21 | 2 | 1 | buy | BID | 50 | 10 | 258 | lpprov | ETH/DEC21 | 2 | 1 | sell | ASK | 50 | 10 | 259 260 When the parties place the following orders: 261 | party | market id | side | volume | price | resulting trades | type | tif | reference | 262 | aux1 | ETH/DEC19 | buy | 1 | 999 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 263 | aux2 | ETH/DEC19 | sell | 1 | 1001 | 0 | TYPE_LIMIT | TIF_GTC | ref-2 | 264 | aux1 | ETH/DEC19 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-3 | 265 | aux2 | ETH/DEC19 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-4 | 266 267 # Other market 268 And the parties place the following orders: 269 | party | market id | side | volume | price | resulting trades | type | tif | reference | 270 | aux1 | ETH/DEC21 | buy | 1 | 999 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 271 | aux2 | ETH/DEC21 | sell | 1 | 1001 | 0 | TYPE_LIMIT | TIF_GTC | ref-2 | 272 | aux1 | ETH/DEC21 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-3 | 273 | aux2 | ETH/DEC21 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-4 | 274 275 Then the opening auction period ends for market "ETH/DEC19" 276 And the mark price should be "1000" for the market "ETH/DEC19" 277 278 Then the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" 279 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC21" 280 And the market state should be "STATE_ACTIVE" for the market "ETH/DEC19" 281 And the market state should be "STATE_ACTIVE" for the market "ETH/DEC21" 282 283 Then the parties place the following orders with ticks: 284 | party | market id | side | volume | price | resulting trades | type | tif | reference | 285 | aux2 | ETH/DEC21 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-2 | 286 | aux1 | ETH/DEC21 | sell | 1 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | ref-3 | 287 288 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC21" 289 290 Then the network moves ahead "2" blocks 291 292 # The market considered here ("ETH/DEC19") relies on "0xCAFECAFE" oracle, checking that broadcasting events from "0xCAFECAFE1" should have no effect on it apart from insurance pool transfer 293 And the oracles broadcast data signed with "0xCAFECAFE1": 294 | name | value | 295 | trading.terminated | true | 296 297 And the network moves ahead "2" blocks 298 299 Then the market state should be "STATE_ACTIVE" for the market "ETH/DEC19" 300 Then the market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC21" 301 302 And the insurance pool balance should be "10000" for the market "ETH/DEC21" 303 And the insurance pool balance should be "10000" for the market "ETH/DEC19" 304 And the global insurance pool balance should be "0" for the asset "ETH" 305 306 When the oracles broadcast data signed with "0xCAFECAFE1": 307 | name | value | 308 | prices.ETH.value | 700 | 309 310 And the network moves ahead "3" blocks 311 And the insurance pool balance should be "0" for the market "ETH/DEC21" 312 And the insurance pool balance should be "10000" for the market "ETH/DEC19" 313 And the global insurance pool balance should be "10000" for the asset "ETH" 314 315 Then the market state should be "STATE_ACTIVE" for the market "ETH/DEC19" 316 317 When the parties place the following orders with ticks: 318 | party | market id | side | volume | price | resulting trades | type | tif | reference | 319 | party1 | ETH/DEC19 | sell | 2 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 320 | party2 | ETH/DEC19 | buy | 1 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | ref-2 | 321 | party3 | ETH/DEC19 | buy | 1 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | ref-3 | 322 323 And the cumulated balance for all accounts should be worth "200236000" 324 325 # Close positions by aux parties 326 When the parties place the following orders with ticks: 327 | party | market id | side | volume | price | resulting trades | type | tif | 328 | aux1 | ETH/DEC19 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 329 | aux2 | ETH/DEC19 | buy | 1 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | 330 331 When the oracles broadcast data signed with "0xCAFECAFE": 332 | name | value | 333 | trading.terminated | true | 334 335 And time is updated to "2020-01-01T01:01:01Z" 336 337 Then the market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC19" 338 Then the oracles broadcast data signed with "0xCAFECAFE": 339 | name | value | 340 | prices.ETH.value | 42 | 341 342 Then time is updated to "2020-01-01T01:01:02Z" 343 344 Then the parties place the following orders: 345 | party | market id | side | volume | price | resulting trades | type | tif | reference | error | 346 | party1 | ETH/DEC19 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | OrderError: Invalid Market ID | 347 348 And the parties should have the following account balances: 349 | party | asset | market id | margin | general | 350 | party1 | ETH | ETH/DEC19 | 0 | 11916 | 351 | party2 | ETH | ETH/DEC19 | 0 | 42 | 352 | party3 | ETH | ETH/DEC19 | 0 | 4042 | 353 354 When the network moves ahead "2" blocks 355 Then the cumulated balance for all accounts should be worth "200236000" 356 And the insurance pool balance should be "0" for the market "ETH/DEC19" 357 And the insurance pool balance should be "0" for the market "ETH/DEC21" 358 And the global insurance pool balance should be "20000" for the asset "ETH" 359 360 Scenario: Settlement happened when market is being closed - no loss socialisation needed - insurance covers losses (0002-STTL-008) 361 Given the initial insurance pool balance is "1000" for all the markets 362 Given the parties deposit on asset's general account the following amount: 363 | party | asset | amount | 364 | party1 | ETH | 10000 | 365 | party2 | ETH | 1000 | 366 | aux1 | ETH | 100000 | 367 | aux2 | ETH | 100000 | 368 | party-lp | ETH | 100000000 | 369 And the parties submit the following liquidity provision: 370 | id | party | market id | commitment amount | fee | lp type | 371 | lp1 | party-lp | ETH/DEC19 | 30000000 | 0 | submission | 372 | lp1 | party-lp | ETH/DEC19 | 30000000 | 0 | amendment | 373 And the parties place the following pegged iceberg orders: 374 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 375 | party-lp | ETH/DEC19 | 2 | 1 | buy | BID | 50 | 10 | 376 | party-lp | ETH/DEC19 | 2 | 1 | sell | ASK | 50 | 10 | 377 378 When the parties place the following orders: 379 | party | market id | side | volume | price | resulting trades | type | tif | reference | 380 | aux1 | ETH/DEC19 | buy | 1 | 999 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 381 | aux2 | ETH/DEC19 | sell | 1 | 1001 | 0 | TYPE_LIMIT | TIF_GTC | ref-2 | 382 | aux1 | ETH/DEC19 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-3 | 383 | aux2 | ETH/DEC19 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-4 | 384 Then the opening auction period ends for market "ETH/DEC19" 385 And the mark price should be "1000" for the market "ETH/DEC19" 386 387 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" 388 389 When the parties place the following orders with ticks: 390 | party | market id | side | volume | price | resulting trades | type | tif | reference | 391 | party1 | ETH/DEC19 | sell | 2 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 392 | party2 | ETH/DEC19 | buy | 2 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | ref-2 | 393 394 Then the parties should have the following account balances: 395 | party | asset | market id | margin | general | 396 | party1 | ETH | ETH/DEC19 | 840 | 9160 | 397 | party2 | ETH | ETH/DEC19 | 864 | 136 | 398 399 And the settlement account should have a balance of "0" for the market "ETH/DEC19" 400 And the cumulated balance for all accounts should be worth "100213000" 401 402 # Close positions by aux parties 403 When the parties place the following orders with ticks: 404 | party | market id | side | volume | price | resulting trades | type | tif | 405 | aux1 | ETH/DEC19 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 406 | aux2 | ETH/DEC19 | buy | 1 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | 407 408 When the oracles broadcast data signed with "0xCAFECAFE": 409 | name | value | 410 | trading.terminated | true | 411 And time is updated to "2020-01-01T01:01:01Z" 412 Then the market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC19" 413 Then the oracles broadcast data signed with "0xCAFECAFE": 414 | name | value | 415 | prices.ETH.value | 42 | 416 Then time is updated to "2020-01-01T01:01:02Z" 417 418 And the parties should have the following account balances: 419 | party | asset | market id | margin | general | 420 | party1 | ETH | ETH/DEC19 | 0 | 11916 | 421 | party2 | ETH | ETH/DEC19 | 0 | 0 | 422 423 When the network moves ahead "2" blocks 424 Then the cumulated balance for all accounts should be worth "100213000" 425 And the insurance pool balance should be "0" for the market "ETH/DEC19" 426 # 916 were taken from the insurance pool to cover the losses of party 2, the remaining is moved into the global insurance pool 427 And the global insurance pool balance should be "84" for the asset "ETH" 428 And the insurance pool balance should be "1000" for the market "ETH/DEC21" 429 430 Scenario: Settlement happened when market is being closed - loss socialisation in action - insurance doesn't cover all losses (0002-STTL-009) 431 Given the initial insurance pool balance is "500" for all the markets 432 Given the parties deposit on asset's general account the following amount: 433 | party | asset | amount | 434 | party1 | ETH | 10000 | 435 | party2 | ETH | 1000 | 436 | aux1 | ETH | 1000000 | 437 | aux2 | ETH | 1000000 | 438 | party-lp | ETH | 100000000 | 439 And the cumulated balance for all accounts should be worth "102012000" 440 441 And the parties submit the following liquidity provision: 442 | id | party | market id | commitment amount | fee | lp type | 443 | lp1 | party-lp | ETH/DEC19 | 30000000 | 0 | submission | 444 | lp1 | party-lp | ETH/DEC19 | 30000000 | 0 | amendment | 445 And the parties place the following pegged iceberg orders: 446 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 447 | party-lp | ETH/DEC19 | 2 | 1 | buy | BID | 50 | 10 | 448 | party-lp | ETH/DEC19 | 2 | 1 | sell | ASK | 50 | 10 | 449 When the parties place the following orders: 450 | party | market id | side | volume | price | resulting trades | type | tif | reference | 451 | aux1 | ETH/DEC19 | buy | 1 | 999 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 452 | aux2 | ETH/DEC19 | sell | 1 | 1001 | 0 | TYPE_LIMIT | TIF_GTC | ref-2 | 453 | aux1 | ETH/DEC19 | buy | 2 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-3 | 454 | aux2 | ETH/DEC19 | sell | 2 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-4 | 455 Then the opening auction period ends for market "ETH/DEC19" 456 And the mark price should be "1000" for the market "ETH/DEC19" 457 458 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC19" 459 460 When the parties place the following orders with ticks: 461 | party | market id | side | volume | price | resulting trades | type | tif | reference | 462 | party1 | ETH/DEC19 | sell | 2 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 463 | party2 | ETH/DEC19 | buy | 2 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | ref-2 | 464 Then the parties should have the following account balances: 465 | party | asset | market id | margin | general | 466 | party1 | ETH | ETH/DEC19 | 840 | 9160 | 467 | party2 | ETH | ETH/DEC19 | 864 | 136 | 468 And the settlement account should have a balance of "0" for the market "ETH/DEC19" 469 And the cumulated balance for all accounts should be worth "102012000" 470 471 When the oracles broadcast data signed with "0xCAFECAFE": 472 | name | value | 473 | trading.terminated | true | 474 475 And time is updated to "2020-01-01T01:01:01Z" 476 Then the market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC19" 477 When the oracles broadcast data signed with "0xCAFECAFE": 478 | name | value | 479 | prices.ETH.value | 42 | 480 And time is updated to "2020-01-01T01:01:02Z" 481 482 483 # 416 missing, but party1 & aux1 get a haircut of 209 each due to flooring 484 And the parties should have the following account balances: 485 | party | asset | market id | margin | general | 486 | party1 | ETH | ETH/DEC19 | 0 | 11709 | 487 | party2 | ETH | ETH/DEC19 | 0 | 0 | 488 And the cumulated balance for all accounts should be worth "102012000" 489 And the insurance pool balance should be "0" for the market "ETH/DEC19" 490 # 500 were taken from the insurance pool to cover the losses of party 2, still not enough to cover losses of (1000-42)*2 for party2 491 And the global insurance pool balance should be "0" for the asset "ETH" 492 And the insurance pool balance should be "500" for the market "ETH/DEC21" 493 494 Scenario: Settlement happened when market is being closed whilst being suspended (due to protective auction) - loss socialisation in action - insurance doesn't covers all losses (0002-STTL-004, 0002-STTL-009) 495 496 Given the initial insurance pool balance is "500" for all the markets 497 Given the parties deposit on asset's general account the following amount: 498 | party | asset | amount | 499 | party1 | ETH | 10000 | 500 | party2 | ETH | 1000 | 501 | aux1 | ETH | 1000000 | 502 | aux2 | ETH | 1000000 | 503 | party-lp | ETH | 100000000 | 504 And the cumulated balance for all accounts should be worth "102012000" 505 506 And the parties submit the following liquidity provision: 507 | id | party | market id | commitment amount | fee | lp type | 508 | lp1 | party-lp | ETH/DEC21 | 30000000 | 0 | submission | 509 | lp1 | party-lp | ETH/DEC21 | 30000000 | 0 | amendment | 510 And the parties place the following pegged iceberg orders: 511 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 512 | party-lp | ETH/DEC21 | 2 | 1 | buy | BID | 50 | 10 | 513 | party-lp | ETH/DEC21 | 2 | 1 | sell | ASK | 50 | 10 | 514 When the parties place the following orders: 515 | party | market id | side | volume | price | resulting trades | type | tif | reference | 516 | aux1 | ETH/DEC21 | buy | 1 | 890 | 0 | TYPE_LIMIT | TIF_GTC | ref-1 | 517 | aux2 | ETH/DEC21 | sell | 1 | 1110 | 0 | TYPE_LIMIT | TIF_GTC | ref-2 | 518 | aux1 | ETH/DEC21 | buy | 2 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-3 | 519 | aux2 | ETH/DEC21 | sell | 2 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-4 | 520 Then the opening auction period ends for market "ETH/DEC21" 521 And the mark price should be "1000" for the market "ETH/DEC21" 522 523 And the trading mode should be "TRADING_MODE_CONTINUOUS" for the market "ETH/DEC21" 524 525 When the parties place the following orders with ticks: 526 | party | market id | side | volume | price | resulting trades | type | tif | reference | 527 | party1 | ETH/DEC21 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | ref-5 | 528 | party2 | ETH/DEC21 | buy | 1 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | ref-6 | 529 530 And the mark price should be "1000" for the market "ETH/DEC21" 531 532 Then the parties should have the following profit and loss: 533 | party | volume | unrealised pnl | realised pnl | 534 | party1 | -1 | 0 | 0 | 535 | party2 | 1 | 0 | 0 | 536 537 And the parties should have the following account balances: 538 | party | asset | market id | margin | general | 539 | party1 | ETH | ETH/DEC21 | 420 | 9585 | 540 | party2 | ETH | ETH/DEC21 | 540 | 435 | 541 542 And then the network moves ahead "10" blocks 543 544 When the parties place the following orders with ticks: 545 | party | market id | side | volume | price | resulting trades | type | tif | reference | 546 | party1 | ETH/DEC21 | sell | 1 | 1101 | 0 | TYPE_LIMIT | TIF_GTC | ref-7 | 547 | party2 | ETH/DEC21 | buy | 1 | 1101 | 0 | TYPE_LIMIT | TIF_GTC | ref-8 | 548 549 And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/DEC21" 550 And the market state should be "STATE_SUSPENDED" for the market "ETH/DEC21" 551 552 And then the network moves ahead "10" blocks 553 554 When the oracles broadcast data signed with "0xCAFECAFE1": 555 | name | value | 556 | trading.terminated | true | 557 558 And then the network moves ahead "1" blocks 559 560 Then the market state should be "STATE_TRADING_TERMINATED" for the market "ETH/DEC21" 561 562 And then the network moves ahead "400" blocks 563 564 Then the parties should have the following profit and loss: 565 | party | volume | unrealised pnl | realised pnl | 566 | party1 | -1 | 0 | 0 | 567 | party2 | 1 | 0 | 0 | 568 569 And then the network moves ahead "10" blocks 570 571 When the oracles broadcast data signed with "0xCAFECAFE1": 572 | name | value | 573 | prices.ETH.value | 800 | 574 575 And then the network moves ahead "10" blocks 576 577 # Check that party positions and overall account balances are the same as before auction start (accounting for a settlement transfer of 200 from party2 to party1) 578 Then the parties should have the following profit and loss: 579 | party | volume | unrealised pnl | realised pnl | 580 | party1 | -1 | 0 | 200 | 581 | party2 | 1 | 0 | -200 | 582 583 And the parties should have the following account balances: 584 | party | asset | market id | margin | general | 585 | party1 | ETH | ETH/DEC21 | 0 | 10205 | 586 | party2 | ETH | ETH/DEC21 | 0 | 775 | 587 588 And the cumulated balance for all accounts should be worth "102012000" 589 And the insurance pool balance should be "0" for the market "ETH/DEC21" 590 And the global insurance pool balance should be "500" for the asset "ETH" 591 And the insurance pool balance should be "500" for the market "ETH/DEC19"