{
    "Function": "stashRewards",
    "File": "contracts/ExtraRewardStashV2.sol",
    "Parent Contracts": [],
    "High-Level Calls": [
        "IERC20",
        "IDeposit",
        "IStaker",
        "IRewardFactory",
        "SafeMath",
        "IERC20",
        "SafeERC20"
    ],
    "Internal Calls": [
        "require(bool,string)"
    ],
    "Library Calls": [
        "safeTransfer",
        "sub"
    ],
    "Low-Level Calls": [],
    "Code": "function stashRewards() external returns (bool) {\n        require(msg.sender == operator, \"!authorized\");\n\n        //after depositing/withdrawing, extra incentive tokens are transfered to the staking contract\n        //need to pull them off and stash here.\n        for (uint256 i = 0; i < tokenCount; i++) {\n            TokenInfo storage t = tokenInfo[i];\n            address token = t.token;\n            if (token == address(0)) continue;\n\n            //only stash if rewards are active\n            if (block.timestamp <= t.lastActiveTime + WEEK) {\n                uint256 before = IERC20(token).balanceOf(address(this));\n                IStaker(staker).withdraw(token);\n\n                //check for multiple pools claiming same token\n                uint256 activeCount = IRewardFactory(rewardFactory).activeRewardCount(token);\n                if (activeCount > 1) {\n                    //take difference of before/after(only send new tokens)\n                    uint256 amount = IERC20(token).balanceOf(address(this));\n                    amount = amount.sub(before);\n\n                    //send to arbitrator\n                    address arb = IDeposit(operator).rewardArbitrator();\n                    if (arb != address(0)) {\n                        IERC20(token).safeTransfer(arb, amount);\n                    }\n                }\n            }\n        }\n        return true;\n    }"
}