-
Notifications
You must be signed in to change notification settings - Fork 143
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
Proposal Incentives & Voting Incentives #797
base: development
Are you sure you want to change the base?
Conversation
@ismellike, the proposal incentives contract looks great! |
Need to add tests
I think there's a bug in the removal of multiple hooks at the same time
.unwrap(); | ||
let results = vote_yes_on_proposal(&mut context, 3u64); | ||
for (i, result) in results.iter().enumerate() { | ||
assert!(result.is_ok()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This actually panics, because the hooks simultaneously return an error of expiration.
When the error is processed in the proposal module, it tries to remove by index on a list that has changed already.
thread 'tests::test_hooks' panicked at packages/cw-hooks/src/lib.rs:60:26:
removal index (is 1) should be < len (is 1)
VoteHook of index 0 is successfully removed at index 0, but VoteHook of index 1 tries to be removed at index 1 of a list of length 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a new method in cw-hooks for remove_hook_by_index_from_reply
that takes a new parameter removed_hook_indexes: Item<Vec<u64>>
.
We can adjust the given index to the actual index from this new tracked state on the proposal modules: REMOVED_VOTE_HOOKS_BY_INDEX
or REMOVED_PROPOSAL_HOOKS_BY_INDEX
Co-authored-by: Jake Hartnell <[email protected]>
Can we rebase? In the README for these contracts make sure we note that they aren't audited. |
Need to add tests
I think there's a bug in the removal of multiple hooks at the same time
Co-authored-by: Jake Hartnell <[email protected]>
…tracts into gov-incentives
Proposal Incentives Contract (dao-proposal-incentives):
A new contract has been added to implement incentives for making successful proposals in a DAO. This contract allows DAO's to offer rewards for successful proposals, which can be configured as native or CW20 tokens. The rewards are determined based on the configuration at the proposal's start time.
A new query has been added to the proposal modules for
GenericProposalInfo
, which we can call from a received hook to get a proposal'sproposer
andstart_time
.A new query has been added to the DAO core for
ProposalModule
, which we can call from the incentives contract to check authorization of the sender as a proposal module of the DAO.Voting Incentives Contract (dao-voting-incentives):
The voting incentives contract is adapted from the proposal incentives contract.
When a vote hook is received, its proposal is queried to make sure the proposal occurred after the contract was instantiated (
config.start_height
). If the user has already voted, then we ignore the vote. Otherwise, we incrementconfig.total_vote_count
and the user's votes. From this, we can determine how much a user will be awarded after the voting incentives' expiration. If no users have voted during the voting incentives' period, then the funds will be sent to the contract's owner on expiration.Anyone can call the expire function to set the amount available for distribution. Users can then call
ExecuteMsg::Claim{}
to receive their rewards.