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

Proposal Incentives & Voting Incentives #797

Open
wants to merge 49 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
fb60e86
Smart contract skeleton for voting incentives
JakeHartnell Jan 9, 2024
16bfaee
More comments
JakeHartnell Jan 23, 2024
bd79371
dao-proposal-incentives initial commit
JakeHartnell Jan 24, 2024
97e2472
Add more design notes and TODOs
JakeHartnell Jan 24, 2024
c1ef0bf
Proposal incentives fixups and notes
JakeHartnell Jan 25, 2024
a7bb852
Voting incentives checks and notes
JakeHartnell Jan 25, 2024
21c488b
More notes
JakeHartnell Jan 25, 2024
b7b01cb
Proposal Incentives
ismellike Jan 31, 2024
834e16e
Fix clippy errors
ismellike Jan 31, 2024
34c7474
More clippy
ismellike Jan 31, 2024
41b15fe
Schema + clippy fix
ismellike Feb 1, 2024
ed344a4
Progress on voting incentives
ismellike Feb 7, 2024
f0c494b
Handle revoting and update readme's
ismellike Feb 7, 2024
1c3d428
Update README.md
ismellike Feb 7, 2024
86c85f5
Work on voting tests
ismellike Feb 8, 2024
01eedd6
Fix for simultaneous hook error handling
ismellike Feb 9, 2024
e4477df
Wrap up tests for voting incentives
ismellike Feb 10, 2024
30bfeab
Combine rewards queries
ismellike Feb 13, 2024
2816beb
Add is_claimable flag to reward response
ismellike Feb 14, 2024
a86f0dc
Merge branch 'development' into gov-incentives
ismellike May 7, 2024
a76127f
Schemas and clippy fixes
ismellike May 8, 2024
064f353
Update contracts/external/dao-proposal-incentives/Cargo.toml
ismellike Jun 13, 2024
8849221
Smart contract skeleton for voting incentives
JakeHartnell Jan 9, 2024
55b9665
More comments
JakeHartnell Jan 23, 2024
aa3dd76
dao-proposal-incentives initial commit
JakeHartnell Jan 24, 2024
e219dea
Add more design notes and TODOs
JakeHartnell Jan 24, 2024
76f5ca1
Proposal incentives fixups and notes
JakeHartnell Jan 25, 2024
40dd5fe
Voting incentives checks and notes
JakeHartnell Jan 25, 2024
632bfe4
More notes
JakeHartnell Jan 25, 2024
d2c39be
Proposal Incentives
ismellike Jan 31, 2024
dbab201
Fix clippy errors
ismellike Jan 31, 2024
3597697
More clippy
ismellike Jan 31, 2024
012f8c3
Schema + clippy fix
ismellike Feb 1, 2024
2bf1ec1
Progress on voting incentives
ismellike Feb 7, 2024
5c9383f
Handle revoting and update readme's
ismellike Feb 7, 2024
22a13d1
Update README.md
ismellike Feb 7, 2024
65fa0de
Work on voting tests
ismellike Feb 8, 2024
9419658
Fix for simultaneous hook error handling
ismellike Feb 9, 2024
6961ce6
Wrap up tests for voting incentives
ismellike Feb 10, 2024
809ba2c
Combine rewards queries
ismellike Feb 13, 2024
1d5bd35
Add is_claimable flag to reward response
ismellike Feb 14, 2024
21eb271
Schemas and clippy fixes
ismellike May 8, 2024
4a9a9e1
Update contracts/external/dao-proposal-incentives/Cargo.toml
ismellike Jun 13, 2024
778a361
Improve proposal & voting incentives readme's + add not audited warnings
ismellike Aug 16, 2024
2fb9ec5
Merge branch 'gov-incentives' of https://github.com/ismellike/dao-con…
ismellike Aug 16, 2024
7cce5b3
gen schema
ismellike Aug 16, 2024
754442d
Disable doctests on gov-incentives
ismellike Aug 16, 2024
ffe92b1
Bump integration_tests to nightly toolchain
ismellike Aug 16, 2024
c3b6321
Free up space for test_tube.yml
ismellike Aug 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
447 changes: 244 additions & 203 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ dao-pre-propose-multiple = { path = "./contracts/pre-propose/dao-pre-propose-mul
dao-pre-propose-single = { path = "./contracts/pre-propose/dao-pre-propose-single", version = "2.4.0" }
dao-proposal-condorcet = { path = "./contracts/proposal/dao-proposal-condorcet", version = "2.4.0" }
dao-proposal-hook-counter = { path = "./contracts/test/dao-proposal-hook-counter", version = "2.4.0" }
dao-proposal-incentives = { path = "./contracts/external/dao-proposal-incentives", version = "2.4.0" }
dao-proposal-multiple = { path = "./contracts/proposal/dao-proposal-multiple", version = "2.4.0" }
dao-proposal-single = { path = "./contracts/proposal/dao-proposal-single", version = "2.4.0" }
dao-proposal-sudo = { path = "./contracts/test/dao-proposal-sudo", version = "2.4.0" }
Expand All @@ -116,6 +117,7 @@ dao-voting-cw20-staked = { path = "./contracts/voting/dao-voting-cw20-staked", v
dao-voting-cw4 = { path = "./contracts/voting/dao-voting-cw4", version = "2.4.0" }
dao-voting-cw721-roles = { path = "./contracts/voting/dao-voting-cw721-roles", version = "2.4.0" }
dao-voting-cw721-staked = { path = "./contracts/voting/dao-voting-cw721-staked", version = "2.4.0" }
dao-voting-incentives = { path = "./contracts/external/dao-voting-incentives", version = "2.4.0" }
dao-voting-token-staked = { path = "./contracts/voting/dao-voting-token-staked", version = "2.4.0" }

# v1 dependencies. used for state migrations.
Expand Down
8 changes: 8 additions & 0 deletions contracts/dao-dao-core/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
QueryMsg::ProposalModules { start_after, limit } => {
query_proposal_modules(deps, start_after, limit)
}
QueryMsg::ProposalModule { address } => query_proposal_module(deps, address),
QueryMsg::ProposalModuleCount {} => query_proposal_module_count(deps),
QueryMsg::TotalPowerAtHeight { height } => query_total_power_at_height(deps, height),
QueryMsg::VotingModule {} => query_voting_module(deps),
Expand All @@ -577,6 +578,13 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
}
}

