Stake Accounts in Solana
Starting from scratch
What are they?
- Stake accounts in solana are uysed to delegate tokens to validatos in the network in exhcange of rewards.
- These are not the same as system accounts.
- Thye allow more complex actions than system accounts.
- Each account has a unique address that can or cannot have a keypair associated (eg. only keypair if generated from CLI)
Authorities
-
Solana accounts may have one or more signing authorities.
-
The account authority is used for signing certain transactions on the accounts it controls.
-
For stake accounts there are two authorities:
- Stake authority, that is used to sign:
- Stake delegation
- Stake delegation deactivation
- Splitting the stake (create a new staking account with portion of the funds on the account)
- Merge two accounts into one
- Set a new stake authority
- Withdraw authority:
- Withdraw deactivated (un-delegated) stake
- Set a new withdraw authority
- Set new stake authority
- Stake authority, that is used to sign:
-
Both of these are set when the stake account is created. They can be the same or different address and they can be updated
-
Each stake account can just delegate to one validator at a time, for multiple delegations, multiple accounts must be created
- We can have one wallet with multiple stake accounts or one large stake account that uses its authority to create multiple sub staking accounts that all share the same stake and withdraw authorities
-
Accounts sharing the same authorities and lockup can be merged if:
- Both have deactivated stakes
- One of them is in activation process for the epoch
- Both have active stakes and share the same voter pubkey and credits
- Both are being activated in the epoch
Nits
- Activation or deactivation of stake does not take effect immediately but takes several epochs to be settled. A fraction of each activation/deactivation becomes avaliable at teach epoch boundary https://docs.anza.xyz/consensus/stake-delegation-and-rewards#stake-warmup-cooldown-withdrawal
- The stake accounts cab have lockups, preventing the tokens they hold from being withdrawn before a particular date has been reached. Only withdrawal or withdraw authority update is not allowed.
- The lockup can only be added when the account is created although can be updated later on. A lockup authority or custodian must be defined