{"author":"Digix Holdings","title":"Contract to manage DAO funds","fileName":"/contracts/interactive/DaoFundingManager.sol","name":"DaoFundingManager","abi":[{"constant":true,"inputs":[],"name":"resolver","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"currentQuarterIndex","outputs":[{"name":"_quarterIndex","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_configKey","type":"bytes32"}],"name":"getAddressConfig","outputs":[{"name":"_configValue","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"key","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_key","type":"bytes32"}],"name":"get_contract","outputs":[{"name":"_contract","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"currentTimeInQuarter","outputs":[{"name":"_currentT","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isMainPhase","outputs":[{"name":"_isMainPhase","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_proposalId","type":"bytes32"},{"name":"_index","type":"uint256"}],"name":"claimFunding","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isLockingPhase","outputs":[{"name":"_isLockingPhase","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_receiver","type":"address"},{"name":"_proposalId","type":"bytes32"}],"name":"refundCollateral","outputs":[{"name":"_success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_user","type":"address"}],"name":"isParticipant","outputs":[{"name":"_is","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_configKey","type":"bytes32"}],"name":"getBytesConfig","outputs":[{"name":"_configValue","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_configKey","type":"bytes32"}],"name":"getUintConfig","outputs":[{"name":"_configValue","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_destinationForDaoFunds","type":"address"}],"name":"moveFundsToNewDao","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isDaoNotReplaced","outputs":[{"name":"_isNotReplaced","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CONTRACT_ADDRESS","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_proposalId","type":"bytes32"}],"name":"isProposalPaused","outputs":[{"name":"_isPausedOrStopped","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_user","type":"address"}],"name":"isModerator","outputs":[{"name":"_is","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_resolver","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"}],"bin":false,"opcodes":false,"source":"pragma solidity ^0.4.24;\n\nimport \"../common/DaoCommon.sol\";\nimport \"./Dao.sol\";\n\n\n/**\n@title Contract to manage DAO funds\n@author Digix Holdings\n*/\ncontract DaoFundingManager is DaoCommon {\n\n    constructor(address _resolver) public {\n        require(init(CONTRACT_DAO_FUNDING_MANAGER, _resolver));\n    }\n\n    function dao()\n        internal\n        constant\n        returns (Dao _contract)\n    {\n        _contract = Dao(get_contract(CONTRACT_DAO));\n    }\n\n    \n    /**\n    @notice Call function to claim the ETH funding for a certain milestone\n    @dev Note that the proposer can do this anytime, even in the locking phase\n    @param _proposalId ID of the proposal\n    @param _index Index of the proposal voting round that they got passed, which is also the same as the milestone index\n    */\n    function claimFunding(bytes32 _proposalId, uint256 _index)\n        public\n    {\n        require(identity_storage().is_kyc_approved(msg.sender));\n        require(isFromProposer(_proposalId));\n\n        // proposal should not be paused/stopped\n        require(!isProposalPaused(_proposalId));\n\n        require(!daoStorage().readIfMilestoneFunded(_proposalId, _index));\n\n        require(daoStorage().readProposalVotingResult(_proposalId, _index));\n        require(daoStorage().isClaimed(_proposalId, _index));\n\n        uint256 _funding = daoStorage().readProposalMilestone(_proposalId, _index);\n\n        daoFundingStorage().withdrawEth(_funding);\n        daoStorage().setMilestoneFunded(_proposalId, _index);\n\n        msg.sender.transfer(_funding);\n    }\n\n\n    /**\n    @notice Function to refund the collateral to _receiver\n    @dev Can only be called from the Dao contract\n    @param _receiver The receiver of the funds\n    @return {\n      \"_success\": \"Boolean, true if refund was successful\"\n    }\n    */\n    function refundCollateral(address _receiver, bytes32 _proposalId)\n        public\n        returns (bool _success)\n    {\n        require(sender_is_from([CONTRACT_DAO, CONTRACT_DAO_VOTING_CLAIMS, EMPTY_BYTES]));\n        refundCollateralInternal(_receiver, _proposalId);\n        _success = true;\n    }\n\n\n    function refundCollateralInternal(address _receiver, bytes32 _proposalId)\n        internal\n    {\n        uint256 _collateralAmount = daoStorage().readProposalCollateralAmount(_proposalId);\n        daoFundingStorage().withdrawEth(_collateralAmount);\n        _receiver.transfer(_collateralAmount);\n    }\n\n\n    /**\n    @notice Function to move funds to a new DAO\n    @param _destinationForDaoFunds Ethereum contract address of the new DaoFundingManager\n    */\n    function moveFundsToNewDao(address _destinationForDaoFunds)\n        public\n    {\n        require(sender_is(CONTRACT_DAO));\n        uint256 _remainingBalance = address(this).balance;\n        daoFundingStorage().withdrawEth(_remainingBalance);\n        _destinationForDaoFunds.transfer(_remainingBalance);\n    }\n\n\n    /**\n    @notice Payable function to receive ETH funds from DigixDAO crowdsale contract\n    */\n    function () payable public {\n        daoFundingStorage().addEth(msg.value);\n    }\n}\n","abiDocs":[{"constant":true,"inputs":[],"name":"resolver","payable":false,"stateMutability":"view","type":"function","signature":"resolver()","signatureHash":"04f3bcec"},{"constant":true,"inputs":[],"name":"currentQuarterIndex","outputs":[{"name":"_quarterIndex","type":"uint256","description":"the current quarter index"}],"payable":false,"stateMutability":"view","type":"function","details":"Quarter indexes starts from 1","return":"_quarterIndex the current quarter index","notice":"Get the current quarter index","signature":"currentQuarterIndex()","signatureHash":"0d7cc561"},{"constant":true,"inputs":[{"name":"_configKey","type":"bytes32"}],"name":"getAddressConfig","payable":false,"stateMutability":"view","type":"function","signature":"getAddressConfig(bytes32)","signatureHash":"1d8ccd04"},{"constant":true,"inputs":[],"name":"key","payable":false,"stateMutability":"view","type":"function","signature":"key()","signatureHash":"3943380c"},{"constant":true,"inputs":[{"name":"_key","type":"bytes32","description":"the resolver key to look up"}],"name":"get_contract","outputs":[{"name":"_contract","type":"address","description":"the address of the contract"}],"payable":false,"stateMutability":"view","type":"function","details":"Get the address of a contract","return":"_contract the address of the contract","signature":"get_contract(bytes32)","signatureHash":"3f83acff"},{"constant":true,"inputs":[],"name":"currentTimeInQuarter","outputs":[{"name":"_currentT","type":"uint256","description":"the current relative time in the quarter"}],"payable":false,"stateMutability":"view","type":"function","details":"For example: the currentTimeInQuarter of the first second of any quarter is 1","return":"_currentT the current relative time in the quarter","notice":"Get the current relative time in the quarter","signature":"currentTimeInQuarter()","signatureHash":"560a25ea"},{"constant":true,"inputs":[],"name":"isMainPhase","outputs":[{"name":"_isMainPhase","type":"bool","description":"true if it is in a main phase"}],"payable":false,"stateMutability":"view","type":"function","details":"The main phase is where all the governance activities could take plase. If the DAO is replaced, there can never be any more main phase.","return":"_isMainPhase true if it is in a main phase","notice":"Check if it is currently in a main phase.","signature":"isMainPhase()","signatureHash":"68533060"},{"constant":false,"inputs":[{"name":"_proposalId","type":"bytes32","description":"ID of the proposal"},{"name":"_index","type":"uint256","description":"Index of the proposal voting round that they got passed, which is also the same as the milestone index"}],"name":"claimFunding","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","details":"Note that the proposer can do this anytime, even in the locking phase","notice":"Call function to claim the ETH funding for a certain milestone","signature":"claimFunding(bytes32,uint256)","signatureHash":"7bf6b37e"},{"constant":true,"inputs":[],"name":"isLockingPhase","outputs":[{"name":"_isLockingPhase","type":"bool","description":"true if it is in the locking phase"}],"payable":false,"stateMutability":"view","type":"function","details":"No governance activities can happen in the locking phase. The locking phase is from t=0 to t=CONFIG_LOCKING_PHASE_DURATION-1","return":"_isLockingPhase true if it is in the locking phase","notice":"Check if it is currently in the locking phase","signature":"isLockingPhase()","signatureHash":"7d6fed80"},{"constant":false,"inputs":[{"name":"_receiver","type":"address","description":"The receiver of the funds"},{"name":"_proposalId","type":"bytes32"}],"name":"refundCollateral","outputs":[{"name":"_success","type":"bool","description":"Boolean, true if refund was successful"}],"payable":false,"stateMutability":"nonpayable","type":"function","details":"Can only be called from the Dao contract","return":"{ \"_success\": \"Boolean, true if refund was successful\" }","notice":"Function to refund the collateral to _receiver","signature":"refundCollateral(address,bytes32)","signatureHash":"7e71332b"},{"constant":true,"inputs":[{"name":"_user","type":"address"}],"name":"isParticipant","payable":false,"stateMutability":"view","type":"function","notice":"Check if a user is a participant in the current quarter","signature":"isParticipant(address)","signatureHash":"929066f5"},{"constant":true,"inputs":[{"name":"_configKey","type":"bytes32"}],"name":"getBytesConfig","payable":false,"stateMutability":"view","type":"function","signature":"getBytesConfig(bytes32)","signatureHash":"93ddad08"},{"constant":true,"inputs":[{"name":"_configKey","type":"bytes32"}],"name":"getUintConfig","payable":false,"stateMutability":"view","type":"function","signature":"getUintConfig(bytes32)","signatureHash":"b1e2b9dd"},{"constant":false,"inputs":[{"name":"_destinationForDaoFunds","type":"address","description":"Ethereum contract address of the new DaoFundingManager"}],"name":"moveFundsToNewDao","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","notice":"Function to move funds to a new DAO","signature":"moveFundsToNewDao(address)","signatureHash":"c72deb9a"},{"constant":true,"inputs":[],"name":"isDaoNotReplaced","outputs":[{"name":"_isNotReplaced","type":"bool","description":"true if it is not replaced, false if it has already been replaced"}],"payable":false,"stateMutability":"view","type":"function","return":"_isNotReplaced true if it is not replaced, false if it has already been replaced","notice":"Check if the DAO contracts have been replaced by a new set of contracts","signature":"isDaoNotReplaced()","signatureHash":"d70d9358"},{"constant":true,"inputs":[],"name":"CONTRACT_ADDRESS","payable":false,"stateMutability":"view","type":"function","signature":"CONTRACT_ADDRESS()","signatureHash":"db4ecbc1"},{"constant":true,"inputs":[{"name":"_proposalId","type":"bytes32"}],"name":"isProposalPaused","outputs":[{"name":"_isPausedOrStopped","type":"bool","description":"true if the proposal is paused(or stopped)"}],"payable":false,"stateMutability":"view","type":"function","details":"If a proposal is paused/stopped (by the PRLs): proposer cannot call for voting, a current on-going voting round can still pass, but no funding can be withdrawn.A paused proposal can still be unpausedIf a proposal is stopped, this function also returns true","return":"_isPausedOrStopped true if the proposal is paused(or stopped)","notice":"Check if a proposal is currently paused/stopped","signature":"isProposalPaused(bytes32)","signatureHash":"f94f0f33"},{"constant":true,"inputs":[{"name":"_user","type":"address"}],"name":"isModerator","payable":false,"stateMutability":"view","type":"function","notice":"Check if a user is a moderator in the current quarter","signature":"isModerator(address)","signatureHash":"fa6f3936"},{"inputs":[{"name":"_resolver","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback","inputs":[]}]}
