code.vegaprotocol.io/vega@v0.79.0/core/integration/features/amm/0090-VAMM-037.feature (about) 1 Feature: 0090-VAMM-037: Pegged orders are deployed using vAMM orders as pegs if possible 2 Background: 3 Given the average block duration is "1" 4 And the margin calculator named "margin-calculator-1": 5 | search factor | initial factor | release factor | 6 | 1.2 | 1.5 | 1.7 | 7 And the log normal risk model named "log-normal-risk-model": 8 | risk aversion | tau | mu | r | sigma | 9 | 0.001 | 0.0011407711613050422 | 0 | 0.9 | 3.0 | 10 And the liquidity monitoring parameters: 11 | name | triggering ratio | time window | scaling factor | 12 | lqm-params | 1.00 | 20s | 1 | 13 14 And the following network parameters are set: 15 | name | value | 16 | market.value.windowLength | 60s | 17 | network.markPriceUpdateMaximumFrequency | 2s | 18 | limits.markets.maxPeggedOrders | 6 | 19 | market.auction.minimumDuration | 1 | 20 | market.fee.factors.infrastructureFee | 0.001 | 21 | market.fee.factors.makerFee | 0.004 | 22 | spam.protection.max.stopOrdersPerMarket | 5 | 23 | market.liquidity.equityLikeShareFeeFraction | 1 | 24 | market.amm.minCommitmentQuantum | 1 | 25 | market.liquidity.bondPenaltyParameter | 0.2 | 26 | market.liquidity.stakeToCcyVolume | 1 | 27 | market.liquidity.successorLaunchWindowLength | 1h | 28 | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0.1 | 29 | market.liquidity.sla.nonPerformanceBondPenaltyMax | 0.6 | 30 | validators.epoch.length | 10s | 31 | market.liquidity.earlyExitPenalty | 0.25 | 32 | market.liquidity.maximumLiquidityFeeFactorLevel | 0.25 | 33 #risk factor short:3.5569037 34 #risk factor long:0.801225765 35 And the following assets are registered: 36 | id | decimal places | 37 | USD | 0 | 38 And the fees configuration named "fees-config-1": 39 | maker fee | infrastructure fee | 40 | 0.0004 | 0.001 | 41 42 And the liquidity sla params named "SLA-22": 43 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 44 | 0.5 | 0.6 | 1 | 1.0 | 45 46 And the markets: 47 | 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 | 48 | ETH/MAR22 | USD | USD | lqm-params | log-normal-risk-model | margin-calculator-1 | 2 | fees-config-1 | default-none | default-eth-for-future | 1e0 | 0 | SLA-22 | 49 50 # Setting up the accounts and vAMM submission now is part of the background, because we'll be running scenarios 0090-VAMM-006 through 0090-VAMM-014 on this setup 51 Given the parties deposit on asset's general account the following amount: 52 | party | asset | amount | 53 | lp1 | USD | 1000000 | 54 | lp2 | USD | 1000000 | 55 | lp3 | USD | 1000000 | 56 | party1 | USD | 1000000 | 57 | party2 | USD | 1000000 | 58 | party3 | USD | 1000000 | 59 | party4 | USD | 1000000 | 60 | party5 | USD | 1000000 | 61 | vamm1 | USD | 1000000 | 62 63 When the parties submit the following liquidity provision: 64 | id | party | market id | commitment amount | fee | lp type | 65 | lp_1 | lp1 | ETH/MAR22 | 600 | 0.02 | submission | 66 | lp_2 | lp2 | ETH/MAR22 | 400 | 0.015 | submission | 67 Then the network moves ahead "4" blocks 68 And the current epoch is "0" 69 70 And the parties place the following orders: 71 | party | market id | side | volume | price | resulting trades | type | tif | reference | 72 | lp1 | ETH/MAR22 | buy | 20 | 40 | 0 | TYPE_LIMIT | TIF_GTC | LP1BO | 73 | party1 | ETH/MAR22 | buy | 1 | 100 | 0 | TYPE_LIMIT | TIF_GTC | | 74 | party2 | ETH/MAR22 | sell | 1 | 100 | 0 | TYPE_LIMIT | TIF_GTC | | 75 | lp1 | ETH/MAR22 | sell | 10 | 160 | 0 | TYPE_LIMIT | TIF_GTC | LP1SO | 76 When the opening auction period ends for market "ETH/MAR22" 77 Then the following trades should be executed: 78 | buyer | price | size | seller | 79 | party1 | 100 | 1 | party2 | 80 81 And the market data for the market "ETH/MAR22" should be: 82 | mark price | trading mode | target stake | supplied stake | open interest | ref price | mid price | static mid price | 83 | 100 | TRADING_MODE_CONTINUOUS | 39 | 1000 | 1 | 100 | 100 | 100 | 84 When the parties submit the following AMM: 85 | party | market id | amount | slippage | base | upper bound | upper leverage | proposed fee | 86 | vamm1 | ETH/MAR22 | 100000 | 0.1 | 100 | 150 | 4 | 0.01 | 87 Then the AMM pool status should be: 88 | party | market id | amount | status | base | upper bound | upper leverage | 89 | vamm1 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 100 | 150 | 4 | 90 91 And set the following AMM sub account aliases: 92 | party | market id | alias | 93 | vamm1 | ETH/MAR22 | vamm1-id | 94 And the following transfers should happen: 95 | from | from account | to | to account | market id | amount | asset | is amm | type | 96 | vamm1 | ACCOUNT_TYPE_GENERAL | vamm1-id | ACCOUNT_TYPE_GENERAL | | 100000 | USD | true | TRANSFER_TYPE_AMM_LOW | 97 98 @VAMM 99 Scenario: 0090-VAMM-037: With an existing book consisting solely of vAMM orders on one side, pegged orders referencing best bid/best ask remain deployed on the side with the vAMM orders. Pegged orders referencing the empty side of the book are parked. 100 # LPs submit pegged iceberg orders 101 When the parties place the following pegged iceberg orders: 102 | party | market id | side | volume | peak size | minimum visible size | pegged reference | offset | 103 | lp1 | ETH/MAR22 | buy | 100 | 10 | 2 | BID | 5 | 104 | lp1 | ETH/MAR22 | sell | 100 | 10 | 2 | ASK | 5 | 105 Then the order book should have the following volumes for market "ETH/MAR22": 106 | side | price | volume | 107 | buy | 40 | 20 | 108 | buy | 35 | 10 | 109 | sell | 106 | 10 | 110 | sell | 160 | 10 | 111 112 # Make sure the book stays the same when moving ahead blocks 113 When the network moves ahead "1" blocks 114 Then the order book should have the following volumes for market "ETH/MAR22": 115 | side | price | volume | 116 | buy | 40 | 20 | 117 | buy | 35 | 10 | 118 | sell | 106 | 10 | 119 | sell | 160 | 10 | 120 121 When the parties cancel the following orders: 122 | party | reference | 123 | lp1 | LP1BO | 124 | lp1 | LP1SO | 125 Then the order book should have the following volumes for market "ETH/MAR22": 126 | side | price | volume | 127 | buy | 40 | 0 | 128 | buy | 35 | 0 | 129 | sell | 106 | 10 | 130 | sell | 160 | 0 | 131 132 # Move ahead 1 block to ensure the end block CheckBook call doesn't panic. 133 When the network moves ahead "1" blocks 134 Then the order book should have the following volumes for market "ETH/MAR22": 135 | side | price | volume | 136 | buy | 40 | 0 | 137 | buy | 35 | 0 | 138 | sell | 106 | 10 | 139 | sell | 160 | 0 | 140 141 # Switch sides, still on an empty book, the pegged orders on sell side are now parked 142 # but the buy order is deployed again. 143 When the parties amend the following AMM: 144 | party | market id | slippage | base | lower bound | 145 | vamm1 | ETH/MAR22 | 0.05 | 100 | 85 | 146 Then the AMM pool status should be: 147 | party | market id | amount | status | base | lower bound | 148 | vamm1 | ETH/MAR22 | 100000 | STATUS_ACTIVE | 100 | 85 | 149 150 When the network moves ahead "1" blocks 151 Then the order book should have the following volumes for market "ETH/MAR22": 152 | side | price | volume | 153 | buy | 40 | 0 | 154 | buy | 94 | 10 | 155 | sell | 106 | 0 | 156 | sell | 160 | 0 | 157 158 @VAMM 159 Scenario: 0090-VAMM-037: Cancelling an AMM with pegged orders hanging off its quotes causes them to be re-pegged 160 161 And the market data for the market "ETH/MAR22" should be: 162 | mark price | trading mode | ref price | mid price | static mid price | best bid price | best offer price | 163 | 100 | TRADING_MODE_CONTINUOUS | 100 | 70 | 70 | 40 | 101 | 164 165 166 When the parties place the following pegged orders: 167 | party | market id | side | volume | pegged reference | offset | 168 | lp1 | ETH/MAR22 | buy | 100 | BID | 5 | 169 | lp1 | ETH/MAR22 | sell | 100 | ASK | 5 | 170 171 172 Then the order book should have the following volumes for market "ETH/MAR22": 173 | side | price | volume | 174 | buy | 40 | 20 | 175 | buy | 35 | 100 | 176 | sell | 106 | 100 | 177 | sell | 160 | 10 | 178 179 # cancel the AMM and the pegged order should get repriced 180 When the network moves ahead "1" blocks 181 When the parties cancel the following AMM: 182 | party | market id | method | 183 | vamm1 | ETH/MAR22 | METHOD_IMMEDIATE | 184 185 Then the market data for the market "ETH/MAR22" should be: 186 | mark price | trading mode | ref price | mid price | static mid price | best bid price | best offer price | 187 | 100 | TRADING_MODE_CONTINUOUS | 100 | 100 | 100 | 40 | 160 | 188 189 Then the order book should have the following volumes for market "ETH/MAR22": 190 | side | price | volume | 191 | buy | 40 | 20 | 192 | buy | 35 | 100 | 193 | sell | 160 | 10 | 194 | sell | 165 | 100 | 195 196 # submit a new AMM that will cause a reprice again 197 When the network moves ahead "1" blocks 198 When the parties submit the following AMM: 199 | party | market id | amount | slippage | lower bound | base | upper bound | upper leverage | proposed fee | 200 | vamm1 | ETH/MAR22 | 100000 | 0.1 | 90 | 100 | 150 | 4 | 0.01 | 201 202 Then the market data for the market "ETH/MAR22" should be: 203 | mark price | trading mode | ref price | mid price | static mid price | best bid price | best offer price | 204 | 100 | TRADING_MODE_CONTINUOUS | 100 | 100 | 100 | 99 | 101 | 205 206 207 Then the order book should have the following volumes for market "ETH/MAR22": 208 | side | price | volume | 209 | buy | 40 | 20 | 210 | buy | 94 | 100 | 211 | sell | 106 | 100 | 212 | sell | 160 | 10 |