@@ -68,17 +68,49 @@ mod tests {
6868 }
6969 } ;
7070
71- let amm_inventory_and_price: Vec < ( u16 , i64 , i64 ) > = vec ! [
72- ( 0 , 4 * BASE_PRECISION_I64 , 100_000 * PRICE_PRECISION_I64 ) , // $400k BTC
73- ( 1 , 2000 * BASE_PRECISION_I64 , 200 * PRICE_PRECISION_I64 ) , // $400k SOL
74- ( 2 , 200 * BASE_PRECISION_I64 , 1500 * PRICE_PRECISION_I64 ) , // $300k ETH
75- ( 3 , 16500 * BASE_PRECISION_I64 , PRICE_PRECISION_I64 ) , // $16.5k FARTCOIN
71+ let amm_inventory_and_price: Vec < AmmInventoryAndPrices > = vec ! [
72+ AmmInventoryAndPrices {
73+ perp_market_index: 0 ,
74+ inventory: 4 * BASE_PRECISION_I64 ,
75+ price: 100_000 * PRICE_PRECISION_I64 ,
76+ } , // $400k BTC
77+ AmmInventoryAndPrices {
78+ perp_market_index: 1 ,
79+ inventory: 2000 * BASE_PRECISION_I64 ,
80+ price: 200 * PRICE_PRECISION_I64 ,
81+ } , // $400k SOL
82+ AmmInventoryAndPrices {
83+ perp_market_index: 2 ,
84+ inventory: 200 * BASE_PRECISION_I64 ,
85+ price: 1500 * PRICE_PRECISION_I64 ,
86+ } , // $300k ETH
87+ AmmInventoryAndPrices {
88+ perp_market_index: 3 ,
89+ inventory: 16500 * BASE_PRECISION_I64 ,
90+ price: PRICE_PRECISION_I64 ,
91+ } , // $16.5k FARTCOIN
7692 ] ;
7793 let constituents_indexes_and_decimals_and_prices = vec ! [
78- ( 0 , 6 , 100_000 * PRICE_PRECISION_I64 ) ,
79- ( 1 , 6 , 200 * PRICE_PRECISION_I64 ) ,
80- ( 2 , 6 , 1500 * PRICE_PRECISION_I64 ) ,
81- ( 3 , 6 , PRICE_PRECISION_I64 ) , // USDC
94+ ConstituentIndexAndDecimalAndPrice {
95+ constituent_index: 0 ,
96+ decimals: 6 ,
97+ price: 100_000 * PRICE_PRECISION_I64 ,
98+ } ,
99+ ConstituentIndexAndDecimalAndPrice {
100+ constituent_index: 1 ,
101+ decimals: 6 ,
102+ price: 200 * PRICE_PRECISION_I64 ,
103+ } ,
104+ ConstituentIndexAndDecimalAndPrice {
105+ constituent_index: 2 ,
106+ decimals: 6 ,
107+ price: 1500 * PRICE_PRECISION_I64 ,
108+ } ,
109+ ConstituentIndexAndDecimalAndPrice {
110+ constituent_index: 3 ,
111+ decimals: 6 ,
112+ price: PRICE_PRECISION_I64 ,
113+ } , // USDC
82114 ] ;
83115 let aum = 2_000_000 * QUOTE_PRECISION ; // $2M AUM
84116
@@ -112,7 +144,7 @@ mod tests {
112144 calculate_target_weight (
113145 base. cast :: < i64 > ( ) . unwrap ( ) ,
114146 & SpotMarket :: default_quote_market ( ) ,
115- amm_inventory_and_price. get ( index) . unwrap ( ) . 2 ,
147+ amm_inventory_and_price. get ( index) . unwrap ( ) . price ,
116148 aum,
117149 )
118150 . unwrap ( )
@@ -155,8 +187,17 @@ mod tests {
155187 }
156188 } ;
157189
158- let amm_inventory_and_prices: Vec < ( u16 , i64 , i64 ) > = vec ! [ ( 0 , 1_000_000 , 1_000_000 ) ] ;
159- let constituents_indexes_and_decimals_and_prices = vec ! [ ( 1 , 6 , 1_000_000 ) ] ;
190+ let amm_inventory_and_prices: Vec < AmmInventoryAndPrices > = vec ! [ AmmInventoryAndPrices {
191+ perp_market_index: 0 ,
192+ inventory: 1_000_000 ,
193+ price: 1_000_000 ,
194+ } ] ;
195+ let constituents_indexes_and_decimals_and_prices =
196+ vec ! [ ConstituentIndexAndDecimalAndPrice {
197+ constituent_index: 1 ,
198+ decimals: 6 ,
199+ price: 1_000_000 ,
200+ } ] ;
160201 let aum = 1_000_000 ;
161202 let now_ts = 1000 ;
162203
@@ -215,8 +256,17 @@ mod tests {
215256 } ;
216257
217258 let price = PRICE_PRECISION_I64 ;
218- let amm_inventory_and_prices: Vec < ( u16 , i64 , i64 ) > = vec ! [ ( 0 , BASE_PRECISION_I64 , price) ] ;
219- let constituents_indexes_and_decimals_and_prices = vec ! [ ( 1 , 6 , price) ] ;
259+ let amm_inventory_and_prices: Vec < AmmInventoryAndPrices > = vec ! [ AmmInventoryAndPrices {
260+ perp_market_index: 0 ,
261+ inventory: BASE_PRECISION_I64 ,
262+ price,
263+ } ] ;
264+ let constituents_indexes_and_decimals_and_prices =
265+ vec ! [ ConstituentIndexAndDecimalAndPrice {
266+ constituent_index: 1 ,
267+ decimals: 6 ,
268+ price,
269+ } ] ;
220270 let aum = 1_000_000 ;
221271 let now_ts = 1234 ;
222272
@@ -293,9 +343,23 @@ mod tests {
293343 }
294344 } ;
295345
296- let amm_inventory_and_prices: Vec < ( u16 , i64 , i64 ) > = vec ! [ ( 0 , 1_000_000_000 , 1_000_000 ) ] ;
297- let constituents_indexes_and_decimals_and_prices =
298- vec ! [ ( 1 , 6 , 1_000_000 ) , ( 2 , 6 , 1_000_000 ) ] ;
346+ let amm_inventory_and_prices: Vec < AmmInventoryAndPrices > = vec ! [ AmmInventoryAndPrices {
347+ perp_market_index: 0 ,
348+ inventory: 1_000_000_000 ,
349+ price: 1_000_000 ,
350+ } ] ;
351+ let constituents_indexes_and_decimals_and_prices = vec ! [
352+ ConstituentIndexAndDecimalAndPrice {
353+ constituent_index: 1 ,
354+ decimals: 6 ,
355+ price: 1_000_000 ,
356+ } ,
357+ ConstituentIndexAndDecimalAndPrice {
358+ constituent_index: 2 ,
359+ decimals: 6 ,
360+ price: 1_000_000 ,
361+ } ,
362+ ] ;
299363
300364 let aum = 1_000_000 ;
301365 let now_ts = 999 ;
@@ -330,7 +394,7 @@ mod tests {
330394 constituents_indexes_and_decimals_and_prices
331395 . get( i as usize )
332396 . unwrap( )
333- . 2 ,
397+ . price ,
334398 aum,
335399 )
336400 . unwrap( ) ,
@@ -368,8 +432,17 @@ mod tests {
368432 }
369433 } ;
370434
371- let amm_inventory_and_prices: Vec < ( u16 , i64 , i64 ) > = vec ! [ ( 0 , 1_000_000 , 142_000_000 ) ] ;
372- let constituents_indexes_and_decimals_and_prices = vec ! [ ( 1 , 6 , 142_000_000 ) ] ;
435+ let amm_inventory_and_prices: Vec < AmmInventoryAndPrices > = vec ! [ AmmInventoryAndPrices {
436+ perp_market_index: 0 ,
437+ inventory: 1_000_000 ,
438+ price: 142_000_000 ,
439+ } ] ;
440+ let constituents_indexes_and_decimals_and_prices =
441+ vec ! [ ConstituentIndexAndDecimalAndPrice {
442+ constituent_index: 1 ,
443+ decimals: 6 ,
444+ price: 142_000_000 ,
445+ } ] ;
373446
374447 let prices = vec ! [ 142_000_000 ] ;
375448 let aum = 0 ;
0 commit comments