{"fileName":"/contracts/interactive/DaoRewardsManagerExtras.sol","name":"DaoRewardsManagerExtras","abi":[{"constant":true,"inputs":[],"name":"resolver","outputs":[{"name":"","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":true,"inputs":[],"name":"isLockingPhase","outputs":[{"name":"_isLockingPhase","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"currentQuarterNumber","outputs":[{"name":"_quarterNumber","type":"uint256"}],"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":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":"_user","type":"address"}],"name":"calculateUserRewardsForLastParticipatingQuarter","outputs":[{"name":"_dgxRewardsAsParticipant","type":"uint256"},{"name":"_dgxRewardsAsModerator","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_resolver","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}],"bin":false,"opcodes":false,"source":"pragma solidity ^0.4.25;\n\nimport \"../common/DaoRewardsManagerCommon.sol\";\nimport \"../service/DaoCalculatorService.sol\";\n\ncontract DaoRewardsManagerExtras is DaoRewardsManagerCommon {\n\n    constructor(address _resolver) public {\n        require(init(CONTRACT_DAO_REWARDS_MANAGER_EXTRAS, _resolver));\n    }\n\n    function daoCalculatorService()\n        internal\n        view\n        returns (DaoCalculatorService _contract)\n    {\n        _contract = DaoCalculatorService(get_contract(CONTRACT_SERVICE_DAO_CALCULATOR));\n    }\n\n    // done\n    // calculate dgx rewards; This is basically the DGXs that user has earned from participating in lastParticipatedQuarter, and can be withdrawn on the dgxDistributionDay of the (lastParticipatedQuarter + 1)\n    // when user actually withdraw some time after that, he will be deducted demurrage.\n    function calculateUserRewardsForLastParticipatingQuarter(address _user)\n        public\n        view\n        returns (uint256 _dgxRewardsAsParticipant, uint256 _dgxRewardsAsModerator)\n    {\n        UserRewards memory data = getUserRewardsStruct(_user);\n\n        data.effectiveDGDBalance = daoCalculatorService().calculateUserEffectiveBalance(\n            data.qInfo.minimalParticipationPoint,\n            data.qInfo.quarterPointScalingFactor,\n            data.qInfo.reputationPointScalingFactor,\n            daoPointsStorage().getQuarterPoint(_user, data.lastParticipatedQuarter),\n\n            // RP has been updated at the beginning of the lastParticipatedQuarter in\n            // a call to updateRewardsAndReputationBeforeNewQuarter(); It should not have changed since then\n            daoPointsStorage().getReputation(_user),\n\n            // lockedDGDStake should have stayed the same throughout since the lastParticipatedQuarter\n            // if this participant has done anything (lock/unlock/continue) to change the lockedDGDStake,\n            // updateUserRewardsForLastParticipatingQuarter, and hence this function, would have been called first before the lockedDGDStake is changed\n            daoStakeStorage().lockedDGDStake(_user)\n        );\n\n        data.effectiveModeratorDGDBalance = daoCalculatorService().calculateUserEffectiveBalance(\n            data.qInfo.moderatorMinimalParticipationPoint,\n            data.qInfo.moderatorQuarterPointScalingFactor,\n            data.qInfo.moderatorReputationPointScalingFactor,\n            daoPointsStorage().getQuarterModeratorPoint(_user, data.lastParticipatedQuarter),\n\n            // RP has been updated at the beginning of the lastParticipatedQuarter in\n            // a call to updateRewardsAndReputationBeforeNewQuarter();\n            daoPointsStorage().getReputation(_user),\n\n            // lockedDGDStake should have stayed the same throughout since the lastParticipatedQuarter\n            // if this participant has done anything (lock/unlock/continue) to change the lockedDGDStake,\n            // updateUserRewardsForLastParticipatingQuarter would have been called first before the lockedDGDStake is changed\n            daoStakeStorage().lockedDGDStake(_user)\n        );\n\n        // will not need to calculate if the totalEffectiveDGDLastQuarter is 0 (no one participated)\n        if (daoRewardsStorage().readTotalEffectiveDGDLastQuarter(data.lastParticipatedQuarter.add(1)) > 0) {\n            _dgxRewardsAsParticipant =\n                data.effectiveDGDBalance\n                .mul(daoRewardsStorage().readRewardsPoolOfLastQuarter(\n                    data.lastParticipatedQuarter.add(1)\n                ))\n                .mul(\n                    getUintConfig(CONFIG_PORTION_TO_MODERATORS_DEN)\n                    .sub(getUintConfig(CONFIG_PORTION_TO_MODERATORS_NUM))\n                )\n                .div(daoRewardsStorage().readTotalEffectiveDGDLastQuarter(\n                    data.lastParticipatedQuarter.add(1)\n                ))\n                .div(getUintConfig(CONFIG_PORTION_TO_MODERATORS_DEN));\n        }\n\n        // will not need to calculate if the totalEffectiveModeratorDGDLastQuarter is 0 (no one participated)\n        if (daoRewardsStorage().readTotalEffectiveModeratorDGDLastQuarter(data.lastParticipatedQuarter.add(1)) > 0) {\n            _dgxRewardsAsModerator =\n                data.effectiveModeratorDGDBalance\n                .mul(daoRewardsStorage().readRewardsPoolOfLastQuarter(\n                    data.lastParticipatedQuarter.add(1)\n                ))\n                .mul(\n                     getUintConfig(CONFIG_PORTION_TO_MODERATORS_NUM)\n                )\n                .div(daoRewardsStorage().readTotalEffectiveModeratorDGDLastQuarter(\n                    data.lastParticipatedQuarter.add(1)\n                ))\n                .div(getUintConfig(CONFIG_PORTION_TO_MODERATORS_DEN));\n        }\n    }\n}\n","abiDocs":[{"constant":true,"inputs":[],"name":"resolver","payable":false,"stateMutability":"view","type":"function","signature":"resolver()","signatureHash":"04f3bcec"},{"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":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":true,"inputs":[],"name":"currentQuarterNumber","outputs":[{"name":"_quarterNumber","type":"uint256","description":"the current quarter index"}],"payable":false,"stateMutability":"view","type":"function","details":"Quarter indexes starts from 1","return":"_quarterNumber the current quarter index","notice":"Get the current quarter index","signature":"currentQuarterNumber()","signatureHash":"7f6a26b6"},{"constant":true,"inputs":[{"name":"_configKey","type":"bytes32"}],"name":"getUintConfig","payable":false,"stateMutability":"view","type":"function","signature":"getUintConfig(bytes32)","signatureHash":"b1e2b9dd"},{"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":"_user","type":"address"}],"name":"calculateUserRewardsForLastParticipatingQuarter","payable":false,"stateMutability":"view","type":"function","signature":"calculateUserRewardsForLastParticipatingQuarter(address)","signatureHash":"fd56ff83"},{"inputs":[{"name":"_resolver","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]}
