{
    "Function": "verifyVestingSchedule",
    "File": "contracts/MerkleResistor.sol",
    "Parent Contracts": [],
    "High-Level Calls": [],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function verifyVestingSchedule(uint treeIndex, uint vestingTime, uint minTotalPayments, uint maxTotalPayments) public view returns (bool, uint, uint, uint) {\n        // vesting schedules for non-existing trees are invalid, I don't care how much you like uninitialized structs\n        if (treeIndex > numTrees) {\n            return (false, 0, 0, 0);\n        }\n\n        // memory not storage, since we do not edit the tree, and it's a view function anyways\n        MerkleTree memory tree = merkleTrees[treeIndex];\n\n        // vesting time must sit within the closed interval of [minEndTime, maxEndTime]\n        if (vestingTime > tree.maxEndTime || vestingTime < tree.minEndTime) {\n            return (false, 0, 0, 0);\n        }\n\n        uint totalCoins;\n        if (vestingTime == tree.maxEndTime) {\n            // this is to prevent dust accumulation from rounding errors\n            // maxEndTime results in max payments, no further computation necessary\n            totalCoins = maxTotalPayments;\n        } else {\n            // remember grade school algebra? slope = \u0394y / \u0394x\n            // this is the slope of eligible vesting schedules. In general, 0 < m < 1,\n            // (longer vesting schedules should result in less coins per second, hence \"resistor\")\n            // so we multiply by a precision factor to reduce rounding errors\n            // y axis = total coins released after vesting completed\n            // x axis = length of vesting schedule\n            // this is the line of valid end-points for the chosen vesting schedule line, see below\n            // NOTE: this reverts if minTotalPayments > maxTotalPayments, which is a good thing\n            uint paymentSlope = (maxTotalPayments - minTotalPayments) * PRECISION / (tree.maxEndTime - tree.minEndTime);\n\n            // y = mx + b = paymentSlope * (x - x0) + y0\n            // divide by precision factor here since we have completed the rounding error sensitive operations\n            totalCoins = (paymentSlope * (vestingTime - tree.minEndTime) / PRECISION) + minTotalPayments;\n        }\n\n        // this is a different slope, the slope of their chosen vesting schedule\n        // y axis = cumulative coins emitted\n        // x axis = time elapsed\n        // NOTE: vestingTime starts from block.timestamp, so doesn't include coins already available from pctUpFront\n        // totalCoins / vestingTime is wrong, we have to multiple by the proportion of the coins that are indexed\n        // by vestingTime, which is (100 - pctUpFront) / 100\n        uint coinsPerSecond = (totalCoins * (uint(100) - tree.pctUpFront)) / (vestingTime * 100);\n\n        // vestingTime is relative to initialization point\n        // endTime = block.timestamp + vestingTime\n        // vestingLength = totalCoins / coinsPerSecond\n        uint startTime = block.timestamp + vestingTime - (totalCoins / coinsPerSecond);\n\n        return (true, totalCoins, coinsPerSecond, startTime);\n    }"
}