contract DivvyUpFactory is Owned {

    event Create(
        bytes32 name,
        bytes32 symbol,
        uint8 dividendDivisor,
        uint8 decimals,
        uint256 initialPrice,
        uint256 incrementPrice,
        uint256 magnitude,
        address creator
    );

  
    DivvyUp[] public registry;

    function create(
        bytes32 name, // Name of the DivvyUp
        bytes32 symbol,  // ERC20 Symbol fo the DivvyUp
        uint8 dividendDivisor, // Amount to divide incoming counter by as fees for dividens. Example: 3 for 33%, 10 for 10%, 100 for 1%
        uint8 decimals, // Number of decimals the token has. Example: 18
        uint256 initialPrice, // Starting price per token. Example: 0.0000001 ether
        uint256 incrementPrice, // How much to increment the price by. Example: 0.00000001 ether
        uint256 magnitude, //magnitude to multiply the fees by before distribution. Example: 2**64
        address counter // The counter currency to accept. Example: 0x0 for ETH, otherwise the ERC20 token address.
     )
        public 
        returns(address)
    {
        DivvyUp divvyUp = new DivvyUp(name, symbol, dividendDivisor, decimals, initialPrice, incrementPrice, magnitude, counter);
        divvyUp.changeOwner(msg.sender);
        registry.push(divvyUp);
        emit Create(name, symbol, dividendDivisor, decimals, initialPrice, incrementPrice, magnitude, msg.sender);
        return divvyUp;
    }

    function die() onlyOwner public {
        selfdestruct(msg.sender);
    }

    /**
    * Owner can transfer out any accidentally sent ERC20 tokens
    * 
    * Implementation taken from ERC20 reference
    * 
    */
    function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
        return ERC20Interface(tokenAddress).transfer(owner, tokens);
    }
}
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
    return ERC20Interface(tokenAddress).transfer(owner, tokens);
}

/**
 * Owner can transfer out any accidentally sent ERC20 tokens
 * 
 * Implementation taken from ERC20 reference
 * 
 */