code.vegaprotocol.io/vega@v0.79.0/core/integration/features/amm/0090-VAMM-sparse-auction.feature (about) 1 Feature: vAMM rebasing when created or amended 2 3 Background: 4 Given the average block duration is "1" 5 And the margin calculator named "margin-calculator-1": 6 | search factor | initial factor | release factor | 7 | 1.2 | 1.5 | 1.7 | 8 And the log normal risk model named "log-normal-risk-model": 9 | risk aversion | tau | mu | r | sigma | 10 | 0.001 | 0.0011407711613050422 | 0 | 0.9 | 3.0 | 11 And the liquidity monitoring parameters: 12 | name | triggering ratio | time window | scaling factor | 13 | lqm-params | 1.00 | 20s | 1 | 14 15 And the following network parameters are set: 16 | name | value | 17 | market.value.windowLength | 60s | 18 | network.markPriceUpdateMaximumFrequency | 0s | 19 | limits.markets.maxPeggedOrders | 6 | 20 | market.auction.minimumDuration | 1 | 21 | market.fee.factors.infrastructureFee | 0.001 | 22 | market.fee.factors.makerFee | 0.004 | 23 | spam.protection.max.stopOrdersPerMarket | 5 | 24 | market.liquidity.equityLikeShareFeeFraction | 1 | 25 | market.amm.minCommitmentQuantum | 1 | 26 | market.liquidity.bondPenaltyParameter | 0.2 | 27 | market.liquidity.stakeToCcyVolume | 1 | 28 | market.liquidity.successorLaunchWindowLength | 1h | 29 | market.liquidity.sla.nonPerformanceBondPenaltySlope | 0 | 30 | market.liquidity.sla.nonPerformanceBondPenaltyMax | 0.6 | 31 | validators.epoch.length | 10s | 32 | market.liquidity.earlyExitPenalty | 0.25 | 33 | market.liquidity.maximumLiquidityFeeFactorLevel | 0.25 | 34 #risk factor short:3.5569036 35 #risk factor long:0.801225765 36 And the following assets are registered: 37 | id | decimal places | 38 | USD | 0 | 39 And the fees configuration named "fees-config-1": 40 | maker fee | infrastructure fee | 41 | 0.0004 | 0.001 | 42 43 And the liquidity sla params named "SLA-22": 44 | price range | commitment min time fraction | performance hysteresis epochs | sla competition factor | 45 | 0.5 | 0.6 | 1 | 1.0 | 46 47 And the oracle spec for settlement data filtering data from "0xCAFECAFE19" named "termination-oracle": 48 | property | type | binding | decimals | 49 | prices.ETH.value | TYPE_INTEGER | settlement data | 0 | 50 51 And the oracle spec for trading termination filtering data from "0xCAFECAFE19" named "termination-oracle": 52 | property | type | binding | 53 | trading.terminated | TYPE_BOOLEAN | trading termination | 54 55 And the markets: 56 | 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 | 57 | ETH/MAR22 | USD | USD | lqm-params | log-normal-risk-model | margin-calculator-1 | 2 | fees-config-1 | default-none | termination-oracle | 1e0 | 0 | SLA-22 | 58 59 # 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 60 Given the parties deposit on asset's general account the following amount: 61 | party | asset | amount | 62 | lp1 | USD | 1000000 | 63 | lp2 | USD | 1000000 | 64 | lp3 | USD | 1000000 | 65 | party1 | USD | 1000000 | 66 | party2 | USD | 1000000 | 67 | party3 | USD | 1000000 | 68 | party4 | USD | 1000000 | 69 | party5 | USD | 1000000 | 70 | vamm1 | USD | 1000000 | 71 | vamm2 | USD | 1000000 | 72 73 @VAMM 74 Scenario: Uncrossing with one low-volume AMM 75 Then the parties submit the following AMM: 76 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 77 | vamm1 | ETH/MAR22 | 1000 | 0.05 | 100 | 90 | 120 | 0.03 | 78 Then the AMM pool status should be: 79 | party | market id | amount | status | base | lower bound | upper bound | 80 | vamm1 | ETH/MAR22 | 1000 | STATUS_ACTIVE | 100 | 90 | 120 | 81 82 Then the parties submit the following AMM: 83 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 84 | vamm2 | ETH/MAR22 | 1000 | 0.05 | 90 | 80 | 140 | 0.03 | 85 Then the AMM pool status should be: 86 | party | market id | amount | status | base | lower bound | upper bound | 87 | vamm2 | ETH/MAR22 | 1000 | STATUS_ACTIVE | 90 | 80 | 140 | 88 89 90 # even though their bounds are crossed, the sparse-ness means their volume it not crossed 91 And the market data for the market "ETH/MAR22" should be: 92 | mark price | trading mode | best bid price | best offer price | best bid volume | best offer volume | 93 | 0 | TRADING_MODE_OPENING_AUCTION | 98 | 103 | 1 | 1 | 94 95 96 # amend the second one so that it has more volume now and they should cross 97 When the parties amend the following AMM: 98 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 99 | vamm2 | ETH/MAR22 | 10000 | 0.05 | 90 | 80 | 140 | 0.03 | 100 Then the AMM pool status should be: 101 | party | market id | amount | status | base | lower bound | upper bound | 102 | vamm2 | ETH/MAR22 | 10000 | STATUS_ACTIVE | 90 | 80 | 140 | 103 104 And the market data for the market "ETH/MAR22" should be: 105 | mark price | trading mode | best bid price | best offer price | best bid volume | best offer volume | 106 | 0 | TRADING_MODE_OPENING_AUCTION | 98 | 92 | 1 | 1 | 107 108 # uncross! 109 When the opening auction period ends for market "ETH/MAR22" 110 And the market data for the market "ETH/MAR22" should be: 111 | mark price | trading mode | best bid price | best offer price | best bid volume | best offer volume | 112 | 95 | TRADING_MODE_CONTINUOUS | 94 | 95 | 1 | 1 | 113 114 115 @VAMM 116 Scenario: Uncrossing orders entirely within a low volume AMM's spread 117 Then the parties submit the following AMM: 118 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 119 | vamm1 | ETH/MAR22 | 1000 | 0.05 | 100 | 90 | 120 | 0.03 | 120 Then the AMM pool status should be: 121 | party | market id | amount | status | base | lower bound | upper bound | 122 | vamm1 | ETH/MAR22 | 1000 | STATUS_ACTIVE | 100 | 90 | 120 | 123 124 And the market data for the market "ETH/MAR22" should be: 125 | mark price | trading mode | best bid price | best offer price | best bid volume | best offer volume | 126 | 0 | TRADING_MODE_OPENING_AUCTION | 98 | 105 | 1 | 1 | 127 128 # lets splatter some orders in the AMM's spread 129 And the parties place the following orders: 130 | party | market id | side | volume | price | resulting trades | type | tif | reference | 131 | party1 | ETH/MAR22 | sell | 5 | 99 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 132 | party1 | ETH/MAR22 | sell | 5 | 100 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 133 | party2 | ETH/MAR22 | buy | 5 | 101 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 134 | party2 | ETH/MAR22 | buy | 10 | 104 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 135 136 And the market data for the market "ETH/MAR22" should be: 137 | mark price | trading mode | best bid price | best offer price | best bid volume | best offer volume | 138 | 0 | TRADING_MODE_OPENING_AUCTION | 104 | 99 | 10 | 5 | 139 140 141 # uncross! AMM should be unaffected 142 When the opening auction period ends for market "ETH/MAR22" 143 And the market data for the market "ETH/MAR22" should be: 144 | mark price | trading mode | best bid price | best offer price | best bid volume | best offer volume | 145 | 102 | TRADING_MODE_CONTINUOUS | 101 | 105 | 5 | 1 | 146 147 148 When the parties cancel all their orders for the markets: 149 | party | market id | 150 | party1 | ETH/MAR22 | 151 | party2 | ETH/MAR22 | 152 153 Then the market data for the market "ETH/MAR22" should be: 154 | mark price | trading mode | best bid price | best offer price | best bid volume | best offer volume | 155 | 102 | TRADING_MODE_CONTINUOUS | 98 | 105 | 1 | 1 | 156 157 158 @VAMM 159 Scenario: Uncrossing orders with a low volume AMM 160 Then the parties submit the following AMM: 161 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 162 | vamm1 | ETH/MAR22 | 1000 | 0.05 | 100 | 90 | 120 | 0.03 | 163 Then the AMM pool status should be: 164 | party | market id | amount | status | base | lower bound | upper bound | 165 | vamm1 | ETH/MAR22 | 1000 | STATUS_ACTIVE | 100 | 90 | 120 | 166 167 And the market data for the market "ETH/MAR22" should be: 168 | mark price | trading mode | best bid price | best offer price | best bid volume | best offer volume | 169 | 0 | TRADING_MODE_OPENING_AUCTION | 98 | 105 | 1 | 1 | 170 171 And the parties place the following orders: 172 | party | market id | side | volume | price | resulting trades | type | tif | reference | 173 | party1 | ETH/MAR22 | sell | 5 | 95 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 174 | party2 | ETH/MAR22 | buy | 5 | 91 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 175 176 And the market data for the market "ETH/MAR22" should be: 177 | mark price | trading mode | best bid price | best offer price | best bid volume | best offer volume | 178 | 0 | TRADING_MODE_OPENING_AUCTION | 98 | 95 | 1 | 5 | 179 180 181 # uncross! AMM should be unaffected 182 When the opening auction period ends for market "ETH/MAR22" 183 And the market data for the market "ETH/MAR22" should be: 184 | mark price | trading mode | best bid price | best offer price | best bid volume | best offer volume | 185 | 95 | TRADING_MODE_CONTINUOUS | 94 | 95 | 1 | 3 |