Skip to content

Commit 6b9b7a2

Browse files
committed
feat(jito): implements staking deactivate
Ticket: SC-2418
1 parent 0de3c54 commit 6b9b7a2

14 files changed

+684
-206
lines changed

examples/ts/sol/stake-jito.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ async function main() {
6060
.stakingAddress(JITO_STAKE_POOL_ADDRESS)
6161
.validator(JITO_STAKE_POOL_ADDRESS)
6262
.isJito(true)
63+
.jitoParams({
64+
stakePoolData: {
65+
managerFeeAccount: stakePoolAccount.account.data.managerFeeAccount.toString(),
66+
poolMint: stakePoolAccount.account.data.poolMint.toString(),
67+
reserveStake: stakePoolAccount.account.data.toString(),
68+
}
69+
})
6370
.nonce(recentBlockhash.blockhash)
6471
txBuilder.sign({ key: account.secretKey })
6572
const tx = await txBuilder.build()
@@ -85,7 +92,7 @@ const getAccount = () => {
8592
const secretKey = process.env.ACCOUNT_SECRET_KEY
8693
if (publicKey === undefined || secretKey === undefined) {
8794
const { publicKey, secretKey } = Keypair.generate()
88-
console.log('Here is a new account to save into your .env file.')
95+
console.log('# Here is a new account to save into your .env file.')
8996
console.log(`ACCOUNT_PUBLIC_KEY=${publicKey.toBase58()}`)
9097
console.log(`ACCOUNT_SECRET_KEY=${bs58.encode(secretKey)}`)
9198
throw new Error("Missing account information")

modules/sdk-coin-sol/src/lib/constants.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export enum ValidInstructionTypesEnum {
3838
MintTo = 'MintTo',
3939
Burn = 'Burn',
4040
DepositSol = 'DepositSol',
41+
WithdrawStake = 'WithdrawStake',
42+
Approve = 'Approve',
4143
}
4244

4345
// Internal instructions types
@@ -58,6 +60,8 @@ export enum InstructionBuilderTypes {
5860
MintTo = 'MintTo',
5961
Burn = 'Burn',
6062
CustomInstruction = 'CustomInstruction',
63+
Approve = 'Approve',
64+
WithdrawStake = 'WithdrawStake',
6165
}
6266

6367
export const VALID_SYSTEM_INSTRUCTION_TYPES: ValidInstructionTypes[] = [
@@ -80,7 +84,9 @@ export const VALID_SYSTEM_INSTRUCTION_TYPES: ValidInstructionTypes[] = [
8084
ValidInstructionTypesEnum.SetPriorityFee,
8185
ValidInstructionTypesEnum.MintTo,
8286
ValidInstructionTypesEnum.Burn,
87+
ValidInstructionTypesEnum.Approve,
8388
ValidInstructionTypesEnum.DepositSol,
89+
ValidInstructionTypesEnum.WithdrawStake,
8490
];
8591

8692
/** Const to check the order of the Wallet Init instructions when decode */
@@ -111,6 +117,13 @@ export const jitoStakingActivateInstructionsIndexes = {
111117
DepositSol: 1,
112118
} as const;
113119

120+
/** Const to check the order of the Jito Staking Activate instructions when decode */
121+
export const jitoStakingDeactivateInstructionsIndexes = {
122+
Approve: 0,
123+
Create: 1,
124+
WithdrawStake: 2,
125+
} as const;
126+
114127
/** Const to check the order of the Staking Authorize instructions when decode */
115128
export const stakingAuthorizeInstructionsIndexes = {
116129
Authorize: 0,

modules/sdk-coin-sol/src/lib/iface.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { DecodedCloseAccountInstruction } from '@solana/spl-token';
33
import { Blockhash, StakeInstructionType, SystemInstructionType, TransactionSignature } from '@solana/web3.js';
44
import { InstructionBuilderTypes } from './constants';
55
import { StakePoolInstructionType } from '@solana/spl-stake-pool';
6+
import { DepositSolStakePoolData, WithdrawStakeStakePoolData } from './jitoStakePoolOperations';
67

78
// TODO(STLX-9890): Add the interfaces for validityWindow and SequenceId
89
export interface SolanaKeys {
@@ -41,6 +42,7 @@ export type InstructionParams =
4142
| StakingDelegate
4243
| MintTo
4344
| Burn
45+
| Approve
4446
| CustomInstruction;
4547

4648
export interface Memo {
@@ -107,6 +109,17 @@ export interface Burn {
107109
};
108110
}
109111

112+
export interface Approve {
113+
type: InstructionBuilderTypes.Approve;
114+
params: {
115+
accountAddress: string;
116+
delegateAddress: string;
117+
ownerAddress: string;
118+
amount: string;
119+
programId?: string;
120+
};
121+
}
122+
110123
export interface StakingActivate {
111124
type: InstructionBuilderTypes.StakingActivate;
112125
params: {
@@ -116,6 +129,9 @@ export interface StakingActivate {
116129
validator: string;
117130
isMarinade?: boolean;
118131
isJito?: boolean;
132+
jitoParams?: {
133+
stakePoolData: DepositSolStakePoolData;
134+
};
119135
};
120136
}
121137

@@ -132,6 +148,12 @@ export interface StakingDeactivate {
132148
amount?: string;
133149
unstakingAddress?: string;
134150
isMarinade?: boolean;
151+
isJito?: boolean;
152+
jitoParams?: {
153+
stakePoolData: WithdrawStakeStakePoolData;
154+
validatorAddress: string;
155+
transferAuthorityAddress: string;
156+
};
135157
recipients?: Recipient[];
136158
};
137159
}
@@ -187,7 +209,8 @@ export type ValidInstructionTypes =
187209
| 'TokenTransfer'
188210
| 'SetPriorityFee'
189211
| 'MintTo'
190-
| 'Burn';
212+
| 'Burn'
213+
| 'Approve';
191214

192215
export type StakingAuthorizeParams = {
193216
stakingAddress: string;

0 commit comments

Comments
 (0)