diff --git a/sdk/src/adminClient.ts b/sdk/src/adminClient.ts index 1d665c634..dde5aea08 100644 --- a/sdk/src/adminClient.ts +++ b/sdk/src/adminClient.ts @@ -1063,7 +1063,9 @@ export class AdminClient extends DriftClient { const tokenProgram = this.getTokenProgramForSpotMarket(spotMarket); return await this.program.instruction.depositIntoSpotMarketVault(amount, { accounts: { - admin: this.wallet.publicKey, + admin: this.useHotWalletAdmin + ? this.wallet.publicKey + : this.getStateAccount().admin, state: await this.getStatePublicKey(), sourceVault, spotMarket: spotMarket.pubkey, @@ -1192,7 +1194,9 @@ export class AdminClient extends DriftClient { }, { accounts: { - admin: this.wallet.publicKey, + admin: this.useHotWalletAdmin + ? this.wallet.publicKey + : this.getStateAccount().admin, state: await this.getStatePublicKey(), perpMarket: await getPerpMarketPublicKey( this.program.programId, @@ -3885,7 +3889,9 @@ export class AdminClient extends DriftClient { fuelBonusInsurance || null, { accounts: { - admin: this.wallet.publicKey, + admin: this.useHotWalletAdmin + ? this.wallet.publicKey + : this.getStateAccount().admin, state: await this.getStatePublicKey(), user, userStats, @@ -3895,12 +3901,10 @@ export class AdminClient extends DriftClient { } public async initializePythPullOracle( - feedId: string, - isAdmin = false + feedId: string ): Promise { const initializePythPullOracleIx = await this.getInitializePythPullOracleIx( - feedId, - isAdmin + feedId ); const tx = await this.buildTransaction(initializePythPullOracleIx); const { txSig } = await this.sendTransaction(tx, [], this.opts); @@ -3909,15 +3913,16 @@ export class AdminClient extends DriftClient { } public async getInitializePythPullOracleIx( - feedId: string, - isAdmin = false + feedId: string ): Promise { const feedIdBuffer = getFeedIdUint8Array(feedId); return await this.program.instruction.initializePythPullOracle( feedIdBuffer, { accounts: { - admin: isAdmin ? this.getStateAccount().admin : this.wallet.publicKey, + admin: this.useHotWalletAdmin + ? this.wallet.publicKey + : this.getStateAccount().admin, state: await this.getStatePublicKey(), systemProgram: SystemProgram.programId, priceFeed: getPythPullOraclePublicKey( @@ -3931,11 +3936,10 @@ export class AdminClient extends DriftClient { } public async initializePythLazerOracle( - feedId: number, - isAdmin = false + feedId: number ): Promise { const initializePythPullOracleIx = - await this.getInitializePythLazerOracleIx(feedId, isAdmin); + await this.getInitializePythLazerOracleIx(feedId); const tx = await this.buildTransaction(initializePythPullOracleIx); const { txSig } = await this.sendTransaction(tx, [], this.opts); @@ -3943,12 +3947,13 @@ export class AdminClient extends DriftClient { } public async getInitializePythLazerOracleIx( - feedId: number, - isAdmin = false + feedId: number ): Promise { return await this.program.instruction.initializePythLazerOracle(feedId, { accounts: { - admin: isAdmin ? this.getStateAccount().admin : this.wallet.publicKey, + admin: this.useHotWalletAdmin + ? this.wallet.publicKey + : this.getStateAccount().admin, state: await this.getStatePublicKey(), systemProgram: SystemProgram.programId, lazerOracle: getPythLazerOraclePublicKey( @@ -4030,10 +4035,11 @@ export class AdminClient extends DriftClient { } public async initializeProtectedMakerModeConfig( - maxUsers: number + maxUsers: number, + stateAdmin?: boolean ): Promise { const initializeProtectedMakerModeConfigIx = - await this.getInitializeProtectedMakerModeConfigIx(maxUsers); + await this.getInitializeProtectedMakerModeConfigIx(maxUsers, stateAdmin); const tx = await this.buildTransaction( initializeProtectedMakerModeConfigIx @@ -4045,13 +4051,14 @@ export class AdminClient extends DriftClient { } public async getInitializeProtectedMakerModeConfigIx( - maxUsers: number + maxUsers: number, + stateAdmin?: boolean ): Promise { return await this.program.instruction.initializeProtectedMakerModeConfig( maxUsers, { accounts: { - admin: this.isSubscribed + admin: stateAdmin ? this.getStateAccount().admin : this.wallet.publicKey, state: await this.getStatePublicKey(), diff --git a/sdk/src/driftClient.ts b/sdk/src/driftClient.ts index 75a4b5c11..952404037 100644 --- a/sdk/src/driftClient.ts +++ b/sdk/src/driftClient.ts @@ -202,6 +202,7 @@ export class DriftClient { public program: Program; provider: AnchorProvider; opts?: ConfirmOptions; + useHotWalletAdmin?: boolean; users = new Map(); userStats?: UserStats; activeSubAccountId: number; @@ -251,6 +252,7 @@ export class DriftClient { this.opts = config.opts || { ...DEFAULT_CONFIRMATION_OPTS, }; + this.useHotWalletAdmin = config.useHotWalletAdmin ?? false; if (config?.connection?.commitment) { // At the moment this ensures that our transaction simulations (which use Connection object) will use the same commitment level as our Transaction blockhashes (which use these opts) this.opts.commitment = config.connection.commitment; diff --git a/sdk/src/driftClientConfig.ts b/sdk/src/driftClientConfig.ts index 1b74de6ec..6deaf6bbb 100644 --- a/sdk/src/driftClientConfig.ts +++ b/sdk/src/driftClientConfig.ts @@ -38,6 +38,7 @@ export type DriftClientConfig = { enableMetricsEvents?: boolean; txHandlerConfig?: TxHandlerConfig; delistedMarketSetting?: DelistedMarketSetting; + useHotWalletAdmin?: boolean; }; export type DriftClientSubscriptionConfig =