code.vegaprotocol.io/vega@v0.79.0/core/integration/features/liquidity-provision/0044-LIME-092.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 #risk factor short:3.5569036 12 #risk factor long:0.801225765 13 And the following assets are registered: 14 | id | decimal places | 15 | USD | 0 | 16 And the fees configuration named "fees-config-1": 17 | maker fee | infrastructure fee | 18 | 0.0004 | 0.001 | 19 # price monitoring duration should be > 3 epochs 20 And the price monitoring named "price-monitoring": 21 | horizon | probability | auction extension | 22 | 3600 | 0.99 | 40 | 23 24 And the liquidity sla params named "SLA": 25 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 26 | 0.00001 | 0.5 | 1 | 1.0 | 27 28 And the liquidity sla params named "SLA2": 29 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 30 | 0.5 | 0.5 | 1 | 1.0 | 31 32 And the liquidity sla params named "SLA3": 33 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 34 | 0.05 | 1 | 1 | 1.0 | 35 36 And the liquidity monitoring parameters: 37 | name | triggering ratio | time window | scaling factor | 38 | lqm-params | 10 | 3600s | 1 | 39 40 And the following network parameters are set: 41 | name | value | 42 | market.value.windowLength | 60s | 43 | network.markPriceUpdateMaximumFrequency | 0s | 44 | limits.markets.maxPeggedOrders | 6 | 45 | market.auction.minimumDuration | 1 | 46 | market.fee.factors.infrastructureFee | 0.001 | 47 | market.fee.factors.makerFee | 0.004 | 48 | market.liquidity.bondPenaltyParameter | 0.2 | 49 | validators.epoch.length | 5s | 50 | market.liquidity.stakeToCcyVolume | 1 | 51 | market.liquidity.successorLaunchWindowLength | 1h | 52 | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0.5 | 53 | market.liquidity.sla.nonPerformanceBondPenaltyMax | 1 | 54 | validators.epoch.length | 10s | 55 | market.liquidity.providersFeeCalculationTimeStep | 10s | 56 And the liquidity monitoring parameters: 57 | name | triggering ratio | time window | scaling factor | 58 | lqm-params | 0.5 | 20s | 1 | 59 60 61 And the markets: 62 | 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 | liquidity monitoring | 63 | 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 | lqm-params | 64 | 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 | SLA2 | lqm-params | 65 | ETH/JAN23 | USD | USD | lqm-params | log-normal-risk-model | margin-calculator-1 | 2 | fees-config-1 | price-monitoring | default-eth-for-future | 1e0 | 0 | SLA3 | lqm-params | 66 67 Given the average block duration is "2" 68 69 @Now 70 Scenario: An LP with bid orders inside valid range during auction (and market has no indicative price), is not penalised (0044-LIME-092) 71 Given the parties deposit on asset's general account the following amount: 72 | party | asset | amount | 73 | lp1 | USD | 20000000 | 74 | party1 | USD | 1000000000 | 75 | party2 | USD | 1000000000 | 76 | party3 | USD | 1000000 | 77 | ptbuy | USD | 10000000 | 78 | ptsell | USD | 10000000 | 79 80 And the parties submit the following liquidity provision: 81 | id | party | market id | commitment amount | fee | lp type | 82 | lp_1 | lp1 | ETH/JAN23 | 180000 | 0.02 | submission | 83 84 When the network moves ahead "2" blocks 85 Then the parties place the following orders: 86 | party | market id | side | volume | price | resulting trades | type | tif | 87 | lp1 | ETH/JAN23 | buy | 100 | 4750 | 0 | TYPE_LIMIT | TIF_GTC | 88 | lp1 | ETH/JAN23 | sell | 100 | 5250 | 0 | TYPE_LIMIT | TIF_GTC | 89 | party1 | ETH/JAN23 | buy | 1 | 5000 | 0 | TYPE_LIMIT | TIF_GTC | 90 | party2 | ETH/JAN23 | sell | 10 | 5100 | 0 | TYPE_LIMIT | TIF_GTC | 91 | party2 | ETH/JAN23 | sell | 1 | 5000 | 0 | TYPE_LIMIT | TIF_GTC | 92 # Remove this so we can trigger price auction, we add it back later 93 #| party1 | ETH/JAN23 | buy | 10 | 4900 | 0 | TYPE_LIMIT | TIF_GTC | 94 95 Then the opening auction period ends for market "ETH/JAN23" 96 And the following trades should be executed: 97 | buyer | price | size | seller | 98 | party1 | 5000 | 1 | party2 | 99 100 And the market data for the market "ETH/JAN23" should be: 101 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 102 | 5000 | TRADING_MODE_CONTINUOUS | 3600 | 4865 | 5139 | 17784 | 180000 | 1 | 103 104 Then the parties place the following orders: 105 | party | market id | side | volume | price | resulting trades | type | tif | 106 | party1 | ETH/JAN23 | buy | 5000 | 5000 | 0 | TYPE_LIMIT | TIF_GTC | 107 | party2 | ETH/JAN23 | sell | 5000 | 5000 | 1 | TYPE_LIMIT | TIF_GTC | 108 109 When the network moves ahead "1" blocks 110 Then the market data for the market "ETH/JAN23" should be: 111 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 112 | 5000 | TRADING_MODE_CONTINUOUS | 3600 | 4865 | 5139 | 88940284 | 180000 | 5001 | 113 114 ## Now trigger price monitoring auction - sell outside of max bound, and make sure orders can't uncross with existing volume 115 When the parties place the following orders: 116 | party | market id | side | volume | price | resulting trades | type | tif | reference | 117 | ptbuy | ETH/JAN23 | buy | 1 | 4740 | 0 | TYPE_LIMIT | TIF_GTC | pt-buy | 118 | ptsell | ETH/JAN23 | sell | 1 | 4740 | 0 | TYPE_LIMIT | TIF_GTC | pt-sell | 119 Then the market data for the market "ETH/JAN23" should be: 120 | mark price | trading mode | auction trigger | target stake | supplied stake | open interest | auction end | 121 | 5000 | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | 84421207 | 180000 | 5001 | 40 | 122 Then the parties place the following orders: 123 | party | market id | side | volume | price | resulting trades | type | tif | 124 | party1 | ETH/JAN23 | buy | 10 | 4900 | 0 | TYPE_LIMIT | TIF_GTC | 125 | party1 | ETH/JAN23 | buy | 1 | 5000 | 0 | TYPE_LIMIT | TIF_GTC | 126 | party2 | ETH/JAN23 | sell | 1 | 5000 | 0 | TYPE_LIMIT | TIF_GTC | 127 128 When the network moves ahead "1" epochs 129 And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/JAN23" 130 Then the parties should have the following account balances: 131 | party | asset | market id | margin | general | bond | 132 | lp1 | USD | ETH/JAN23 | 2801062 | 17018938 | 162000 | 133 134 When the network moves ahead "2" epochs 135 Then the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/JAN23" 136 Then the parties should have the following account balances: 137 | party | asset | market id | margin | general | bond | 138 | lp1 | USD | ETH/JAN23 | 2801062 | 17018938 | 162000 | 139 140 Scenario: An LP with ask orders outside valid range during auction is penalised (0044-LIME-094) 141 Given the parties deposit on asset's general account the following amount: 142 | party | asset | amount | 143 | lp1 | USD | 20000000 | 144 | party1 | USD | 1000000000 | 145 | party2 | USD | 1000000000 | 146 | party3 | USD | 1000000 | 147 | ptbuy | USD | 10000000 | 148 | ptsell | USD | 10000000 | 149 150 And the parties submit the following liquidity provision: 151 | id | party | market id | commitment amount | fee | lp type | 152 | lp_1 | lp1 | ETH/JAN23 | 180000 | 0.02 | submission | 153 154 When the network moves ahead "2" blocks 155 Then the parties place the following orders: 156 | party | market id | side | volume | price | resulting trades | type | tif | 157 | lp1 | ETH/JAN23 | buy | 100 | 3790 | 0 | TYPE_LIMIT | TIF_GTC | 158 | lp1 | ETH/JAN23 | sell | 100 | 5250 | 0 | TYPE_LIMIT | TIF_GTC | 159 | party1 | ETH/JAN23 | buy | 1 | 5000 | 0 | TYPE_LIMIT | TIF_GTC | 160 | party2 | ETH/JAN23 | sell | 10 | 5100 | 0 | TYPE_LIMIT | TIF_GTC | 161 | party2 | ETH/JAN23 | sell | 1 | 5000 | 0 | TYPE_LIMIT | TIF_GTC | 162 163 Then the opening auction period ends for market "ETH/JAN23" 164 And the following trades should be executed: 165 | buyer | price | size | seller | 166 | party1 | 5000 | 1 | party2 | 167 168 And the market data for the market "ETH/JAN23" should be: 169 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 170 | 5000 | TRADING_MODE_CONTINUOUS | 3600 | 4865 | 5139 | 17784 | 180000 | 1 | 171 172 When the parties place the following orders: 173 | party | market id | side | volume | price | resulting trades | type | tif | reference | 174 | ptbuy | ETH/JAN23 | buy | 1 | 4740 | 0 | TYPE_LIMIT | TIF_GTC | pt-buy | 175 | ptsell | ETH/JAN23 | sell | 1 | 4740 | 0 | TYPE_LIMIT | TIF_GTC | pt-sell | 176 And the network moves ahead "2" blocks 177 Then the market data for the market "ETH/JAN23" should be: 178 | mark price | trading mode | auction trigger | target stake | supplied stake | open interest | auction end | 179 | 5000 | TRADING_MODE_MONITORING_AUCTION | AUCTION_TRIGGER_PRICE | 33719 | 180000 | 1 | 40 | 180 181 When the parties place the following orders: 182 | party | market id | side | volume | price | resulting trades | type | tif | 183 | party1 | ETH/JAN23 | buy | 10 | 4900 | 0 | TYPE_LIMIT | TIF_GTC | 184 | party1 | ETH/JAN23 | buy | 1 | 4000 | 0 | TYPE_LIMIT | TIF_GTC | 185 | party2 | ETH/JAN23 | sell | 1 | 4000 | 0 | TYPE_LIMIT | TIF_GTC | 186 Then the network moves ahead "1" epochs 187 And the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/JAN23" 188 And the parties should have the following account balances: 189 | party | asset | market id | margin | general | bond | 190 | lp1 | USD | ETH/JAN23 | 2801062 | 17018938 | 90000 | 191 192 When the network moves ahead "2" epochs 193 Then the trading mode should be "TRADING_MODE_MONITORING_AUCTION" for the market "ETH/JAN23" 194 Then the parties should have the following account balances: 195 | party | asset | market id | margin | general | bond | 196 | lp1 | USD | ETH/JAN23 | 2801062 | 17018938 | 22500 | 197 198 Then the following transfers should happen: 199 | from | to | from account | to account | market id | amount | asset | 200 | lp1 | market | ACCOUNT_TYPE_BOND | ACCOUNT_TYPE_INSURANCE | ETH/JAN23 | 90000 | USD | 201 | lp1 | market | ACCOUNT_TYPE_BOND | ACCOUNT_TYPE_INSURANCE | ETH/JAN23 | 45000 | USD | 202 | lp1 | market | ACCOUNT_TYPE_BOND | ACCOUNT_TYPE_INSURANCE | ETH/JAN23 | 22500 | USD | 203 #| market | lp1 | ACCOUNT_TYPE_FEES_LIQUIDITY | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ETH/JAN23 | 500000 | USD | 204 #| lp1 | market | ACCOUNT_TYPE_LP_LIQUIDITY_FEES | ACCOUNT_TYPE_INSURANCE | ETH/JAN23 | 500000 | USD | 205 206 207 208 209 210 211