{
    "Function": "_baseVestedAmount",
    "File": "contracts/VTVLVesting.sol",
    "Parent Contracts": [
        "contracts/AccessProtected.sol",
        "node_modules/@openzeppelin/contracts/utils/Context.sol"
    ],
    "High-Level Calls": [],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function _baseVestedAmount(Claim memory _claim, uint40 _referenceTs) internal pure returns (uint112) {\n        uint112 vestAmt = 0;\n        \n        // the condition to have anything vested is to be active\n        if(_claim.isActive) {\n            // no point of looking past the endTimestamp as nothing should vest afterwards\n            // So if we're past the end, just get the ref frame back to the end\n            if(_referenceTs > _claim.endTimestamp) {\n                _referenceTs = _claim.endTimestamp;\n            }\n\n            // If we're past the cliffReleaseTimestamp, we release the cliffAmount\n            // We don't check here that cliffReleaseTimestamp is after the startTimestamp \n            if(_referenceTs >= _claim.cliffReleaseTimestamp) {\n                vestAmt += _claim.cliffAmount;\n            }\n\n            // Calculate the linearly vested amount - this is relevant only if we're past the schedule start\n            // at _referenceTs == _claim.startTimestamp, the period proportion will be 0 so we don't need to start the calc\n            if(_referenceTs > _claim.startTimestamp) {\n                uint40 currentVestingDurationSecs = _referenceTs - _claim.startTimestamp; // How long since the start\n                // Next, we need to calculated the duration truncated to nearest releaseIntervalSecs\n                uint40 truncatedCurrentVestingDurationSecs = (currentVestingDurationSecs / _claim.releaseIntervalSecs) * _claim.releaseIntervalSecs;\n                uint40 finalVestingDurationSecs = _claim.endTimestamp - _claim.startTimestamp; // length of the interval\n\n                // Calculate the linear vested amount - fraction_of_interval_completed * linearVestedAmount\n                // Since fraction_of_interval_completed is truncatedCurrentVestingDurationSecs / finalVestingDurationSecs, the formula becomes\n                // truncatedCurrentVestingDurationSecs / finalVestingDurationSecs * linearVestAmount, so we can rewrite as below to avoid \n                // rounding errors\n                uint112 linearVestAmount = _claim.linearVestAmount * truncatedCurrentVestingDurationSecs / finalVestingDurationSecs;\n\n                // Having calculated the linearVestAmount, simply add it to the vested amount\n                vestAmt += linearVestAmount;\n            }\n        }\n        \n        // Return the bigger of (vestAmt, _claim.amountWithdrawn)\n        // Rationale: no matter how we calculate the vestAmt, we can never return that less was vested than was already withdrawn.\n        // Case where this could be relevant - If the claim is inactive, vestAmt would be 0, yet if something was already withdrawn \n        // on that claim, we want to return that as vested thus far - as we want the function to be monotonic.\n        return (vestAmt > _claim.amountWithdrawn) ? vestAmt : _claim.amountWithdrawn;\n    }"
}