code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/0042-LIQF-fees_rewards_with_decimal.feature (about) 1 Feature: Test decimal places in LP order, liquidity provider reward distribution; Should also cover liquidity-fee-setting and equity-like-share calc and total stake. 2 3 @SLABug 4 Scenario: 001: 0070-MKTD-007, 0042-LIQF-001, 0018-RSKM-005, 0018-RSKM-008 5 Given the following network parameters are set: 6 | name | value | 7 | market.value.windowLength | 1h | 8 | network.markPriceUpdateMaximumFrequency | 0s | 9 | limits.markets.maxPeggedOrders | 18 | 10 | market.liquidity.providersFeeCalculationTimeStep | 600s | 11 | market.liquidity.equityLikeShareFeeFraction | 1 | 12 Given the liquidity monitoring parameters: 13 | name | triggering ratio | time window | scaling factor | 14 | lqm-params | 0.0 | 24h | 1.0 | 15 And the following assets are registered: 16 | id | decimal places | 17 | ETH | 5 | 18 | USD | 2 | 19 And the average block duration is "2" 20 21 And the log normal risk model named "log-normal-risk-model-1": 22 | risk aversion | tau | mu | r | sigma | 23 | 0.000001 | 0.1 | 0 | 0 | 1.0 | 24 And the fees configuration named "fees-config-1": 25 | maker fee | infrastructure fee | 26 | 0.0004 | 0.001 | 27 And the price monitoring named "price-monitoring-1": 28 | horizon | probability | auction extension | 29 | 100000 | 0.99 | 3 | 30 And the liquidity sla params named "SLA": 31 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 32 | 1.0 | 0.5 | 1 | 1.0 | 33 And the markets: 34 | id | quote name | asset | liquidity monitoring | risk model | margin calculator | auction duration | fees | price monitoring | data source config | decimal places | position decimal places | linear slippage factor | quadratic slippage factor | sla params | 35 | ETH/MAR22 | ETH | USD | lqm-params | log-normal-risk-model-1 | default-margin-calculator | 1 | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0 | 0 | 0.5 | 0 | SLA | 36 | USD/DEC19 | USD | ETH | lqm-params | log-normal-risk-model-1 | default-margin-calculator | 1 | default-none | price-monitoring-1 | default-usd-for-future | 3 | 3 | 0.5 | 0 | SLA | 37 | USD/DEC20 | USD | ETH | lqm-params | log-normal-risk-model-1 | default-margin-calculator | 1 | default-none | price-monitoring-1 | default-usd-for-future | 5 | 5 | 0.5 | 0 | SLA | 38 | USD/DEC21 | USD | ETH | lqm-params | log-normal-risk-model-1 | default-margin-calculator | 1 | default-none | price-monitoring-1 | default-usd-for-future | 5 | 3 | 0.5 | 0 | SLA | 39 40 Given the parties deposit on asset's general account the following amount: 41 | party | asset | amount | 42 | lp1 | USD | 100000000000 | 43 | lp1 | ETH | 100000000000000 | 44 | party1 | USD | 10000000000 | 45 | party1 | ETH | 10000000000000 | 46 | party2 | USD | 10000000000 | 47 | party2 | ETH | 10000000000000 | 48 | lpprov | ETH | 100000000000000 | 49 | lpprov | USD | 100000000000000 | 50 51 And the parties submit the following liquidity provision: 52 | id | party | market id | commitment amount | fee | lp type | 53 | lp1 | lp1 | USD/DEC19 | 1000000000 | 0.001 | submission | 54 | lp2 | lp1 | USD/DEC20 | 1000000000 | 0.001 | submission | 55 | lp3 | lp1 | USD/DEC21 | 1000000000 | 0.001 | submission | 56 | lp4 | lpprov | USD/DEC19 | 5000000000 | 0.001 | submission | 57 | lp5 | lpprov | USD/DEC20 | 5000000000 | 0.001 | submission | 58 | lp6 | lpprov | USD/DEC21 | 5000000000 | 0.001 | submission | 59 60 And the parties place the following pegged iceberg orders: 61 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 62 | lp1 | USD/DEC19 | 2 | 1 | buy | BID | 1 | 2000 | 63 | lp1 | USD/DEC20 | 2 | 1 | buy | BID | 1 | 200000 | 64 | lp1 | USD/DEC21 | 2 | 1 | buy | BID | 1 | 200000 | 65 | lp1 | USD/DEC19 | 2 | 1 | buy | MID | 2 | 1000 | 66 | lp1 | USD/DEC20 | 2 | 1 | buy | MID | 2 | 100000 | 67 | lp1 | USD/DEC21 | 2 | 1 | buy | MID | 2 | 100000 | 68 | lp1 | USD/DEC19 | 2 | 1 | sell | ASK | 1 | 2000 | 69 | lp1 | USD/DEC20 | 2 | 1 | sell | ASK | 1 | 200000 | 70 | lp1 | USD/DEC21 | 2 | 1 | sell | ASK | 1 | 200000 | 71 | lp1 | USD/DEC19 | 2 | 1 | sell | MID | 2 | 1000 | 72 | lp1 | USD/DEC20 | 2 | 1 | sell | MID | 2 | 100000 | 73 | lp1 | USD/DEC21 | 2 | 1 | sell | MID | 2 | 100000 | 74 | lpprov | USD/DEC19 | 2 | 1 | buy | BID | 1 | 2000 | 75 | lpprov | USD/DEC20 | 2 | 1 | buy | BID | 1 | 200000 | 76 | lpprov | USD/DEC21 | 2 | 1 | buy | BID | 1 | 200000 | 77 | lpprov | USD/DEC19 | 2 | 1 | sell | MID | 2 | 1000 | 78 | lpprov | USD/DEC20 | 2 | 1 | sell | MID | 2 | 100000 | 79 | lpprov | USD/DEC21 | 2 | 1 | sell | MID | 2 | 100000 | 80 81 Then the parties place the following orders: 82 | party | market id | side | volume | price | resulting trades | type | tif | 83 | party1 | USD/DEC19 | buy | 1000 | 900000 | 0 | TYPE_LIMIT | TIF_GTC | 84 | party1 | USD/DEC20 | buy | 100000 | 90000000 | 0 | TYPE_LIMIT | TIF_GTC | 85 | party1 | USD/DEC21 | buy | 1000 | 90000000 | 0 | TYPE_LIMIT | TIF_GTC | 86 | party1 | USD/DEC19 | buy | 10000 | 1000000 | 0 | TYPE_LIMIT | TIF_GTC | 87 | party1 | USD/DEC20 | buy | 1000000 | 100000000 | 0 | TYPE_LIMIT | TIF_GTC | 88 | party1 | USD/DEC21 | buy | 10000 | 100000000 | 0 | TYPE_LIMIT | TIF_GTC | 89 | party2 | USD/DEC19 | sell | 1000 | 1100000 | 0 | TYPE_LIMIT | TIF_GTC | 90 | party2 | USD/DEC20 | sell | 100000 | 110000000 | 0 | TYPE_LIMIT | TIF_GTC | 91 | party2 | USD/DEC21 | sell | 1000 | 110000000 | 0 | TYPE_LIMIT | TIF_GTC | 92 | party2 | USD/DEC19 | sell | 10000 | 1000000 | 0 | TYPE_LIMIT | TIF_GTC | 93 | party2 | USD/DEC20 | sell | 1000000 | 100000000 | 0 | TYPE_LIMIT | TIF_GTC | 94 | party2 | USD/DEC21 | sell | 10000 | 100000000 | 0 | TYPE_LIMIT | TIF_GTC | 95 96 When the network moves ahead "2" blocks 97 98 Then the market data for the market "USD/DEC19" should be: 99 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 100 | 1000000 | TRADING_MODE_CONTINUOUS | 100000 | 863654 | 1154208 | 3556900000 | 6000000000 | 10000 | 101 # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1000 x 10 x 1 x 3.5569 *100 = 3556900 (using asset decimal) 102 103 And the market data for the market "USD/DEC20" should be: 104 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 105 | 100000000 | TRADING_MODE_CONTINUOUS | 100000 | 86365368 | 115420826 | 3556900000 | 6000000000 | 1000000 | 106 # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1000 x 10 x 1 x 3.5569 107 108 And the market data for the market "USD/DEC21" should be: 109 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 110 | 100000000 | TRADING_MODE_CONTINUOUS | 100000 | 86365368 | 115420826 | 3556900000 | 6000000000 | 10000 | 111 # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1000 x 10 x 1 x 3.5569 112 # max_oi: max open interest 113 114 Then the order book should have the following volumes for market "USD/DEC19": 115 | side | price | volume | 116 | buy | 898000 | 2 | 117 | buy | 900000 | 1000 | 118 | buy | 999000 | 2 | 119 | sell | 1001000 | 4 | 120 | sell | 1100000 | 1000 | 121 | sell | 1102000 | 1 | 122 123 Then the order book should have the following volumes for market "USD/DEC20": 124 | side | price | volume | 125 | buy | 89800000 | 2 | 126 | buy | 90000000 | 100000 | 127 | buy | 99900000 | 2 | 128 | sell | 100100000 | 4 | 129 | sell | 110000000 | 100000 | 130 | sell | 110200000 | 1 | 131 132 Then the order book should have the following volumes for market "USD/DEC21": 133 | side | price | volume | 134 | buy | 89800000 | 2 | 135 | buy | 90000000 | 1000 | 136 | buy | 99900000 | 2 | 137 | sell | 100100000 | 4 | 138 | sell | 110000000 | 1000 | 139 | sell | 110200000 | 1 | 140 141 And the liquidity provider fee shares for the market "USD/DEC19" should be: 142 | party | equity like share | average entry valuation | 143 | lp1 | 0.1666666666666667 | 1000000000 | 144 145 And the liquidity provider fee shares for the market "USD/DEC20" should be: 146 | party | equity like share | average entry valuation | 147 | lp1 | 0.1666666666666667 | 1000000000 | 148 149 And the liquidity provider fee shares for the market "USD/DEC21" should be: 150 | party | equity like share | average entry valuation | 151 | lp1 | 0.1666666666666667 | 1000000000 | 152 153 And the parties should have the following account balances: 154 | party | asset | market id | margin | general | bond | 155 | lp1 | ETH | USD/DEC19 | 1280486 | 99996997426223 | 1000000000 | 156 | lp1 | USD | | | 100000000000 | | 157 | lp1 | ETH | USD/DEC20 | 12805 | 99996997426223 | 1000000000 | 158 | lp1 | USD | | | 100000000000 | | 159 | lp1 | ETH | USD/DEC21 | 1280486 | 99996997426223 | 1000000000 | 160 | lp1 | USD | | | 100000000000 | | 161 | party1 | ETH | USD/DEC19 | 1656961234 | 9995029116298 | | 162 | party1 | USD | | | 10000000000 | | 163 | party2 | ETH | USD/DEC19 | 5295112741 | 9984114661777 | | 164 | party2 | USD | | | 10000000000 | | 165 166 @SLABug 167 Scenario: 002: 0070-MKTD-007, 0042-LIQF-001, 0019-MCAL-008, check updated version of dpd feature in 0038-OLIQ-liquidity_provision_order_type.md 168 Given the following network parameters are set: 169 | name | value | 170 | market.value.windowLength | 1h | 171 | network.markPriceUpdateMaximumFrequency | 0s | 172 | limits.markets.maxPeggedOrders | 30 | 173 | market.liquidity.earlyExitPenalty | 1.0 | 174 | market.liquidity.bondPenaltyParameter | 1.0 | 175 Given the liquidity monitoring parameters: 176 | name | triggering ratio | time window | scaling factor | 177 | lqm-params | 1.0 | 24h | 1.0 | 178 179 180 And the following assets are registered: 181 | id | decimal places | 182 | ETH | 5 | 183 | USD | 2 | 184 And the average block duration is "2" 185 186 And the log normal risk model named "log-normal-risk-model-1": 187 | risk aversion | tau | mu | r | sigma | 188 | 0.000001 | 0.1 | 0 | 0 | 1.0 | 189 #risk factor: 4.556903591579 190 And the fees configuration named "fees-config-1": 191 | maker fee | infrastructure fee | 192 | 0.0004 | 0.001 | 193 And the price monitoring named "price-monitoring-1": 194 | horizon | probability | auction extension | 195 | 100000 | 0.99 | 3 | 196 And the liquidity sla params named "SLA": 197 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 198 | 1.0 | 0.5 | 1 | 1.0 | 199 And the markets: 200 | id | quote name | asset | liquidity monitoring | risk model | margin calculator | auction duration | fees | price monitoring | data source config | decimal places | position decimal places | linear slippage factor | quadratic slippage factor | sla params | 201 | ETH/MAR22 | ETH | USD | lqm-params | log-normal-risk-model-1 | default-margin-calculator | 1 | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0 | 0 | 0.5 | 0 | SLA | 202 | USD/DEC19 | USD | ETH | lqm-params | log-normal-risk-model-1 | default-margin-calculator | 1 | default-none | price-monitoring-1 | default-usd-for-future | 3 | 3 | 0.5 | 0 | SLA | 203 | USD/DEC20 | USD | ETH | lqm-params | log-normal-risk-model-1 | default-margin-calculator | 1 | default-none | price-monitoring-1 | default-usd-for-future | 5 | 5 | 0.5 | 0 | SLA | 204 | USD/DEC21 | USD | ETH | lqm-params | log-normal-risk-model-1 | default-margin-calculator | 1 | default-none | price-monitoring-1 | default-usd-for-future | 5 | 3 | 0.5 | 0 | SLA | 205 206 Given the parties deposit on asset's general account the following amount: 207 | party | asset | amount | 208 | lp1 | USD | 100000000000 | 209 | lp1 | ETH | 100000000000000 | 210 | party1 | USD | 10000000000 | 211 | party1 | ETH | 10000000000000 | 212 | party2 | USD | 10000000000 | 213 | party2 | ETH | 10000000000000 | 214 | lpprov | ETH | 100000000000000 | 215 | lpprov | USD | 100000000000000 | 216 217 And the parties submit the following liquidity provision: 218 | id | party | market id | commitment amount | fee | lp type | 219 | lp1 | lp1 | USD/DEC19 | 1000000 | 0.001 | submission | 220 | lp2 | lp1 | USD/DEC20 | 1000000 | 0.001 | submission | 221 | lp3 | lp1 | USD/DEC21 | 1000000 | 0.001 | submission | 222 | lp4 | lpprov | USD/DEC19 | 5000000000 | 0.001 | submission | 223 | lp5 | lpprov | USD/DEC20 | 5000000000 | 0.001 | submission | 224 | lp6 | lpprov | USD/DEC21 | 5000000000 | 0.001 | submission | 225 And the parties place the following pegged iceberg orders: 226 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 227 | lp1 | USD/DEC19 | 2 | 1 | buy | BID | 1 | 2000 | 228 | lp1 | USD/DEC20 | 2 | 1 | buy | BID | 1 | 200000 | 229 | lp1 | USD/DEC21 | 2 | 1 | buy | BID | 1 | 200000 | 230 | lp1 | USD/DEC19 | 2 | 1 | buy | MID | 2 | 1000 | 231 | lp1 | USD/DEC20 | 2 | 1 | buy | MID | 2 | 100000 | 232 | lp1 | USD/DEC21 | 2 | 1 | buy | MID | 2 | 100000 | 233 | lp1 | USD/DEC19 | 2 | 1 | sell | ASK | 1 | 2000 | 234 | lp1 | USD/DEC20 | 2 | 1 | sell | ASK | 1 | 200000 | 235 | lp1 | USD/DEC21 | 2 | 1 | sell | ASK | 1 | 200000 | 236 | lp1 | USD/DEC19 | 8 | 1 | sell | MID | 8 | 1000 | 237 | lp1 | USD/DEC20 | 8 | 1 | sell | MID | 8 | 100000 | 238 | lp1 | USD/DEC21 | 8 | 1 | sell | MID | 8 | 100000 | 239 | lpprov | USD/DEC19 | 2 | 1 | buy | BID | 1 | 2000 | 240 | lpprov | USD/DEC20 | 2 | 1 | buy | BID | 1 | 200000 | 241 | lpprov | USD/DEC21 | 2 | 1 | buy | BID | 1 | 200000 | 242 | lpprov | USD/DEC19 | 2 | 1 | sell | MID | 2 | 1000 | 243 | lpprov | USD/DEC20 | 2 | 1 | sell | MID | 2 | 100000 | 244 | lpprov | USD/DEC21 | 2 | 1 | sell | MID | 2 | 100000 | 245 246 Then the parties place the following orders: 247 | party | market id | side | volume | price | resulting trades | type | tif | 248 | party1 | USD/DEC19 | buy | 1000 | 900000 | 0 | TYPE_LIMIT | TIF_GTC | 249 | party1 | USD/DEC20 | buy | 100000 | 90000000 | 0 | TYPE_LIMIT | TIF_GTC | 250 | party1 | USD/DEC21 | buy | 1000 | 90000000 | 0 | TYPE_LIMIT | TIF_GTC | 251 | party1 | USD/DEC19 | buy | 10000 | 1000000 | 0 | TYPE_LIMIT | TIF_GTC | 252 | party1 | USD/DEC20 | buy | 1000000 | 100000000 | 0 | TYPE_LIMIT | TIF_GTC | 253 | party1 | USD/DEC21 | buy | 10000 | 100000000 | 0 | TYPE_LIMIT | TIF_GTC | 254 | party2 | USD/DEC19 | sell | 1000 | 1100000 | 0 | TYPE_LIMIT | TIF_GTC | 255 | party2 | USD/DEC20 | sell | 100000 | 110000000 | 0 | TYPE_LIMIT | TIF_GTC | 256 | party2 | USD/DEC21 | sell | 1000 | 110000000 | 0 | TYPE_LIMIT | TIF_GTC | 257 | party2 | USD/DEC19 | sell | 10000 | 1000000 | 0 | TYPE_LIMIT | TIF_GTC | 258 | party2 | USD/DEC20 | sell | 1000000 | 100000000 | 0 | TYPE_LIMIT | TIF_GTC | 259 | party2 | USD/DEC21 | sell | 10000 | 100000000 | 0 | TYPE_LIMIT | TIF_GTC | 260 261 When the network moves ahead "2" blocks 262 263 And the market data for the market "USD/DEC19" should be: 264 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 265 | 1000000 | TRADING_MODE_CONTINUOUS | 100000 | 863654 | 1154208 | 3556900000 | 5001000000 | 10000 | 266 # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1000 x 10 x 1 x 3.5569 *100000 = 3556900000 (using asset decimal) 267 268 And the market data for the market "USD/DEC20" should be: 269 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 270 | 100000000 | TRADING_MODE_CONTINUOUS | 100000 | 86365368 | 115420826 | 3556900000 | 5001000000 | 1000000 | 271 # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1000 x 10 x 1 x 3.5569 *100000 = 3556900000 (using asset decimal) 272 273 And the market data for the market "USD/DEC21" should be: 274 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 275 | 100000000 | TRADING_MODE_CONTINUOUS | 100000 | 86365368 | 115420826 | 3556900000 | 5001000000 | 10000 | 276 # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1000 x 10 x 1 x 3.5569 *100000 = 3556900000 (using asset decimal) 277 # max_oi: max open interest 278 279 # could be improved: as we do have fractional order, if we do the position scaling before we divide by price we can get a more sensible result 280 Then the order book should have the following volumes for market "USD/DEC19": 281 | side | price | volume | 282 | buy | 898000 | 2 | 283 | buy | 900000 | 1000 | 284 | buy | 999000 | 2 | 285 | sell | 1001000 | 10 | 286 | sell | 1100000 | 1000 | 287 | sell | 1102000 | 1 | 288 289 Then the order book should have the following volumes for market "USD/DEC20": 290 | side | price | volume | 291 | buy | 89800000 | 2 | 292 | buy | 90000000 | 100000 | 293 | buy | 99900000 | 2 | 294 | sell | 100100000 | 10 | 295 | sell | 110000000 | 100000 | 296 | sell | 110200000 | 1 | 297 298 Then the order book should have the following volumes for market "USD/DEC21": 299 | side | price | volume | 300 | buy | 89800000 | 2 | 301 | buy | 90000000 | 1000 | 302 | buy | 99900000 | 2 | 303 | sell | 100100000 | 10 | 304 | sell | 110000000 | 1000 | 305 | sell | 110200000 | 1 | 306 307 And the liquidity provider fee shares for the market "USD/DEC19" should be: 308 | party | equity like share | average entry valuation | 309 | lp1 | 0.0001999600079984 | 1000000 | 310 311 And the liquidity provider fee shares for the market "USD/DEC20" should be: 312 | party | equity like share | average entry valuation | 313 | lp1 | 0.0001999600079984 | 1000000 | 314 315 And the liquidity provider fee shares for the market "USD/DEC21" should be: 316 | party | equity like share | average entry valuation | 317 | lp1 | 0.0001999600079984 | 1000000 | 318 319 And the parties should have the following account balances: 320 | party | asset | market id | margin | general | bond | 321 | lp1 | ETH | USD/DEC19 | 3841456 | 99999989278673 | 1000000 | 322 | lp1 | USD | | | 100000000000 | | 323 | lp1 | ETH | USD/DEC20 | 38415 | 99999989278673 | 1000000 | 324 | lp1 | USD | | | 100000000000 | | 325 | lp1 | ETH | USD/DEC21 | 3841456 | 99999989278673 | 1000000 | 326 | lp1 | USD | | | 100000000000 | | 327 | party1 | ETH | USD/DEC19 | 1656961234 | 9995029116298 | | 328 | party1 | USD | | | 10000000000 | | 329 | party2 | ETH | USD/DEC19 | 5295112741 | 9984114661777 | | 330 | party2 | USD | | | 10000000000 | | 331 332 333 And the accumulated liquidity fees should be "0" for the market "USD/DEC19" 334 335 Then the parties place the following orders: 336 | party | market id | side | volume | price | type | tif | 337 | party1 | USD/DEC19 | buy | 5 | 1001000 | TYPE_LIMIT | TIF_GTC | 338 339 And the accumulated liquidity fees should be "501" for the market "USD/DEC19" 340 # liquidity fee = 5 * 1001000 * 0.001 which means actual number without decimal is 0.005*1001*0.001 = 0.005005, and translate back into asset decimal 501, given asset decimal 5, market decimal 3, position decimal 3 341 342 Then the parties place the following orders: 343 | party | market id | side | volume | price | type | tif | 344 | party1 | USD/DEC20 | buy | 5 | 100100000 | TYPE_LIMIT | TIF_GTC | 345 And the accumulated liquidity fees should be "6" for the market "USD/DEC20" 346 # liquidity fee = 5 * 100100000 * 0.001 which means actual number without decimal is 0.00005*1001*0.001 = 0.00005005, and translate back into asset decimal 5.005 (given fee is rounded up in vega, so it should be 6) given asset decimal 5, market decimal 5, position decimal 5 347 348 Then the parties place the following orders with ticks: 349 | party | market id | side | volume | price | type | tif | 350 | party1 | USD/DEC21 | buy | 1 | 100100000 | TYPE_LIMIT | TIF_GTC | 351 And the accumulated liquidity fees should be "101" for the market "USD/DEC21" 352 # liquidity fee = 1 * 100100000 * 0.001 which means actual number without decimal is 0.001*1001*0.001 = 0.001001, and translate back into asset decimal 100.1 (given fee is rounded up in vega, so it should be 101) given asset decimal 5, market decimal 5, position decimal 3 353 354 355 And the network moves ahead "10" blocks 356 #check MTM settlement with correct PDP 357 And the market data for the market "USD/DEC21" should be: 358 | mark price | last traded price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 359 | 100100000 | 100100000 | TRADING_MODE_CONTINUOUS | 100000 | 86365368 | 115420826 | 3560812945 | 5001000000 | 10001 | 360 # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1001 x 10.001 x 1 x 3.5569=35608.1294569, which is 3560812945 in asset decimal (which is 5) 361 362 And the parties should have the following account balances: 363 | party | asset | market id | margin | general | bond | 364 | lp1 | ETH | USD/DEC21 | 3841456 | 99999989278976 | 1000000 | 365 | lp1 | USD | | | 100000000000 | | 366 367 # amend LP commintment amount 368 And the parties submit the following liquidity provision: 369 | id | party | market id | commitment amount | fee | lp type | 370 | lp1 | lp1 | USD/DEC19 | 2000000 | 0.001 | amendment | 371 372 And the parties place the following pegged iceberg orders: 373 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 374 | lp1 | USD/DEC19 | 2 | 1 | buy | MID | 2 | 100000 | 375 | lp1 | USD/DEC19 | 2 | 1 | sell | ASK | 1 | 200000 | 376 377 And the market data for the market "USD/DEC19" should be: 378 | mark price | last traded price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 379 | 1001000 | 1001000 | TRADING_MODE_CONTINUOUS | 100000 | 863654 | 1154208 | 3562237128 | 5002000000 | 10005 | 380 381 And the parties submit the following liquidity provision: 382 | id | party | market id | commitment amount | fee | lp type | 383 | lp1 | lp1 | USD/DEC19 | 4000000000 | 0.001 | amendment | 384 | lp4 | lpprov | USD/DEC19 | 1000000000 | 0.001 | amendment | 385 386 And the parties place the following pegged iceberg orders: 387 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 388 | lp1 | USD/DEC19 | 2 | 1 | buy | MID | 2 | 100000 | 389 | lp1 | USD/DEC19 | 2 | 1 | sell | ASK | 1 | 200000 | 390 | lpprov | USD/DEC19 | 2 | 1 | buy | BID | 1 | 2000 | 391 | lpprov | USD/DEC19 | 2 | 1 | sell | MID | 2 | 1000 | 392 393 And the market data for the market "USD/DEC19" should be: 394 | mark price | last traded price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 395 | 1001000 | 1001000 | TRADING_MODE_CONTINUOUS | 100000 | 863654 | 1154208 | 3562237128 | 9000000000 | 10005 | 396 397 And the network moves ahead "10" blocks 398 399 And the parties place the following pegged iceberg orders: 400 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 401 | lp1 | USD/DEC19 | 2 | 1 | buy | MID | 2 | 100000 | 402 | lp1 | USD/DEC19 | 2 | 1 | sell | ASK | 1 | 200000 | 403 | lpprov | USD/DEC19 | 2 | 1 | buy | BID | 1 | 2000 | 404 | lpprov | USD/DEC19 | 2 | 1 | sell | MID | 2 | 1000 | 405 406 And the market data for the market "USD/DEC19" should be: 407 | mark price | last traded price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 408 | 1001000 | 1001000 | TRADING_MODE_CONTINUOUS | 100000 | 863654 | 1154208 | 3562237128 | 5000000000 | 10005 | 409 410 #reduce LP commitment amount 411 And the parties submit the following liquidity provision: 412 | id | party | market id | commitment amount | fee | lp type | 413 | lp1 | lp1 | USD/DEC19 | 3600000000 | 0.001 | amendment | 414 415 And the market data for the market "USD/DEC19" should be: 416 | mark price | last traded price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 417 | 1001000 | 1001000 | TRADING_MODE_CONTINUOUS | 100000 | 863654 | 1154208 | 3562237128 | 5000000000 | 10005 | 418 419 And the network moves ahead "10" blocks 420 421 And the parties place the following pegged iceberg orders: 422 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 423 | lp1 | USD/DEC19 | 2 | 1 | buy | MID | 2 | 100000 | 424 | lp1 | USD/DEC19 | 2 | 1 | sell | ASK | 1 | 200000 | 425 426 And the market data for the market "USD/DEC19" should be: 427 | mark price | last traded price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 428 | 1001000 | 1001000 | TRADING_MODE_CONTINUOUS | 100000 | 863654 | 1154208 | 3562237128 | 4600000000 | 10005 | 429 430 And the parties should have the following account balances: 431 | party | asset | market id | margin | general | bond | 432 | lp1 | ETH | USD/DEC19 | 5854618 | 99996388265814 | 3600000000 | 433 434 # Reduce LP stake below target, results in slashing 435 And the parties submit the following liquidity provision: 436 | id | party | market id | commitment amount | fee | lp type | 437 | lp1 | lp1 | USD/DEC19 | 10 | 0.001 | amendment | 438 439 Then the network moves ahead "10" blocks 440 441 # This should be slashed, as amendment brought market below target stake, but is currently not 442 And the parties should have the following account balances: 443 | party | asset | market id | margin | general | bond | 444 | lp1 | ETH | USD/DEC19 | 5854618 | 99997426028686 | 10 | 445 446 And the market data for the market "USD/DEC19" should be: 447 | mark price | last traded price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 448 | 1001000 | 1001000 | TRADING_MODE_CONTINUOUS | 100000 | 863654 | 1154208 | 3562237128 | 1000000010 | 10005 | 449 450 451 Scenario: 003, no decimal, 0042-LIQF-001 452 Given the log normal risk model named "log-normal-risk-model-1": 453 | risk aversion | tau | mu | r | sigma | 454 | 0.000001 | 0.1 | 0 | 0 | 1.0 | 455 And the fees configuration named "fees-config-1": 456 | maker fee | infrastructure fee | 457 | 0.0004 | 0.001 | 458 And the price monitoring named "price-monitoring-1": 459 | horizon | probability | auction extension | 460 | 100000 | 0.99 | 3 | 461 And the following network parameters are set: 462 | name | value | 463 | market.value.windowLength | 1h | 464 | network.markPriceUpdateMaximumFrequency | 0s | 465 | limits.markets.maxPeggedOrders | 18 | 466 Given the liquidity monitoring parameters: 467 | name | triggering ratio | time window | scaling factor | 468 | lqm-params | 0.0 | 24h | 1.0 | 469 470 And the liquidity sla params named "SLA": 471 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 472 | 1.0 | 0.5 | 1 | 1.0 | 473 And the markets: 474 | 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 | 475 | ETH/MAR22 | USD | USD | lqm-params | log-normal-risk-model-1 | default-margin-calculator | 2 | fees-config-1 | price-monitoring-1 | default-eth-for-future | 0.5 | 0 | SLA | 476 477 Given the average block duration is "2" 478 479 Given the parties deposit on asset's general account the following amount: 480 | party | asset | amount | 481 | lp1 | USD | 1000000000 | 482 | party1 | USD | 100000000 | 483 | party2 | USD | 100000000 | 484 | lpprov | USD | 1000000000 | 485 486 And the parties submit the following liquidity provision: 487 | id | party | market id | commitment amount | fee | lp type | 488 | lp1 | lp1 | ETH/MAR22 | 40000 | 0.001 | submission | 489 | lp1 | lp1 | ETH/MAR22 | 40000 | 0.001 | submission | 490 | lp1 | lp1 | ETH/MAR22 | 40000 | 0.001 | submission | 491 | lp1 | lp1 | ETH/MAR22 | 40000 | 0.001 | submission | 492 And the parties place the following pegged iceberg orders: 493 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | 494 | lp1 | ETH/MAR22 | 2 | 1 | buy | BID | 1 | 2 | 495 | lp1 | ETH/MAR22 | 2 | 1 | buy | MID | 2 | 1 | 496 | lp1 | ETH/MAR22 | 2 | 1 | sell | ASK | 1 | 2 | 497 | lp1 | ETH/MAR22 | 2 | 1 | sell | MID | 2 | 1 | 498 499 Then the parties place the following orders: 500 | party | market id | side | volume | price | resulting trades | type | tif | 501 | party1 | ETH/MAR22 | buy | 1 | 900 | 0 | TYPE_LIMIT | TIF_GTC | 502 | party1 | ETH/MAR22 | buy | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 503 | party2 | ETH/MAR22 | sell | 1 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | 504 | party2 | ETH/MAR22 | sell | 10 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 505 506 Then the opening auction period ends for market "ETH/MAR22" 507 508 And the following trades should be executed: 509 | buyer | price | size | seller | 510 | party1 | 1000 | 10 | party2 | 511 512 And the market data for the market "ETH/MAR22" should be: 513 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 514 | 1000 | TRADING_MODE_CONTINUOUS | 100000 | 864 | 1154 | 35569 | 40000 | 10 | 515 # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1000 x 10 x 1 x 3.5569 516 # max_oi: max open interest 517 518 Then the order book should have the following volumes for market "ETH/MAR22": 519 | side | price | volume | 520 | buy | 898 | 1 | 521 | buy | 900 | 1 | 522 | buy | 999 | 2 | 523 | sell | 1001 | 2 | 524 | sell | 1100 | 1 | 525 | sell | 1102 | 1 | 526 527 And the liquidity provider fee shares for the market "ETH/MAR22" should be: 528 | party | equity like share | average entry valuation | 529 | lp1 | 1 | 40000 | 530 531 And the parties should have the following account balances: 532 | party | asset | market id | margin | general | bond | 533 | lp1 | USD | ETH/MAR22 | 12805 | 999947195 | 40000 | 534 | party1 | USD | ETH/MAR22 | 16570 | 99983430 | | 535 | party2 | USD | ETH/MAR22 | 52951 | 99947049 | | 536 537 Then the network moves ahead "1" blocks 538 539 And the price monitoring bounds for the market "ETH/MAR22" should be: 540 | min bound | max bound | 541 | 864 | 1154 | 542 543 And the liquidity fee factor should be "0.001" for the market "ETH/MAR22"