{
    "Function": "setAllocatedTokensPerEpoch",
    "File": "contracts/DelegatedStaking.sol",
    "Parent Contracts": [
        "node_modules/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol",
        "node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol",
        "node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"
    ],
    "High-Level Calls": [],
    "Internal Calls": [
        "onlyOwner",
        "_updateGlobalExchangeRate",
        "require(bool,string)",
        "require(bool,string)",
        "_transferFromContract"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function setAllocatedTokensPerEpoch(uint128 amount) public onlyOwner {\n        require(amount > 0, \"Amount is 0\");\n        uint128 toTransfer;\n        if (endEpoch != 0){\n            _updateGlobalExchangeRate();\n            // get number of epochs from now to the end epoch\n            uint128 epochs = endEpoch > uint128(block.number) ? endEpoch - uint128(block.number) : 0;\n            // calculate how much rewards would be distributed with the old emission rate\n            uint128 futureRewards = allocatedTokensPerEpoch * epochs;\n            // calculate how many epochs will be covered\n            uint128 addEpochs = futureRewards / amount;\n            toTransfer = futureRewards % amount;\n            require(addEpochs != 0, \"This amount will end the program\");\n            unchecked { endEpoch = uint128(block.number) + addEpochs; }\n        }\n        else {\n          toTransfer = rewardsLocked % amount;\n        }\n        allocatedTokensPerEpoch = amount;\n        emit EmissionRateChanged(amount);\n        if(toTransfer > 0)\n            _transferFromContract(msg.sender, toTransfer);\n\n    }"
}