Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xB2467b69799051CCb007C2bC8f44Ba5E002d931f
Balance 1.7955 ETH
Nonce 1
Code Size 5347 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

5347 bytes
0x6080604052600436106100c5575f3560e01c806314cbd9931461011e57806315a0ea6a1461014857806320b27f231461016757806326aa101f1461018657806347ccca02146101c45780638da5cb5b1461020f578063a6f9dae11461022e578063bc9b96c71461024d578063be9a71bd1461026c578063bfcfa66b1461029e578063c9dc4b01146102e5578063e3ea222514610304578063ebb6dad814610323578063ebbc496514610350578063ebf3471214610364578063ef6445f114610383575f80fd5b3661011a576100d26103b1565b6100dc5f3461040d565b6040513481527ff51957990bb940e921e7f30e11ff8797a11f108721059218e471c9172e0095ca9060200160405180910390a161011860015f55565b005b5f80fd5b348015610129575f80fd5b50610132610632565b60405161013f9190611171565b60405180910390f35b348015610153575f80fd5b506101186101623660046111e1565b610692565b348015610172575f80fd5b50610118610181366004611210565b6107b0565b348015610191575f80fd5b506101b46101a03660046111e1565b60036020525f908152604090205460ff1681565b604051901515815260200161013f565b3480156101cf575f80fd5b506101f77f0000000000000000000000001b2fa8042a1273cc708be575b92cfd4caf6d5d7381565b6040516001600160a01b03909116815260200161013f565b34801561021a575f80fd5b506001546101f7906001600160a01b031681565b348015610239575f80fd5b506101186102483660046111e1565b610828565b348015610258575f80fd5b5061011861026736600461125b565b6108a8565b348015610277575f80fd5b507f0000000000000000000000001b2fa8042a1273cc708be575b92cfd4caf6d5d736101f7565b3480156102a9575f80fd5b506102d06102b83660046111e1565b60026020525f90815260409020805460019091015482565b6040805192835260208301919091520161013f565b3480156102f0575f80fd5b506101186102ff36600461125b565b6109ad565b34801561030f575f80fd5b5061011861031e36600461131a565b610b1f565b34801561032e575f80fd5b5061034261033d3660046111e1565b610bf7565b60405190815260200161013f565b34801561035b575f80fd5b50610118610c4a565b34801561036f575f80fd5b5061034261037e366004611344565b610cd0565b34801561038e575f80fd5b506101b461039d3660046111e1565b60046020525f908152604090205460ff1681565b60025f54036104075760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b60025f55565b5f7f0000000000000000000000001b2fa8042a1273cc708be575b92cfd4caf6d5d736001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561046a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061048e9190611370565b9050805f036104b05760405163f05afedf60e01b815260040160405180910390fd5b6001600160a01b0383165f90815260026020526040812060018101549091906104d9908561139b565b90505f6104e684836113ae565b90505f805b858110156105fc576040516331a9108f60e11b8152600481018290525f907f0000000000000000000000001b2fa8042a1273cc708be575b92cfd4caf6d5d736001600160a01b031690636352211e90602401602060405180830381865afa158015610558573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061057c91906113cd565b9050803b8015806105a457506001600160a01b0382165f9081526004602052604090205460ff165b156105f2576001600160a01b038083165f908152600660209081526040808320938e16835292905290812080548792906105df90849061139b565b909155506105ef9050858561139b565b93505b50506001016104eb565b5080845f015f82825461060f919061139b565b909155505f905061062082856113e8565b60019095019490945550505050505050565b6060600780548060200260200160405190810160405280929190818152602001828054801561068857602002820191905f5260205f20905b81546001600160a01b0316815260019091019060200180831161066a575b5050505050905090565b61069a6103b1565b6001600160a01b0381165f9081526003602052604090205460ff166106d25760405163259ba1ad60e01b815260040160405180910390fd5b335f9081526006602090815260408083206001600160a01b038516845290915281205490819003610716576040516354e668c360e11b815260040160405180910390fd5b335f9081526006602090815260408083206001600160a01b038616808552925282209190915561074f5761074a3382610d35565b610763565b6107636001600160a01b0383163383610e47565b6040518181526001600160a01b0383169033907f4a34429a0ef883c4301d5b40aa8ae85d4eb024946062f2c7ebd8320acedc831a9060200160405180910390a3506107ad60015f55565b50565b6107b8610eaa565b6001600160a01b0382165f81815260046020908152604091829020805485151560ff1982168117909255835160ff9091168015158252928101919091529092917f7f610610562e0ac37a8d728c455f8d82f81b0b1b9257f47b45aa411e40388984910160405180910390a2505050565b610830610eaa565b6001600160a01b0381166108575760405163d92e233d60e01b815260040160405180910390fd5b600580546001600160a01b0319166001600160a01b03838116918217909255600154604051919216907f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e22700905f90a350565b6108b0610eaa565b80515f5b818110156109a85760035f8483815181106108d1576108d16113fb565b6020908102919091018101516001600160a01b031682528101919091526040015f205460ff166109a057600783828151811061090f5761090f6113fb565b6020908102919091018101518254600180820185555f9485529284200180546001600160a01b0319166001600160a01b0390921691909117905584519091600391869085908110610962576109626113fb565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f205f6101000a81548160ff0219169083151502179055505b6001016108b4565b505050565b6109b5610eaa565b80515f5b818110156109a8576007545f5b81811015610b15578483815181106109e0576109e06113fb565b60200260200101516001600160a01b031660078281548110610a0457610a046113fb565b5f918252602090912001546001600160a01b031603610b0d575f60035f878681518110610a3357610a336113fb565b6020908102919091018101516001600160a01b031682528101919091526040015f20805460ff19169115159190911790556007610a716001846113e8565b81548110610a8157610a816113fb565b5f91825260209091200154600780546001600160a01b039092169183908110610aac57610aac6113fb565b905f5260205f20015f6101000a8154816001600160a01b0302191690836001600160a01b031602179055506007805480610ae857610ae861140f565b5f8281526020902081015f1990810180546001600160a01b0319169055019055610b15565b6001016109c6565b50506001016109b9565b610b276103b1565b6001600160a01b0382165f9081526003602052604090205460ff16610b5f5760405163259ba1ad60e01b815260040160405180910390fd5b6001600160a01b038216610b865760405163d92e233d60e01b815260040160405180910390fd5b81610b9c6001600160a01b038216333085610ed6565b610ba6838361040d565b826001600160a01b03167fd094a977cc88e3fad872be2bd112b129b27b1bf76c6b1175e732572871dba43483604051610be191815260200190565b60405180910390a250610bf360015f55565b5050565b6001600160a01b0381165f9081526003602052604081205460ff16610c2f5760405163259ba1ad60e01b815260040160405180910390fd5b506001600160a01b03165f9081526002602052604090205490565b6005546001600160a01b03163314610c74576040516282b42960e81b815260040160405180910390fd5b60018054600580546001600160a01b03198084166001600160a01b038381169182179096559116909155604051929091169182907f70aea8d848e8a90fb7661b227dc522eb6395c3dac71b63cb59edd5c9899b2364905f90a350565b6001600160a01b0382165f9081526003602052604081205460ff16610d085760405163259ba1ad60e01b815260040160405180910390fd5b506001600160a01b038082165f908152600660209081526040808320938616835292905220545b92915050565b80471015610d855760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016103fe565b5f826001600160a01b0316826040515f6040518083038185875af1925050503d805f8114610dce576040519150601f19603f3d011682016040523d82523d5f602084013e610dd3565b606091505b50509050806109a85760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c20726044820152791958da5c1a595b9d081b585e481a185d99481c995d995c9d195960321b60648201526084016103fe565b6040516001600160a01b0383166024820152604481018290526109a890849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610f14565b6001546001600160a01b03163314610ed4576040516282b42960e81b815260040160405180910390fd5b565b6040516001600160a01b0380851660248301528316604482015260648101829052610f0e9085906323b872dd60e01b90608401610e73565b50505050565b5f610f68826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610fe79092919063ffffffff16565b905080515f1480610f88575080806020019051810190610f889190611423565b6109a85760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016103fe565b6060610ff584845f85610ffd565b949350505050565b60608247101561105e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016103fe565b5f80866001600160a01b031685876040516110799190611460565b5f6040518083038185875af1925050503d805f81146110b3576040519150601f19603f3d011682016040523d82523d5f602084013e6110b8565b606091505b50915091506110c9878383876110d4565b979650505050505050565b606083156111425782515f0361113b576001600160a01b0385163b61113b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103fe565b5081610ff5565b610ff583838151156111575781518083602001fd5b8060405162461bcd60e51b81526004016103fe919061147b565b602080825282518282018190525f9190848201906040850190845b818110156111b15783516001600160a01b03168352928401929184019160010161118c565b50909695505050505050565b6001600160a01b03811681146107ad575f80fd5b80356111dc816111bd565b919050565b5f602082840312156111f1575f80fd5b81356111fc816111bd565b9392505050565b80151581146107ad575f80fd5b5f8060408385031215611221575f80fd5b823561122c816111bd565b9150602083013561123c81611203565b809150509250929050565b634e487b7160e01b5f52604160045260245ffd5b5f602080838503121561126c575f80fd5b82356001600160401b0380821115611282575f80fd5b818501915085601f830112611295575f80fd5b8135818111156112a7576112a7611247565b8060051b604051601f19603f830116810181811085821117156112cc576112cc611247565b6040529182528482019250838101850191888311156112e9575f80fd5b938501935b8285101561130e576112ff856111d1565b845293850193928501926112ee565b98975050505050505050565b5f806040838503121561132b575f80fd5b8235611336816111bd565b946020939093013593505050565b5f8060408385031215611355575f80fd5b8235611360816111bd565b9150602083013561123c816111bd565b5f60208284031215611380575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b80820180821115610d2f57610d2f611387565b5f826113c857634e487b7160e01b5f52601260045260245ffd5b500490565b5f602082840312156113dd575f80fd5b81516111fc816111bd565b81810381811115610d2f57610d2f611387565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52603160045260245ffd5b5f60208284031215611433575f80fd5b81516111fc81611203565b5f5b83811015611458578181015183820152602001611440565b50505f910152565b5f825161147181846020870161143e565b9190910192915050565b602081525f825180602084015261149981604085016020870161143e565b601f01601f1916919091016040019291505056fea2646970667358221220fb846565bd55ca3c999196293c2f9ea4f62ba7884c81c6597f848d9d72587a5364736f6c63430008180033

