code.vegaprotocol.io/vega@v0.79.0/core/integration/features/margin/0019-MCAL-201.feature (about) 1 Feature: Amending order trades in full, plenty of balance to cover the order amendment + trades + fees 2 Background: 3 Given the average block duration is "1" 4 And the following network parameters are set: 5 | name | value | 6 | network.markPriceUpdateMaximumFrequency | 0s | 7 | limits.markets.maxPeggedOrders | 6 | 8 | market.auction.minimumDuration | 1 | 9 And the price monitoring named "my-price-monitoring-1": 10 | horizon | probability | auction extension | 11 | 5 | 0.99 | 6 | 12 13 And the liquidity monitoring parameters: 14 | name | triggering ratio | time window | scaling factor | 15 | lqm-params | 0.00 | 24h | 1e-9 | 16 And the simple risk model named "simple-risk-model": 17 | long | short | max move up | min move down | probability of trading | 18 | 0.1 | 0.2 | 100 | -100 | 0.2 | 19 And the markets: 20 | id | quote name | asset | liquidity monitoring | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | position decimal places | sla params | 21 | ETH/FEB23 | ETH | USD | lqm-params | simple-risk-model | default-margin-calculator | 1 | default-none | my-price-monitoring-1 | default-eth-for-future | 0.000125 | 0 | 2 | default-futures | 22 23 @MCAL201 24 Scenario: 25 Given the parties deposit on asset's general account the following amount: 26 | party | asset | amount | 27 | trader1 | USD | 100000000000 | 28 | trader2 | USD | 100000000000 | 29 | trader3 | USD | 100000000000 | 30 | trader4 | USD | 100000000000 | 31 | lprov1 | USD | 100000000000 | 32 33 And the parties submit the following liquidity provision: 34 | id | party | market id | commitment amount | fee | lp type | 35 | lp1 | lprov1 | ETH/FEB23 | 1000 | 0.1 | submission | 36 37 And the parties place the following orders with ticks: 38 | party | market id | side | volume | price | resulting trades | type | tif | reference | 39 | trader1 | ETH/FEB23 | buy | 1000 | 14900 | 0 | TYPE_LIMIT | TIF_GTC | | 40 | trader1 | ETH/FEB23 | buy | 300 | 15600 | 0 | TYPE_LIMIT | TIF_GTC | | 41 | lprov1 | ETH/FEB23 | buy | 100 | 15700 | 0 | TYPE_LIMIT | TIF_GTC | lp-buy-1 | 42 | trader3 | ETH/FEB23 | buy | 300 | 15800 | 0 | TYPE_LIMIT | TIF_GTC | | 43 | lprov1 | ETH/FEB23 | sell | 300 | 15800 | 0 | TYPE_LIMIT | TIF_GTC | lp-sell-1 | 44 | trader2 | ETH/FEB23 | sell | 600 | 15802 | 0 | TYPE_LIMIT | TIF_GTC | t2-sell-1 | 45 | trader2 | ETH/FEB23 | sell | 300 | 200000 | 0 | TYPE_LIMIT | TIF_GTC | | 46 | trader2 | ETH/FEB23 | sell | 1000 | 200100 | 0 | TYPE_LIMIT | TIF_GTC | | 47 48 When the network moves ahead "2" blocks 49 Then the market data for the market "ETH/FEB23" should be: 50 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 51 | 15800 | TRADING_MODE_CONTINUOUS | 5 | 15701 | 15899 | 0 | 1000 | 300 | 52 53 When the parties place the following pegged orders: 54 | party | market id | side | volume | pegged reference | offset | reference | 55 | lprov1 | ETH/FEB23 | buy | 100 | BID | 10 | buy_peg_1 | 56 | lprov1 | ETH/FEB23 | buy | 200 | BID | 20 | buy_peg_2 | 57 58 Then the parties should have the following margin levels: 59 | party | market id | maintenance | margin mode | margin factor | order | 60 | lprov1 | ETH/FEB23 | 9486 | cross margin | 0 | 0 | 61 | trader1 | ETH/FEB23 | 20540 | cross margin | 0 | 0 | 62 | trader3 | ETH/FEB23 | 4746 | cross margin | 0 | 0 | 63 64 When the parties place the following orders with ticks: 65 | party | market id | side | volume | price | resulting trades | type | tif | reference | 66 | trader3 | ETH/FEB23 | buy | 100 | 15500 | 0 | TYPE_LIMIT | TIF_GTC | t3-to-amend | 67 Then the parties should have the following margin levels: 68 | party | market id | maintenance | margin mode | margin factor | order | 69 | trader3 | ETH/FEB23 | 6326 | cross margin | 0 | 0 | 70 71 When the parties submit update margin mode: 72 | party | market | margin_mode | margin_factor | error | 73 | trader3 | ETH/FEB23 | isolated margin | 0.3 | | 74 Then the parties should have the following margin levels: 75 | party | market id | maintenance | search | release | margin mode | margin factor | order | 76 | trader3 | ETH/FEB23 | 4746 | 0 | 0 | isolated margin | 0.3 | 4650 | 77 And the parties should have the following account balances: 78 | party | asset | market id | margin | general | 79 | trader3 | USD | ETH/FEB23 | 14220 | 99999981130 | 80 81 # amend the order to increase the required margin, and the order trades in full 82 When the parties amend the following orders: 83 | party | reference | price | size delta | tif | error | 84 | trader3 | t3-to-amend | 15802 | -90 | TIF_GTC | | 85 Then the orders should have the following status: 86 | party | reference | status | 87 | trader3 | t3-to-amend | STATUS_FILLED | 88 And the parties should have the following margin levels: 89 | party | market id | maintenance | search | release | margin mode | margin factor | order | 90 | trader3 | ETH/FEB23 | 4905 | 0 | 0 | isolated margin | 0.3 | 0 | 91 And the parties should have the following account balances: 92 | party | asset | market id | margin | general | 93 | trader3 | USD | ETH/FEB23 | 14694 | 99999985147 | 94