code.vegaprotocol.io/vega@v0.79.0/core/integration/features/capped-futures/0016-PFUT-016.feature (about) 1 Feature: Oracle price data within range is used to determine the mid price 2 3 Background: 4 Given the following network parameters are set: 5 | name | value | 6 | network.markPriceUpdateMaximumFrequency | 1s | 7 | market.auction.minimumDuration | 1 | 8 | limits.markets.maxPeggedOrders | 2 | 9 Given the following assets are registered: 10 | id | decimal places | 11 | DAI | 2 | 12 Given the liquidity monitoring parameters: 13 | name | triggering ratio | time window | scaling factor | 14 | lqm-params | 1.0 | 20s | 10 | 15 And the log normal risk model named "dai-lognormal-risk": 16 | risk aversion | tau | mu | r | sigma | 17 | 0.00001 | 0.000114077 | 0 | 0 | 0.41 | 18 And the composite price oracles from "0xCAFECAFE1": 19 | name | price property | price type | price decimals | 20 | oracle1 | price1.USD.value | TYPE_INTEGER | 0 | 21 And the markets: 22 | id | quote name | asset | liquidity monitoring | risk model | margin calculator | auction duration | fees | price monitoring | data source config | decimal places | linear slippage factor | quadratic slippage factor | sla params | max price cap | binary | fully collateralised | price type | decay weight | decay power | cash amount | source weights | source staleness tolerance | oracle1 | 23 | DAI/DEC22 | DAI | DAI | lqm-params | dai-lognormal-risk | default-margin-calculator | 1 | default-none | default-none | default-eth-for-future | 2 | 0.25 | 0 | default-futures | 4500000 | false | false | weight | 1 | 1 | 0 | 0,0,1,0 | 0s,0s,10s,0s | oracle1 | 24 25 @MidPrice @NoPerp @Capped 26 Scenario: 0016-PFUT-016: When a market is setup to use oracle based mark price and the value received from oracle is less than max_price then it gets used as is and mark-to-market flows are calculated according to that price. 27 Given the parties deposit on asset's general account the following amount: 28 | party | asset | amount | 29 | party1 | DAI | 110000000 | 30 | party2 | DAI | 110000000 | 31 | party3 | DAI | 110000000 | 32 | party4 | DAI | 110000000 | 33 | party5 | DAI | 110000000 | 34 35 And the average block duration is "1" 36 37 And the parties submit the following liquidity provision: 38 | id | party | market id | commitment amount | fee | reference | lp type | 39 | lp1 | party1 | DAI/DEC22 | 200000 | 0.01 | lp-1 | submission | 40 | lp1 | party1 | DAI/DEC22 | 200000 | 0.01 | lp-1 | submission | 41 And the parties place the following pegged iceberg orders: 42 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 43 | party1 | DAI/DEC22 | 5 | 3 | buy | MID | 5 | 100000 | 44 | party1 | DAI/DEC22 | 5 | 3 | sell | MID | 5 | 100000 | 45 46 #0016-PFUT-014:When `max_price` is specified, an order with a `price > max_price` gets rejected. 47 When the parties place the following orders: 48 | party | market id | side | volume | price | resulting trades | type | tif | reference | error | 49 | party2 | DAI/DEC22 | buy | 1 | 2500000 | 0 | TYPE_LIMIT | TIF_GTC | party2-1 | | 50 | party2 | DAI/DEC22 | buy | 1 | 3500000 | 0 | TYPE_LIMIT | TIF_GTC | party2-2 | | 51 | party3 | DAI/DEC22 | sell | 1 | 3500000 | 0 | TYPE_LIMIT | TIF_GTC | party3-1 | | 52 | party3 | DAI/DEC22 | sell | 1 | 4499999 | 0 | TYPE_LIMIT | TIF_GTC | party3-2 | | 53 | party3 | DAI/DEC22 | sell | 1 | 8000000 | 0 | TYPE_LIMIT | TIF_GTC | party3-2 | invalid order price | 54 55 And the opening auction period ends for market "DAI/DEC22" 56 Then the following trades should be executed: 57 | buyer | price | size | seller | 58 | party2 | 3500000 | 1 | party3 | 59 60 And the market data for the market "DAI/DEC22" should be: 61 | mark price | best static bid price | static mid price | best static offer price | 62 | 3500000 | 2500000 | 3499999 | 4499999 | 63 And debug detailed orderbook volumes for market "DAI/DEC22" 64 And the order book should have the following volumes for market "DAI/DEC22": 65 | side | price | volume | 66 | sell | 3599999 | 5 | 67 | sell | 4499999 | 1 | 68 | buy | 3400000 | 5 | 69 | buy | 2500000 | 1 | 70 71 When the parties place the following orders: 72 | party | market id | side | volume | price | resulting trades | type | tif | reference | 73 | party4 | DAI/DEC22 | buy | 1 | 3200000 | 0 | TYPE_LIMIT | TIF_GTC | party2-2 | 74 | party5 | DAI/DEC22 | sell | 1 | 3200000 | 1 | TYPE_LIMIT | TIF_GTC | party3-1 | 75 When the network moves ahead "2" blocks 76 Then the mark price should be "3500000" for the market "DAI/DEC22" 77 78 #0016-PFUT-017: When `max_price` set by oracle, `mark price > max_price`, then it gets ignored and mark-to-market settlement doesn't occur 79 Then the oracles broadcast data with block time signed with "0xCAFECAFE1": 80 | name | value | time offset | 81 | price1.USD.value | 330000 | -1s | 82 83 When the network moves ahead "2" blocks 84 Then the mark price should be "3500000" for the market "DAI/DEC22" 85 86 #0016-PFUT-016: When `max_price` set by oracle, `mark price < max_price`, then it gets used 87 Then the oracles broadcast data with block time signed with "0xCAFECAFE1": 88 | name | value | time offset | 89 | price1.USD.value | 32000 | -1s | 90 91 When the network moves ahead "2" blocks 92 Then the mark price should be "3200000" for the market "DAI/DEC22" 93 94 # #MTM happens if mark price < max_price 95 And the following transfers should happen: 96 | type | from | to | from account | to account | market id | amount | asset | 97 | TRANSFER_TYPE_MTM_LOSS | party1 | market | ACCOUNT_TYPE_MARGIN | ACCOUNT_TYPE_SETTLEMENT | DAI/DEC22 | 300000 | DAI | 98 | TRANSFER_TYPE_MTM_WIN | market | party3 | ACCOUNT_TYPE_SETTLEMENT | ACCOUNT_TYPE_MARGIN | DAI/DEC22 | 300000 | DAI | 99 100