Verified Source Code Full Match

Compiler: v0.8.24+commit.e11b9ed9 EVM: shanghai Optimization: Yes (1 runs)
FeeDistributor.sol 282 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import { SafeERC20, Address } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { IERC721Enumerable, IERC165 } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";

/// @title A contract for distributing fees to NFT holders
/// @notice This contract allows the collection and distribution of fees (in ETH or ERC20 tokens) among holders of a specific NFT.
/// @dev Utilizes OpenZeppelin's SafeERC20 for safe ERC20 interactions and supports dynamic registration of tokens for fee distribution.
/// @dev This contract is designed to work only with native ETH, users with WETH should unwrap prior to interact with the contract
/// @dev This contract is designed to work with non deflationary tokens and tokens without taxation
contract FeeDistributor is ReentrancyGuard {
    using SafeERC20 for IERC20;
    using Address for address payable;

    /// @dev Struct to store total fees collected
    struct FeeInfo {
        uint256 totalDistributed;
        uint256 remainder;
    }

    IERC721Enumerable public immutable nft;
    address public owner;
    mapping(address => FeeInfo) public feeInfo;
    mapping(address => bool) public isTokenRegistered;
    mapping(address => bool) public contractWhitelisted;

    address private _pendingOwner;
    bytes4 private constant ERC721_ENUMERABLE_INTERFACE_ID = 0x780e9d63;

    // New mapping to track the accumulated fee per user at the time of the last claim or transfer
    // tokenId to address to value
    mapping(address => mapping(address => uint256)) private _feeToClaimPerUser;
    address[] private _registeredTokens;

    /// @notice Events for tracking contract activities
    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
    event NewOwner(address indexed previousOwner, address indexed newOwner);
    event ETHFeesReceived(uint256 amount);
    event ERC20FeesReceived(address indexed tokenAddress, uint256 amount);
    event WhiteListSet(address indexed contractAddress, bool oldStatus, bool newStatus);
    event FeeClaimed(address indexed user, address indexed tokenAddress, uint256 amount);

    error Unauthorized();
    error ZeroAddress();
    error TokenNotRegistered();
    error NoNFTs();
    error IERC721EnumerableInterfaceNotSupported();
    error Disabled();
    error ClaimAmountIsZero();

    /// @dev Modifier to restrict function access to the contract owner
    modifier onlyOwner {
        _onlyOwner();
        _;
    }

    /// @notice Initializes the contract with a specified NFT address
    /// @param _nftAddress The address of the NFT contract whose holders are eligible for fee distribution
    constructor(address _nftAddress) {
        if(_nftAddress == address(0)){
            revert ZeroAddress();
        }

        if (!IERC165(_nftAddress).supportsInterface(ERC721_ENUMERABLE_INTERFACE_ID)) {
            revert IERC721EnumerableInterfaceNotSupported();
        }

        nft = IERC721Enumerable(_nftAddress);
        owner = msg.sender;

        // Register Ether by default
        _registeredTokens.push(address(0));
        isTokenRegistered[address(0)] = true;
    }

    /// @notice Allows the contract to receive Ether and automatically distribute it
    receive() external payable nonReentrant {
        _distributeFees(address(0), msg.value);

        emit ETHFeesReceived(msg.value);
    }

    /// @notice Receives and distributes ERC20 token fees
    /// @dev Requires the token to be registered and the transfer to succeed
    /// @param _tokenAddress The address of the ERC20 token
    /// @param _amount The amount of tokens to distribute
    function receiveERC20Fees(address _tokenAddress, uint256 _amount) external nonReentrant {
        if(!isTokenRegistered[_tokenAddress]){
            revert TokenNotRegistered();
        }
        if(_tokenAddress == address(0)){
            revert ZeroAddress();
        }

        IERC20 token = IERC20(_tokenAddress);
        token.safeTransferFrom(msg.sender, address(this), _amount);

        _distributeFees(_tokenAddress, _amount);

        emit ERC20FeesReceived(_tokenAddress, _amount);
    }

    /// @notice Allows NFT holders to claim their share of fees for a specific token
    /// @param _tokenAddress The address of the token (ETH or ERC20) from which to claim fees
    function claimFees(address _tokenAddress) external nonReentrant {
        if(!isTokenRegistered[_tokenAddress]){
            revert TokenNotRegistered();
        }

        uint256 claimable = _feeToClaimPerUser[msg.sender][_tokenAddress];

        if (claimable == 0) {
            revert ClaimAmountIsZero();
        }

        _feeToClaimPerUser[msg.sender][_tokenAddress] = 0;

        if (_tokenAddress == address(0)) {
            // Ether
            payable(msg.sender).sendValue(claimable);
        } else {
            // ERC20 Token
            IERC20(_tokenAddress).safeTransfer(msg.sender, claimable);
        }

        emit FeeClaimed(msg.sender, _tokenAddress, claimable);
    }

    /// @notice Registers new tokens for fee distribution
    /// @param _tokenAddresses An array of addresses of the tokens to register
    function registerTokens(address[] memory _tokenAddresses) external onlyOwner {
        uint256 tokenLen = _tokenAddresses.length;

        for (uint256 i; i < tokenLen; i++) {
            if (!isTokenRegistered[_tokenAddresses[i]]) {
                _registeredTokens.push(_tokenAddresses[i]);
                isTokenRegistered[_tokenAddresses[i]] = true;
            }
        }
    }

    /// @notice Deregisters tokens from fee distribution
    /// @param _tokenAddresses An array of addresses of the tokens to deregister
    function deRegisterTokens(address[] memory _tokenAddresses) external onlyOwner {
        uint256 tokenLen = _tokenAddresses.length;
        for (uint256 i; i < tokenLen; i++) {

            uint256 registerLen = _registeredTokens.length;
            for (uint256 j; j < registerLen; j++) {
                if (_registeredTokens[j] == _tokenAddresses[i]) {
                    isTokenRegistered[_tokenAddresses[i]] = false;
                    // Move the last element into the place to delete
                    _registeredTokens[j] = _registeredTokens[registerLen - 1];
                    // Remove the last element
                    _registeredTokens.pop();
                    break;
                }
            }
        }
    }

    /// @notice Sets the value for whitelisted status for contracts on fee distribution
    /// @param _contractAddress The contract address to set the status for
    /// @param _status The new status of the contract address in terms of whitelisting
    function setContractWhitelistStatus(address _contractAddress, bool _status) external onlyOwner {
        bool oldStatus = contractWhitelisted[_contractAddress];
        contractWhitelisted[_contractAddress] = _status;

        emit WhiteListSet(_contractAddress, oldStatus, _status);
    }

    /// @notice Initiates the process of transferring ownership of the contract
    /// @dev Can only be called by the current owner
    /// @param newOwner The address of the new owner
    function changeOwner(address newOwner) external onlyOwner {
        if(newOwner == address(0)){
            revert ZeroAddress();
        }

        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner, newOwner);
    }

    /// @notice Completes the process of transferring ownership of the contract
    /// @dev Can only be completed by the pending owner
    function acceptOwner() external {
        if(_pendingOwner != msg.sender){
            revert Unauthorized();
        }
        address oldOwner = owner;
        owner = _pendingOwner;
        delete _pendingOwner;
        emit NewOwner(oldOwner, owner);
    }

    /// @notice Returns a list of all registered tokens
    /// @return An array of registered token addresses
    function getRegisteredTokens() external view returns (address[] memory) {
        return _registeredTokens;
    }

    /// @notice Provides total fees collected
    /// @param _tokenAddress The address of the token to query
    /// @return totalFees The total fees collected for the token
    function getTotal(address _tokenAddress) external view returns (uint256 totalFees) {
        if(!isTokenRegistered[_tokenAddress]){
            revert TokenNotRegistered();
        }
        FeeInfo storage info = feeInfo[_tokenAddress];
        return (info.totalDistributed);
    }

    /// @notice Calculates the amount of fees claimable by an NFT holder for a specific token
    /// @param _tokenAddress The address of the token to query
    /// @param _holder The address of the NFT holder
    /// @return The amount of fees claimable by the holder
    function getClaimableFees(address _tokenAddress, address _holder) public view returns (uint256) {
        if(!isTokenRegistered[_tokenAddress]){
            revert TokenNotRegistered();
        }

        return _feeToClaimPerUser[_holder][_tokenAddress];
    }

    /// @notice Returns the address of the NFT contract
    /// @return The NFT contract address
    function getNftAddress() public view returns (address) {
        return address(nft);
    }

    /// @dev Distributes the specified amount of fees to the NFT holders
    /// @param _tokenAddress The address of the token (ETH or ERC20) for which fees are being distributed
    /// @param _amount The total amount of fees to distribute
    function _distributeFees(address _tokenAddress, uint256 _amount) internal {
        // get amount of staked NFTs
        uint256 totalNFTs = nft.totalSupply();
        if(totalNFTs == 0){
            revert NoNFTs();
        }

        FeeInfo storage info = feeInfo[_tokenAddress];
        uint256 amountWithRemainder = _amount + info.remainder;
        uint256 feesToAdd = amountWithRemainder / totalNFTs;
        uint256 totalDistributed;

        // Update the accumulated fee for each NFT
        for (uint256 i; i < totalNFTs; i++) {
            address nftOwner = nft.ownerOf(i);

            uint256 codeSize;
            assembly {
                codeSize := extcodesize(nftOwner)
            }

            // contracts are excluded from fee distribution
            // if contract is whitelisted it can receive fees
            if (codeSize == 0 || contractWhitelisted[nftOwner]) {
                _feeToClaimPerUser[nftOwner][_tokenAddress] += feesToAdd;
                totalDistributed += feesToAdd;
            }
        }

        // Update total fees after distribution
        info.totalDistributed += totalDistributed;

        // Calculate any undistributed fees (including the previous remainder)
        uint256 newUndistributed = amountWithRemainder - totalDistributed;

        // Update the remainder in the FeeInfo struct for use in the next distribution
        info.remainder = newUndistributed;
    }

    /// @dev Internal function to enforce ownership restriction
    function _onlyOwner() private view {
        if(msg.sender != owner){
            revert Unauthorized();
        }
    }
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}
IERC20.sol 78 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
IERC721.sol 132 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}
ReentrancyGuard.sol 77 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _ENTERED;
    }
}
SafeERC20.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IERC20Permit.sol 90 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}
IERC721Enumerable.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

Read Contract

contractWhitelisted 0xef6445f1 → bool
feeInfo 0xbfcfa66b → uint256, uint256
getClaimableFees 0xebf34712 → uint256
getNftAddress 0xbe9a71bd → address
getRegisteredTokens 0x14cbd993 → address[]
getTotal 0xebb6dad8 → uint256
isTokenRegistered 0x26aa101f → bool
nft 0x47ccca02 → address
owner 0x8da5cb5b → address

Write Contract 7 functions

These functions modify contract state and require a wallet transaction to execute.

acceptOwner 0xebbc4965
No parameters
changeOwner 0xa6f9dae1
address newOwner
claimFees 0x15a0ea6a
address _tokenAddress
deRegisterTokens 0xc9dc4b01
address[] _tokenAddresses
receiveERC20Fees 0xe3ea2225
address _tokenAddress
uint256 _amount
registerTokens 0xbc9b96c7
address[] _tokenAddresses
setContractWhitelistStatus 0x20b27f23
address _contractAddress
bool _status

Recent Transactions

No transactions found for this address