```\nfunction mint(uint256 pid, uint256 amount)\n    external\n    nonReentrant\n    returns (uint256)\n{\n    address lpToken = ichiFarm.lpToken(pid);\n    IERC20Upgradeable(lpToken).safeTransferFrom(\n        msg.sender,\n        address(this),\n        amount\n    );\n    if (\n        IERC20Upgradeable(lpToken).allowance(\n            address(this),\n            address(ichiFarm)\n        ) != type(uint256).max\n    ) {\n        // We only need to do this once per pool, as LP token's allowance won't decrease if it's -1.\n        IERC20Upgradeable(lpToken).safeApprove(\n            address(ichiFarm),\n            type(uint256).max\n        );\n    }\n    ichiFarm.deposit(pid, amount, address(this));\n    // @ok if accIchiPerShare is always changing, so how does this work?\n    // it's basically just saving the accIchiPerShare at staking time, so when you unstake, it can calculate the difference\n    // really fucking smart actually\n    (uint256 ichiPerShare, , ) = ichiFarm.poolInfo(pid);\n    uint256 id = encodeId(pid, ichiPerShare);\n    _mint(msg.sender, id, amount, "");\n    return id;\n}\n```\n