-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
staking rewards distribution followup (#835)
Co-authored-by: Noah Saso <[email protected]> Co-authored-by: Jake Hartnell <[email protected]>
- Loading branch information
1 parent
bb8224e
commit 8be18d1
Showing
33 changed files
with
4,782 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...stributor/schema/cw-fund-distributor.json → ...stributor/schema/cw-fund-distributor.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
[package] | ||
name = "dao-rewards-distributor" | ||
authors = ["Ben2x4 <[email protected]>", "ekez <[email protected]>", "Jake Hartnell <[email protected]>", "bekauz <[email protected]>"] | ||
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 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
11
contracts/distribution/dao-rewards-distributor/examples/schema.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} | ||
} |
Oops, something went wrong.