Instruction
The purpose of the instruction module is to contain all functionality and structures related to the Solido program instructions.
#
Enums#
Lido InstructionThe Lido instruction enum contains all the possible instructions for the Solido program.
#
InitializeThe initialise instruction should be passed an appropriate FeeDistribution along with the maximum number of validators and maintainers the instance of Solido will support.
#
DepositThe instruction to deposit an amount defined using the helper struct Lamports
#
StakeDepositThe StakeDeposit instruction moves deposits, specified in Lamports, into a new stake account and delegates it to a member validator.
#
WithdrawThe Withdraw instruction withdraws an amount, specified in Lamports, from the Solido program.
Note: Withdraws are not currently supported in the Solido program but will be implemeted in a future version.
#
DistributeFeesThe DistributeFees instruction will calculate any fees due to the Lido stakeholders, allocate the fees to the program accounts and update the validator fees to be claimed when the ClaimValidatorFees instruction is called.
Note: Only a maintainer can call this instruction
#
ClaimValidatorFeesThe ClaimValidatorFees instruction will mint any unclaimed fees to the validator's fee account.
#
ChangeFeeSpecThe ChangeFeeSpec instruction changes the fee distribution ratios after initialisation when given an appropriate new FeeDistribution.
#
AddValidatorThe AddValidator instruction add a given validator to the pool of validators.
Note: Only the manager role can call this instruction.
#
RemoveValidatorThe RemoveValidator instruction removes a given validator from the pool of validators. This instruction will fail with an ValidatorHasUnclaimedCredit error if the validator still has unclaimed credit.
Note: Only the manager role can call this instruction.
#
AddMaintainerThe AddMaintainer instruction add a given maintainer to the pool of maintainers.
Note: Only the manager role can call this instruction.
#
RemoveMaintainerNote: Only the manager role can call this instruction.
#
Macros#
Accounts Struct and Accounts Struct MetaThe accounts_struct and accounts_struct_meta macros assist in generating two structs for passing accounts by name. This has the following advantages over dealing with a list of accounts manually:
- There is no risk of making a mistake in the ordering of accounts, or forgetting to update one place after modifying a different place.
- For every account, it forces consideration of if that account should be writable or not.
- It has a shorthand for defining accounts that have a statically known address.
Example:
This will generate two structs of the form:
The generated structs ensure that the accounts returned by to_vec
are in the same order that
try_from_slice
expects them. try_from_slice
additionally validates that is_signer
and is_writable
match the definition.
#
AccountsThe accounts used by Solido are generated using the accounts_struct macro. They are summarized here, for each instruction, along with the signable and writable status.
#
InitializeAccountsGenerated structs => InitializeAccountsMeta and InitializeAccountsInfo
Account Name | Purpose | is_signer | is_writable |
---|---|---|---|
lido | false | true | |
manager | false | false | |
st_sol_mint | false | false | |
treasury_account | false | false | |
developer_account | false | false | |
reserve_account | false | false |
Constants included:
#
DepositAccountsGenerated structs => DepositAccountsMeta and DepositAccountsInfo
Account Name | Purpose | is_signer | is_writable |
---|---|---|---|
lido | false | true | |
user | true | true | |
recipient | false | true | |
st_sol_mint | false | true | |
reserve_account | false | true |
Constants included:
#
StakeDepositAccountGenerated structs => StakeDepositAccountMeta and StakeDepositAccountInfo
Account Name | Purpose | is_signer | is_writable |
---|---|---|---|
lido | false | true | |
maintainer | true | false | |
reserve | false | true | |
validator_vote_account | false | false | |
stake_account_end | false | true | |
deposit_authority | false | true |
Constants included:
#
ChangeFeeSpecGenerated structs => ChangeFeeSpecMeta and ChangeFeeSpecInfo
Account Name | Purpose | is_signer | is_writable |
---|---|---|---|
lido | false | true | |
manager | true | false | |
treasury_account | false | false | |
developer_account | false | false |
No additonal constants.
#
AddValidatorGenerated structs => AddValidatorMeta and AddValidatorInfo
Account Name | Purpose | is_signer | is_writable |
---|---|---|---|
lido | false | true | |
manager | true | false | |
validator_vote_account | false | false | |
validator_fee_st_sol_account | false | false |
Constants included:
#
RemoveValidatorGenerated structs => RemoveValidatorMeta and RemoveValidatorInfo
Account Name | Purpose | is_signer | is_writable |
---|---|---|---|
lido | false | true | |
manager | true | false | |
validator_vote_account_to_remove | false | false |
Constants included:
#
DistributeFeesGenerated structs => DistributeFeesMeta and DistributeFeesInfo
Account Name | Purpose | is_signer | is_writable |
---|---|---|---|
lido | false | true | |
maintainer | true | false | |
st_sol_mint | false | true | |
reserve_authority | false | false | |
treasury_account | false | true | |
developer_account | false | true |
Constants included:
#
ClaimValidatorFeesGenerated structs => ClaimValidatorFeesMeta and DistributeFeesInfo
Account Name | Purpose | is_signer | is_writable |
---|---|---|---|
lido | false | true | |
st_sol_mint | false | true | |
reserve_authority | false | false | |
validator_fee_st_sol_account | false | true |
Constants included:
#
AddMaintainerGenerated structs => AddMaintainerMeta and AddMaintainerInfo
Account Name | Purpose | is_signer | is_writable |
---|---|---|---|
lido | false | true | |
manager | true | false | |
maintainer | false | false |
No additonal constants.
#
RemoveMaintainerGenerated structs => RemoveMaintainerMeta and RemoveMaintainerInfo
Account Name | Purpose | is_signer | is_writable |
---|---|---|---|
lido | false | true | |
manager | true | false | |
maintainer | false | false |
No additonal constants.
#
FunctionsFor each of the instructions (and their associated account structs) the module contains the functions required to generate the appropriate instructions.
Each of the functions return a result object of the appropriate instruction or a ProgramError
:
#
initialiseConstructs, verifies the accounts and returns the Lido::Initialize
instruction.
#
depositConstructs, verifies the accounts and returns the Lido::Deposit
instruction.
#
stake_depositConstructs, verifies the accounts and returns the Lido::StakeDeposit
instruction.
#
change_fee_distributionConstructs, verifies the accounts and returns the Lido::ChangeFeeSpec
instruction.
#
add_validatorConstructs, verifies the accounts and returns the Lido::AddValidator
instruction.
#
remove_validatorConstructs, verifies the accounts and returns the Lido::RemoveValidator
instruction.
#
distribute_feesConstructs, verifies the accounts and returns the Lido::DistributeFees
instruction.
#
claim_validator_feesConstructs, verifies the accounts and returns the Lido::ClaimValidatorFees
instruction.
#
add_maintainerConstructs, verifies the accounts and returns the Lido::AddMaintainer
instruction.
#
remove_maintainerConstructs, verifies the accounts and returns the Lido::RemoveMaintainer
instruction.