Voter-stake-registry is a voter weight addin for Solana's spl-governance program.
With the addin enabled, the governance realm authority can:
-
Control which token mints can be used to vote, and at what scaling factor.
That means that tokens from mints other than the governing mint can be used to vote and that their relative weight can be set.
-
Claw back locked tokens from user deposits where the user has enabled it.
This is intended for use with token grants. Users would not enable clawback for normal deposits.
Users can:
-
Deposit and withdraw tokens of the chosen mints to gain voting weight.
When an addin is enabled, the default deposit/withdraw flow of the governing token mints is disabled in spl-governance. The addin adds back the ability to deposit and withdraw without lockup.
-
Lock up tokens with different vesting schedules.
The tokens will only be withdrawable once vested or the lock up has expired. Locked up tokens may have extra voting weight.
-
Use their voting weight to vote on spl-governance proposals.
To start using the addin, make a governance proposal with the spl-governance realm authority to:
- Deploy an instance of the voter-stake-registry.
- Create a registrar for the realm with the
CreateRegistrar
instruction. - Add voting token mints to the registrar by calling the
ConfigureVotingMint
instruction as often as desired. - Call the
SetRealmConfig
instruction on spl-governance to set the voter-weight-addin program id and thereby enable the addin.
-
Call
CreateVoter
on the addin (first time only). Use the same voter_authority that was used for registering with spl-governance. -
Call
CreateDepositEntry
for the voter withLockupKind::None
and the token mint for that tokens are to be deposited. (first time only)This creates a new deposit entry that can be used for depositing and withdrawing funds without lockup.
-
Call
Deposit
for the voter and same deposit entry id to deposit funds. -
To vote, call
UpdateVoterWeightRecord
on the addin and then callCastVote
on spl-governance in the same transaction, passing the voter weight record to both. -
Withdraw funds with
Withdraw
once proposals have resolved.
- Ask the recepient for their desired address.
- Make a proposal to call
Grant
for depositing tokens into a new locked deposit entry for their address. Use a governance that either is the realm authority or the token mint's grant authority. - If necessary, later make a proposal to call
Clawback
on their deposit to retrieve all remaining locked tokens.
-
Creates a Registrar account for a governance realm.
-
Enables voting with tokens from a mint and sets the exchange rate for vote weight.
-
Create a new voter account for a user.
-
Create a deposit entry on a voter. A deposit entry is where tokens from a voting mint are deposited, and which may optionally have a lockup period and vesting schedule.
Each voter can have multiple deposit entries.
-
Add tokens to a deposit entry.
-
Remove tokens from a deposit entry, either unlocked or vested.
-
Re-lock tokens where the lockup has expired, or increase the duration of the lockup.
-
Write the current voter weight to the account that spl-governance can read to prepare for voting.
-
Close an empty deposit entry, so it can be reused for a different mint or lockup type.
-
Close an empty voter, reclaiming rent.
-
As the realm authority or mint's grant authority: create a voter (if needed), create a new deposit and fund it. This instruction is intended for use with DAO proposals.
-
As the clawback authority, claim locked tokens from a voter's deposit entry that has opted-in to clawback.
-
Unfinished instruction for telling spl-governance about the total maximum vote weight.
-
Debug instruction for advancing time in tests. Not usable.
This code is currently not free to use while in development.