{
    "Function": "balanceAtEpochOf",
    "File": "contracts/AuraLocker.sol",
    "Parent Contracts": [
        "contracts/Interfaces.sol",
        "node_modules/@openzeppelin/contracts-0.8/access/Ownable.sol",
        "node_modules/@openzeppelin/contracts-0.8/utils/Context.sol",
        "node_modules/@openzeppelin/contracts-0.8/security/ReentrancyGuard.sol"
    ],
    "High-Level Calls": [
        "AuraMath",
        "AuraMath",
        "AuraMath",
        "AuraMath",
        "AuraMath"
    ],
    "Internal Calls": [
        "require(bool,string)"
    ],
    "Library Calls": [
        "sub",
        "mul",
        "add",
        "sub",
        "add"
    ],
    "Low-Level Calls": [],
    "Code": "function balanceAtEpochOf(uint256 _epoch, address _user) public view returns (uint256 amount) {\n        uint256 epochStart = uint256(epochs[0].date).add(uint256(_epoch).mul(rewardsDuration));\n        require(epochStart < block.timestamp, \"Epoch is in the future\");\n\n        uint256 cutoffEpoch = epochStart.sub(lockDuration);\n\n        LockedBalance[] storage locks = userLocks[_user];\n\n        //need to add up since the range could be in the middle somewhere\n        //traverse inversely to make more current queries more gas efficient\n        uint256 locksLength = locks.length;\n        for (uint256 i = locksLength; i > 0; i--) {\n            uint256 lockEpoch = uint256(locks[i - 1].unlockTime).sub(lockDuration);\n            //lock epoch must be less or equal to the epoch we're basing from.\n            //also not include the current epoch\n            if (lockEpoch < epochStart) {\n                if (lockEpoch > cutoffEpoch) {\n                    amount = amount.add(locks[i - 1].amount);\n                } else {\n                    //stop now as no futher checks matter\n                    break;\n                }\n            }\n        }\n\n        return amount;\n    }"
}