Skip to content

Commit

Permalink
Merge pull request #149 from DA0-DA0/prep-for-launch
Browse files Browse the repository at this point in the history
Prep for launch
  • Loading branch information
JakeHartnell authored Jan 31, 2022
2 parents f9b0bb2 + ee7e830 commit 6555c1c
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 93 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 18 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
# DAO DAO Contracts

**NOT PRODUCTION READY**
| Contract | Description |
| :------------------------------------------ | :---------------------------------------------------------------- |
| [cw-distribution](contract/cw-distribution) | A contract for distributing staking rewards. |
| [cw3-dao](contracts/cw3-dao) | A DAO with voting power based on staked governance tokens. |
| [cw3-multisig](contract/cw3-multisig) | A multisig contract |
| [cw4-registry](contract/cw4-registry) | A contract for indexing multisig group members |
| [stake-cw20](contract/stake-cw20) | A cw20 staking contract |
| [stake-cw20-gov](contract/stake-cw20-gov) | A cw20 staking contract, with vote delegation (used by `cw3-dao`) |

| Contract | Description |
| :---------------------------------------- | :-------------------------------------------------------------- |
| [cw3-dao](contracts/cw3-dao) | A governance token based DAO. |
| [cw3-multisig](contract/cw3-multisig) | A multisig contract |
| [stake-cw20](contract/stake-cw20) | A cw20 staking contract |
| [stake-cw20-gov](contract/stake-cw20-gov) | A cw20 staking contract, with vote delegation used be `cw3-dao` |
NOTE: _These contracts have yet to be audited. Please see the [disclaimer](#Disclaimer)._

## Contributing

Interested in contributing to DAO DAO? Check out [CONTRIBUTING.md](./CONTRIBUTING.md).

## Deploying in a development environment

Deploy the contract to a local chain with:
Build and deploy the contracts to a local chain running in Docker with:

```sh
bash scripts/deploy_local.sh juno10j9gpw9t4jsz47qgnkvl5n3zlm2fz72k67rxsg
Expand All @@ -32,22 +34,24 @@ NEXT_PUBLIC_DAO_TOKEN_CODE_ID=1
NEXT_PUBLIC_DAO_CONTRACT_CODE_ID=2
NEXT_PUBLIC_MULTISIG_CODE_ID=3
NEXT_PUBLIC_C4_GROUP_CODE_ID=4
NEXT_PUBLIC_DAO_TOKEN_ADDRESS=juno14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9skjuwg8
NEXT_PUBLIC_DAO_CONTRACT_ADDRESS=juno1nc5tatafv6eyq7llkr2gv50ff9e22mnf70qgjlv737ktmt4eswrq68ev2p
NEXT_PUBLIC_STAKE_CW20_CODE_ID=5
NEXT_PUBLIC_DAO_CONTRACT_ADDRESS=juno1wug8sewp6cedgkmrmvhl3lf3tulagm9hnvy8p0rppz9yjw0g4wtqwrw37d
```

Add these to your frontend environment variables (`.env.local`).

You can then interact with the contract addresses.
You can then instantiate and interact with contracts.

Note, to send commands to the docker container:

```sh
docker exec -i cosmwasm junod status
docker exec -i cosmwasm junod status
```

Some commands require a password which defaults to `xxxxxxxxx`. You can use them like so:

```sh
echo xxxxxxxxx | docker exec -i cosmwasm junod keys show validator -a
```

## Disclaimer

DAO DAO TOOLING IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND. No developer or entity involved in creating the DAO DAO UI or smart contract will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of DAO DAO tooling, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
2 changes: 1 addition & 1 deletion contracts/cw-distribution/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cw-distribution"
version = "0.2.0"
version = "0.2.5"
authors = ["Ben2x4 <Ben2x4@tutanota.com>"]
edition = "2018"
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion contracts/cw3-dao/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cw3-dao"
version = "0.2.0"
version = "0.2.5"
authors = ["Jake Hartnell <jake@stargaze.zone>", "Ben2x4 <Ben2x4@tutanota.com>", "Ethan Frey <ethanfrey@users.noreply.github.com>"]
edition = "2018"
description = "Implements a cw20 token governed DAO with multiple voting patterns."
Expand Down
2 changes: 1 addition & 1 deletion contracts/cw3-dao/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ These contracts can be used in combination with the cw-dao contract to extend fu

## Testing

You will need Rust 1.44.1+ with `wasm32-unknown-unknown` target installed.
You will need Rust 1.58.1+ with `wasm32-unknown-unknown` target installed.

You can run unit tests on this via:

Expand Down
2 changes: 1 addition & 1 deletion contracts/cw3-multisig/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cw3-multisig"
version = "0.2.0"
version = "0.2.5"
authors = ["Ethan Frey <ethanfrey@users.noreply.github.com>"]
edition = "2018"
description = "Implementing cw3 with multiple voting patterns and dynamic groups"
Expand Down
31 changes: 2 additions & 29 deletions contracts/cw3-multisig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,21 @@

This is a DAO DAO fork of [cw3-flex-multisig](https://github.com/CosmWasm/cw-plus/tree/main/contracts/cw3-flex-multisig) which builds on [cw3-fixed-multisig](https://github.com/CosmWasm/cw-plus/tree/main/contracts/cw3-fixed-multisig) with a more powerful implementation of the [cw3 spec](https://github.com/CosmWasm/cw-plus/tree/main/packages/cw3). It is a multisig contract that is backed by a [cw4 (group)](https://github.com/CosmWasm/cw-plus/tree/main/packages/cw4) contract, which independently maintains the voter set.

This provides 2 main advantages:

* You can create two different multisigs with different voting thresholds
backed by the same group. Thus, you can have a 50% vote, and a 67% vote
that always use the same voter set, but can take other actions.
* The multisig can be the admin of the group and can vote to add new members

In addition to the dynamic voting set, the main difference with the native Cosmos SDK multisig, is that it aggregates the signatures on chain, with visible proposals (like `x/gov` in the Cosmos SDK), rather than requiring signers to share signatures off chain.

## Instantiation

The first step to create such a multisig is to instantiate a cw4 contract
with the desired member set. For now, this only is supported by
[cw4-group](https://github.com/CosmWasm/cw-plus/tree/main/contracts/cw4-group).

If you create a `cw4-group` contract and want a multisig to be able
to modify its own group, do the following in multiple transactions:

* instantiate cw4-group, with your personal key as admin
* instantiate a multisig pointing to the group
* `AddHook{multisig}` on the group contract
* `UpdateAdmin{multisig}` on the group contract

This is the current practice to create such circular dependencies, and depends on an external driver (hard to impossible to script such a self-deploying contract on-chain).

When creating the multisig, you must set the required weight to pass a vote as well as the max/default voting period. (TODO: allow more threshold types)

## Execution Process

First, a registered voter must submit a proposal. This also includes the first "Yes" vote on the proposal by the proposer. The proposer can set an expiration time for the voting process, or it defaults to the limit provided when creating the contract (so proposals can be closed after several days).
First, a registered voter (a member of the multisig) must submit a proposal. This also includes the first "Yes" vote on the proposal by the proposer. The proposer can set an expiration time for the voting process, or it defaults to the limit provided when creating the contract (so proposals can be closed after several days).

Before the proposal has expired, any voter with non-zero weight can add their vote. Only "Yes" votes are tallied. If enough "Yes" votes were submitted before the proposal expiration date, the status is set to "Passed".

Once a proposal is "Passed", anyone may submit an "Execute" message. This will trigger the proposal to send all stored messages from the proposal and update it's state to "Executed", so it cannot run again. (Note if the execution fails for any reason - out of gas, insufficient funds, etc - the state update will be reverted, and it will remain "Passed", so you can try again).

Once a proposal has expired without passing, anyone can submit a "Close" message to mark it closed. This has no effect beyond cleaning up the UI/database.

TODO: this contract currently assumes the group membership is static during the lifetime of one proposal. If the membership changes when a proposal is open, this will calculate incorrect values (future PR).

## Running this contract

You will need Rust 1.44.1+ with `wasm32-unknown-unknown` target installed.
You will need Rust 1.58.1+ with `wasm32-unknown-unknown` target installed.

You can run unit tests on this via:

Expand Down
2 changes: 1 addition & 1 deletion contracts/cw4-registry/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cw4-registry"
version = "0.1.0"
version = "0.2.5"
authors = ["Orkun Külçe <orkunkl@users.noreply.github.com>"]
edition = "2018"

Expand Down
22 changes: 20 additions & 2 deletions contracts/cw4-registry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,23 @@

cw4 registry contract indexes group members.

Group admin must register the registry contract address as hook before adding the group to the registry. Membership
changes will be executed automatically.
Group admin must register the registry contract address as hook before adding the group to the registry. Membership changes will be executed automatically.

## Running this contract

You will need Rust 1.58.1+ with `wasm32-unknown-unknown` target installed.

You can run unit tests on this via:

`cargo test`

Once you are happy with the content, you can compile it to wasm via:

```
RUSTFLAGS='-C link-arg=-s' cargo wasm
cp ../../target/wasm32-unknown-unknown/release/cw4_registry.wasm .
ls -l cw4_registry.wasm
sha256sum cw4_registry.wasm
```

Or for a production-ready (optimized) build, run a build command in the the repository root: https://github.com/CosmWasm/cw-plus#compiling.
2 changes: 1 addition & 1 deletion contracts/stake-cw20-gov/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "stake-cw20-gov"
version = "0.2.0"
version = "0.2.5"
authors = ["Ben2x4 <ben2x4@tutanota.com>"]
edition = "2018"
description = "CosmWasm-20 compliant token with checkpointing to enable DAOs"
Expand Down
42 changes: 9 additions & 33 deletions contracts/stake-cw20-gov/README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,24 @@
# CW20 Gov
# Stake CW20 Gov

This is a basic implementation of a cw20 governance contract. It implements
the CW20 spec with the addition of a BalanceAtHeight Query Message and
is designed to be deployed as is, or imported into other contracts to easily build
cw20-compatible tokens with custom logic.
This is a governance implementation of a cw20 staking contract with support for vote delegation. Staked tokens can be unbonded with a configurable unbonding period. Staked balances and voting power can be queried at any arbitrary height by external contracts.

Inspired by the design of the Compound governance token, `BalanceAtHeight`
can be used to get a users balance at the start of a governance proposal.
This contract is used to enable DAO voting.

Implements:

- [x] CW20 Base
- [x] Mintable extension
- [x] Allowances extension
- [x] BalanceAtHeight QueryMsg
## Running this contract

You will need Rust 1.44.1+ with `wasm32-unknown-unknown` target installed.
You will need Rust 1.58.1+ with `wasm32-unknown-unknown` target installed.

You can run unit tests on this via:
You can run unit tests on this via:

`cargo test`

Once you are happy with the content, you can compile it to wasm via:

```
RUSTFLAGS='-C link-arg=-s' cargo wasm
cp ../../target/wasm32-unknown-unknown/release/cw20_gov.wasm .
ls -l cw20_gov.wasm
sha256sum cw20_gov.wasm
cp ../../target/wasm32-unknown-unknown/release/stake_cw20_gov.wasm .
ls -l stake_cw20_gov.wasm
sha256sum stake_cw20_gov.wasm
```

Or for a production-ready (optimized) build, run a build command in the
the repository root: https://github.com/CosmWasm/cw-plus#compiling.

## Importing this contract

You can also import much of the logic of this contract to build another
ERC20-contract, such as a bonding curve, overiding or extending what you
need.

Basically, you just need to write your handle function and import
`cw20_gov::contract::handle_transfer`, etc and dispatch to them.
This allows you to use custom `ExecuteMsg` and `QueryMsg` with your additional
calls, but then use the underlying implementation for the standard cw20
messages you want to support. The same with `QueryMsg`. You *could* reuse `instantiate`
as it, but it is likely you will want to change it. And it is rather simple.
Or for a production-ready (optimized) build, run a build command in the the repository root: https://github.com/CosmWasm/cw-plus#compiling.
2 changes: 1 addition & 1 deletion contracts/stake-cw20/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "stake-cw20"
version = "0.2.0"
version = "0.2.5"
authors = ["Ben2x4 <Ben2x4@tutanota.com>"]
edition = "2018"
license = "Apache-2.0"
Expand Down
23 changes: 21 additions & 2 deletions contracts/stake-cw20/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# CW20 Stakeable
# Stake CW20

This is an extension of cw20 that allows the token to be staked. Staked tokens can be unbonded with a configurable unbonding period. Staked balances can be queried at any arbitrary height by external contracts. This contract will be used to enable DAO voting.
This is a basic implementation of a cw20 staking contract. Staked tokens can be unbonded with a configurable unbonding period. Staked balances can be queried at any arbitrary height by external contracts.

## Running this contract

You will need Rust 1.58.1+ with `wasm32-unknown-unknown` target installed.

You can run unit tests on this via:

`cargo test`

Once you are happy with the content, you can compile it to wasm via:

```
RUSTFLAGS='-C link-arg=-s' cargo wasm
cp ../../target/wasm32-unknown-unknown/release/stake_cw20.wasm .
ls -l stake_cw20.wasm
sha256sum stake_cw20.wasm
```

Or for a production-ready (optimized) build, run a build command in the the repository root: https://github.com/CosmWasm/cw-plus#compiling.

0 comments on commit 6555c1c

Please sign in to comment.