{
    "Function": "initialize",
    "File": "contracts/MerkleResistor.sol",
    "Parent Contracts": [],
    "High-Level Calls": [
        "MerkleLib"
    ],
    "Internal Calls": [
        "require(bool,string)",
        "withdraw",
        "verifyVestingSchedule",
        "require(bool,string)",
        "require(bool,string)",
        "require(bool,string)",
        "abi.encode()",
        "keccak256(bytes)"
    ],
    "Library Calls": [
        "verifyProof"
    ],
    "Low-Level Calls": [],
    "Code": "function initialize(uint treeIndex, address destination, uint vestingTime, uint minTotalPayments, uint maxTotalPayments, bytes32[] memory proof) external {\n        // user selects own vesting schedule, not others\n        require(msg.sender == destination, 'Can only initialize your own tranche');\n        // can only initialize once\n        require(!initialized[destination][treeIndex], \"Already initialized\");\n        // compute merkle leaf, this is first element of proof\n        bytes32 leaf = keccak256(abi.encode(destination, minTotalPayments, maxTotalPayments));\n        // memory because we do not edit\n        MerkleTree memory tree = merkleTrees[treeIndex];\n        // this calls into MerkleLib, super cheap ~1000 gas per proof element\n        require(tree.merkleRoot.verifyProof(leaf, proof), \"The proof could not be verified.\");\n        // mark tree as initialized, preventing re-entrance or multiple initializations\n        initialized[destination][treeIndex] = true;\n\n        (bool valid, uint totalCoins, uint coinsPerSecond, uint startTime) = verifyVestingSchedule(treeIndex, vestingTime, minTotalPayments, maxTotalPayments);\n        require(valid, 'Invalid vesting schedule');\n\n        // fill out the struct for the address' vesting schedule\n        // don't have to mark as storage here, it's implied (why isn't it always implied when written to? solc-devs?)\n        tranches[destination][treeIndex] = Tranche(\n            totalCoins,    // this is just a cached number for UI, not used\n            totalCoins,    // starts out full\n            startTime,     // start time will usually be in the past, if pctUpFront > 0\n            block.timestamp + vestingTime,  // vesting starts from initialization time\n            coinsPerSecond,  // cached value to avoid recomputation\n            startTime      // this is lastWithdrawalTime, set to startTime to indicate no withdrawals have occurred yet\n        );\n        withdraw(treeIndex, destination);\n    }"
}