Manablast Program Docs
Program interacte with native Solana Stake Program, but instead of staking rewards you receive Quote Tokens $MANA that you can spend for more fast transactions over our lite-rpc node.
General MANA tokens
Once you stake sol - program creates two accounts where storing data about your stake:
StakeAccountInfo
struct stores info about position in native stake programStakeInfo
struct stores info about your stake in our program
Accounts signatures:
StakeAccountInfo {
stake: pubkey,
amount: u64,
}
StakeInfo {
start_count_date: i64,
stop_count_date: Option<i64>
spent_charges: u64,
saved_charges: u64,
last_charge_date: Option<i64>
restorable_charges: u64,
amount: u64,
stake_quantity: u16,
}
Every replenish will creates additional
StakeAccountInfo
, because native stake program doesn`t support increasing stake amount for stake in active state and we handle it in sepatare stake accounts. After you unstake and withdraw your funds allStakeAccountInfo
will be closed.Such as
StakeInfo
stores info about your Quote MANA it will not be closed after withdrawal and still exists while you have at least 1 Quote MANA. Rent for this accont is about 0.0015 sol, and it will be returned after spending all Quote MANA.TODO: implement closing
StakeInfo
account by user initiative with losing Quote MANA
Instructions
Stake
Creates stake account and invoke native stake program that delegate whole balance to validator
Parameters:
amount: u64
Accounts:
payer
[SIGNER]stake
[SIGNER]vote
Replenish
Increase summary stake amount with creating separate stake account and delegate it to validator
Parameters:
amount: u64
Accounts:
payer
[SIGNER]stake
[SIGNER]vote
Unstake
Deactivate stake account. To deactivate whole stake you should bundle this instruction for every opened account in one transaction
Accounts:
payer
[SIGNER]stake
Withdraw
Withdraw funds from stake account to your wallet. Can be used only after stake goes to deactivated state. To withdraw whole stake amount you should bundle this instruction for every opened account in one transaction
Accounts:
payer
[SIGNER]stake
Charge
Calculates your current Quote MANA, check ability to make transaction, and update info about spent MANA
Accounts:
payer
PDAs & Authority
Stake
andReplenish
instuctions must be signed both by user and stake accounts. Further authority moves toStakeInfo
PDA, that can be fetched byseeds = ["stake", <user_pubkey>]
.StakeAccountInfo
PDA can be fetch withseeds = ["stake", <user_pubkey>, <index>]
. Such as user could have several stake accounts we use<index>
seed to iterate over it.GlobalConfig
PDA contains info about MANA` calculation rules and can be fetched byseeds = ["global_config"]
.
Calculations
GlobalConfig
signature:
GlobalConfig {
rewards_recipient: Pubkey,
charges_per_day: u64,
charges_per_tx: u64,
restorable_charges: u64,
}
Also there is logic for restorable MANA. While you have active stake, MANA for the first transaction per day wil be refunded over 1 day.
$MANA Token calculation examples:
// Calculate rewards for staking
((now - ctx.accounts.authority.start_count_date) / DAY_MS) as u64 * ctx.accounts.config.charges_per_day;
// Calculate spent MANA
ctx.accounts.authority.spent_charges - ctx.accounts.authority.restorable_charges;
// Calculate available MANA
ctx.accounts.authority.saved_charges + stake_rewards - spent_charges
Once you replenish or unstake, info about your stake collapled to single StakeInfo
account. Available MANA moves to saved_charges
and count starts from current MANA in replenish case.
Last updated