Go to file
microwavedcola1 9823f282d4 split accounts.rs into state/*
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2021-12-02 20:05:43 +01:00
migrations Init 2021-10-05 13:41:01 -07:00
programs/voter-stake-registry split accounts.rs into state/* 2021-12-02 20:05:43 +01:00
.gitignore fix types in tests + fix seeds in withdraw 2021-11-26 07:30:14 +01:00
.travis.yml traivs: Run cargo tests 2021-10-25 09:51:14 -07:00
Anchor.toml Rename to voter-stake-registry 2021-12-01 13:28:38 +01:00
Cargo.lock Rename to voter-stake-registry 2021-12-01 13:28:38 +01:00
Cargo.toml Init 2021-10-05 13:41:01 -07:00
README.md Rename UpdateDeposit -> Deposit 2021-12-02 11:06:15 +01:00
package.json Create and write vote weight records 2021-10-21 19:16:32 -07:00
run-format.sh make withdraw ts tests work 2021-11-26 07:49:22 +01:00
run-test.sh make withdraw ts tests work 2021-11-26 07:49:22 +01:00
tsconfig.json Init 2021-10-05 13:41:01 -07:00
yarn.lock Decompose deposits into separate instructions 2021-10-16 09:48:59 -07:00

README.md

Description

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.

Usage Scenarios

Setup

To start using the addin, make a governance proposal with the spl-governance realm authority to:

  1. Deploy an instance of the voter-stake-registry.
  2. Create a registrar for the realm with the CreateRegistrar instruction.
  3. Add voting token mints to the registrar by calling the CreateExchangeRate instruction as often as desired.
  4. Call the SetRealmConfig instruction on spl-governance to set the voter-weight-addin program id and thereby enable the addin.

Deposit and Vote Without Lockup

  1. Call CreateVoter on the addin (first time only). Use the same voter_authority that was used for registering with spl-governance.

  2. Call CreateDeposit for the voter with LockupKind::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. If it's the voter's first deposit entry, it will have deposit id 0.

  3. Call Deposit for the voter and deposit id to deposit funds.

  4. To vote, call UpdateVoterWeightRecord on the addin and then vote with that on spl-governance in the same transaction.

  5. Withdraw funds with Withdraw once proposals have resolved.

Give Grants of Locked Tokens

  1. Ask the recepient to CreateVoter and CreateDeposit with the desired lock up period, vesting and allow_clawback=true. Double check the address and deposit id they communicate.
  2. Make a proposal to call Deposit for depositing tokens into their locked deposit entry.
  3. If necessary, later make a proposal to call Clawback on their deposit to retrieve all remaining locked tokens.

License

This code is currently not free to use while in development.

References: