@@ -22,6 +22,9 @@ import {
2222 LPPool ,
2323 User ,
2424 getConstituentVaultPublicKey ,
25+ SPOT_MARKET_WEIGHT_PRECISION ,
26+ SPOT_MARKET_RATE_PRECISION ,
27+ OracleSource ,
2528} from '../sdk/src' ;
2629
2730import {
@@ -43,7 +46,10 @@ describe('LP Pool', () => {
4346 let bulkAccountLoader : TestBulkAccountLoader ;
4447
4548 let adminClient : TestClient ;
46- let usdcMint ;
49+ let usdcMint : Keypair ;
50+ let spotTokenMint : Keypair ;
51+ let spotMarketIndex : number ;
52+ let spotMarketOracle : PublicKey ;
4753
4854 const mantissaSqrtScale = new BN ( Math . sqrt ( PRICE_PRECISION . toNumber ( ) ) ) ;
4955 const ammInitialQuoteAssetReserve = new anchor . BN ( 10 * 10 ** 13 ) . mul (
@@ -85,12 +91,12 @@ describe('LP Pool', () => {
8591 ) ;
8692
8793 usdcMint = await mockUSDCMint ( bankrunContextWrapper ) ;
94+ spotTokenMint = await mockUSDCMint ( bankrunContextWrapper ) ;
95+ spotMarketOracle = await mockOracleNoProgram ( bankrunContextWrapper , 200 ) ;
8896
8997 const keypair = new Keypair ( ) ;
9098 await bankrunContextWrapper . fundKeypair ( keypair , 10 ** 9 ) ;
9199
92- usdcMint = await mockUSDCMint ( bankrunContextWrapper ) ;
93-
94100 adminClient = new TestClient ( {
95101 connection : bankrunContextWrapper . connection . toConnection ( ) ,
96102 wallet : new anchor . Wallet ( keypair ) ,
@@ -154,6 +160,32 @@ describe('LP Pool', () => {
154160 new BN ( 224 * PEG_PRECISION . toNumber ( ) )
155161 ) ;
156162
163+ const optimalUtilization = SPOT_MARKET_RATE_PRECISION . div (
164+ new BN ( 2 )
165+ ) . toNumber ( ) ; // 50% utilization
166+ const optimalRate = SPOT_MARKET_RATE_PRECISION . toNumber ( ) ;
167+ const maxRate = SPOT_MARKET_RATE_PRECISION . toNumber ( ) ;
168+ const initialAssetWeight = SPOT_MARKET_WEIGHT_PRECISION . toNumber ( ) ;
169+ const maintenanceAssetWeight = SPOT_MARKET_WEIGHT_PRECISION . toNumber ( ) ;
170+ const initialLiabilityWeight = SPOT_MARKET_WEIGHT_PRECISION . toNumber ( ) ;
171+ const maintenanceLiabilityWeight = SPOT_MARKET_WEIGHT_PRECISION . toNumber ( ) ;
172+ const imfFactor = 0 ;
173+ spotMarketIndex = adminClient . getStateAccount ( ) . numberOfSpotMarkets ;
174+
175+ await adminClient . initializeSpotMarket (
176+ spotTokenMint . publicKey ,
177+ optimalUtilization ,
178+ optimalRate ,
179+ maxRate ,
180+ spotMarketOracle ,
181+ OracleSource . PYTH ,
182+ initialAssetWeight ,
183+ maintenanceAssetWeight ,
184+ initialLiabilityWeight ,
185+ maintenanceLiabilityWeight ,
186+ imfFactor
187+ ) ;
188+
157189 await adminClient . initializeLpPool (
158190 lpPoolName ,
159191 new BN ( 100_000_000 ) . mul ( QUOTE_PRECISION ) ,
@@ -433,6 +465,5 @@ describe('LP Pool', () => {
433465 expect ( ammMapping ) . to . not . be . null ;
434466 assert ( ammMapping . weights . find ( ( x ) => x . perpMarketIndex == 2 ) == undefined ) ;
435467 assert ( ammMapping . weights . length === 2 ) ;
436-
437468 } ) ;
438469} ) ;
0 commit comments