Skip to content

Commit 6f881ba

Browse files
committed
change amm cache pda seed for devnet reset
1 parent bc1ae68 commit 6f881ba

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

programs/drift/src/state/amm_cache.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use anchor_lang::prelude::*;
2222

2323
use 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

6363
impl Size for CacheInfo {

sdk/src/addresses/pda.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ export function getConstituentVaultPublicKey(
508508

509509
export 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
}

sdk/src/adminClient.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff 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> {

0 commit comments

Comments
 (0)