code.vegaprotocol.io/vega@v0.79.0/core/integration/features/liquidity-provision/0044-LIME-088.feature (about) 1 Feature: Test LP SLA Bond penalty on change of SLA market parameter: price range 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 And the liquidity monitoring parameters: 20 | name | triggering ratio | time window | scaling factor | 21 | lqm-params | 1.0 | 20s | 1 | 22 #risk factor short:3.5569036 23 #risk factor long:0.801225765 24 And the following assets are registered: 25 | id | decimal places | 26 | USD | 0 | 27 And the fees configuration named "fees-config-1": 28 | maker fee | infrastructure fee | 29 | 0.0004 | 0.001 | 30 And the price monitoring named "price-monitoring": 31 | horizon | probability | auction extension | 32 | 3600 | 0.99 | 3 | 33 34 And the liquidity sla params named "SLA-22": 35 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 36 | 0.5 | 0.6 | 1 | 1.0 | 37 And the liquidity sla params named "SLA-23": 38 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 39 | 0.5 | 0.3 | 1 | 1.0 | 40 41 And the markets: 42 | 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 | 43 | 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 | 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.7 | 52 | market.liquidity.sla.nonPerformanceBondPenaltyMax | 0.6 | 53 | validators.epoch.length | 10s | 54 | market.liquidity.earlyExitPenalty | 0.25 | 55 56 Given the average block duration is "1" 57 @Now 58 Scenario: 001: If a liquidity provider has `fraction_of_time_on_book` = `0.3`, `market.liquidity.commitmentMinTimeFraction = 0.6`, `market.liquidity.sla.nonPerformanceBondPenaltySlope = 0.7`, `market.liquidity.sla.nonPerformanceBondPenaltyMax = 0.6`and the market parameter change `market.liquidity.commitmentMinTimeFraction = 0.3` is enacted during the epoch then at the end of the current epoch LP will have their bond slashed. If the LP has `fraction_of_time_on_book` = `0.3` at the end of the next epoch, they are meeting their commitment and will not forfeit any of their bond stake. (0044-LIME-088) 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 | 4000 | 0.02 | submission | 70 | lp_2 | lp2 | ETH/MAR22 | 4000 | 0.015 | submission | 71 72 When the network moves ahead "1" blocks 73 74 Then the parties place the following orders: 75 | party | market id | side | volume | price | resulting trades | type | tif | 76 | party1 | ETH/MAR22 | buy | 10 | 900 | 0 | TYPE_LIMIT | TIF_GTC | 77 | party1 | ETH/MAR22 | buy | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 78 | party2 | ETH/MAR22 | sell | 10 | 1100 | 0 | TYPE_LIMIT | TIF_GTC | 79 | party2 | ETH/MAR22 | sell | 1 | 1000 | 0 | TYPE_LIMIT | TIF_GTC | 80 81 Then the opening auction period ends for market "ETH/MAR22" 82 And the following trades should be executed: 83 | buyer | price | size | seller | 84 | party1 | 1000 | 1 | party2 | 85 86 And the market data for the market "ETH/MAR22" should be: 87 | mark price | trading mode | horizon | min bound | max bound | target stake | supplied stake | open interest | 88 | 1000 | TRADING_MODE_CONTINUOUS | 3600 | 973 | 1027 | 3556 | 8000 | 1 | 89 # target_stake = mark_price x max_oi x target_stake_scaling_factor x rf = 1000 x 1 x 1 x 3.5569036 =3556 90 And the liquidity fee factor should be "0.015" for the market "ETH/MAR22" 91 92 When the network moves ahead "7" blocks 93 94 And the parties place the following pegged iceberg orders: 95 | party | market id | peak size | minimum visible size | side | pegged reference | volume | offset | reference | 96 | lp1 | ETH/MAR22 | 12 | 1 | buy | BID | 12 | 20 | lp-b-1 | 97 | lp1 | ETH/MAR22 | 12 | 1 | sell | ASK | 12 | 20 | lp-s-1 | 98 99 When the network moves ahead "4" blocks 100 101 #fraction_of_time_on_book=0.3 102 #0.7 * (1 - 0.3 / 0.6) = 0.35, so bond penalty for lp1 should be 0.35*4000=1400; bond penalty for lp2 should be 0.6*4000=2400 103 Then the following transfers should happen: 104 | from | to | from account | to account | market id | amount | asset | 105 | lp1 | market | ACCOUNT_TYPE_BOND | ACCOUNT_TYPE_INSURANCE | ETH/MAR22 | 1400 | USD | 106 | lp2 | market | ACCOUNT_TYPE_BOND | ACCOUNT_TYPE_INSURANCE | ETH/MAR22 | 2400 | USD | 107 108 Then the markets are updated: 109 | id | risk model | price monitoring | data source config | linear slippage factor | quadratic slippage factor | sla params | 110 | ETH/MAR22 | log-normal-risk-model | price-monitoring | default-eth-for-future | 1e0 | 0 | SLA-23 | 111 Then the network moves ahead "1" epochs 112 113 #once market parameter 'price range' has been updated from 0.6 to 0.3, lp1 is fulfilling SLA duty, and should get penalty 114 # bond penalty for lp2 should be 0.6*1600=960 115 Then the following transfers should happen: 116 | from | to | from account | to account | market id | amount | asset | 117 | lp2 | market | ACCOUNT_TYPE_BOND | ACCOUNT_TYPE_INSURANCE | ETH/MAR22 | 960 | USD | 118