I wrote this guide after spending lots of hours trying to understand the DAO accounting system. Hope that this guide helps any one that’s studying the DAO contract at https://github.com/slockit/DAO or simply wants to deepen how the accounting is carried inside the DAO contract.
Token types in the DAO
DAO Tokens ( Ð )
DAO tokens ( Ð ) represents the ownership of the DAO. If you have Ð then you are member (aka. DTH) of the “The DAO”. The ownership percentage is calculated as:
Where totalSupply is the total number of DAO tokens that exist. The totalSupply is fixed after the Creation phase, and only decreases as a result of splits. The act of splitting burns DAO tokens.
Reward Tokens (RT)
Every time that a proposal is executed and some money gets out of the DAO all the DTH (Dao Token Holders) receive reward tokens. Theses reward tokens represent the ownership of the investment made by the DAO. For each Ether that gets out of the DAO, 1RT is generated. The ownership of this RT is the whole DAO. For example if a DAO invest 140Ξ in a proposal, the DAO will generate and hold 140RT. If Alice owns 10% of the DAO tokens, we can say that Alice owns 14RT implicitly. As the DAO Tokens are backed by RT and Ξ that are held by the DAO. What’s important to understand here is that the DAO never just spends money, it only supports projects. The ownership of all the returns the projects provide is determined by the reward token holders. What’s interesting here is that when somebody splits, they still keep the rewardTokens accumulated until the split. They do not lose the ownership of the investment! Of course, after the split, They will not receive any more reward tokens in the following DAO investments but they have the rights to receive the return of the investment proportionally to their accumulated rewardsTokens until the split.
Here totalRewardToken is the total investment made by the DAO in its history. This number increases on each investment but never decreases.
Accounts in the DAO
The ether inside the DAO can reside in the main contract or in some child contracts called Managed Accounts.
A managed account is a different contract than the main DAO contract but controlled absolutely from the main DAO contract. That means that only the DAO contract can payOut money from a managedAccount.
The DAO main account (0xbb9bc244d798123fde783fcc1c72d3bb8c189413 )
Like any other contract, the DAO contract can hold money by itself. This is the default place where ether resides. The ownership of the money in this account is determined by DAOtokens . Each one with the proportion of their tokens.
The extraBalance (0x807640a13483f8ac783c557fcdf27be11ea4ac7a)
During the token creation phase, the price of the Dao Token is not the same. At the beginning of the process, 100Ð cost 1E. But at the end to the process 100Ð costs 1.5Ξ.
There is a s simple attack that consist of buying lots of tokens at price 1 and then split immediately after the creation process ends. In this case, the attacker would get more than 1Ξ for each Ξ invested if there are people buying Ð at more than 1Ξ/100Ð. So to solve that, developers created the extraBalance account. This account stores the extra money that the DAO gets because of selling Ð at higher price that 1Ξ/100Ð in the final phases. For example, if you buy 100Ð for 1.5Ξ just before the creation phase ends, then there will be 1Ξ that will go to the main DAO account and 0.5Ξ that will go to the extra balance. In this case, all the splits that go immediately after the creation period closes will get exactly 1Ξ/100Ð regardless what he Paid for each Ð. The Ethers in the extraBalance will go to the main DAO account later in time, when a proposal is approved and at least the same amount of Ether that the extraBalance has been invested with regular proposals.
The rewardAccount (0xd2e16a20dd7b1ae54fb0312209784478d069c7b0 )
The DAO, like any other “for profit” organization is created because there are people (tokenHolders) that expect that sooner or later will pay rewards to the token holders. When the DAO approves to pay rewards to their tokenHolders via a proposal, what it does is transfer the total amount of Ethers that wants to pay to the rewardAccount. Once the Ether is in this account, the tokenHolders can take the Ether that corresponds according to the Ð that holds.
The DAOrewardAccount (0x17cd41543a3c3c77d5e372704c9577df09eea003)
The DAO will invest in some proposals. Those investments, directly or indirectly should return the investment to the DAO. For example, the DAO% will be send to this account. The owner of the Ether in this account belongs to any body that pay the investments, and that is not only the current DAO token holders, They are also all the child DAO’s that split some day and holds reward tokens. So, the ether on this account should be distributed according the RewardTokens that the DAO and each child DAO holds. When there is some Ether in this account, the DAO will probably approve a proposal to takes all the Ether that belongs to it and transfer it to the main DAO account. (It can also opt to transfer the Ether directly to the rewards account). The split DAOs will do exactly the same when there is some money in his parent DAO DAOrewardAccount that belongs to it because of rewardTokens of the parent DAO before the split.
Flux of the Money
During the creation phase, all the Ether will go to the main DAO account and to the Extra Balance. Concretely, in the phase of rate 1 (before two weeks prior to the creation period ends), the Ether will go entirely to the main DAO account. When the rate increases to more than 1, the extra money because of the increase of the DAO token price, is stored in the extraBalance. The money in the extraBalance will stay there until at least the same amount of money in the extraBalance is invested in regular proposals.
Proposal execution (invest)
When a proposal is approved, the amount of money approved is sent from the DAO to the recipient of the proposal. As a side note, I would like to remember here that it is possible to send the approved amount to a regular account or to a contract. In the last case, the proposal can specify with which methods and with which parameters the DAO contract will call if the proposal is approved. When a proposal is executed, all the DAO token holders will receive the rewardToken holders. 1RT is equivalent to 1Ξ invested. For example if Alice owns 10% of the DAO Tokens and 150Ξ are Invested in a proposal, the DAO will generate 150RT of which 15 belongs to Alice.
Receive rewards (Return of investment)
When an investment pays the DAO, it should do it in the DAOrewardAccount. The most typical example is the DAO% of the Ethereum computer. When an ethereum computer is installed, an amount of ether (DAO%) will be returned to the DAO via the DAOrewardAccount. Ether in this account belongs to the reward Token Holders. That is the Main DAO and all split DAO’s in the history.
Distribute return of investment
Ether in DAOrewardAccount will be sent to the main DAO and to all the child splitDAO’s. Each one in proportion to the rewardTokens that hold. This is done by a proposal in each DAO (including the main DAO) The proposal says to execute the main DAO method retrieveDAOReward(). The ether can be send directly to the main DAO account of the calling DAO or to the rewardAccount if they approve to distribute the rewards to their DAO token holders.
Pay dividends process
Finally, when some day the DAO wants to distribute dividends to their DAO token holders, the DAO will approve a proposal to send the total amount that wants to be distributed into the rewardAccount. Once the Ether in this account, the DAO token Holders can call thegetMyReward() method to get the portion of ether that belongs to each tokenHolder according to the DAO tokens that each one holds.
Example of how the evolution of a DAO
If the DAO is not fuelled, each TokenHolder recovers
1: A Proposal is approved.
The proposal approved is to send 30 Ξ to company S
2: 10 Lamps are sold
The reward is sent to the DAORewardAccount.
(*) a/b in the account means: a -> ethers in the account actually; b -> total ethers sent to this account in its history.
3: A proposal is approved
4: A proposal is approved to distribute 10 Ξ to the TokenHolders
5: Dave gets his rewards
6: Dave transfers 10 Ð to Charlie
7: 10 more lamps are selled.
8: Alice split
During the split happen all this things:
9: 10 more lamps are sold
10: 10 DAO_A get his rewards (DAO all still owns reward tokens)
The DAO_A main account will increase by 2 Ξ more.
11: DAO approves to send his DAOrewards to the reward account.
12: Bob gets his rewards
13: A new investment is approved
for an Ethereum router of 40Ξ to company T 2Ξ will be sent
14: 20 Routers are sold