code.vegaprotocol.io/vega@v0.79.0/core/integration/features/liquidity-provision/0044-LIME-026.feature (about) 1 Feature: Check we process commitment changes in time order 2 3 # For a futures market with market.liquidity.earlyExitPenalty = 0.25 and 4 # total stake = target stake + 140 already, if the following transactions occur: 5 # * LP1 places a transaction to reduce their stake by 30 6 # * LP2 places a transaction to reduce their stake by 100, 7 # * LP1 places a transaction to update their reduction to 100 8 # LP2 will receive a full 100 stake back 9 # whilst LP1 will receive a total of 85 back into their general account with 10 # 15 transferred into the market's insurance account (0044-LIME-026) 11 12 Background: 13 Given the following network parameters are set: 14 | name | value | 15 | market.liquidity.bondPenaltyParameter | 1 | 16 | network.markPriceUpdateMaximumFrequency | 0s | 17 | limits.markets.maxPeggedOrders | 2 | 18 | validators.epoch.length | 5s | 19 | market.liquidity.earlyExitPenalty | 0.25 | 20 | market.liquidity.stakeToCcyVolume | 1.0 | 21 | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0.19 | 22 | market.liquidity.sla.nonPerformanceBondPenaltyMax | 1 | 23 And the liquidity monitoring parameters: 24 | name | triggering ratio | time window | scaling factor | 25 | lqm-params | 0.1 | 24h | 1 | 26 And the average block duration is "1" 27 And the simple risk model named "simple-risk-model-1": 28 | long | short | max move up | min move down | probability of trading | 29 | 0.1 | 0.1 | 60 | 50 | 0.2 | 30 And the fees configuration named "fees-config-1": 31 | maker fee | infrastructure fee | 32 | 0.004 | 0.001 | 33 And the price monitoring named "price-monitoring-1": 34 | horizon | probability | auction extension | 35 | 1 | 0.99 | 5 | 36 And the liquidity sla params named "SLA": 37 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 38 | 0.01 | 0.5 | 1 | 1.0 | 39 And the markets: 40 | id | quote name | asset | liquidity monitoring | risk model | margin calculator | auction duration | fees | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | 41 | ETH/DEC21 | ETH | ETH | lqm-params | simple-risk-model-1 | default-margin-calculator | 1 | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.5 | 0 | SLA | 42 And the parties deposit on asset's general account the following amount: 43 | party | asset | amount | 44 | party1 | ETH | 100000000 | 45 | party2 | ETH | 100000000 | 46 | party3 | ETH | 100000000 | 47 | party4 | ETH | 100000000 | 48 And the parties submit the following liquidity provision: 49 | id | party | market id | commitment amount | fee | lp type | 50 | lp1 | party1 | ETH/DEC21 | 570 | 0.001 | submission | 51 | lp2 | party2 | ETH/DEC21 | 570 | 0.001 | submission | 52 And the parties place the following orders: 53 | party | market id | side | volume | price | resulting trades | type | tif | reference | 54 | party3 | ETH/DEC21 | buy | 1000 | 900 | 0 | TYPE_LIMIT | TIF_GTC | p3b1 | 55 | party3 | ETH/DEC21 | buy | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | p3b2 | 56 | party4 | ETH/DEC21 | sell | 1000 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | p4s1 | 57 | party4 | ETH/DEC21 | sell | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | p4s2 | 58 59 Scenario: 001, Check commitment updated are handling in time order 60 When the opening auction period ends for market "ETH/DEC21" 61 And the auction ends with a traded volume of "10" at a price of "1000" 62 Then the market data for the market "ETH/DEC21" should be: 63 | mark price | trading mode | target stake | supplied stake | open interest | best static bid price | static mid price | best static offer price | 64 | 1000 | TRADING_MODE_CONTINUOUS | 1000 | 1140 | 10 | 900 | 1000 | 1100 | 65 # Place LIMIT orders to cover our commitment 66 And the parties place the following orders: 67 | party | market id | side | volume | price | resulting trades | type | tif | reference | 68 | party1 | ETH/DEC21 | buy | 10 | 999 | 0 | TYPE_LIMIT | TIF_GTC | party1-order1 | 69 | party1 | ETH/DEC21 | sell | 10 | 1001 | 0 | TYPE_LIMIT | TIF_GTC | party1-order2 | 70 | party2 | ETH/DEC21 | buy | 10 | 999 | 0 | TYPE_LIMIT | TIF_GTC | party2-order1 | 71 | party2 | ETH/DEC21 | sell | 10 | 1001 | 0 | TYPE_LIMIT | TIF_GTC | party2-order2 | 72 When the network moves ahead "1" blocks 73 Then the liquidity provisions should have the following states: 74 | id | party | market | commitment amount | status | 75 | lp1 | party1 | ETH/DEC21 | 570 | STATUS_ACTIVE | 76 | lp2 | party2 | ETH/DEC21 | 570 | STATUS_ACTIVE | 77 And the parties should have the following account balances: 78 | party | asset | market id | margin | general | bond | 79 | party1 | ETH | ETH/DEC21 | 1200 | 99998230 | 570 | 80 | party2 | ETH | ETH/DEC21 | 1200 | 99998230 | 570 | 81 And the insurance pool balance should be "0" for the market "ETH/DEC21" 82 83 84 # Now the parties try to reduce their commitment 85 And the parties submit the following liquidity provision: 86 | id | party | market id | commitment amount | fee | lp type | 87 | lp1 | party1 | ETH/DEC21 | 540 | 0.001 | amendment | 88 When the network moves ahead "5" blocks 89 90 91 And the parties submit the following liquidity provision: 92 | id | party | market id | commitment amount | fee | lp type | 93 | lp2 | party2 | ETH/DEC21 | 470 | 0.001 | amendment | 94 When the network moves ahead "7" blocks 95 96 And the parties submit the following liquidity provision: 97 | id | party | market id | commitment amount | fee | lp type | 98 | lp1 | party1 | ETH/DEC21 | 470 | 0.001 | amendment | 99 When the network moves ahead "7" blocks 100 101 102 Then the liquidity provisions should have the following states: 103 | id | party | market | commitment amount | status | 104 | lp1 | party1 | ETH/DEC21 | 470 | STATUS_ACTIVE | 105 | lp2 | party2 | ETH/DEC21 | 470 | STATUS_ACTIVE | 106 107 And the parties should have the following account balances: 108 | party | asset | market id | margin | general | bond | 109 | party1 | ETH | ETH/DEC21 | 1200 | 99998315 | 470 | 110 | party2 | ETH | ETH/DEC21 | 1200 | 99998330 | 470 | 111 And the insurance pool balance should be "15" for the market "ETH/DEC21" 112