{
    "Function": "deposit",
    "File": "contracts/GeVault.sol",
    "Parent Contracts": [
        "contracts/openzeppelin-solidity/contracts/security/ReentrancyGuard.sol",
        "contracts/openzeppelin-solidity/contracts/access/Ownable.sol",
        "contracts/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol",
        "contracts/openzeppelin-solidity/contracts/token/ERC20/extensions/IERC20Metadata.sol",
        "contracts/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol",
        "contracts/openzeppelin-solidity/contracts/utils/Context.sol"
    ],
    "High-Level Calls": [
        "IPriceOracle",
        "ERC20",
        "SafeERC20",
        "SafeERC20",
        "IWETH"
    ],
    "Internal Calls": [
        "require(bool,string)",
        "require(bool,string)",
        "nonReentrant",
        "require(bool,string)",
        "require(bool,string)",
        "_mint",
        "totalSupply",
        "require(bool,string)",
        "require(bool,string)",
        "rebalance",
        "getAdjustedBaseFee",
        "getTVL",
        "getTVL",
        "poolMatchesOracle",
        "require(bool,string)"
    ],
    "Library Calls": [
        "safeTransfer",
        "safeTransferFrom"
    ],
    "Low-Level Calls": [],
    "Code": "function deposit(address token, uint amount) public payable nonReentrant returns (uint liquidity) \n  {\n    require(isEnabled, \"GEV: Pool Disabled\");\n    require(poolMatchesOracle(), \"GEV: Oracle Error\");\n    require(token == address(token0) || token == address(token1), \"GEV: Invalid Token\");\n    require(amount > 0 || msg.value > 0, \"GEV: Deposit Zero\");\n    \n    // Wrap if necessary and deposit here\n    if (msg.value > 0){\n      require(token == address(WETH), \"GEV: Invalid Weth\");\n      // wraps ETH by sending to the wrapper that sends back WETH\n      WETH.deposit{value: msg.value}();\n      amount = msg.value;\n    }\n    else { \n      ERC20(token).safeTransferFrom(msg.sender, address(this), amount);\n    }\n    \n    // Send deposit fee to treasury\n    uint fee = amount * getAdjustedBaseFee(token == address(token0)) / 1e4;\n    ERC20(token).safeTransfer(treasury, fee);\n    uint valueX8 = oracle.getAssetPrice(token) * (amount - fee) / 10**ERC20(token).decimals();\n    require(tvlCap > valueX8 + getTVL(), \"GEV: Max Cap Reached\");\n\n    uint vaultValueX8 = getTVL();\n    uint tSupply = totalSupply();\n    // initial liquidity at 1e18 token ~ $1\n    if (tSupply == 0 || vaultValueX8 == 0)\n      liquidity = valueX8 * 1e10;\n    else {\n      liquidity = tSupply * valueX8 / vaultValueX8;\n    }\n    \n    rebalance();\n    require(liquidity > 0, \"GEV: No Liquidity Added\");\n    _mint(msg.sender, liquidity);    \n    emit Deposit(msg.sender, token, amount, liquidity);\n  }"
}