pub fn query_proposal_module(deps: Deps, address: String) -> StdResult<Binary> {
let address = deps.api.addr_validate(&address)?;
let proposal_module = &PROPOSAL_MODULES.load(deps.storage, address)?;

to_json_binary(&proposal_module)
}

pub fn query_admin(deps: Deps) -> StdResult<Binary> {
let admin = ADMIN.load(deps.storage)?;
to_json_binary(&admin)
Expand Down
4 changes: 4 additions & 0 deletions contracts/external/dao-proposal-incentives/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[alias]
wasm = "build --release --target wasm32-unknown-unknown"
unit-test = "test --lib"
schema = "run --example schema"
40 changes: 40 additions & 0 deletions contracts/external/dao-proposal-incentives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[package]
name ="dao-proposal-incentives"
authors = ["Jake Hartnell <[email protected]>", "ismellike"]
description = "A contract that implements incentives for voting in a DAO."
ismellike marked this conversation as resolved.
Show resolved Hide resolved
edition = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
version = { workspace = true }

[lib]
crate-type = ["cdylib", "rlib"]

[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

[dependencies]
cosmwasm-std = { workspace = true }
cosmwasm-schema = { workspace = true }
cw-storage-plus = { workspace = true }
cw2 = { workspace = true }
dao-hooks = { workspace = true }
dao-interface = { workspace = true }
dao-voting = { workspace = true }
thiserror = { workspace = true }
cw-utils = { workspace = true }
cw-denom = { workspace = true }
cw-ownable = { workspace = true }
cw20 = { workspace = true }

[dev-dependencies]
cosmwasm-schema = { workspace = true }
cw-multi-test = { workspace = true }
dao-dao-core = { workspace = true, features = ["library"] }
cw20-base = { workspace = true, features = ["library"] }
dao-testing = { workspace = true }
dao-proposal-single = { workspace = true, features = ["library"] }
cw-hooks = { workspace = true }
31 changes: 31 additions & 0 deletions contracts/external/dao-proposal-incentives/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# dao-proposal-incentives

[![dao-proposal-incentives on crates.io](https://img.shields.io/crates/v/dao-proposal-incentives.svg?logo=rust)](https://crates.io/crates/dao-proposal-incentives)
[![docs.rs](https://img.shields.io/docsrs/dao-proposal-incentives?logo=docsdotrs)](https://docs.rs/dao-proposal-incentives/latest/cw_admin_factory/)

This contract enables DAO's to incentivize members for making successful proposals. By integrating this contract, DAO's can automatically reward members whose proposals are successfully passed, using either native tokens or CW20 tokens.

## Instantiate

To instantiate the contract, provide the following parameters:

- `owner`: The DAO sending this contract proposal hooks.
- `proposal_incentives`: Configuration for the incentives to be awarded for successful proposals. This should be specified using the `ProposalIncentivesUnchecked` structure.

## Configuration

- This contract should be added as a `ProposalHook` to either the `dao-voting-single` or `dao-voting-multiple` proposal modules.
- The DAO must be set as the `owner` of this contract to manage incentives and ownership.

The incentives can be adjusted at any time by the owner of the contract. The rewards are determined based on the configuration at the proposal's `start_time`. This allows for dynamic adjustment of incentives to reflect the DAO's evolving priorities and resources.

## Execute

- **ProposalHook(ProposalHookMsg)**: Triggered when a proposal's status changes. This is used to evaluate and potentially reward successful proposals.
- **UpdateOwnership(cw_ownable::Action)**: Updates the ownership of the contract. This can be used to transfer ownership or perform other ownership-related actions.
- **UpdateProposalIncentives { proposal_incentives: ProposalIncentivesUnchecked }**: Updates the incentives configuration. This allows the DAO to modify the rewards for successful proposals.
- **Receive(Cw20ReceiveMsg)**: Handles the receipt of CW20 tokens. This is necessary for managing CW20-based incentives.

## Query

- **ProposalIncentives { height: Option<u64> }**: Returns the current configuration of the proposal incentives. The `height` parameter is optional and can be used to query the incentives at a specific blockchain height, providing a snapshot of the incentives at that point in time.
11 changes: 11 additions & 0 deletions contracts/external/dao-proposal-incentives/examples/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use cosmwasm_schema::write_api;
use dao_proposal_incentives::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};

fn main() {
write_api! {
instantiate: InstantiateMsg,
query: QueryMsg,
execute: ExecuteMsg,
migrate: MigrateMsg,
}
}
Loading
Loading