@@ -507,12 +507,6 @@ 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-
516510 const initializeMarketIxs = await this . getInitializePerpMarketIx (
517511 marketIndex ,
518512 priceOracle ,
@@ -540,7 +534,6 @@ export class AdminClient extends DriftClient {
540534 curveUpdateIntensity ,
541535 ammJitIntensity ,
542536 name ,
543- mustInitializeAmmCache ,
544537 lpPoolId
545538 ) ;
546539 const tx = await this . buildTransaction ( initializeMarketIxs ) ;
@@ -588,7 +581,6 @@ export class AdminClient extends DriftClient {
588581 curveUpdateIntensity = 0 ,
589582 ammJitIntensity = 0 ,
590583 name = DEFAULT_MARKET_NAME ,
591- includeInitAmmCacheIx = false ,
592584 lpPoolId : number = 0
593585 ) : Promise < TransactionInstruction [ ] > {
594586 const perpMarketPublicKey = await getPerpMarketPublicKey (
@@ -597,9 +589,6 @@ export class AdminClient extends DriftClient {
597589 ) ;
598590
599591 const ixs : TransactionInstruction [ ] = [ ] ;
600- if ( includeInitAmmCacheIx ) {
601- ixs . push ( await this . getInitializeAmmCacheIx ( ) ) ;
602- }
603592
604593 const nameBuffer = encodeName ( name ) ;
605594 const initPerpIx = await this . program . instruction . initializePerpMarket (
@@ -663,9 +652,35 @@ export class AdminClient extends DriftClient {
663652 return await this . program . instruction . initializeAmmCache ( {
664653 accounts : {
665654 state : await this . getStatePublicKey ( ) ,
666- admin : this . isSubscribed
667- ? this . getStateAccount ( ) . admin
668- : this . wallet . publicKey ,
655+ admin : this . useHotWalletAdmin
656+ ? this . wallet . publicKey
657+ : this . getStateAccount ( ) . admin ,
658+ ammCache : getAmmCachePublicKey ( this . program . programId ) ,
659+ rent : SYSVAR_RENT_PUBKEY ,
660+ systemProgram : anchor . web3 . SystemProgram . programId ,
661+ } ,
662+ } ) ;
663+ }
664+
665+ public async resizeAmmCache (
666+ txParams ?: TxParams
667+ ) : Promise < TransactionSignature > {
668+ const initializeAmmCacheIx = await this . getInitializeAmmCacheIx ( ) ;
669+
670+ const tx = await this . buildTransaction ( initializeAmmCacheIx , txParams ) ;
671+
672+ const { txSig } = await this . sendTransaction ( tx , [ ] , this . opts ) ;
673+
674+ return txSig ;
675+ }
676+
677+ public async getResizeAmmCacheIx ( ) : Promise < TransactionInstruction > {
678+ return await this . program . instruction . resizeAmmCache ( {
679+ accounts : {
680+ state : await this . getStatePublicKey ( ) ,
681+ admin : this . useHotWalletAdmin
682+ ? this . wallet . publicKey
683+ : this . getStateAccount ( ) . admin ,
669684 ammCache : getAmmCachePublicKey ( this . program . programId ) ,
670685 rent : SYSVAR_RENT_PUBKEY ,
671686 systemProgram : anchor . web3 . SystemProgram . programId ,
0 commit comments