contract PassTokenManagerInterface {

    // The Pass Dao smart contract
    PassDao public passDao;
    // The adress of the creator of this smart contract
    address creator;
    
    // The token name for display purpose
    string public name;
    // The token symbol for display purpose
    string public symbol;
    // The quantity of decimals for display purpose
    uint8 public decimals;
    // Total amount of tokens
    uint256 totalTokenSupply;

    // True if tokens, false if Dao shares
    bool token;
    // If true, the shares or tokens can be transferred
    bool transferable;

    // The address of the last Manager before cloning
    address public clonedFrom;
    // True if the initial token supply is over
    bool initialTokenSupplyDone;

    // Array of token or share holders (used for cloning)
    address[] holders;
    // Map with the indexes of the holders (used for cloning)
    mapping (address => uint) holderID;
    
    // Array with all balances
    mapping (address => uint256) balances;
    // Array with all allowances
    mapping (address => mapping (address => uint256)) allowed;

    struct funding {
        // The address which sets partners and manages the funding (not mandatory)
        address moderator;
        // The amount (in wei) of the funding
        uint amountToFund;
        // The funded amount (in wei)
        uint fundedAmount;
        // A unix timestamp, denoting the start time of the funding
        uint startTime; 
        // A unix timestamp, denoting the closing time of the funding
        uint closingTime;  
        // The price multiplier for a share or a token without considering the inflation rate
        uint initialPriceMultiplier;
        // Rate per year in percentage applied to the share or token price 
        uint inflationRate; 
        // The total amount of wei given
        uint totalWeiGiven;
    } 
    // Map with the fundings rules for each Dao proposal
    mapping (uint => funding) public fundings;

    // The index of the last funding and proposal
    uint lastProposalID;
    // The index of the last fueled funding and proposal
    uint public lastFueledFundingID;
    
    struct amountsGiven {
        uint weiAmount;
        uint tokenAmount;
    }
    // Map with the amounts given for each proposal 
    mapping (uint => mapping (address => amountsGiven)) public Given;
    
    // Map of blocked Dao share accounts. Points to the date when the share holder can transfer shares
    mapping (address => uint) public blockedDeadLine; 

    // @return The client of this manager
    function Client() constant returns (address);
    
    /// @return The total supply of shares or tokens 
    function totalSupply() constant external returns (uint256);

    /// @param _owner The address from which the balance will be retrieved
    /// @return The balance
     function balanceOf(address _owner) constant external returns (uint256 balance);

    /// @return True if tokens can be transferred
    function Transferable() constant external returns (bool);
    
    /// @param _owner The address of the account owning tokens
    /// @param _spender The address of the account able to transfer the tokens
    /// @return Quantity of remaining tokens of _owner that _spender is allowed to spend
    function allowance(address _owner, address _spender) constant external returns (uint256 remaining);
    
    /// @param _proposalID Index of the funding or proposal
    /// @return The result (in wei) of the funding
    function FundedAmount(uint _proposalID) constant external returns (uint);

    /// @param _proposalID Index of the funding or proposal
    /// @return The amount to fund
    function AmountToFund(uint _proposalID) constant external returns (uint);
    
    /// @param _proposalID Index of the funding or proposal
    /// @return the token price multiplier
    function priceMultiplier(uint _proposalID) constant internal returns (uint);
    
    /// @param _proposalID Index of the funding or proposal
    /// @param _saleDate in case of presale, the date of the presale
    /// @return the share or token price divisor condidering the sale date and the inflation rate
    function priceDivisor(
        uint _proposalID, 
        uint _saleDate) constant internal returns (uint);
    
    /// @param _proposalID Index of the funding or proposal
    /// @return the actual price divisor of a share or token
    function actualPriceDivisor(uint _proposalID) constant internal returns (uint);

    /// @dev Internal function to calculate the amount in tokens according to a price    
    /// @param _weiAmount The amount (in wei)
    /// @param _priceMultiplier The price multiplier
    /// @param _priceDivisor The price divisor
    /// @return the amount in tokens 
    function TokenAmount(
        uint _weiAmount,
        uint _priceMultiplier, 
        uint _priceDivisor) constant internal returns (uint);

    /// @dev Internal function to calculate the amount in wei according to a price    
    /// @param _tokenAmount The amount (in wei)
    /// @param _priceMultiplier The price multiplier
    /// @param _priceDivisor The price divisor
    /// @return the amount in wei
    function weiAmount(
        uint _tokenAmount, 
        uint _priceMultiplier, 
        uint _priceDivisor) constant internal returns (uint);
        
    /// @param _tokenAmount The amount in tokens
    /// @param _proposalID Index of the client proposal. 0 if not linked to a proposal.
    /// @return the actual token price in wei
    function TokenPriceInWei(uint _tokenAmount, uint _proposalID) constant returns (uint);
    
    /// @return The index of the last funding and client's proposal 
    function LastProposalID() constant returns (uint);

    /// @return The number of share or token holders (used for cloning)
    function numberOfHolders() constant returns (uint);

    /// @param _index The index of the holder
    /// @return the address of the holder
    function HolderAddress(uint _index) constant external returns (address);
   
    /// @dev The constructor function
    /// @param _passDao Address of the pass Dao smart contract
    /// @param _clonedFrom The address of the last Manager before cloning
    /// @param _tokenName The token name for display purpose
    /// @param _tokenSymbol The token symbol for display purpose
    /// @param _tokenDecimals The quantity of decimals for display purpose
    /// @param  _token True if tokens, false if shares
    /// @param  _transferable True if tokens can be transferred
    /// @param _initialPriceMultiplier Price multiplier without considering any inflation rate
    /// @param _inflationRate If 0, the token price doesn't change during the funding
    //function PassTokenManager(
    //    address _passDao,
    //    address _clonedFrom,
    //    string _tokenName,
    //    string _tokenSymbol,
    //    uint8 _tokenDecimals,
    //    bool _token,
    //    bool _transferable,
    //    uint _initialPriceMultiplier,
    //    uint _inflationRate);
    
    /// @dev Function to create initial tokens    
    /// @param _recipient The beneficiary of the created tokens
    /// @param _quantity The quantity of tokens to create    
    /// @param _last True if the initial token suppy is over
    /// @return Whether the function was successful or not     
    function initialTokenSupply(
        address _recipient, 
        uint _quantity,
        bool _last) returns (bool success);
        
    /// @notice Function to clone tokens before upgrading
    /// @param _from The index of the first holder
    /// @param _to The index of the last holder
    /// @return Whether the function was successful or not 
    function cloneTokens(
        uint _from,
        uint _to) returns (bool success);

    /// @dev Internal function to add a new token or share holder
    /// @param _holder The address of the token or share holder
    function addHolder(address _holder) internal;
    
    /// @dev Internal function to create initial tokens    
    /// @param _holder The beneficiary of the created tokens
    /// @param _tokenAmount The amount in tokens to create
    function createTokens(
        address _holder, 
        uint _tokenAmount) internal;
        
    /// @notice Function used by the client to pay with shares or tokens
    /// @param _recipient The address of the recipient of shares or tokens
    /// @param _amount The amount (in Wei) to calculate the quantity of shares or tokens to create
    /// @return the rewarded amount in tokens or shares
    function rewardTokensForClient(
        address _recipient, 
        uint _amount) external  returns (uint);
        
    /// @notice Function to set a funding
    /// @param _moderator The address of the smart contract to manage a private funding
    /// @param _initialPriceMultiplier Price multiplier without considering any inflation rate
    /// @param _amountToFund The amount (in wei) of the funding
    /// @param _minutesFundingPeriod Period in minutes of the funding
    /// @param _inflationRate If 0, the token price doesn't change during the funding
    /// @param _proposalID Index of the client proposal
    function setFundingRules(
        address _moderator,
        uint _initialPriceMultiplier,
        uint _amountToFund,
        uint _minutesFundingPeriod, 
        uint _inflationRate,
        uint _proposalID) external;

    /// @dev Internal function for the sale of shares or tokens
    /// @param _proposalID Index of the client proposal
    /// @param _recipient The recipient address of shares or tokens
    /// @param _amount The funded amount (in wei)
    /// @param _saleDate In case of presale, the date of the presale
    /// @param _presale True if presale
    /// @return Whether the creation was successful or not
    function sale(
        uint _proposalID,
        address _recipient, 
        uint _amount,
        uint _saleDate,
        bool _presale
    ) internal returns (bool success);
    
    /// @dev Internal function to close the actual funding
    /// @param _proposalID Index of the client proposal
    function closeFunding(uint _proposalID) internal;
   
    /// @notice Function to send tokens or refund after the closing time of the funding proposals
    /// @param _from The first proposal. 0 if not linked to a proposal
    /// @param _to The last proposal
    /// @param _buyer The address of the buyer
    /// @return Whether the function was successful or not 
    function sendPendingAmounts(        
        uint _from,
        uint _to,
        address _buyer) returns (bool);
        
    /// @notice Function to get fees, shares or refund after the closing time of the funding proposals
    /// @return Whether the function was successful or not
    function withdrawPendingAmounts() returns (bool);
    
    /// @notice Function used by the main partner to set the start time of the funding
    /// @param _proposalID Index of the client proposal
    /// @param _startTime The unix start date of the funding 
    function setFundingStartTime(
        uint _proposalID, 
        uint _startTime) external;
    
    /// @notice Function used by the main partner to set the funding fueled
    /// @param _proposalID Index of the client proposal
    function setFundingFueled(uint _proposalID) external;

    /// @notice Function to able the transfer of Dao shares or contractor tokens
    function ableTransfer();

    /// @notice Function to disable the transfer of Dao shares
    function disableTransfer();

    /// @notice Function used by the client to block the transfer of shares from and to a share holder
    /// @param _shareHolder The address of the share holder
    /// @param _deadLine When the account will be unblocked
    function blockTransfer(
        address _shareHolder, 
        uint _deadLine) external;
    
    /// @dev Internal function to send `_value` token to `_to` from `_From`
    /// @param _from The address of the sender
    /// @param _to The address of the recipient
    /// @param _value The quantity of shares or tokens to be transferred
    /// @return Whether the function was successful or not 
    function transferFromTo(
        address _from,
        address _to, 
        uint256 _value
        ) internal returns (bool success);
    
    /// @notice send `_value` token to `_to` from `msg.sender`
    /// @param _to The address of the recipient
    /// @param _value The quantity of shares or tokens to be transferred
    /// @return Whether the function was successful or not 
    function transfer(address _to, uint256 _value) returns (bool success);

    /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
    /// @param _from The address of the sender
    /// @param _to The address of the recipient
    /// @param _value The quantity of shares or tokens to be transferred
    function transferFrom(
        address _from, 
        address _to, 
        uint256 _value
        ) returns (bool success);

    /// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on its behalf
    /// @param _spender The address of the account able to transfer the tokens
    /// @param _value The amount of tokens to be approved for transfer
    /// @return Whether the approval was successful or not
    function approve(
        address _spender, 
        uint256 _value) returns (bool success);
    
    event TokensCreated(address indexed Sender, address indexed TokenHolder, uint TokenAmount);
    event FundingRulesSet(address indexed Moderator, uint indexed ProposalId, uint AmountToFund, uint indexed StartTime, uint ClosingTime);
    event FundingFueled(uint indexed ProposalID, uint FundedAmount);
    event TransferAble();
    event TransferDisable();
    event Transfer(address indexed _from, address indexed _to, uint256 _value);
    event Refund(address indexed Buyer, uint Amount);
    
}
/// @title Token Manager smart contract of the Pass Decentralized Autonomous Organisation
function setFundingRules(
    address _moderator,
    uint _initialPriceMultiplier,
    uint _amountToFund,
    uint _minutesFundingPeriod, 
    uint _inflationRate,
    uint _proposalID) external;

/// @notice Function to set a funding
/// @param _moderator The address of the smart contract to manage a private funding
/// @param _initialPriceMultiplier Price multiplier without considering any inflation rate
/// @param _amountToFund The amount (in wei) of the funding
/// @param _minutesFundingPeriod Period in minutes of the funding
/// @param _inflationRate If 0, the token price doesn't change during the funding
/// @param _proposalID Index of the client proposal