{
    "Function": "slitherConstructorConstantVariables",
    "File": "src/libraries/DelegateTokenTransferHelpers.sol",
    "Parent Contracts": [],
    "High-Level Calls": [],
    "Internal Calls": [],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "library DelegateTokenTransferHelpers {\n    /// 1155 callbacks\n    uint256 internal constant ERC1155_NOT_PULLED = 5;\n    uint256 internal constant ERC1155_PULLED = 6;\n\n    function checkAndPullByType(Structs.Uint256 storage erc1155Pulled, Structs.DelegateInfo calldata delegateInfo) internal {\n        if (delegateInfo.tokenType == IDelegateRegistry.DelegationType.ERC721) {\n            checkERC721BeforePull(delegateInfo.amount, delegateInfo.tokenContract, delegateInfo.tokenId);\n            pullERC721AfterCheck(delegateInfo.tokenContract, delegateInfo.tokenId);\n        } else if (delegateInfo.tokenType == IDelegateRegistry.DelegationType.ERC20) {\n            checkERC20BeforePull(delegateInfo.amount, delegateInfo.tokenContract, delegateInfo.tokenId);\n            pullERC20AfterCheck(delegateInfo.tokenContract, delegateInfo.amount);\n        } else if (delegateInfo.tokenType == IDelegateRegistry.DelegationType.ERC1155) {\n            checkERC1155BeforePull(erc1155Pulled, delegateInfo.amount);\n            pullERC1155AfterCheck(erc1155Pulled, delegateInfo.amount, delegateInfo.tokenContract, delegateInfo.tokenId);\n        } else {\n            revert Errors.InvalidTokenType(delegateInfo.tokenType);\n        }\n    }\n\n    /// @dev Should revert for a typical 20 / 1155, and pass for a typical 721\n    function checkERC721BeforePull(uint256 underlyingAmount, address underlyingContract, uint256 underlyingTokenId) internal view {\n        if (underlyingAmount != 0) {\n            revert Errors.WrongAmountForType(IDelegateRegistry.DelegationType.ERC721, underlyingAmount);\n        }\n        if (IERC721(underlyingContract).ownerOf(underlyingTokenId) != msg.sender) {\n            revert Errors.CallerNotOwnerOrInvalidToken();\n        }\n    }\n\n    function pullERC721AfterCheck(address underlyingContract, uint256 underlyingTokenId) internal {\n        IERC721(underlyingContract).transferFrom(msg.sender, address(this), underlyingTokenId);\n    }\n\n    /// @dev Should revert for a typical 721 / 1155 and pass for a typical 20\n    function checkERC20BeforePull(uint256 underlyingAmount, address underlyingContract, uint256 underlyingTokenId) internal view {\n        if (underlyingTokenId != 0) {\n            revert Errors.WrongTokenIdForType(IDelegateRegistry.DelegationType.ERC20, underlyingTokenId);\n        }\n        if (underlyingAmount == 0) {\n            revert Errors.WrongAmountForType(IDelegateRegistry.DelegationType.ERC20, underlyingAmount);\n        }\n        if (IERC20(underlyingContract).allowance(msg.sender, address(this)) < underlyingAmount) {\n            revert Errors.InsufficientAllowanceOrInvalidToken();\n        }\n    }\n\n    function pullERC20AfterCheck(address underlyingContract, uint256 pullAmount) internal {\n        SafeERC20.safeTransferFrom(IERC20(underlyingContract), msg.sender, address(this), pullAmount);\n    }\n\n    function checkERC1155BeforePull(Structs.Uint256 storage erc1155Pulled, uint256 pullAmount) internal {\n        if (pullAmount == 0) revert Errors.WrongAmountForType(IDelegateRegistry.DelegationType.ERC1155, pullAmount);\n        if (erc1155Pulled.flag == ERC1155_NOT_PULLED) {\n            erc1155Pulled.flag = ERC1155_PULLED;\n        } else {\n            revert Errors.ERC1155Pulled();\n        }\n    }\n\n    function pullERC1155AfterCheck(Structs.Uint256 storage erc1155Pulled, uint256 pullAmount, address underlyingContract, uint256 underlyingTokenId) internal {\n        IERC1155(underlyingContract).safeTransferFrom(msg.sender, address(this), underlyingTokenId, pullAmount, \"\");\n        if (erc1155Pulled.flag == ERC1155_PULLED) {\n            revert Errors.ERC1155NotPulled();\n        }\n    }\n\n    function checkERC1155Pulled(Structs.Uint256 storage erc1155Pulled, address operator) internal returns (bool) {\n        if (erc1155Pulled.flag == ERC1155_PULLED && address(this) == operator) {\n            erc1155Pulled.flag = ERC1155_NOT_PULLED;\n            return true;\n        }\n        return false;\n    }\n\n    function revertInvalidERC1155PullCheck(Structs.Uint256 storage erc1155PullAuthorization, address operator) internal {\n        if (!checkERC1155Pulled(erc1155PullAuthorization, operator)) revert Errors.ERC1155PullNotRequested(operator);\n    }\n}"
}