Skip to content

Commit

Permalink
Merge branch 'development' into feature/cw-orch-interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ismellike committed Jul 11, 2024
2 parents 87925b2 + 5918cbe commit d5a1850
Show file tree
Hide file tree
Showing 129 changed files with 13,296 additions and 420 deletions.
1 change: 1 addition & 0 deletions .cargo/config → .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ all-test = "test --workspace"
unit-test = "test --lib"
integration-test = "test --package integration-tests -- --ignored --test-threads 1 -Z unstable-options --report-time"
test-tube = "test --features test-tube"
schema = "run --example schema"

[env]
RUSTFLAGS = "-C link-arg=-s"
41 changes: 20 additions & 21 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,26 @@ env:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: llvm-tools-preview
- name: cargo install cargo-llvm-cov
run: cargo install cargo-llvm-cov
- name: cargo llvm-cov
run: cargo llvm-cov --workspace --lcov --output-path lcov.info
- name: Codecov
# You may pin to the exact commit or the version.
# uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378
uses: codecov/codecov-action@v3
with:
# Repository upload token - get it from codecov.io. Required only for private repositories
# token: # optional
# Specify whether the Codecov output should be verbose
verbose: true
fail_ci_if_error: true
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: llvm-tools-preview
- name: cargo install cargo-llvm-cov
run: cargo install cargo-llvm-cov
- name: cargo llvm-cov
run: cargo llvm-cov --workspace --lcov --output-path lcov.info
- name: Codecov
# You may pin to the exact commit or the version.
# uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378
uses: codecov/codecov-action@v3
with:
# Repository upload token - get it from codecov.io.
token: ${{ secrets.CODECOV_TOKEN }}
# Specify whether the Codecov output should be verbose
verbose: true
fail_ci_if_error: true
87 changes: 46 additions & 41 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
exclude = ["ci/configs/", "wasmvm/libwasmvm"]
members = [
"contracts/dao-dao-core",
"contracts/distribution/*",
"contracts/external/*",
"contracts/proposal/*",
"contracts/pre-propose/*",
Expand All @@ -17,7 +18,7 @@ resolver = "2"
edition = "2021"
license = "BSD-3-Clause"
repository = "https://github.com/DA0-DA0/dao-contracts"
version = "2.4.2"
version = "2.5.0"

[profile.release]
codegen-units = 1
Expand All @@ -38,10 +39,10 @@ assert_matches = "1.5"
cosm-orc = { version = "4.0" }
cosm-tome = "0.2"
cosmos-sdk-proto = "0.19"
cosmwasm-schema = { version = "1.2" }
cosmwasm-std = { version = "1.5.0", features = ["ibc3"] }
cosmwasm-schema = { version = "1.5.4" }
cosmwasm-std = { version = "1.5.4", features = ["ibc3", "cosmwasm_1_1"] }
cw-controllers = "1.1"
cw-multi-test = "0.18"
cw-multi-test = { version = "0.20.1", features = ["cosmwasm_1_1"] }
cw-storage-plus = { version = "1.1" }
cw-utils = "1.0"
cw2 = "1.1"
Expand All @@ -54,6 +55,7 @@ cw721 = "0.18"
cw721-base = "0.18"
env_logger = "0.10"
once_cell = "1.18"
omniflix-std = "0.1.8"
osmosis-std = "0.20.1"
osmosis-std-derive = "0.20.1"
osmosis-test-tube = "20.1.1"
Expand Down Expand Up @@ -81,43 +83,46 @@ cw-orch = "0.22.2"
# optional owner.
cw-ownable = "0.5"

cw-admin-factory = { path = "./contracts/external/cw-admin-factory", version = "2.4.2" }
cw-denom = { path = "./packages/cw-denom", version = "2.4.2" }
cw-hooks = { path = "./packages/cw-hooks", version = "2.4.2" }
cw-paginate-storage = { path = "./packages/cw-paginate-storage", version = "2.4.2" }
cw-payroll-factory = { path = "./contracts/external/cw-payroll-factory", version = "2.4.2" }
cw-stake-tracker = { path = "./packages/cw-stake-tracker", version = "2.4.2" }
cw-tokenfactory-issuer = { path = "./contracts/external/cw-tokenfactory-issuer", version = "2.4.2", default-features = false }
cw-tokenfactory-types = { path = "./packages/cw-tokenfactory-types", version = "2.4.2", default-features = false }
cw-vesting = { path = "./contracts/external/cw-vesting", version = "2.4.2" }
cw-wormhole = { path = "./packages/cw-wormhole", version = "2.4.2" }
cw20-stake = { path = "./contracts/staking/cw20-stake", version = "2.4.2" }
cw721-controllers = { path = "./packages/cw721-controllers", version = "2.4.2" }
cw721-roles = { path = "./contracts/external/cw721-roles", version = "2.4.2" }
dao-cw721-extensions = { path = "./packages/dao-cw721-extensions", version = "2.4.2" }
dao-dao-core = { path = "./contracts/dao-dao-core", version = "2.4.2" }
dao-dao-macros = { path = "./packages/dao-dao-macros", version = "2.4.2" }
dao-hooks = { path = "./packages/dao-hooks", version = "2.4.2" }
dao-interface = { path = "./packages/dao-interface", version = "2.4.2" }
dao-pre-propose-approval-single = { path = "./contracts/pre-propose/dao-pre-propose-approval-single", version = "2.4.2" }
dao-pre-propose-approver = { path = "./contracts/pre-propose/dao-pre-propose-approver", version = "2.4.2" }
dao-pre-propose-base = { path = "./packages/dao-pre-propose-base", version = "2.4.2" }
dao-pre-propose-multiple = { path = "./contracts/pre-propose/dao-pre-propose-multiple", version = "2.4.2" }
dao-pre-propose-single = { path = "./contracts/pre-propose/dao-pre-propose-single", version = "2.4.2" }
dao-proposal-condorcet = { path = "./contracts/proposal/dao-proposal-condorcet", version = "2.4.2" }
dao-proposal-hook-counter = { path = "./contracts/test/dao-proposal-hook-counter", version = "2.4.2" }
dao-proposal-multiple = { path = "./contracts/proposal/dao-proposal-multiple", version = "2.4.2" }
dao-proposal-single = { path = "./contracts/proposal/dao-proposal-single", version = "2.4.2" }
dao-proposal-sudo = { path = "./contracts/test/dao-proposal-sudo", version = "2.4.2" }
dao-test-custom-factory = { path = "./contracts/test/dao-test-custom-factory", version = "2.4.2" }
dao-testing = { path = "./packages/dao-testing", version = "2.4.2" }
dao-voting = { path = "./packages/dao-voting", version = "2.4.2" }
dao-voting-cw20-balance = { path = "./contracts/test/dao-voting-cw20-balance", version = "2.4.2" }
dao-voting-cw20-staked = { path = "./contracts/voting/dao-voting-cw20-staked", version = "2.4.2" }
dao-voting-cw4 = { path = "./contracts/voting/dao-voting-cw4", version = "2.4.2" }
dao-voting-cw721-roles = { path = "./contracts/voting/dao-voting-cw721-roles", version = "2.4.2" }
dao-voting-cw721-staked = { path = "./contracts/voting/dao-voting-cw721-staked", version = "2.4.2" }
dao-voting-token-staked = { path = "./contracts/voting/dao-voting-token-staked", version = "2.4.2" }
cw-admin-factory = { path = "./contracts/external/cw-admin-factory", version = "2.5.0" }
cw-denom = { path = "./packages/cw-denom", version = "2.5.0" }
cw-fund-distributor = { path = "./contracts/distribution/cw-fund-distributor", version = "2.5.0" }
cw-hooks = { path = "./packages/cw-hooks", version = "2.5.0" }
cw-paginate-storage = { path = "./packages/cw-paginate-storage", version = "2.5.0" }
cw-payroll-factory = { path = "./contracts/external/cw-payroll-factory", version = "2.5.0" }
cw-stake-tracker = { path = "./packages/cw-stake-tracker", version = "2.5.0" }
cw-tokenfactory-issuer = { path = "./contracts/external/cw-tokenfactory-issuer", version = "2.5.0", default-features = false }
cw-tokenfactory-types = { path = "./packages/cw-tokenfactory-types", version = "2.5.0", default-features = false }
cw-vesting = { path = "./contracts/external/cw-vesting", version = "2.5.0" }
cw-wormhole = { path = "./packages/cw-wormhole", version = "2.5.0" }
cw20-stake = { path = "./contracts/staking/cw20-stake", version = "2.5.0" }
cw721-controllers = { path = "./packages/cw721-controllers", version = "2.5.0" }
cw721-roles = { path = "./contracts/external/cw721-roles", version = "2.5.0" }
dao-cw721-extensions = { path = "./packages/dao-cw721-extensions", version = "2.5.0" }
dao-dao-core = { path = "./contracts/dao-dao-core", version = "2.5.0" }
dao-dao-macros = { path = "./packages/dao-dao-macros", version = "2.5.0" }
dao-hooks = { path = "./packages/dao-hooks", version = "2.5.0" }
dao-interface = { path = "./packages/dao-interface", version = "2.5.0" }
dao-pre-propose-approval-single = { path = "./contracts/pre-propose/dao-pre-propose-approval-single", version = "2.5.0" }
dao-pre-propose-approver = { path = "./contracts/pre-propose/dao-pre-propose-approver", version = "2.5.0" }
dao-pre-propose-base = { path = "./packages/dao-pre-propose-base", version = "2.5.0" }
dao-pre-propose-multiple = { path = "./contracts/pre-propose/dao-pre-propose-multiple", version = "2.5.0" }
dao-pre-propose-single = { path = "./contracts/pre-propose/dao-pre-propose-single", version = "2.5.0" }
dao-proposal-condorcet = { path = "./contracts/proposal/dao-proposal-condorcet", version = "2.5.0" }
dao-proposal-hook-counter = { path = "./contracts/test/dao-proposal-hook-counter", version = "2.5.0" }
dao-proposal-multiple = { path = "./contracts/proposal/dao-proposal-multiple", version = "2.5.0" }
dao-proposal-single = { path = "./contracts/proposal/dao-proposal-single", version = "2.5.0" }
dao-proposal-sudo = { path = "./contracts/test/dao-proposal-sudo", version = "2.5.0" }
dao-rewards-distributor = { path = "./contracts/distribution/dao-rewards-distributor", version = "2.5.0" }
dao-test-custom-factory = { path = "./contracts/test/dao-test-custom-factory", version = "2.5.0" }
dao-testing = { path = "./packages/dao-testing", version = "2.5.0" }
dao-voting = { path = "./packages/dao-voting", version = "2.5.0" }
dao-voting-cw20-balance = { path = "./contracts/test/dao-voting-cw20-balance", version = "2.5.0" }
dao-voting-cw20-staked = { path = "./contracts/voting/dao-voting-cw20-staked", version = "2.5.0" }
dao-voting-cw4 = { path = "./contracts/voting/dao-voting-cw4", version = "2.5.0" }
dao-voting-cw721-roles = { path = "./contracts/voting/dao-voting-cw721-roles", version = "2.5.0" }
dao-voting-cw721-staked = { path = "./contracts/voting/dao-voting-cw721-staked", version = "2.5.0" }
dao-voting-onft-staked = { path = "./contracts/voting/dao-voting-onft-staked", version = "2.5.0" }
dao-voting-token-staked = { path = "./contracts/voting/dao-voting-token-staked", version = "2.5.0" }

# v1 dependencies. used for state migrations.
cw-core-v1 = { package = "cw-core", version = "0.1.0" }
Expand Down
7 changes: 6 additions & 1 deletion ci/bootstrap-env/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use cosm_orc::{config::cfg::Config, orchestrator::cosm_orc::CosmOrc};
use cosmwasm_std::{to_json_binary, Decimal, Empty, Uint128};
use cw20::Cw20Coin;
use dao_interface::state::{Admin, ModuleInstantiateInfo};
use dao_voting::pre_propose::PreProposeSubmissionPolicy;
use dao_voting::{
deposit::{DepositRefundPolicy, DepositToken, UncheckedDepositInfo, VotingModuleTokenType},
pre_propose::PreProposeInfo,
Expand Down Expand Up @@ -99,7 +100,11 @@ fn main() -> Result<()> {
amount: Uint128::new(1000000000),
refund_policy: DepositRefundPolicy::OnlyPassed,
}),
open_proposal_submission: false,
submission_policy: PreProposeSubmissionPolicy::Specific {
dao_members: true,
allowlist: None,
denylist: None,
},
extension: Empty::default(),
})
.unwrap(),
Expand Down
File renamed without changes.
8 changes: 6 additions & 2 deletions ci/integration-tests/src/helpers/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use dao_interface::query::DumpStateResponse;
use dao_interface::state::{Admin, ModuleInstantiateInfo};
use dao_voting::{
deposit::{DepositRefundPolicy, DepositToken, UncheckedDepositInfo, VotingModuleTokenType},
pre_propose::{PreProposeInfo, ProposalCreationPolicy},
pre_propose::{PreProposeInfo, PreProposeSubmissionPolicy, ProposalCreationPolicy},
threshold::PercentageThreshold,
threshold::Threshold,
voting::Vote,
Expand Down Expand Up @@ -84,7 +84,11 @@ pub fn create_dao(
amount: DEPOSIT_AMOUNT,
refund_policy: DepositRefundPolicy::OnlyPassed,
}),
open_proposal_submission: false,
submission_policy: PreProposeSubmissionPolicy::Specific {
dao_members: true,
allowlist: None,
denylist: None,
},
extension: Empty::default(),
})
.unwrap(),
Expand Down
4 changes: 0 additions & 4 deletions contracts/dao-dao-core/.cargo/config

