{
    "Function": "withdraw",
    "File": "contracts/VTVLVesting.sol",
    "Parent Contracts": [
        "contracts/AccessProtected.sol",
        "node_modules/@openzeppelin/contracts/utils/Context.sol"
    ],
    "High-Level Calls": [
        "SafeERC20"
    ],
    "Internal Calls": [
        "_msgSender",
        "_msgSender",
        "_msgSender",
        "_msgSender",
        "hasActiveClaim",
        "_msgSender",
        "vestedAmount",
        "hasActiveClaim",
        "require(bool,string)",
        "_msgSender"
    ],
    "Library Calls": [
        "safeTransfer"
    ],
    "Low-Level Calls": [],
    "Code": "function withdraw() hasActiveClaim(_msgSender()) external {\n        // Get the message sender claim - if any\n\n        Claim storage usrClaim = claims[_msgSender()];\n\n        // we can use block.timestamp directly here as reference TS, as the function itself will make sure to cap it to endTimestamp\n        // Conversion of timestamp to uint40 should be safe since 48 bit allows for a lot of years.\n        uint112 allowance = vestedAmount(_msgSender(), uint40(block.timestamp));\n\n        // Make sure we didn't already withdraw more that we're allowed.\n        require(allowance > usrClaim.amountWithdrawn, \"NOTHING_TO_WITHDRAW\");\n\n        // Calculate how much can we withdraw (equivalent to the above inequality)\n        uint112 amountRemaining = allowance - usrClaim.amountWithdrawn;\n\n        // \"Double-entry bookkeeping\"\n        // Carry out the withdrawal by noting the withdrawn amount, and by transferring the tokens.\n        usrClaim.amountWithdrawn += amountRemaining;\n        // Reduce the allocated amount since the following transaction pays out so the \"debt\" gets reduced\n        numTokensReservedForVesting -= amountRemaining;\n        \n        // After the \"books\" are set, transfer the tokens\n        // Reentrancy note - internal vars have been changed by now\n        // Also following Checks-effects-interactions pattern\n        tokenAddress.safeTransfer(_msgSender(), amountRemaining);\n\n        // Let withdrawal known to everyone.\n        emit Claimed(_msgSender(), amountRemaining);\n    }"
}