• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bmresearch / Solnet / 15458437619

05 Jun 2025 04:27AM UTC coverage: 66.061% (-4.7%) from 70.792%
15458437619

Pull #497

github

web-flow
Merge da1be547c into 632c6bef2
Pull Request #497: Stakepool program

1161 of 2022 branches covered (57.42%)

Branch coverage included in aggregate %.

705 of 1521 new or added lines in 12 files covered. (46.35%)

5823 of 8550 relevant lines covered (68.11%)

987890.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Solnet.Programs/StakePool/StakePoolProgramInstructions.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6

7
namespace Solnet.Programs.StakePool
8
{
9
    /// <summary>
10
    /// Represents the instruction types for the <see cref="StakePoolProgram"/> along with a friendly name so as not to use reflection.
11
    /// </summary>
12
    /// <remarks>
13
    /// For more information see:
14
    /// https://spl.solana.com/stake-pool
15
    /// https://docs.rs/spl-stake-pool/latest/spl_stake_pool/
16
    /// </remarks>
17
    internal static class StakePoolProgramInstructions
18
    {
19
        /// <summary>
20
        /// Represents the user-friendly names for the instruction types for the <see cref="StakePoolProgram"/>.
21
        /// </summary>
NEW
22
        internal static readonly Dictionary<Values, string> Names = new()
×
NEW
23
        {
×
NEW
24
            { Values.Initialize, "Initialize" },
×
NEW
25
            { Values.AddValidatorToPool, "Add Validator To Pool" },
×
NEW
26
            { Values.RemoveValidatorFromPool, "Remove Validator From Pool" },
×
NEW
27
            { Values.DecreaseValidatorStake, "Decrease Validator Stake" },
×
NEW
28
            { Values.IncreaseValidatorStake, "Increase Validator Stake" },
×
NEW
29
            { Values.SetPreferredValidator, "Set Preferred Deposit Validator" },
×
NEW
30
            { Values.UpdateValidatorListBalance, "Update Validator List Balance" },
×
NEW
31
            { Values.UpdateStakePoolBalance, "Update Stake Pool Balance" },
×
NEW
32
            { Values.CleanupRemovedValidatorEntries, "Cleanup Removed Validator Entries" },
×
NEW
33
            { Values.DecreaseValidatorStakeWithReserve, "Decrease Validator Stake With Reserve" },
×
NEW
34
            { Values.CreateTokenMetadata, "Create Token Metadata" },
×
NEW
35
            { Values.UpdateTokenMetadata, "Update Token Metadata" },
×
NEW
36
            { Values.DepositStake, "Deposit some stake into the pool" },
×
NEW
37
            { Values.WithdrawStake, "Withdraw Stake" },
×
NEW
38
            { Values.DecreaseAdditionalValidatorStake, "Decrease Additional Validator Stake" },
×
NEW
39
            { Values.SetManager, "Set Manager" },
×
NEW
40
            { Values.Redelegate, "Redelegate active stake on a validator" },
×
NEW
41
            { Values.DepositStakeWithSlippage, "Deposit some stake into the pool, with a specified slippage" },
×
NEW
42
            { Values.WithdrawStakeWithSlippage, "Withdraw the token from the pool at the current ratio" },
×
NEW
43
            { Values.DepositSolWithSlippage, "Deposit SOL directly into the pool's reserve account, with a specified slippage constraint." },
×
NEW
44
            { Values.SetFee, "Set Fee" },
×
NEW
45
            { Values.SetStaker, "Set Staker" },
×
NEW
46
            { Values.DepositSol, "Deposit Sol" },
×
NEW
47
            { Values.SetFundingAuthority, "Set Funding Authority" },
×
NEW
48
            { Values.WithdrawSol, "Withdraw Sol" },
×
NEW
49
            { Values.IncreaseAdditionalValidatorStake, "Increase Additional Validator Stake" },
×
NEW
50
        };
×
51

52
        /// <summary>
53
        /// Represents the instruction types for the <see cref="StakePoolProgram"/>.
54
        /// </summary>
55
        internal enum Values : uint
56
        {            
57
            /// <summary>
58
            /// Initializes a new StakePool.
59
            /// </summary>
60
            Initialize = 0,
61

62
            /// <summary>
63
            /// (Staker only) Adds stake account delegated to validator to the pool's list of managed validators.
64
            /// The stake account will have the rent-exempt amount plus max(crate::MINIMUM_ACTIVE_STAKE, solana_program::stake::tools::get_minimum_delegation()).
65
            /// It is funded from the stake pool reserve.
66
            /// Userdata: optional non-zero u32 seed used for generating the validator stake address.
67
            /// </summary>
68
            AddValidatorToPool = 1,
69

70
            /// <summary>
71
            /// (Staker only) Removes validator from the pool, deactivating its stake.
72
            /// Only succeeds if the validator stake account has the minimum of max(crate::MINIMUM_ACTIVE_STAKE, solana_program::stake::tools::get_minimum_delegation()) plus the rent-exempt amount.
73
            /// </summary>
74
            RemoveValidatorFromPool = 2,
75

76
            /// <summary>
77
            /// (Deprecated since v0.7.0, use <see cref="DecreaseValidatorStakeWithReserve"/> instead)
78
            /// (Staker only) Decrease active stake on a validator, eventually moving it to the reserve.
79
            /// Internally, this instruction splits a validator stake account into its corresponding transient stake account and deactivates it.
80
            /// </summary>
81
            DecreaseValidatorStake = 3,
82

83
            /// <summary>
84
            /// (Staker only) Increase stake on a validator from the reserve account.
85
            /// Internally, this instruction splits reserve stake into a transient stake account and delegates to the appropriate validator.
86
            /// <see cref="UpdateValidatorListBalance"/> will do the work of merging once it's ready.
87
            /// Userdata: amount of lamports to increase on the given validator.
88
            /// The actual amount split into the transient stake account is: lamports + stake_rent_exemption.
89
            /// The rent-exemption of the stake account is withdrawn back to the reserve after it is merged.
90
            /// </summary>
91
            IncreaseValidatorStake = 4,
92

93
            /// <summary>
94
            /// (Staker only) Set the preferred deposit or withdraw stake account for the stake pool.
95
            /// In order to avoid users abusing the stake pool as a free conversion between SOL staked on different validators,
96
            /// the staker can force all deposits and/or withdraws to go to one chosen account, or unset that account.
97
            /// </summary>
98
            SetPreferredValidator = 5,
99

100
            /// <summary>
101
            /// Updates balances of validator and transient stake accounts in the pool.
102
            /// While going through the pairs of validator and transient stake accounts, if the transient stake is inactive,
103
            /// it is merged into the reserve stake account. If the transient stake is active and has matching credits observed,
104
            /// it is merged into the canonical validator stake account. In all other states, nothing is done, and the balance is simply added to the canonical stake account balance.
105
            /// </summary>
106
            UpdateValidatorListBalance = 6,
107

108
            /// <summary>
109
            /// Updates total pool balance based on balances in the reserve and validator list.
110
            /// </summary>
111
            UpdateStakePoolBalance = 7,
112

113
            /// <summary>
114
            /// Cleans up validator stake account entries marked as ReadyForRemoval.
115
            /// </summary>
116
            CleanupRemovedValidatorEntries = 8,
117

118
            /// <summary>
119
            /// Deposit some stake into the pool. The output is a "pool" token representing ownership into the pool. Inputs are converted to the current ratio.
120
            /// </summary>
121
            DepositStake = 9,
122

123
            /// <summary>
124
            /// Withdraw the token from the pool at the current ratio.
125
            /// Succeeds if the stake account has enough SOL to cover the desired amount of pool tokens, and if the withdrawal keeps the total staked amount above the minimum of rent-exempt amount + max(crate::MINIMUM_ACTIVE_STAKE, solana_program::stake::tools::get_minimum_delegation()).
126
            /// When allowing withdrawals, the order of priority goes: preferred withdraw validator stake account (if set), validator stake accounts, transient stake accounts, reserve stake account OR totally remove validator stake accounts.
127
            /// Userdata: amount of pool tokens to withdraw.
128
            /// </summary>
129
            WithdrawStake = 10,
130

131
            /// <summary>
132
            /// (Manager only) Update manager.
133
            /// </summary>
134
            SetManager = 11,
135

136
            /// <summary>
137
            /// (Manager only) Update fee.
138
            /// </summary>
139
            SetFee = 12,
140

141
            /// <summary>
142
            /// (Manager or staker only) Update staker.
143
            /// </summary>
144
            SetStaker = 13,
145

146
            /// <summary>
147
            /// Deposit SOL directly into the pool's reserve account. The output is a "pool" token representing ownership into the pool. Inputs are converted to the current ratio.
148
            /// </summary>
149
            DepositSol = 14,
150

151
            /// <summary>
152
            /// (Manager only) Update SOL deposit, stake deposit, or SOL withdrawal authority.
153
            /// </summary>
154
            SetFundingAuthority = 15,
155

156
            /// <summary>
157
            /// Withdraw SOL directly from the pool's reserve account. Fails if the reserve does not have enough SOL.
158
            /// </summary>
159
            WithdrawSol = 16,
160

161
            /// <summary>
162
            /// Create token metadata for the stake-pool token in the metaplex-token program.
163
            /// </summary>
164
            CreateTokenMetadata = 17,
165

166
            /// <summary>
167
            /// Update token metadata for the stake-pool token in the metaplex-token program.
168
            /// </summary>
169
            UpdateTokenMetadata = 18,
170

171
            /// <summary>
172
            /// (Staker only) Increase stake on a validator again in an epoch.
173
            /// Works regardless if the transient stake account exists.
174
            /// Internally, this instruction splits reserve stake into an ephemeral stake account, activates it, then merges or splits it into the transient stake account delegated to the appropriate validator.
175
            /// <see cref="UpdateValidatorListBalance"/> will do the work of merging once it's ready.
176
            /// Userdata: amount of lamports to increase on the given validator.
177
            /// The actual amount split into the transient stake account is: lamports + stake_rent_exemption.
178
            /// The rent-exemption of the stake account is withdrawn back to the reserve after it is merged.
179
            /// </summary>
180
            IncreaseAdditionalValidatorStake = 19,
181

182
            /// <summary>
183
            /// (Staker only) Decrease active stake again from a validator, eventually moving it to the reserve.
184
            /// Works regardless if the transient stake account already exists.
185
            /// Internally, this instruction: withdraws rent-exempt reserve lamports from the reserve into the ephemeral stake, splits a validator stake account into an ephemeral stake account, deactivates the ephemeral account, merges or splits the ephemeral account into the transient stake account delegated to the appropriate validator.
186
            /// </summary>
187
            DecreaseAdditionalValidatorStake = 20,
188

189
            /// <summary>
190
            /// (Staker only) Decrease active stake on a validator, eventually moving it to the reserve.
191
            /// Internally, this instruction: withdraws enough lamports to make the transient account rent-exempt, splits from a validator stake account into a transient stake account, deactivates the transient stake account.
192
            /// </summary>
193
            DecreaseValidatorStakeWithReserve = 21,
194

195
            /// <summary>
196
            /// (Staker only) Redelegate active stake on a validator, eventually moving it to another.
197
            /// Internally, this instruction splits a validator stake account into its corresponding transient stake account, redelegates it to an ephemeral stake account, then merges that stake into the destination transient stake account.
198
            /// </summary>
199
            Redelegate = 22,
200

201
            /// <summary>
202
            /// Deposit some stake into the pool, with a specified slippage constraint. The output is a "pool" token representing ownership into the pool. Inputs are converted at the current ratio.
203
            /// </summary>
204
            DepositStakeWithSlippage = 23,
205

206
            /// <summary>
207
            /// Withdraw the token from the pool at the current ratio, specifying a minimum expected output lamport amount.
208
            /// Succeeds if the stake account has enough SOL to cover the desired amount of pool tokens, and if the withdrawal keeps the total staked amount above the minimum of rent-exempt amount + max(crate::MINIMUM_ACTIVE_STAKE, solana_program::stake::tools::get_minimum_delegation()).
209
            /// Userdata: amount of pool tokens to withdraw.
210
            /// </summary>
211
            WithdrawStakeWithSlippage = 24,
212

213
            /// <summary>
214
            /// Deposit SOL directly into the pool's reserve account, with a specified slippage constraint. The output is a "pool" token representing ownership into the pool. Inputs are converted at the current ratio.
215
            /// </summary>
216
            DepositSolWithSlippage = 25,
217

218
            /// <summary>
219
            /// Withdraw SOL directly from the pool's reserve account. Fails if the reserve does not have enough SOL or if the slippage constraint is not met.
220
            /// </summary>
221
            WithdrawSolWithSlippage = 26,
222
        }
223
    }
224
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc