code.vegaprotocol.io/vega@v0.79.0/core/integration/features/liquidity-provision/0044-LIME-077.feature (about) 1 Feature: Test LP mechanics when there are multiple liquidity providers, test stop-loss orders and parked orders (does not count towards LP commitment) 2 3 Background: 4 5 Given the margin calculator named "margin-calculator-1": 6 | search factor | initial factor | release factor | 7 | 1.2 | 1.5 | 1.7 | 8 Given the log normal risk model named "log-normal-risk-model": 9 | risk aversion | tau | mu | r | sigma | 10 | 0.000001 | 0.1 | 0 | 0 | 1.0 | 11 And the following network parameters are set: 12 | name | value | 13 | market.value.windowLength | 60s | 14 | network.markPriceUpdateMaximumFrequency | 0s | 15 | limits.markets.maxPeggedOrders | 6 | 16 | market.auction.minimumDuration | 1 | 17 | market.fee.factors.infrastructureFee | 0.001 | 18 | market.fee.factors.makerFee | 0.004 | 19 | spam.protection.max.stopOrdersPerMarket | 5 | 20 And the liquidity monitoring parameters: 21 | name | triggering ratio | time window | scaling factor | 22 | lqm-params | 1.0 | 20s | 1 | 23 #risk factor short:3.5569036 24 #risk factor long:0.801225765 25 And the following assets are registered: 26 | id | decimal places | 27 | USD | 0 | 28 And the fees configuration named "fees-config-1": 29 | maker fee | infrastructure fee | 30 | 0.0004 | 0.001 | 31 ## Set auction duration to 3 epochs 32 And the price monitoring named "price-monitoring": 33 | horizon | probability | auction extension | 34 | 3600 | 0.99 | 30 | 35 36 And the liquidity sla params named "SLA-22": 37 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 38 | 0.5 | 0.6 | 1 | 1.0 | 39 And the liquidity sla params named "SLA-23": 40 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 41 | 0 | 0.6 | 1 | 1.0 | 42 43 And the markets: 44 | 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 | 45 | ETH/MAR22 | USD | USD | lqm-params | log-normal-risk-model | margin-calculator-1 | 2 | fees-config-1 | price-monitoring | default-eth-for-future | 1e0 | 0 | SLA-22 | 46 | ETH/MAR23 | USD | USD | lqm-params | log-normal-risk-model | margin-calculator-1 | 2 | fees-config-1 | price-monitoring | default-eth-for-future | 1e0 | 0 | SLA-23 | 47 48 And the following network parameters are set: 49 | name | value | 50 | market.liquidity.bondPenaltyParameter | 0.2 | 51 | market.liquidity.stakeToCcyVolume | 1 | 52 | market.liquidity.successorLaunchWindowLength | 1h | 53 | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0.1 | 54 | market.liquidity.sla.nonPerformanceBondPenaltyMax | 0.6 | 55 | validators.epoch.length | 10s | 56 | market.liquidity.earlyExitPenalty | 0.25 | 57 | market.liquidity.maximumLiquidityFeeFactorLevel | 0.25 | 58 59 Given the average block duration is "1" 60 @Now 61 Scenario: 001: lp1 and lp2 on the market ETH/MAR22, 0044-LIME-077, 0042-LIQF-054 62 Given the parties deposit on asset's general account the following amount: 63 | party | asset | amount | 64 | lp1 | USD | 100000 | 65 | lp2 | USD | 100000 | 66 | lp3 | USD | 100000 | 67 | party1 | USD | 100000 | 68 | party2 | USD | 100000 | 69 | party3 | USD | 100000 | 70 | ptbuy | USD | 100000 | 71 | ptsell | USD | 100000 | 72 73 And the parties submit the following liquidity provision: 74 | id | party | market id | commitment amount | fee | lp type | 75 | lp_1 | lp1 | ETH/MAR22 | 6000 | 0.02 | submission | 76 | lp_2 | lp2 | ETH/MAR22 | 4000 | 0.015 | submission | 77 78 When the network moves ahead "4" blocks 79 And the current epoch is "0" 80 81 # AC: 0042-LIQF-054: If an LP has an active liquidity provision at the start of an epoch and no previous performance penalties and throughout the epoch always meets their liquidity provision requirements 82 # then they will have a `fraction_of_time_on_book == 1` then no penalty will be applied to their liquidity fee payments at the end of the epoch. 83 Then the parties place the following orders: 84 | party | market id | side | volume | price | resulting trades | type | tif | reference | 85 | party1 | ETH/MAR22 | buy | 10 | 900 | 0 | TYPE_LIMIT | TIF_GTC | | 86 | party1 | ETH/MAR22 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | | 87 | party2 | ETH/MAR22 | sell | 10 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | | 88 | party2 | ETH/MAR22 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | | 89 | lp1 | ETH/MAR22 | buy | 10 | 950 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 90 | lp2 | ETH/MAR22 | buy | 10 | 970 | 0 | TYPE_LIMIT | TIF_GTC | lp2-b | 91 | lp2 | ETH/MAR22 | sell | 10 | 1020 | 0 | TYPE_LIMIT | TIF_GTC | lp2-s | 92 | lp1 | ETH/MAR22 | sell | 10 | 1050 | 0 | TYPE_LIMIT | TIF_GTC | lp1-s | 93 94 Then the opening auction period ends for market "ETH/MAR22" 95 And the following trades should be executed: 96 | buyer | price | size | seller | 97 | party1 | 1000 | 1 | party2 | 98 99 And the market data for the market "ETH/MAR22" should be: 100 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 101 | 1000 | TRADING_MODE_CONTINUOUS | 3600 | 973 | 1027 | 3556 | 10000 | 1 | 102 # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1000 x 1 x 1 x 3.5569036 =3556 103 104 When the network moves ahead "1" epochs 105 And the supplied stake should be "10000" for the market "ETH/MAR22" 106 And the insurance pool balance should be "0" for the market "ETH/MAR22" 107 And the current epoch is "1" 108 Then the parties should have the following account balances: 109 | party | asset | market id | margin | general | bond | 110 | lp1 | USD | ETH/MAR22 | 56022 | 37978 | 6000 | 111 | lp2 | USD | ETH/MAR22 | 54421 | 41579 | 4000 | 112 113 Then the parties cancel the following orders: 114 | party | reference | 115 | lp1 | lp1-b | 116 | lp2 | lp2-b | 117 | lp2 | lp2-s | 118 | lp1 | lp1-s | 119 Then the network moves ahead "1" blocks 120 121 #AC 0044-LIME-077: Parked pegged limit orders and stop-loss orders do not count towards an LPs liquidity commitment. 122 # post-only orders count towards an LPs liquidity commitment 123 Then the parties place the following orders: 124 | party | market id | side | volume | price | resulting trades | type | tif | reference | only | 125 | lp1 | ETH/MAR22 | buy | 10 | 950 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | post | 126 | lp2 | ETH/MAR22 | buy | 10 | 970 | 0 | TYPE_LIMIT | TIF_GTC | lp2-b | post | 127 | lp2 | ETH/MAR22 | sell | 10 | 1020 | 0 | TYPE_LIMIT | TIF_GTC | lp2-s | post | 128 | lp1 | ETH/MAR22 | sell | 10 | 1050 | 0 | TYPE_LIMIT | TIF_GTC | lp1-s | post | 129 130 When the network moves ahead "1" epochs 131 And the supplied stake should be "10000" for the market "ETH/MAR22" 132 133 Then the parties cancel the following orders: 134 | party | reference | 135 | lp1 | lp1-b | 136 | lp1 | lp1-s | 137 138 Then the parties place the following orders: 139 | party | market id | side | volume | price | resulting trades | type | tif | 140 | lp1 | ETH/MAR22 | sell | 2 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 141 | lp2 | ETH/MAR22 | buy | 2 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | 142 Then the network moves ahead "1" blocks 143 144 Then the parties place the following orders: 145 | party | market id | side | volume | price | resulting trades | type | tif | reference | only | fb price trigger | 146 | lp1 | ETH/MAR22 | buy | 2 | 950 | 0 | TYPE_MARKET | TIF_GTC | lp1-b-stop-order | reduce | 900 | 147 148 When the network moves ahead "1" epochs 149 150 Then the supplied stake should be "9400" for the market "ETH/MAR22" 151 And the current epoch is "3" 152 And the insurance pool balance should be "600" for the market "ETH/MAR22" 153 And the following transfers should happen: 154 | from | to | from account | to account | market id | amount | asset | 155 | lp1 | market | ACCOUNT_TYPE_BOND | ACCOUNT_TYPE_INSURANCE | ETH/MAR22 | 600 | USD | 156 157 ## Trigger price monitoring auction by trading outside of price bound (973-1027) 158 ## Ensure volume on the book after leaving auction at 900-990 159 When the parties place the following orders: 160 | party | market id | side | volume | price | resulting trades | type | tif | 161 | ptbuy | ETH/MAR22 | buy | 2 | 970 | 0 | TYPE_LIMIT | TIF_GTC | 162 | ptsell | ETH/MAR22 | sell | 2 | 970 | 0 | TYPE_LIMIT | TIF_GTC | 163 | ptbuy | ETH/MAR22 | sell | 1 | 990 | 0 | TYPE_LIMIT | TIF_GTC | 164 | ptsell | ETH/MAR22 | buy | 1 | 900 | 0 | TYPE_LIMIT | TIF_GTC | 165 166 Then the market data for the market "ETH/MAR22" should be: 167 | mark price | trading mode | auction trigger | target stake | supplied stake | open interest | auction end | 168 | 1000 | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | 17250 | 9400 | 3 | 30 | 169 170 And the parties place the following pegged iceberg orders: 171 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference | 172 | lp1 | ETH/MAR22 | 12 | 1 | buy | BID | 12 | 20 | lp1-b | 173 | lp1 | ETH/MAR22 | 12 | 1 | sell | ASK | 12 | 20 | lp1-s | 174 When the network moves ahead "1" blocks 175 176 And the orders should have the following status: 177 | party | reference | status | 178 | lp1 | lp1-b | STATUS_PARKED | 179 | lp1 | lp1-s | STATUS_PARKED | 180 181 When the network moves ahead "1" epochs 182 And the market data for the market "ETH/MAR22" should be: 183 | mark price | trading mode | target stake | supplied stake | open interest | auction end | 184 | 1000 | TRADING_MODE_MONITORING_AUCTION | 17250 | 8860 | 3 | 30 | 185 186 #lp1 got bond penalty for placing parked order 187 Then the following transfers should happen: 188 | from | to | from account | to account | market id | amount | asset | 189 | lp1 | market | ACCOUNT_TYPE_BOND | ACCOUNT_TYPE_INSURANCE | ETH/MAR22 | 540 | USD | 190 And the insurance pool balance should be "1140" for the market "ETH/MAR22" 191 192