File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ use anchor_lang::prelude::*;
2222
2323use super :: user:: MarketType ;
2424
25- pub const AMM_POSITIONS_CACHE : & str = "amm_cache " ;
25+ pub const AMM_POSITIONS_CACHE : & str = "amm_cache_seed " ;
2626
2727#[ account]
2828#[ derive( Debug ) ]
@@ -57,7 +57,7 @@ pub struct CacheInfo {
5757 pub oracle_validity : u8 ,
5858 pub lp_status_for_perp_market : u8 ,
5959 pub amm_position_scalar : u8 ,
60- _padding : [ u8 ; 36 ] ,
60+ pub _padding : [ u8 ; 36 ] ,
6161}
6262
6363impl Size for CacheInfo {
Original file line number Diff line number Diff line change @@ -508,7 +508,7 @@ export function getConstituentVaultPublicKey(
508508
509509export function getAmmCachePublicKey ( programId : PublicKey ) : PublicKey {
510510 return PublicKey . findProgramAddressSync (
511- [ Buffer . from ( anchor . utils . bytes . utf8 . encode ( 'amm_cache ' ) ) ] ,
511+ [ Buffer . from ( anchor . utils . bytes . utf8 . encode ( 'amm_cache_seed ' ) ) ] ,
512512 programId
513513 ) [ 0 ] ;
514514}
Original file line number Diff line number Diff line change @@ -767,6 +767,32 @@ export class AdminClient extends DriftClient {
767767 ) ;
768768 }
769769
770+ public async resetAmmCache (
771+ txParams ?: TxParams
772+ ) : Promise < TransactionSignature > {
773+ const initializeAmmCacheIx = await this . getResetAmmCacheIx ( ) ;
774+ const tx = await this . buildTransaction ( initializeAmmCacheIx , txParams ) ;
775+
776+ const { txSig } = await this . sendTransaction ( tx , [ ] , this . opts ) ;
777+
778+ return txSig ;
779+ }
780+
781+ public async getResetAmmCacheIx ( ) : Promise < TransactionInstruction > {
782+ return this . program . instruction . resetAmmCache (
783+ {
784+ accounts : {
785+ state : await this . getStatePublicKey ( ) ,
786+ admin : this . isSubscribed
787+ ? this . getStateAccount ( ) . admin
788+ : this . wallet . publicKey ,
789+ ammCache : getAmmCachePublicKey ( this . program . programId ) ,
790+ systemProgram : anchor . web3 . SystemProgram . programId ,
791+ } ,
792+ }
793+ ) ;
794+ }
795+
770796 public async initializePredictionMarket (
771797 perpMarketIndex : number
772798 ) : Promise < TransactionSignature > {
You can’t perform that action at this time.
0 commit comments