Skip to content

Commit 1d5420d

Browse files
committed
add sdk
1 parent 001720c commit 1d5420d

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

sdk/src/adminClient.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
getFuelOverflowAccountPublicKey,
4040
getTokenProgramForSpotMarket,
4141
getIfRebalanceConfigPublicKey,
42+
getInsuranceFundStakeAccountPublicKey,
4243
} from './addresses/pda';
4344
import { squareRootBN } from './math/utils';
4445
import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
@@ -50,6 +51,7 @@ import {
5051
ONE,
5152
BASE_PRECISION,
5253
PRICE_PRECISION,
54+
GOV_SPOT_MARKET_INDEX,
5355
} from './constants/numericConstants';
5456
import { calculateTargetPriceTrade } from './math/trade';
5557
import { calculateAmmReservesAfterSwap, getSwapDirection } from './math/amm';
@@ -4649,4 +4651,53 @@ export class AdminClient extends DriftClient {
46494651
}
46504652
);
46514653
}
4654+
4655+
public async updateDelegateUserGovTokenInsuranceStake(
4656+
authority: PublicKey,
4657+
delegate: PublicKey
4658+
): Promise<TransactionSignature> {
4659+
const updateDelegateUserGovTokenInsuranceStakeIx =
4660+
await this.getUpdateDelegateUserGovTokenInsuranceStakeIx(
4661+
authority,
4662+
delegate
4663+
);
4664+
4665+
const tx = await this.buildTransaction(
4666+
updateDelegateUserGovTokenInsuranceStakeIx
4667+
);
4668+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
4669+
4670+
return txSig;
4671+
}
4672+
4673+
public async getUpdateDelegateUserGovTokenInsuranceStakeIx(
4674+
authority: PublicKey,
4675+
delegate: PublicKey
4676+
): Promise<TransactionInstruction> {
4677+
const marketIndex = GOV_SPOT_MARKET_INDEX;
4678+
const spotMarket = this.getSpotMarketAccount(marketIndex);
4679+
const ifStakeAccountPublicKey = getInsuranceFundStakeAccountPublicKey(
4680+
this.program.programId,
4681+
delegate,
4682+
marketIndex
4683+
);
4684+
const userStatsPublicKey = getUserStatsAccountPublicKey(
4685+
this.program.programId,
4686+
authority
4687+
);
4688+
4689+
const ix =
4690+
this.program.instruction.getUpdateDelegateUserGovTokenInsuranceStakeIx({
4691+
accounts: {
4692+
state: await this.getStatePublicKey(),
4693+
spotMarket: spotMarket.pubkey,
4694+
insuranceFundStake: ifStakeAccountPublicKey,
4695+
userStats: userStatsPublicKey,
4696+
signer: this.wallet.publicKey,
4697+
insuranceFundVault: spotMarket.insuranceFund.vault,
4698+
},
4699+
});
4700+
4701+
return ix;
4702+
}
46524703
}

0 commit comments

Comments
 (0)