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