Understanding the DAO accounting

Introduction

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.

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

Token Creation

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

0: Fuelling

  • Alice buys 10 Tokens at 1 Ξ / 100 Ð (10 Ξ)
  • Bob buys 20 Tokens at 1 Ξ / 100 Ð (20 Ξ)
  • Charlie buys 30 Tokens at 1.2 Ξ / 100 Ð
    (36 Ξ; 6 Ξ go in the ExtraBalance Account)
  • Dave buys 40 Tokens at 1.5 Ξ / 100 Ð
    (60 Ξ; 20 Ξ go in the ExtraBalanceAccount)

If the DAO is not fuelled, each TokenHolder recovers
the exact money they invest.

Ether DistributionDAO Token DistributionRewardToken DistributionDAOReward PaidReward Paid

DAO Balance 100 Ξ

Alice 10 Ð

   
ExtraBalance 26 Ξ

Bob 20 Ð

   
 

Charlie 30 Ð

   
 Dave 40 Р  

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

 

1: A Proposal is approved.

The proposal approved is to send 30 Ξ to company S
to manufacture an ethereum lamp.
These lamps will send 1 Ξ to the DAORewardAccount
when the end user turn on the lamp the first time.

Method: executeProposal()

Ether DistributionDAO Token Distribution

RewardToken Distribution

DAOReward PaidReward Paid

DAO Balance 70 Ξ

Alice 10 Ð

DAO 30 RT  
ExtraBalance 26 Ξ

Bob 20 Ð

   
 

Charlie 30 Ð

   
 Dave 40 Р  

2: 10 Lamps are sold

The reward is sent to the DAORewardAccount.

Ether Distribution DAO Token DistributionRewardToken DistributionDAOReward PaidReward Paid

DAO Balance 100 Ξ

Alice 10 Ð

DAO 30 RT  
ExtraBalance 26 Ξ

Bob 20 Ð

   
DAORewardAccount*) 10/10 Ξ

Charlie 30 Ð

   
 Dave 40 Р  

(*) 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
to move the DAOreward account to the DAO Balance

Method: retrieveDAOreward(false)

Ether DistributionDAO Token DistributionRewardToken DistributionDAOReward PaidReward Paid

DAO Balance 80 Ξ

Alice 10 Ð

 DAO 30 RTDAO 10 Ξ 
ExtraBalance 26 Ξ

Bob 20 Ð

   
DAORewardAccount 0/10 Ξ

Charlie 30 Ð

   
 Dave 40 Р  

4: A proposal is approved to distribute 10 Ξ to the TokenHolders

Method: executeProposal

Ether DistributionDAO Token DistributionRewardToken DistributionDAOReward PaidReward Paid

DAO Balance 70 Ξ

Alice 10 Ð

DAO 30 RTDAO 10 Ξ 
ExtraBalance 26 Ξ

Bob 20 Ð

   
DAORewardAccount 0/10 Ξ

Charlie 30 Ð

   
RewardAccount 10/10ΞDave 40 Р  

5: Dave gets his rewards

Method: transfer()

Ether DistributionDAO Token DistributionRewardToken DistributionDAOReward PaidReward Paid

DAO Balance 100 Ξ

Alice 10 Ð

 DAO 30 RTDAO 10 Ξ 
ExtraBalance 26 Ξ

Bob 20 Ð

   
 DAORewardAccount 0/10 Ξ

Charlie 30 Ð

   
RewardAccount 6/10 ΞDave 40 Р Dave 4 Ξ

6: Dave transfers 10 Ð to Charlie

Method: getMyReward()

 

Ether DistributionDAO Token DistributionRewardToken DistributionDAOReward PaidReward Paid

DAO Balance 100 Ξ

Alice 10 Ð

DAO 30 RTDAO 10 Ξ 
ExtraBalance 26 Ξ

Bob 20 Ð

   
DAORewardAccount 0/10 Ξ

Charlie 40 Ð

  Charlie 1 Ξ
RewardAccount 6/10 ΞDave 30 Р Dave 3 Ξ

7: 10 more lamps are selled.

Method: getMyReward()

 

Ether DistributionDAO Token DistributionRewardToken DistributionDAOReward PaidReward Paid

DAO Balance 100 Ξ

Alice 10 Ð

DAO 30 RTDAO 10 Ξ 
ExtraBalance 26 Ξ

Bob 20 Ð

   
 DAORewardAccount 10/20 Ξ

Charlie 30 Ð

  Charlie 1 Ξ
 RewardAccount 6/10 ΞDave 40 Р Dave 3 Ξ

8: Alice split

Method: splitDAO()

