Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token2022 Support as a governance plugin #93

Open
anthonyliriano opened this issue May 8, 2024 · 1 comment
Open

Token2022 Support as a governance plugin #93

anthonyliriano opened this issue May 8, 2024 · 1 comment

Comments

@anthonyliriano
Copy link

anthonyliriano commented May 8, 2024

This is a continuation of Add Token Extensions Support on Governance Program logic should be extracted and reimplemented as a plugin

  1. Write configuration instructions - by convention we store it on account called Registrar,
    Note: the token configured as governing token in Realm doesn't have to be the same as the one which will be used for governance power and which deposits wold be accepted. In fact we could accept several governance tokens (the same way as VSR does) and combine their governance power
  2. Write the logic to take deposits of the tokens and withdrawals. Note: Withdrawals must be checked with spl-governance to check if they are allowed https://github.com/blockworks-foundation/voter-stake-registry/blob/62f96fee961c055e1bef942e7d56e7216ba3051f/programs/voter-stake-registry/src/instructions/withdraw.rs#L100
  3. Write instructions to create and populate VoterWeightRecord and MaxVoterWeightRecord accounts
  4. When you do the Withdraw logic please make sure it's not possible to Deposit and Withdraw in the same slot to prevent flash loan style governance attacks

Some comments for the existing code, that should be addressed for the plugin implementation:

  1. Revoke is not needed - it was done as a workaround to support revokable and none transferable spl-tokens but token2022 supports it natively through extensions
  2. We can avoid some of the is_token_2022 params because this can be inferred from the token_program_id instead
  3. For the deposits we should not subtract the fee, we should attempt to deposit the amount as is and if there is not enough remaining for fees then it should fail. The UI should adjust the amounts to allow for the fee
  4. Instead of checking for the extra and optional account expected_mint_info we should check if the program is token_2022 and then fetch the mint because it’s required in such a case
  5. The tests code probably could be made more compact with less duplication

https://app.gib.work/i/IAesrPp7/token2022-support-as-a-governance-plugin

@SimardeepSingh-zsh
Copy link

#94

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants