diff --git a/examples/dao/README.md b/examples/dao/README.md index c41200306..b629d8b01 100644 --- a/examples/dao/README.md +++ b/examples/dao/README.md @@ -10,6 +10,8 @@ A DAO is usually implemented using blockchain smart contracts: In this template, We are going to implement a DAO, where the members are defined by ASA holding (1 ASA = 1 voting power): each token holder is a DAO member and can participate equally in the governance. +## DAO parameters: + Every DAO has the following parameters: - `deposit` — a deposit amount in `gov_tokens` required to make a proposal. @@ -68,6 +70,12 @@ We use functional notation to describe use cases we will implement. - `withdraw_from_proposal()` - Withdraw the assets from the proposalLsig back to the owner. Receiver must be the owner of the proposalLsig. Transaction composition: - _tx0_: Withdraw _gov_tokens_ from _proposalLsig_ back to _proposer_ (owner) (ASA transfer). +## DAO flow + +Below diagram describes the flow of DAO application. + + + ## Setup Sigma Dao Setup the sigma_daos table. Indexer should be running before executing below script. @@ -86,25 +94,25 @@ Run below script to delete the sigma dao user, sigma dao user should be present: ## Spec document -Algo Builder DAO [specification](https://paper.dropbox.com/doc/Algo-Builder-DAO--BRlh~FwufNzIzk4wNUuAjLTuAg-ncLdytuFa7EJrRerIASSl). +Please read the Algo Builder DAO [specification](https://paper.dropbox.com/doc/Algo-Builder-DAO--BRlh~FwufNzIzk4wNUuAjLTuAg-ncLdytuFa7EJrRerIASSl) for more details about each use case. -## Deploy script +## Scripts -We created a deploy script in `scripts/deploy`, This script deploys initial Gov token, deploys DAO app, fund lsig's, saves deposit_lsig address to DAO app, and does initial distribution of ASA (Gov token). + The scripts provide only a sample code to show how to use the template. For your own needs, you will have to modify the scripts directory to adjust the parameters (eg voting time, execution time etc...) and the proposals. -## Scripts +To deploy the DAO, we created a deploy script in `scripts/deploy`. This script deploys initial Gov token, deploys DAO app, fund lsig's, saves deposit_lsig address to DAO app, and does initial distribution of ASA (Gov token). -Please read the spec document (linked above) for more details about each use case. The scripts provide only a sample code to show how to use the template. For you private needs, you will have to modify the scripts directory to adjust the parameters (eg voting time, execution time etc...) and the proposals. + yarn run algob deploy -To add proposal (`{voting_start, voting_end}` is set as `{now + 1min, now + 3min}`): +To add proposal (`{voting_start, voting_end}` is set as `{now + 1min, now + 3min}`). This records proposal in lsig (local state).: yarn run algob run scripts/run/add_proposal.js -To deposit votes: +To deposit votes. Deposit is used to enable voting for all proposals. User can only vote with deposited tokens. Deposited tokens can be used for all proposals simultaneously.: yarn run algob run scripts/run/deposit_vote_token.js -To vote for a proposal (using deposited tokens): +To vote for a proposal (using deposited tokens). Records vote by voterAcc in proposal (vote can be one of `yes`, `no`, `abstain`): yarn run algob run scripts/run/vote.js @@ -112,15 +120,15 @@ To execute a proposal (`execute_before` is set as 7min from the time of proposal yarn run algob run scripts/run/vote.js -To withdraw deposited votes (withdrawn from depositLsig to voter account): +To withdraw deposited votes. User can only withdraw the deposit after the latest voting he participated in ended.: yarn run algob run scripts/run/withdraw_vote_deposit.js -To clear vote record (from voter's account), fails if the proposal is still in progress: +To clear vote record (from voter's account), fails if the proposal is still in progress. This clears sender's local state by removing a record of vote cast from a non-active proposal.: yarn run algob run scripts/run/clear_vote_record.js -To close proposal record (from proposal_lsig as a sender), fails if the proposal is still in progress: +To close proposal record (from proposal_lsig as a sender), fails if the proposal is still in progress. This closes proposal record and returns back the deposit. Sender must be an account with a recorded proposal.: yarn run algob run scripts/run/close_proposal.js diff --git a/examples/dao/docs/DAO-Flow.svg b/examples/dao/docs/DAO-Flow.svg new file mode 100644 index 000000000..95194e641 --- /dev/null +++ b/examples/dao/docs/DAO-Flow.svg @@ -0,0 +1,4 @@ + + + +
Proposal still
in progress 
Proposal still...
Close Proposal
Close Proposal
Clear Vote Record
Clear Vote Record
Yes
Yes
No
No
Fails, if tried to clear vote record and close the proposal
Fails, if tried...
Add Proposal
Add Proposal
Use try to add proposal
Use try to add p...
Input: Proposal Config
like url, proposal name etc
Input: Proposal Config...
Verify deposit
Verify deposit
Validate Proposal config params like voting start, etc.
Validate Proposal co...
Is voting_end > voting_start > current time,
and min_duration <= voting_end - voting_start <= max_duration?
Is voting_end > voting_start > current time,...
Is there an active proposal in account?
Is there an active pro...
Put proposal config in local state
Put proposal config...
Assign proposal id equal to txn id.
Assign proposal id e...
Proposal added
Proposal added
Yes
Yes
No
No
Use try to vote
Use try to vote
Vote
Vote
Deposit Vote Token
Deposit Vote Token
Withdraw
Deposited
Token
Withdraw...
Yes
Yes
No
No
Is voting_start <= now <= voting_end
and has deposit > 0?
Is voting_start <= now <= voting_end...
Record vote (yes, no, abstain) in local state and increase the counter
Record vote (yes, no,...
Fails
Fails
Yes
Yes
No
No
Proposal passed?
Proposal passed?
End
End
Withdraw deposit
Withdraw deposit
Withdraw deposit and execute
Withdraw deposit and...
Text is not SVG - cannot display
\ No newline at end of file