During the split happen all this things:

  1. Alice gets all penndig rewards (1 Ξ)
  2. A new DAO is created: DAO_A
  3. The 30 RewardTokens generated until now
    are divided 3 to DAO_A and 27 to the old DAO.
  4. DAOreward paid is also split. 10 -> 9 and 1.
  5. Alice DAO tokens are burned.
Ether DistributionDAO Token DistributionRewardToken DistributionDAOReward PaidReward Paid

DAO Balance 63 Ξ

Alice 0 Ð

DAO 27 RTDAO 9 ΞAlice 1 Ξ
ExtraBalance 26 Ξ

Bob 20 Ð

DAO_A 3 RTDAO_A 1 Ξ 
DAORewardAccount 10/20 Ξ

Charlie 40 Ð

  Charlie 1 Ξ
RewardAccount 5/10 Ξ Dave 30 Р Dave 3 Ξ

9: 10 more lamps are sold

Method: splitDAO()

 

Ether DistributionDAO Token DistributionRewardToken DistributionDAOReward PaidReward Paid

DAO Balance 63Ξ

Alice 0Ð

DAO 27RTDAO 9ΞAlice 1Ξ
ExtraBalance 26Ξ

Bob 20Ð

DAO_A 3RT

DAO_A 1Ξ  
DAORewardAccount 20/30Ξ

Charlie 40Ð

  Charlie 1Ξ
RewardAccount 5/10ΞDave 30Р Dave 3Ξ

10: 10 DAO_A get his rewards (DAO all still owns reward tokens)

Method: retrieveDAOreward()

The DAO_A main account will increase by 2 Ξ more.

 

Ether DistributionDAO Token DistributionRewardToken DistributionDAOReward PaidReward Paid

DAO Balance 63Ξ

Alice 0Ð

DAO 27RTDAO 9ΞAlice 1Ξ
ExtraBalance 26Ξ

Bob 20Ð

DAO_A 3RT

DAO_A 3Ξ  
DAORewardAccount 18/30Ξ

Charlie 40Ð

  Charlie 1Ξ
RewardAccount 5/10ΞDave 30Р Dave 3Ξ

 

 

11: DAO approves to send his DAOrewards to the reward account.

Method: retrieveDAOreward(true)

 

Ether DistributionDAO Token DistributionRewardToken DistributionDAOReward PaidReward Paid

DAO Balance 63Ξ

Alice 0Ð

DAO 27RTDAO 27ΞAlice 1Ξ
ExtraBalance 26Ξ

Bob 20Ð

DAO_A 3RT

DAO_A 3Ξ  
DAORewardAccount 0/30Ξ

Charlie 40Ð

  Charlie 1Ξ
RewardAccount 23/28ΞDave 30Р Dave 3Ξ

12: Bob gets his rewards

Method: retrieveDAOreward(true)

 

Ether DistributionDAO Token DistributionRewardToken DistributionDAOReward PaidReward Paid

DAO Balance 63Ξ

Alice 0Ð

DAO 27RTDAO 27ΞAlice 1Ξ
ExtraBalance 26Ξ

Bob 20Ð

DAO_A 3RT

DAO_A 3Ξ Bob 6.22Ξ
DAORewardAccount 0/30Ξ

Charlie 40Ð

  Charlie 1Ξ
RewardAccount 16.78/28ΞDave 30Р Dave 3Ξ

13: A new investment is approved

for an Ethereum router of 40Ξ to company T 2Ξ will be sent
to the DAOrewardAcc when each router is sold.

Method: executeProposal(true)

 

Ether DistributionDAO Token DistributionRewardToken DistributionDAOReward PaidReward Paid

DAO Balance 23Ξ

Alice 0Ð

DAO 67RTDAO 27ΞAlice 1Ξ
ExtraBalance 26Ξ

Bob 20Ð

DAO_A 3RT

DAO_A 3Ξ Bob 6.22Ξ
DAORewardAccount 0/30Ξ

Charlie 40Ð

  Charlie 1Ξ
RewardAccount 16.78/28ΞDave 30Р Dave 3Ξ

 

 

14: 20 Routers are sold

 

Ether DistributionDAO Token DistributionRewardToken DistributionDAOReward PaidReward Paid

DAO Balance 23 Ξ

Alice 0 Ð

DAO 67 RTDAO 27 ΞAlice 1 Ξ
ExtraBalance 26 Ξ

Bob 20 Ð

DAO_A 3 RT

DAO_A 3 Ξ Bob 6.22 Ξ
DAORewardAccount 40/70 Ξ

Charlie 40 Ð

  Charlie 1 Ξ
RewardAccount 16.78/28 ΞDave 30 Р Dave 3 Ξ