code.vegaprotocol.io/vega@v0.79.0/core/integration/features/liquidity-provision/0044-LIME-020.feature (about) 1 Feature: Test LP mechanics when there are multiple liquidity providers; 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 liquidity monitoring parameters: 12 | name | triggering ratio | time window | scaling factor | 13 | lqm-params | 1.0 | 20s | 1 | 14 15 And the following network parameters are set: 16 | name | value | 17 | market.value.windowLength | 60s | 18 | network.markPriceUpdateMaximumFrequency | 0s | 19 | limits.markets.maxPeggedOrders | 6 | 20 | market.auction.minimumDuration | 1 | 21 | market.fee.factors.infrastructureFee | 0.001 | 22 | market.fee.factors.makerFee | 0.004 | 23 | market.liquidity.equityLikeShareFeeFraction | 1 | 24 #risk factor short:3.5569036 25 #risk factor long:0.801225765 26 And the following assets are registered: 27 | id | decimal places | 28 | USD | 0 | 29 And the fees configuration named "fees-config-1": 30 | maker fee | infrastructure fee | 31 | 0.0004 | 0.001 | 32 And the price monitoring named "price-monitoring": 33 | horizon | probability | auction extension | 34 | 3600 | 0.99 | 3 | 35 36 And the liquidity sla params named "SLA": 37 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 38 | 0.5 | 0.5 | 1 | 1.0 | 39 40 And the markets: 41 | 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 | 42 | 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 | 43 | 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 | 44 45 And the following network parameters are set: 46 | name | value | 47 | market.liquidity.bondPenaltyParameter | 0.2 | 48 | validators.epoch.length | 5s | 49 | market.liquidity.stakeToCcyVolume | 1 | 50 | market.liquidity.successorLaunchWindowLength | 1h | 51 | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0.5 | 52 | market.liquidity.sla.nonPerformanceBondPenaltyMax | 1 | 53 | validators.epoch.length | 10s | 54 | market.liquidity.earlyExitPenalty | 0.25 | 55 56 Given the average block duration is "2" 57 @Now 58 Scenario: 001: lp1 and lp2 under supplies liquidity 59 Given the parties deposit on asset's general account the following amount: 60 | party | asset | amount | 61 | lp1 | USD | 100000 | 62 | lp2 | USD | 100000 | 63 | party1 | USD | 100000 | 64 | party2 | USD | 100000 | 65 | party3 | USD | 100000 | 66 67 And the parties submit the following liquidity provision: 68 | id | party | market id | commitment amount | fee | lp type | 69 | lp_1 | lp1 | ETH/MAR22 | 50000 | 0.02 | submission | 70 | lp_2 | lp2 | ETH/MAR22 | 10000 | 0.015 | submission | 71 72 When the network moves ahead "2" blocks 73 And the parties place the following pegged iceberg orders: 74 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference | 75 | lp1 | ETH/MAR22 | 12 | 1 | buy | BID | 12 | 20 | lp-b-1 | 76 | lp1 | ETH/MAR22 | 12 | 1 | sell | ASK | 12 | 20 | lp-s-1 | 77 | lp2 | ETH/MAR22 | 6 | 1 | buy | BID | 6 | 20 | lp-b-2 | 78 | lp2 | ETH/MAR22 | 6 | 1 | sell | ASK | 6 | 20 | lp-s-2 | 79 80 Then the parties place the following orders: 81 | party | market id | side | volume | price | resulting trades | type | tif | 82 | party1 | ETH/MAR22 | buy | 10 | 900 | 0 | TYPE_LIMIT | TIF_GTC | 83 | party1 | ETH/MAR22 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 84 | party2 | ETH/MAR22 | sell | 10 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | 85 | party2 | ETH/MAR22 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 86 87 Then the opening auction period ends for market "ETH/MAR22" 88 And the following trades should be executed: 89 | buyer | price | size | seller | 90 | party1 | 1000 | 1 | party2 | 91 92 And the market data for the market "ETH/MAR22" should be: 93 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 94 | 1000 | TRADING_MODE_CONTINUOUS | 3600 | 973 | 1027 | 3556 | 45976 | 1 | 95 # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1000 x 1 x 1 x 3.5569036 96 97 And the liquidity fee factor should be "0.015" for the market "ETH/MAR22" 98 99 And the parties should have the following margin levels: 100 | party | market id | maintenance | search | initial | release | 101 | lp1 | ETH/MAR22 | 42683 | 51219 | 64024 | 72561 | 102 And the parties should have the following account balances: 103 | party | asset | market id | margin | general | bond | 104 | lp1 | USD | ETH/MAR22 | 64024 | 0 | 35976 | 105 | lp2 | USD | ETH/MAR22 | 32013 | 57987 | 10000 | 106 #margin_intial lp1: 12*1000*3.5569036*1.5=64024 107 Then the network moves ahead "6" blocks 108 And the parties should have the following account balances: 109 | party | asset | market id | margin | general | bond | 110 | lp1 | USD | ETH/MAR22 | 64024 | 0 | 17988 | 111 | lp2 | USD | ETH/MAR22 | 32013 | 57987 | 5000 | 112 113 #AC: 0044-LIME-075, lp commit in multi markets 114 And the parties submit the following liquidity provision: 115 | id | party | market id | commitment amount | fee | lp type | 116 | lp_3 | lp2 | ETH/MAR23 | 500 | 0.02 | submission | 117 118 And the parties should have the following account balances: 119 | party | asset | market id | margin | general | bond | 120 | lp2 | USD | ETH/MAR22 | 32013 | 57487 | 5000 | 121 | lp2 | USD | ETH/MAR23 | 0 | 57487 | 500 | 122 123 @SLABug 124 Scenario: 002: lp1 and lp2 amend LP commitment 125 Given the parties deposit on asset's general account the following amount: 126 | party | asset | amount | 127 | lp1 | USD | 1000000 | 128 | lp2 | USD | 1000000 | 129 | party1 | USD | 100000 | 130 | party2 | USD | 100000 | 131 | party3 | USD | 100000 | 132 | ptbuy | USD | 1000000 | 133 | ptsell | USD | 1000000 | 134 135 And the parties submit the following liquidity provision: 136 | id | party | market id | commitment amount | fee | lp type | 137 | lp_1 | lp1 | ETH/MAR22 | 50000 | 0.02 | submission | 138 | lp_2 | lp2 | ETH/MAR22 | 10000 | 0.01 | submission | 139 140 When the network moves ahead "2" blocks 141 And the parties place the following pegged iceberg orders: 142 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference | 143 | lp1 | ETH/MAR22 | 120 | 1 | buy | BID | 120 | 20 | lp-b-1 | 144 | lp1 | ETH/MAR22 | 120 | 1 | sell | ASK | 120 | 20 | lp-s-1 | 145 | lp2 | ETH/MAR22 | 60 | 1 | buy | BID | 60 | 20 | lp-b-2 | 146 | lp2 | ETH/MAR22 | 60 | 1 | sell | ASK | 60 | 20 | lp-s-2 | 147 Then the network moves ahead "2" blocks 148 And the orders should have the following status: 149 | party | reference | status | 150 | lp1 | lp-b-1 | STATUS_PARKED | 151 152 Then the parties place the following orders: 153 | party | market id | side | volume | price | resulting trades | type | tif | 154 | party1 | ETH/MAR22 | buy | 10 | 900 | 0 | TYPE_LIMIT | TIF_GTC | 155 | party1 | ETH/MAR22 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 156 | party2 | ETH/MAR22 | sell | 10 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | 157 | party2 | ETH/MAR22 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 158 #Then the network moves ahead "2" blocks 159 160 Then the opening auction period ends for market "ETH/MAR22" 161 162 And the orders should have the following status: 163 | party | reference | status | 164 | lp1 | lp-b-1 | STATUS_ACTIVE | 165 166 And the following trades should be executed: 167 | buyer | price | size | seller | 168 | party1 | 1000 | 1 | party2 | 169 170 And the parties should have the following account balances: 171 | party | asset | market id | margin | general | bond | 172 | lp1 | USD | ETH/MAR22 | 640243 | 309757 | 50000 | 173 174 And the market data for the market "ETH/MAR22" should be: 175 | mark price | trading mode | target stake | supplied stake | open interest | 176 | 1000 | TRADING_MODE_CONTINUOUS | 3556 | 60000 | 1 | 177 178 #AC: 0044-LIME-018, lp reduces commitment 179 And the parties submit the following liquidity provision: 180 | id | party | market id | commitment amount | fee | lp type | 181 | lp_1 | lp1 | ETH/MAR22 | 30000 | 0.02 | amendment | 182 And the supplied stake should be "60000" for the market "ETH/MAR22" 183 Then the network moves ahead "10" blocks 184 And the supplied stake should be "40000" for the market "ETH/MAR22" 185 186 #AC: 0044-LIME-019, lp reduces commitment multi times 187 And the parties submit the following liquidity provision: 188 | id | party | market id | commitment amount | fee | lp type | 189 | lp_1 | lp1 | ETH/MAR22 | 28000 | 0.02 | amendment | 190 And the parties submit the following liquidity provision: 191 | id | party | market id | commitment amount | fee | lp type | 192 | lp_1 | lp1 | ETH/MAR22 | 27000 | 0.02 | amendment | 193 And the parties submit the following liquidity provision: 194 | id | party | market id | commitment amount | fee | lp type | 195 | lp_1 | lp1 | ETH/MAR22 | 27000 | 0.02 | amendment | 196 And the supplied stake should be "40000" for the market "ETH/MAR22" 197 Then the network moves ahead "10" blocks 198 And the supplied stake should be "37000" for the market "ETH/MAR22" 199 #AC: 0044-LIME-022, lp reduces commitment, no penalty 200 And the parties should have the following account balances: 201 | party | asset | market id | margin | general | bond | 202 | lp1 | USD | ETH/MAR22 | 640243 | 332757 | 27000 | 203 204 #AC:0044-LIME-021, lp changes fee factor 205 And the parties submit the following liquidity provision: 206 | id | party | market id | commitment amount | fee | lp type | 207 | lp_1 | lp1 | ETH/MAR22 | 50000 | 0.008 | amendment | 208 And the liquidity fee factor should be "0.01" for the market "ETH/MAR22" 209 Then the network moves ahead "10" blocks 210 And the liquidity fee factor should be "0.008" for the market "ETH/MAR22" 211 212 #AC: 0044-LIME-030, lp increases commitment and they do not have sufficient collateral in the settlement asset 213 And the parties submit the following liquidity provision: 214 | id | party | market id | commitment amount | fee | lp type | error | 215 | lp_1 | lp1 | ETH/MAR22 | 600000 | 0.02 | amendment | commitment submission rejected, not enough stake | 216 Then the network moves ahead "1" blocks 217 And the supplied stake should be "60000" for the market "ETH/MAR22" 218 219 #AC: 0044-LIME-031, lp increases commitment and they have sufficient collateral in the settlement asset 220 And the parties submit the following liquidity provision: 221 | id | party | market id | commitment amount | fee | lp type | 222 | lp_1 | lp1 | ETH/MAR22 | 60000 | 0.02 | amendment | 223 And the supplied stake should be "70000" for the market "ETH/MAR22" 224 225 And the parties should have the following account balances: 226 | party | asset | market id | margin | general | bond | 227 | lp1 | USD | ETH/MAR22 | 640243 | 299757 | 60000 | 228 And the market data for the market "ETH/MAR22" should be: 229 | mark price | trading mode | target stake | supplied stake | open interest | 230 | 1000 | TRADING_MODE_CONTINUOUS | 3556 | 70000 | 1 | 231 232 Then the parties place the following orders: 233 | party | market id | side | volume | price | resulting trades | type | tif | 234 | party1 | ETH/MAR22 | buy | 5 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 235 | party2 | ETH/MAR22 | sell | 5 | 1000 | 1 | TYPE_LIMIT | TIF_GTC | 236 | party2 | ETH/MAR22 | buy | 1 | 960 | 0 | TYPE_LIMIT | TIF_GTC | 237 | party3 | ETH/MAR22 | sell | 1 | 970 | 0 | TYPE_LIMIT | TIF_GTC | 238 And the liquidity fee factor should be "0.008" for the market "ETH/MAR22" 239 #liquidity fee collected: 5*1000*0.008=40 240 241 #AC: 0044-LIME-020, lp decreases commitment and gets bond slashing 242 #AC: 0044-LIME-049, at the end of the current epoch rewards/penalties are evaluated based on the balance of the bond account at start of epoch 243 And the parties should have the following account balances: 244 | party | asset | market id | margin | general | bond | 245 | lp1 | USD | ETH/MAR22 | 640243 | 299757 | 60000 | 246 | lp2 | USD | ETH/MAR22 | 320122 | 669878 | 10000 | 247 And the parties submit the following liquidity provision: 248 | id | party | market id | commitment amount | fee | lp type | 249 | lp_1 | lp1 | ETH/MAR22 | 1000 | 0.02 | amendment | 250 | lp_2 | lp2 | ETH/MAR22 | 500 | 0.02 | amendment | 251 Then the network moves ahead "1" blocks 252 And the parties should have the following account balances: 253 | party | asset | market id | margin | general | bond | 254 | lp1 | USD | ETH/MAR22 | 640243 | 309757 | 50000 | 255 | lp2 | USD | ETH/MAR22 | 320122 | 669878 | 10000 | 256 # trigger price auction 257 When the parties place the following orders: 258 | party | market id | side | volume | price | resulting trades | type | tif | 259 | ptsell | ETH/MAR22 | sell | 1 | 940 | 0 | TYPE_LIMIT | TIF_GTC | 260 | ptbuy | ETH/MAR22 | buy | 1 | 940 | 0 | TYPE_LIMIT | TIF_GTC | 261 And the network moves ahead "1" blocks 262 Then the parties should have the following account balances: 263 | party | asset | market id | margin | general | bond | 264 | lp1 | USD | ETH/MAR22 | 0 | 950000 | 50000 | 265 | lp2 | USD | ETH/MAR22 | 0 | 990000 | 10000 | 266 And the market data for the market "ETH/MAR22" should be: 267 | mark price | trading mode | auction trigger | target stake | supplied stake | open interest | auction end | 268 | 1000 | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | 20274 | 60000 | 6 | 3 | 269 When the network moves ahead "10" blocks 270 Then the parties should have the following account balances: 271 | party | asset | market id | margin | general | bond | 272 | lp1 | USD | ETH/MAR22 | 608232 | 386874 | 1002 | 273 | lp2 | USD | ETH/MAR22 | 304116 | 694629 | 501 | 274 And the market data for the market "ETH/MAR22" should be: 275 | mark price | trading mode | auction trigger | target stake | supplied stake | open interest | horizon | min bound | max bound | 276 | 950 | TRADING_MODE_CONTINUOUS | AUCTION_TRIGGER_UNSPECIFIED | 20274 | 1503 | 6 | 3600 | 925 | 976 | 277 278 Then the following transfers should happen: 279 | from | to | from account | to account | market id | amount | asset | 280 | market | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/MAR22 | 33 | USD | 281 | market | lp2 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/MAR22 | 6 | USD |