{
    "Function": "slitherConstructorVariables",
    "File": "contracts/MerkleEligibility.sol",
    "Parent Contracts": [
        "interfaces/IEligibility.sol"
    ],
    "High-Level Calls": [],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "contract MerkleEligibility is IEligibility {\n    using MerkleLib for bytes32;\n\n    // the address of the MerkleIdentity contract\n    address public gateMaster;\n\n    // This represents a single gate or whitelist\n    struct Gate {\n        bytes32 root;  // merkle root of whitelist\n        uint maxWithdrawalsAddress; // maximum amount of withdrawals per address\n        uint maxWithdrawalsTotal;  // maximum total withdrawals allowed, summed across all addresses\n        uint totalWithdrawals;  // number of withdrawals already made\n    }\n\n    // array-like mapping of gate structs\n    mapping (uint => Gate) public gates;\n    // count withdrawals per address timesWithdrawn[gateIndex][user] = count\n    mapping(uint => mapping(address => uint)) public timesWithdrawn;\n    // count the gates\n    uint public numGates = 0;\n\n    /// @notice Deployer connects it to MerkleIdentity\n    /// @param _gateMaster address of MerkleIdentity contract, which has exclusive right to call passThruGate\n    constructor(address _gateMaster) {\n        gateMaster = _gateMaster;\n    }\n\n    /// @notice Add an gate, or set of eligibility criteria\n    /// @dev Anyone may call this, but without connecting it to MerkleIdentity (which only management can do) nothing happens\n    /// @param merkleRoot this is the root of the merkle tree with addresses as the leaf data\n    /// @param maxWithdrawalsAddress the maximum mints allowed per address by this gate\n    /// @param maxWithdrawalsTotal the maximum mints allowed across all addresses\n    /// @return index the index of the gate added\n    function addGate(bytes32 merkleRoot, uint maxWithdrawalsAddress, uint maxWithdrawalsTotal) external returns (uint index) {\n        // increment the number of roots\n        numGates += 1;\n\n        gates[numGates] = Gate(merkleRoot, maxWithdrawalsAddress, maxWithdrawalsTotal, 0);\n        return numGates;\n    }\n\n    /// @notice Get the fields of a particular gate\n    /// @param index the index into the gates mapping, which gate are you talking about?\n    /// @return root the merkle root for this gate\n    /// @return maxWithdrawalsAddress the maximum withdrawals allowed per address\n    /// @return maxWithdrawalsTotal the maximum number of withdrawals across all addresses\n    /// @return totalWithdrawals the number of withdrawals already made thru this gate\n    function getGate(uint index) external view returns (bytes32, uint, uint, uint) {\n        Gate memory gate = gates[index];\n        return (gate.root, gate.maxWithdrawalsAddress, gate.maxWithdrawalsTotal, gate.totalWithdrawals);\n    }\n\n    /// @notice Find out if a given address may pass thru the gate\n    /// @dev Note this is called by passThruGate and represents enforcement of the eligibility criteria\n    /// @param index which gate are we talking about?\n    /// @param recipient the address that wishes to pass thru the gate\n    /// @param proof the array of hashes connecting the leaf data to the merkle root\n    /// @return eligible true if recipient may pass thru gate\n    function isEligible(uint index, address recipient, bytes32[] memory proof) public override view returns (bool eligible) {\n        Gate memory gate = gates[index];\n        // We need to pack the 20 bytes address to the 32 bytes value, so we call abi.encode\n        bytes32 leaf = keccak256(abi.encode(recipient));\n        // Check the per-address count first\n        bool countValid = timesWithdrawn[index][recipient] < gate.maxWithdrawalsAddress;\n        // Then check global count and merkle proof\n        return countValid && gate.totalWithdrawals < gate.maxWithdrawalsTotal && gate.root.verifyProof(leaf, proof);\n    }\n\n    /// @notice Pass thru the gate, incrementing the counters\n    /// @dev This should only be called by the gatemaster, which should be MerkleIdentity\n    /// @param index which gate are we passing thru?\n    /// @param recipient who is passing thru it?\n    /// @param proof merkle proof of whitelist inclusion\n    function passThruGate(uint index, address recipient, bytes32[] memory proof) external override {\n        require(msg.sender == gateMaster, \"Only gatemaster may call this.\");\n\n        // close re-entrance gate, prevent double withdrawals\n        require(isEligible(index, recipient, proof), \"Address is not eligible\");\n\n        timesWithdrawn[index][recipient] += 1;\n        Gate storage gate = gates[index];\n        gate.totalWithdrawals += 1;\n    }\n}"
}