code.vegaprotocol.io/vega@v0.79.0/core/integration/features/amm/0090-VAMM-sparse.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 74 And the parties place the following orders: 75 | party | market id | side | volume | price | resulting trades | type | tif | reference | 76 | lp1 | ETH/MAR22 | buy | 20 | 40 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 77 | party5 | ETH/MAR22 | buy | 20 | 90 | 0 | TYPE_LIMIT | TIF_GTC | lp1-b | 78 | party1 | ETH/MAR22 | buy | 1 | 100 | 0 | TYPE_LIMIT | TIF_GTC | | 79 | party2 | ETH/MAR22 | sell | 1 | 100 | 0 | TYPE_LIMIT | TIF_GTC | | 80 | party3 | ETH/MAR22 | sell | 10 | 130 | 0 | TYPE_LIMIT | TIF_GTC | | 81 | lp1 | ETH/MAR22 | sell | 10 | 160 | 0 | TYPE_LIMIT | TIF_GTC | lp1-s | 82 When the opening auction period ends for market "ETH/MAR22" 83 Then the following trades should be executed: 84 | buyer | price | size | seller | 85 | party1 | 100 | 1 | party2 | 86 87 88 Then the parties submit the following AMM: 89 | party | market id | amount | slippage | base | lower bound | upper bound | proposed fee | 90 | vamm1 | ETH/MAR22 | 1000 | 0.05 | 100 | 90 | 120 | 0.03 | 91 Then the AMM pool status should be: 92 | party | market id | amount | status | base | lower bound | upper bound | 93 | vamm1 | ETH/MAR22 | 1000 | STATUS_ACTIVE | 100 | 90 | 120 | 94 95 And set the following AMM sub account aliases: 96 | party | market id | alias | 97 | vamm1 | ETH/MAR22 | vamm1-id | 98 99 100 # note that the commitment is low and is creating zero volume price ticks so the best bid is more than 1 away from the AMM's 101 # fair price 102 And the market data for the market "ETH/MAR22" should be: 103 | mark price | trading mode | best bid price | best offer price | best bid volume | best offer volume | 104 | 100 | TRADING_MODE_CONTINUOUS | 98 | 105 | 1 | 1 | 105 106 @VAMM 107 Scenario: Sparse AMM incoming orders makes it long 108 109 # AMM's has a BUY at 98 so this SELL order won't match with 99 110 When the parties place the following orders: 111 | party | market id | side | volume | price | resulting trades | type | tif | reference | 112 | party1 | ETH/MAR22 | sell | 5 | 99 | 0 | TYPE_LIMIT | TIF_GTC | | 113 114 And the market data for the market "ETH/MAR22" should be: 115 | mark price | trading mode | best bid price | best offer price | best bid volume | best offer volume | 116 | 100 | TRADING_MODE_CONTINUOUS | 98 | 99 | 1 | 5 | 117 118 # lets send in a 98 that will now match with the AMM 119 When the parties place the following orders: 120 | party | market id | side | volume | price | resulting trades | type | tif | reference | 121 | party1 | ETH/MAR22 | sell | 1 | 98 | 1 | TYPE_LIMIT | TIF_GTC | | 122 Then the following trades should be executed: 123 | buyer | price | size | seller | is amm | 124 | vamm1-id | 99 | 1 | party1 | true | 125 126 # AMM is now quoting at 96 and 100, but we have our sell limit order at 99. 127 And the market data for the market "ETH/MAR22" should be: 128 | trading mode | best bid price | best offer price | best bid volume | best offer volume | 129 | TRADING_MODE_CONTINUOUS | 96 | 99 | 1 | 5 | 130 131 # lets send in a 99 to eat that limit order and leave us with AMM 132 When the parties place the following orders: 133 | party | market id | side | volume | price | resulting trades | type | tif | reference | 134 | party2 | ETH/MAR22 | buy | 5 | 99 | 1 | TYPE_LIMIT | TIF_GTC | | 135 Then the following trades should be executed: 136 | buyer | price | size | seller | is amm | 137 | party2 | 99 | 5 | party1 | true | 138 139 # AMM is now quoting at 96 and 100 140 And the market data for the market "ETH/MAR22" should be: 141 | trading mode | best bid price | best offer price | best bid volume | best offer volume | 142 | TRADING_MODE_CONTINUOUS | 96 | 100 | 1 | 1 | 143 144 # order at 99 doesn't match since the AMM's volume is at 100 145 When the parties place the following orders: 146 | party | market id | side | volume | price | resulting trades | type | tif | reference | 147 | party2 | ETH/MAR22 | buy | 5 | 99 | 0 | TYPE_LIMIT | TIF_FOK | | 148 149 # this one will 150 When the parties place the following orders: 151 | party | market id | side | volume | price | resulting trades | type | tif | reference | 152 | party2 | ETH/MAR22 | buy | 1 | 100 | 1 | TYPE_LIMIT | TIF_FOK | | 153 154 And the market data for the market "ETH/MAR22" should be: 155 | trading mode | best bid price | best offer price | best bid volume | best offer volume | 156 | TRADING_MODE_CONTINUOUS | 98 | 105 | 1 | 1 | 157 158 159 @VAMM 160 Scenario: Sparse AMM incoming orders makes it short 161 162 # AMM's has a BUY at 98 so this SELL order won't match with 99 163 When the parties place the following orders: 164 | party | market id | side | volume | price | resulting trades | type | tif | reference | 165 | party1 | ETH/MAR22 | buy | 5 | 102 | 0 | TYPE_LIMIT | TIF_GTC | | 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 | 100 | TRADING_MODE_CONTINUOUS | 102 | 105 | 5 | 1 | 170 171 # lets send in a 105 that will now match with the AMM 172 When the parties place the following orders: 173 | party | market id | side | volume | price | resulting trades | type | tif | reference | 174 | party1 | ETH/MAR22 | buy | 1 | 105 | 1 | TYPE_LIMIT | TIF_GTC | | 175 176 # AMM is now quoting at 100 and 110, but we have our sell limit order at 102. 177 And the market data for the market "ETH/MAR22" should be: 178 | trading mode | best bid price | best offer price | best bid volume | best offer volume | 179 | TRADING_MODE_CONTINUOUS | 102 | 111 | 5 | 1 | 180 181 # lets send in a 102 to eat that limit order and leave us with AMM 182 When the parties place the following orders: 183 | party | market id | side | volume | price | resulting trades | type | tif | reference | 184 | party2 | ETH/MAR22 | sell | 5 | 102 | 1 | TYPE_LIMIT | TIF_GTC | | 185 Then the following trades should be executed: 186 | buyer | price | size | seller | is amm | 187 | party1 | 102 | 5 | party2 | true | 188 189 # AMM is now quoting at 96 and 100 190 And the market data for the market "ETH/MAR22" should be: 191 | trading mode | best bid price | best offer price | best bid volume | best offer volume | 192 | TRADING_MODE_CONTINUOUS | 100 | 111 | 1 | 1 | 193 194 # order at 102 doesn't match since the AMM's volume is at 100 195 When the parties place the following orders: 196 | party | market id | side | volume | price | resulting trades | type | tif | reference | 197 | party2 | ETH/MAR22 | sell | 5 | 102 | 0 | TYPE_LIMIT | TIF_FOK | | 198 199 # this one will 200 When the parties place the following orders: 201 | party | market id | side | volume | price | resulting trades | type | tif | reference | 202 | party2 | ETH/MAR22 | sell | 1 | 100 | 1 | TYPE_LIMIT | TIF_FOK | | 203 204 And the market data for the market "ETH/MAR22" should be: 205 | trading mode | best bid price | best offer price | best bid volume | best offer volume | 206 | TRADING_MODE_CONTINUOUS | 98 | 105 | 1 | 1 |