Sigma DAO i an Algo Builder
powered project. We provide templates for creating new DAOs, proposals and scripts to vote. User can also setup a webapp UI to interact with a DAO.
Every DAO has the following parameters:
-
deposit
— a deposit amount ingov_tokens
required to make a proposal. -
min_support
— a minimum number ofyes
power votes (other votes likeabstain
andno
are not counted) to validate the proposal. -
min_duration
— minimum voting time (in number of seconds) for a new proposal. -
max_duration
— maximum voting time (in number of seconds) for a new proposal. -
url
— a link with more information about the DAO. We don’t need a hash as this document is meant to evolve and provide more details together with the DAO evolution.
We use functional notation to describe use cases we will implement.
-
initialize(deposit_amount, min_support, min_duration, ..)
— Creates a DAO app and records all above parameters in it’s global state except the gov. Transaction composition:- tx0:
deployer.deployApp
transaction with appArgs: [deposit, min_support, min_duration, max_duration, url].
- tx0:
-
add_proposal(url: string, ..)
— Records proposal in lsig (local state). One lsig can have maximum one active proposal. If a proposal is not active any more we can reuse the lsig to record a new proposal. Transaction composition:- tx0: Call to DAO App with daoParams.
- tx1: Deposit gov_tokens to depositLsig.
-
deposit_vote_token(amount)
— User can only vote with the deposited tokens (to avoid double voting by sending tokens to someone else). User can vote with the “same” tokens for multiple proposals. Transaction composition:- tx0: Call to DAO App with appArg == "deposit_vote_token".
- tx1: Deposit gov_tokens to depositLsig (each token == 1 vote).
-
withdraw_vote_deposit(amount)
— This is used to unlock the deposit and withdraw tokens back to the user. To protect against double vote, user can only withdraw the deposit after the latest voting he participated in ended. Transaction composition:- tx0: Call to DAO App with appArg == "withdraw_vote_deposit".
- tx1: Withdraw gov_tokens from depositLsig (ASA transfer).
-
vote(proposalLsig, voteType)
— Records vote by voterAcc in proposal (vote can be one ofyes
,no
,abstain
). Transaction composition:- tx0: Call to DAO App with appArg == ["register_vote", vote_type].
proposalLsig.address()
is passed as first external account.
Note1: User can vote only once for a given proposal and he will vote with all tokens he deposited before casting the vote. Note2: User can only vote on 14 active proposals at a time.
- tx0: Call to DAO App with appArg == ["register_vote", vote_type].
-
execute()
— Executes a proposal. NOTE: anyone is able to execute a proposal (this way we protect from a situation that a proposer will not be satisfied from the result and will not execute it). Transaction composition:- tx0: Call to DAO App with appArg == "execute".
- tx1: As per proposal instructions (ALGO transfer/ASA transfer/none)
-
clear_vote_record(proposal_lsig)
— Clears Sender local state by removing a record of vote cast from a not active proposal. Transaction composition:- tx0: Call to DAO App with appArg == ["clear_vote_record"].
proposalLsig.address()
is passed as first external account.
- tx0: Call to DAO App with appArg == ["clear_vote_record"].
-
close_proposal()
— Closes proposal record and returns back the deposit. Sender must be an account with a recorded proposal. Transaction composition:- tx0: Call to DAO App with appArg == "close_proposal".
- tx1: Withdraw gov_tokens from depositLsig back to proposalLsig (ASA transfer).
-
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).
Below diagram describes the flow of DAO application.
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.
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).
yarn run algob deploy
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. 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). Records vote by voterAcc in proposal (vote can be one of yes
, no
, abstain
):
yarn run algob run scripts/run/vote.js
To execute a proposal (execute_before
is set as 7min from the time of proposal creation):
yarn run algob run scripts/run/vote.js
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. 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. 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
To withdraw assets from proposalLsig back to the owner (proposer), fails if the receiver is not the owner of the proposalLsig:
yarn run algob run scripts/run/withdraw_from_proposal.js