Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method to withdraw all unstaked SOL from stake accounts #34738

Open
bartenbach opened this issue Jan 11, 2024 · 3 comments · May be fixed by anza-xyz/agave#441
Open

Method to withdraw all unstaked SOL from stake accounts #34738

bartenbach opened this issue Jan 11, 2024 · 3 comments · May be fixed by anza-xyz/agave#441
Labels
community Community contribution good first issue Good for newcomers

Comments

@bartenbach
Copy link
Contributor

Problem

MEV rewards from Jito are airdropped to stake accounts as excess, unstaked SOL.

Stake accounts receiving those airdrops will see something similar to this:

% solana stake-account 74JwpCE61kJMdxaf9j2X5EpnkS1CiCoqoEoJPx5MBdCe
Balance: 97.256865087 SOL
Rent Exempt Reserve: 0.00228288 SOL
Delegated Stake: 96.742412791 SOL
Active Stake: 96.742412791 SOL

Note the difference between the Balance of the stake account and Active Stake.

It looks like you could withdraw the excess SOL using existing functions, but this doesn't appear to work as the ALL keyword implies the full balance of the account:

% solana withdraw-stake --help
solana-withdraw-stake
Withdraw the unstaked SOL from the stake account
    <AMOUNT>                   The amount to withdraw from the stake account, in SOL; accepts keyword ALL
% solana withdraw-stake 74JwpCE61kJMdxaf9j2X5EpnkS1CiCoqoEoJPx5MBdCe HKCgzSzVT92ZUDLj6hTeJnRgY6objrPDAbVr3xyxR6kY ALL
Error: RPC response error -32002: Transaction simulation failed: Error processing Instruction 0: insufficient funds for instruction [2 log messages]

(The client keypair is funded and specifying the --fee-payer doesn't have any effect)

% solana balance HKCgzSzVT92ZUDLj6hTeJnRgY6objrPDAbVr3xyxR6kY.json
102.301790691 SOL

% solana withdraw-stake --fee-payer HKCgzSzVT92ZUDLj6hTeJnRgY6objrPDAbVr3xyxR6kY.json stake-account.json $(solana address) ALL
Error: RPC response error -32002: Transaction simulation failed: Error processing Instruction 0: insufficient funds for instruction [2 log messages]

Proposed Solution

Add a new keyword like AVAILABLE, EXCESS, or UNSTAKED to calculate the difference between a stake accounts Balance and Active Stake.

This makes it very easy to withdraw all unstaked SOL from stake accounts. Before Jito, this wouldn't be necessary - but with MEV being airdropped and excess SOL in stake accounts, this would be incredibly useful.

@bartenbach bartenbach added the community Community contribution label Jan 11, 2024
@bartenbach bartenbach changed the title Shortcut method to withdraw all MEV (any unstaked SOL) from stake accounts Method to withdraw all unstaked SOL from stake accounts Jan 11, 2024
@CriesofCarrots CriesofCarrots added the good first issue Good for newcomers label Jan 11, 2024
@mehdimahro
Copy link

ok tankyo

@diman-io
Copy link
Contributor

I don't think we need a separate new special word. It's enough to adapt ALL so that it withdraws everything possible

@bartenbach
Copy link
Contributor Author

I don't think we need a separate new special word. It's enough to adapt ALL so that it withdraws everything possible

I agree - that's also an acceptable solution. Probably a better UX too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Community contribution good first issue Good for newcomers
Projects
None yet
4 participants