Skip to content

Commit 536f3ce

Browse files
authored
fix tests for amm cache (#2001)
1 parent 84e6e97 commit 536f3ce

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

sdk/src/adminClient.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,12 @@ export class AdminClient extends DriftClient {
507507
): Promise<TransactionSignature> {
508508
const currentPerpMarketIndex = this.getStateAccount().numberOfMarkets;
509509

510+
const ammCachePublicKey = getAmmCachePublicKey(this.program.programId);
511+
const ammCacheAccount = await this.connection.getAccountInfo(
512+
ammCachePublicKey
513+
);
514+
const mustInitializeAmmCache = ammCacheAccount?.data == null;
515+
510516
const initializeMarketIxs = await this.getInitializePerpMarketIx(
511517
marketIndex,
512518
priceOracle,
@@ -534,7 +540,8 @@ export class AdminClient extends DriftClient {
534540
curveUpdateIntensity,
535541
ammJitIntensity,
536542
name,
537-
lpPoolId
543+
lpPoolId,
544+
mustInitializeAmmCache
538545
);
539546
const tx = await this.buildTransaction(initializeMarketIxs);
540547

@@ -581,7 +588,8 @@ export class AdminClient extends DriftClient {
581588
curveUpdateIntensity = 0,
582589
ammJitIntensity = 0,
583590
name = DEFAULT_MARKET_NAME,
584-
lpPoolId: number = 0
591+
lpPoolId: number = 0,
592+
includeInitAmmCacheIx = false
585593
): Promise<TransactionInstruction[]> {
586594
const perpMarketPublicKey = await getPerpMarketPublicKey(
587595
this.program.programId,
@@ -590,6 +598,10 @@ export class AdminClient extends DriftClient {
590598

591599
const ixs: TransactionInstruction[] = [];
592600

601+
if (includeInitAmmCacheIx) {
602+
ixs.push(await this.getInitializeAmmCacheIx());
603+
}
604+
593605
const nameBuffer = encodeName(name);
594606
const initPerpIx = await this.program.instruction.initializePerpMarket(
595607
marketIndex,

tests/lpPool.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,6 @@ describe('LP Pool', () => {
191191
solUsdLazer = getPythLazerOraclePublicKey(program.programId, 6);
192192
await adminClient.initializePythLazerOracle(6);
193193

194-
await adminClient.initializeAmmCache();
195-
196194
await adminClient.initializePerpMarket(
197195
0,
198196
solUsd,
@@ -1741,7 +1739,6 @@ describe('LP Pool', () => {
17411739
// )) as AmmCache;
17421740

17431741
// await adminClient.deleteAmmCache();
1744-
// await adminClient.initializeAmmCache();
17451742
// await adminClient.resizeAmmCache();
17461743
// await adminClient.updateInitialAmmCacheInfo([0, 1, 2]);
17471744
// await adminClient.updateAmmCache([0, 1, 2]);

tests/lpPoolCUs.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,6 @@ describe('LP Pool', () => {
171171

172172
solUsd = await mockOracleNoProgram(bankrunContextWrapper, 200);
173173

174-
await adminClient.initializeAmmCache();
175-
176174
adminClient = new TestClient({
177175
connection: bankrunContextWrapper.connection.toConnection(),
178176
wallet: new anchor.Wallet(keypair),

tests/lpPoolSwap.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,6 @@ describe('LP Pool', () => {
176176

177177
const periodicity = new BN(0);
178178

179-
await adminClient.initializeAmmCache();
180-
181179
await adminClient.initializePerpMarket(
182180
0,
183181
spotMarketOracle,

0 commit comments

Comments
 (0)