Skip to content

Solo Split Feature #2

Merged
merged 1 commit into from May 29, 2016
+65 −0

Solo Split Feature

Initial attempt at creating a solo split function. Code checks out in compiler but untested as of yet.
commit ac8a47a558c0721a7fee67cceb4ef564fc5c88f5 @D-Nice committed May 28, 2016
View
65 DAO.sol
@@ -256,6 +256,15 @@ contract DAOInterface {
uint _proposalID,
address _newCurator
) returns (bool _success);
+
+ /// @notice ATTENTION! I confirm to move my remaining ether to a new DAO
+ /// with myself as the new Curator. This will burn my tokens. This can
+ /// not be undone and will split the DAO into two DAO's, with two
+ /// different underlying tokens.
+ /// @param _confirm Confirmation to proceed with solo split
+ function splitSoloDAO(
+ bool _confirm
+ ) returns (bool _success);
/// @dev can only be called by the DAO itself through a proposal
/// updates the contract of the DAO by sending all ether and rewardTokens
@@ -691,6 +700,62 @@ contract DAO is DAOInterface, Token, TokenCreation {
paidOut[msg.sender] = 0;
return true;
}
+
+ function splitSoloDAO(bool _confirm
+ ) noEther onlyTokenholders returns (bool _success) {
+
+ // Ensure user confirms solo split and is not blocked
+ if (!_confirm || isBlocked(msg.sender))
+ throw;
+
+ // Create new Solo DAO based off this contract
+ SplitData memory soloData;
@cougarously
cougarously added a note Jun 9, 2016 edited

Probably don't need to create a SplitData object. In the original splitDAO() it was necessary because you wanted to take a snapshot of the data so that if subsequent users join the split DAO, they will have the original split data since the data have changed from the first person that join that new DAO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ soloData.newDAO = createNewDAO(msg.sender);
+ // Call depth limit reached, etc.
+ if (address(soloData.newDAO) == 0)
+ throw;
+ // should never happen
+ // Is this needed for solo split as well?
+ if (this.balance < sumOfProposalDeposits)
@cougarously
cougarously added a note Jun 9, 2016 edited

I think to be more accurate this 'if' statement should probably be moved down a few lines and then be modified as follows:

// Move ether and assign new Tokens
uint fundsToBeMoved =
     (balances[msg.sender] * soloData.splitBalance) /
     soloData.totalSupply;

if (this.balance < sumOfProposalDeposits + fundsToBeMoved)
     throw;

if (soloData.newDAO.createTokenProxy.value(fundsToBeMoved)(msg.sender) == false)
      throw;
@D-Nice
Owner
D-Nice added a note Jun 11, 2016

Yes you're correct. Thanks for reviewing the code :), although it seems slockit wishes to do their own iteration of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ throw;
+ soloData.splitBalance = actualBalance();
+ soloData.rewardToken = rewardToken[address(this)];
+ soloData.totalSupply = totalSupply;
+
+ // Move ether and assign new Tokens
+ uint fundsToBeMoved =
+ (balances[msg.sender] * soloData.splitBalance) /
+ soloData.totalSupply;
+ if (soloData.newDAO.createTokenProxy.value(fundsToBeMoved)(msg.sender) == false)
+ throw;
+
+
+ // Assign reward rights to new DAO
+ uint rewardTokenToBeMoved =
+ (balances[msg.sender] * soloData.rewardToken) /
+ soloData.totalSupply;
+
+ uint paidOutToBeMoved = DAOpaidOut[address(this)] * rewardTokenToBeMoved /
+ rewardToken[address(this)];
+
+ rewardToken[address(soloData.newDAO)] += rewardTokenToBeMoved;
+ if (rewardToken[address(this)] < rewardTokenToBeMoved)
+ throw;
+ rewardToken[address(this)] -= rewardTokenToBeMoved;
+
+ DAOpaidOut[address(soloData.newDAO)] += paidOutToBeMoved;
+ if (DAOpaidOut[address(this)] < paidOutToBeMoved)
+ throw;
+ DAOpaidOut[address(this)] -= paidOutToBeMoved;
+
+ // Burn DAO Tokens
+ Transfer(msg.sender, 0, balances[msg.sender]);
+ withdrawRewardFor(msg.sender); // be nice, and get his rewards
+ totalSupply -= balances[msg.sender];
+ balances[msg.sender] = 0;
+ paidOut[msg.sender] = 0;
+ return true;
+ }
function newContract(address _newContract){
if (msg.sender != address(this) || !allowedRecipients[_newContract]) return;
Something went wrong with that request. Please try again.