This file was deleted.

2 changes: 1 addition & 1 deletion contracts/dao-dao-core/schema/dao-dao-core.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "dao-dao-core",
"contract_version": "2.4.2",
"contract_version": "2.5.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "A CosmWasm contract for distributing funds to DAO members based o
edition = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
version = "0.1.0"
version = { workspace = true }

[lib]
crate-type = ["cdylib", "rlib"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "cw-fund-distributor",
"contract_version": "0.1.0",
"contract_version": "2.5.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
44 changes: 44 additions & 0 deletions contracts/distribution/dao-rewards-distributor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[package]
name = "dao-rewards-distributor"
authors = ["Ben2x4 <Ben2x4@tutanota.com>", "ekez <ekez@withoutdoing.com>", "Jake Hartnell <no-reply@no-reply.com>", "bekauz <bekauz@protonmail.com>"]
description = "Distributes rewards based on DAO membership."
edition = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
version = { workspace = true }

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

[features]
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

[dependencies]
cosmwasm-std = { workspace = true }
cosmwasm-schema = { workspace = true }
cw2 = { workspace = true }
cw4 = { workspace = true }
cw20 = { workspace = true }
cw20-base = { workspace = true, features = ["library"] }
cw-controllers = { workspace = true }
cw-ownable = { workspace = true }
cw-storage-plus = { workspace = true }
cw-utils = { workspace = true }
dao-hooks = { workspace = true }
dao-interface = { workspace = true }
dao-voting = { workspace = true }
thiserror = { workspace = true }

[dev-dependencies]
cw-multi-test = { workspace = true }
anyhow = { workspace = true }
cw20-stake = { workspace = true, features = ["library"] }
cw4-group = { workspace = true, features = ["library"] }
cw721-base = { workspace = true, features = ["library"] }
dao-voting-cw20-staked = { workspace = true, features = ["library"] }
dao-voting-cw4 = { workspace = true, features = ["library"] }
dao-voting-token-staked = { workspace = true, features = ["library"] }
dao-voting-cw721-staked = { workspace = true, features = ["library"] }
dao-testing = { workspace = true }
31 changes: 31 additions & 0 deletions contracts/distribution/dao-rewards-distributor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# DAO Rewards Distributor

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

The `dao-rewards-distributor` works in conjuction with DAO voting modules to provide rewards over time for DAO members. The contract supports both cw20 and native Cosmos SDK tokens. The following voting power modules are supported:
- `dao-voting-cw4`: for membership or group based DAOs
- `dao-voting-cw20-staked`: for cw20 token based DAOs.
- `dao-voting-cw721-staked`: for NFT based DAOs.
- `dao-voting-token-staked`: for native and Token Factory token based DAOs.

NOTE: this contract is NOT AUDITED and is _experimental_. USE AT YOUR OWN RISK.

## Instantiation and Setup

The contract is instantiated with a number of parameters:
- `owner`: The owner of the contract. Is able to fund the contract and update the reward duration.
- `vp_contract`: A DAO DAO voting power module contract address, used to determine membership in the DAO over time.
- `hook_caller`: An optional contract that is allowed to call voting power change hooks. Often, as in `dao-voting-token-staked` and `dao-voting-cw721-staked` the vp_contract calls hooks for power change events, but sometimes they are separate. For example, the `cw4-group` contract is separate from the `dao-voting-cw4` contract and since the `cw4-group` contract fires the membership change events, it's address would be used as the `hook_caller`.
- `reward_denom`: the denomination of the reward token, can be either a cw20 or native token.
- `reward_duration`: the time period over which rewards are to be paid out in blocks.

After instantiating the contract it is VITAL to setup the required hooks for it to work. This is because to pay out rewards accurately, this contract needs to know about staking or voting power changes in the DAO.

This can be achieved using the `add_hook` method on contracts that support voting power changes, which are:
- `cw4-group`
- `dao-voting-cw721-staked`
- `dao-voting-token-staked`
- `cw20-stake`

Finally, the contract needs to be funded with a token matching the denom specified in the `reward_denom` field during instantiation. This can be achieved by calling the `fund` method on the `dao-rewards-distributor` smart contract, and sending along the appropriate funds.
11 changes: 11 additions & 0 deletions contracts/distribution/dao-rewards-distributor/examples/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use cosmwasm_schema::write_api;
use dao_rewards_distributor::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};

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

0 comments on commit d5a1850

Please sign in to comment.