ETH Price: $3,155.56 (+2.74%)
Gas: 1 Gwei

Contract

0x4946360377D7d3B73Df887Ada347c1dc4CB5AacE
 

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Claim All Reward...202463262024-07-06 8:38:117 days ago1720255091IN
0x49463603...c4CB5AacE
0 ETH0.000927642.68213739
Claim All Reward...202153872024-07-02 0:55:2311 days ago1719881723IN
0x49463603...c4CB5AacE
0 ETH0.000216811.7985882
Claim All Reward...201750442024-06-26 9:43:5917 days ago1719395039IN
0x49463603...c4CB5AacE
0 ETH0.000438782.34923006
Claim All Reward...200745262024-06-12 8:22:4731 days ago1718180567IN
0x49463603...c4CB5AacE
0 ETH0.0053350817.88765505
Claim All Reward...199110712024-05-20 12:15:1153 days ago1716207311IN
0x49463603...c4CB5AacE
0 ETH0.000625996.08615319
Claim All Reward...199110702024-05-20 12:14:5953 days ago1716207299IN
0x49463603...c4CB5AacE
0 ETH0.002410636.2742708
Claim All Reward...199094322024-05-20 6:44:4754 days ago1716187487IN
0x49463603...c4CB5AacE
0 ETH0.000209982.9033303
Claim All Reward...199094322024-05-20 6:44:4754 days ago1716187487IN
0x49463603...c4CB5AacE
0 ETH0.000674892.88058165
Claim All Reward...198839222024-05-16 17:06:5957 days ago1715879219IN
0x49463603...c4CB5AacE
0 ETH0.001009968.55344769
Claim All Reward...198828842024-05-16 13:37:4757 days ago1715866667IN
0x49463603...c4CB5AacE
0 ETH0.001591416.91761871
Claim All Reward...198687472024-05-14 14:11:1159 days ago1715695871IN
0x49463603...c4CB5AacE
0 ETH0.0020885114.0450541
Claim All Reward...198229142024-05-08 4:18:5966 days ago1715141939IN
0x49463603...c4CB5AacE
0 ETH0.001200154.00468156
Claim All Reward...198224892024-05-08 2:53:3566 days ago1715136815IN
0x49463603...c4CB5AacE
0 ETH0.001027335.13892726
Claim All Reward...198128602024-05-06 18:34:4767 days ago1715020487IN
0x49463603...c4CB5AacE
0 ETH0.001652245.57557679
Claim All Reward...198017562024-05-05 5:18:1169 days ago1714886291IN
0x49463603...c4CB5AacE
0 ETH0.001390175.08639174
Claim All Reward...197888722024-05-03 10:04:1171 days ago1714730651IN
0x49463603...c4CB5AacE
0 ETH0.003555546.75141127
Claim All Reward...197787182024-05-01 23:58:3572 days ago1714607915IN
0x49463603...c4CB5AacE
0 ETH0.000838295.93465226
Claim All Reward...197785802024-05-01 23:30:4772 days ago1714606247IN
0x49463603...c4CB5AacE
0 ETH0.000991564.86672386
Claim All Reward...197784202024-05-01 22:58:4772 days ago1714604327IN
0x49463603...c4CB5AacE
0 ETH0.001632455.41560568
Claim All Reward...197602182024-04-29 9:56:5975 days ago1714384619IN
0x49463603...c4CB5AacE
0 ETH0.001484878.82223559
Claim All Reward...197575312024-04-29 0:56:5975 days ago1714352219IN
0x49463603...c4CB5AacE
0 ETH0.001457294.57513466
Claim All Reward...197522022024-04-28 7:03:2376 days ago1714287803IN
0x49463603...c4CB5AacE
0 ETH0.001982075.57714605
Claim All Reward...197453102024-04-27 7:53:4777 days ago1714204427IN
0x49463603...c4CB5AacE
0 ETH0.000854745.39803874
Claim All Reward...197376132024-04-26 6:00:2378 days ago1714111223IN
0x49463603...c4CB5AacE
0 ETH0.001948937.29719602
Claim All Reward...197359962024-04-26 0:35:1178 days ago1714091711IN
0x49463603...c4CB5AacE
0 ETH0.00156986.01251579
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0xeef053e2...4F8927Ba5
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
RewardDistributor

Compiler Version
v0.8.7+commit.e28d00a7

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, GNU GPLv3 license

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2022-03-24
*/

// Sources flattened with hardhat v2.8.0 https://hardhat.org

pragma solidity ^0.8.0;

// File contracts/libraries/SafeTransfer.sol

// SPDX-License-Identifier: GPL-3.0-or-later

// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
    function safeApprove(
        address token,
        address to,
        uint256 value
    ) internal {
        // bytes4(keccak256(bytes('approve(address,uint256)')));
        (bool success, bytes memory data) = token.call(
            abi.encodeWithSelector(0x095ea7b3, to, value)
        );
        require(
            success && (data.length == 0 || abi.decode(data, (bool))),
            "safe approve failed"
        );
    }

    function safeTransfer(
        address token,
        address to,
        uint256 value
    ) internal {
        // bytes4(keccak256(bytes('transfer(address,uint256)')));
        (bool success, bytes memory data) = token.call(
            abi.encodeWithSelector(0xa9059cbb, to, value)
        );
        require(
            success && (data.length == 0 || abi.decode(data, (bool))),
            "safe transfer failed"
        );
    }

    function safeTransferFrom(
        address token,
        address from,
        address to,
        uint256 value
    ) internal {
        // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
        (bool success, bytes memory data) = token.call(
            abi.encodeWithSelector(0x23b872dd, from, to, value)
        );
        require(
            success && (data.length == 0 || abi.decode(data, (bool))),
            "safe transferFrom failed"
        );
    }

    function safeTransferETH(address to, uint256 value) internal {
        (bool success, ) = to.call{ value: value }(new bytes(0));
        require(success, "safe transferETH failed");
    }
}


// File contracts/libraries/Ownable.sol

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable {
    address private _owner;

    event OwnershipTransferred(
        address indexed previousOwner,
        address indexed newOwner
    );

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(msg.sender);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == msg.sender, "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(
            newOwner != address(0),
            "Ownable: new owner is the zero address"
        );
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}


// File contracts/interfaces/IERC721.sol

// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 {
    /**
     * @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 token collection name.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);

    /**
     * @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 Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * 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 Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId)
        external
        view
        returns (address operator);

    /**
     * @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 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);
}


// File contracts/libraries/Strings.sol

// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length)
        internal
        pure
        returns (string memory)
    {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}


// File contracts/libraries/ERC721.sol

// OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol)

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721 is IERC721 {
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Base URI
    string private _baseURI;

    // Mapping from token ID to owner address
    mapping(uint256 => address) private _owners;

    // Mapping owner address to token count
    mapping(address => uint256) private _balances;

    // Mapping from token ID to approved address
    mapping(uint256 => address) private _tokenApprovals;

    // Mapping from owner to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor(
        string memory name_,
        string memory symbol_,
        string memory baseURI_
    ) {
        _name = name_;
        _symbol = symbol_;
        _baseURI = baseURI_;
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner)
        public
        view
        virtual
        override
        returns (uint256)
    {
        require(
            owner != address(0),
            "ERC721: balance query for the zero address"
        );
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId)
        public
        view
        virtual
        override
        returns (address)
    {
        address owner = _owners[tokenId];
        require(
            owner != address(0),
            "ERC721: owner query for nonexistent token"
        );
        return owner;
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId)
        public
        view
        virtual
        override
        returns (string memory)
    {
        require(
            _exists(tokenId),
            "ERC721Metadata: URI query for nonexistent token"
        );

        string memory baseURI = _baseURI;
        return
            bytes(baseURI).length > 0
                ? string(abi.encodePacked(baseURI, tokenId.toString()))
                : "";
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(
            msg.sender == owner || isApprovedForAll(owner, msg.sender),
            "ERC721: approve caller is not owner nor approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId)
        public
        view
        virtual
        override
        returns (address)
    {
        require(
            _exists(tokenId),
            "ERC721: approved query for nonexistent token"
        );

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved)
        public
        virtual
        override
    {
        _setApprovalForAll(msg.sender, operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator)
        public
        view
        virtual
        override
        returns (bool)
    {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        //solhint-disable-next-line max-line-length
        require(
            _isApprovedOrOwner(msg.sender, tokenId),
            "ERC721: transfer caller is not owner nor approved"
        );

        _transfer(from, to, tokenId);
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return _owners[tokenId] != address(0);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId)
        internal
        view
        virtual
        returns (bool)
    {
        require(
            _exists(tokenId),
            "ERC721: operator query for nonexistent token"
        );
        address owner = ERC721.ownerOf(tokenId);
        return (spender == owner ||
            getApproved(tokenId) == spender ||
            isApprovedForAll(owner, spender));
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");

        _beforeTokenTransfer(address(0), to, tokenId);

        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(address(0), to, tokenId);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721.ownerOf(tokenId);

        _beforeTokenTransfer(owner, address(0), tokenId);

        // Clear approvals
        _approve(address(0), tokenId);

        _balances[owner] -= 1;
        delete _owners[tokenId];

        emit Transfer(owner, address(0), tokenId);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {
        require(
            ERC721.ownerOf(tokenId) == from,
            "ERC721: transfer from incorrect owner"
        );
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _balances[from] -= 1;
        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits a {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits a {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC721: approve to caller");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {}
}


// File contracts/interfaces/IERC721Enumerable.sol

// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.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 tokenId);

    /**
     * @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);
}


// File contracts/libraries/ERC721Enumerable.sol

// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol)

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

    // Mapping from token ID to index of the owner tokens list
    mapping(uint256 => uint256) private _ownedTokensIndex;

    // Array with all token ids, used for enumeration
    uint256[] private _allTokens;

    // Mapping from token id to position in the allTokens array
    mapping(uint256 => uint256) private _allTokensIndex;

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index)
        public
        view
        virtual
        override
        returns (uint256)
    {
        require(
            index < ERC721.balanceOf(owner),
            "ERC721Enumerable: owner index out of bounds"
        );
        return _ownedTokens[owner][index];
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _allTokens.length;
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index)
        public
        view
        virtual
        override
        returns (uint256)
    {
        require(
            index < ERC721Enumerable.totalSupply(),
            "ERC721Enumerable: global index out of bounds"
        );
        return _allTokens[index];
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual override {
        super._beforeTokenTransfer(from, to, tokenId);

        if (from == address(0)) {
            _addTokenToAllTokensEnumeration(tokenId);
        } else if (from != to) {
            _removeTokenFromOwnerEnumeration(from, tokenId);
        }
        if (to == address(0)) {
            _removeTokenFromAllTokensEnumeration(tokenId);
        } else if (to != from) {
            _addTokenToOwnerEnumeration(to, tokenId);
        }
    }

    /**
     * @dev Private function to add a token to this extension's ownership-tracking data structures.
     * @param to address representing the new owner of the given token ID
     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
     */
    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
        uint256 length = ERC721.balanceOf(to);
        _ownedTokens[to][length] = tokenId;
        _ownedTokensIndex[tokenId] = length;
    }

    /**
     * @dev Private function to add a token to this extension's token tracking data structures.
     * @param tokenId uint256 ID of the token to be added to the tokens list
     */
    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
        _allTokensIndex[tokenId] = _allTokens.length;
        _allTokens.push(tokenId);
    }

    /**
     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
     * This has O(1) time complexity, but alters the order of the _ownedTokens array.
     * @param from address representing the previous owner of the given token ID
     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
     */
    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId)
        private
    {
        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
        uint256 tokenIndex = _ownedTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary
        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];

            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
        }

        // This also deletes the contents at the last position of the array
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokens[from][lastTokenIndex];
    }

    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];

        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index

        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }
}


// File contracts/libraries/Math.sol

library Math {
    function compound(uint256 rewardRateX96, uint256 nCompounds)
        internal
        pure
        returns (uint256 compoundedX96)
    {
        if (nCompounds == 0) {
            compoundedX96 = 2**96;
        } else if (nCompounds == 1) {
            compoundedX96 = rewardRateX96;
        } else {
            compoundedX96 = compound(rewardRateX96, nCompounds / 2);
            compoundedX96 = mulX96(compoundedX96, compoundedX96);

            if (nCompounds % 2 == 1) {
                compoundedX96 = mulX96(compoundedX96, rewardRateX96);
            }
        }
    }

    // ref: https://blogs.sas.com/content/iml/2016/05/16/babylonian-square-roots.html
    function sqrt(uint256 x) internal pure returns (uint256 y) {
        uint256 z = (x + 1) / 2;
        y = x;
        while (z < y) {
            y = z;
            z = (x / z + z) / 2;
        }
    }

    function mulX96(uint256 x, uint256 y) internal pure returns (uint256 z) {
        z = (x * y) >> 96;
    }

    function divX96(uint256 x, uint256 y) internal pure returns (uint256 z) {
        z = (x << 96) / y;
    }

    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }
}


// File contracts/libraries/Time.sol

library Time {
    function current_hour_timestamp() internal view returns (uint64) {
        return uint64((block.timestamp / 1 hours) * 1 hours);
    }

    function block_timestamp() internal view returns (uint64) {
        return uint64(block.timestamp);
    }
}


// File contracts/interfaces/IUniswapV3Factory.sol

/// @title The interface for the Uniswap V3 Factory
/// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees
interface IUniswapV3Factory {
    /// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist
    /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order
    /// @param tokenA The contract address of either token0 or token1
    /// @param tokenB The contract address of the other token
    /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
    /// @return pool The pool address
    function getPool(
        address tokenA,
        address tokenB,
        uint24 fee
    ) external view returns (address pool);

    /// @notice Creates a pool for the given two tokens and fee
    /// @param tokenA One of the two tokens in the desired pool
    /// @param tokenB The other of the two tokens in the desired pool
    /// @param fee The desired fee for the pool
    /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved
    /// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments
    /// are invalid.
    /// @return pool The address of the newly created pool
    function createPool(
        address tokenA,
        address tokenB,
        uint24 fee
    ) external returns (address pool);
}


// File contracts/interfaces/IUniswapV3Pool.sol

interface IUniswapV3Pool {
    /// @notice Sets the initial price for the pool
    /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value
    /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96
    function initialize(uint160 sqrtPriceX96) external;

    /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas
    /// when accessed externally.
    /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value
    /// tick The current tick of the pool, i.e. according to the last tick transition that was run.
    /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick
    /// boundary.
    /// observationIndex The index of the last oracle observation that was written,
    /// observationCardinality The current maximum number of observations stored in the pool,
    /// observationCardinalityNext The next maximum number of observations, to be updated when the observation.
    /// feeProtocol The protocol fee for both tokens of the pool.
    /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0
    /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.
    /// unlocked Whether the pool is currently locked to reentrancy
    function slot0()
        external
        view
        returns (
            uint160 sqrtPriceX96,
            int24 tick,
            uint16 observationIndex,
            uint16 observationCardinality,
            uint16 observationCardinalityNext,
            uint8 feeProtocol,
            bool unlocked
        );

    /// @notice Increase the maximum number of price and liquidity observations that this pool will store
    /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to
    /// the input observationCardinalityNext.
    /// @param observationCardinalityNext The desired minimum number of observations for the pool to store
    function increaseObservationCardinalityNext(
        uint16 observationCardinalityNext
    ) external;

    /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp
    /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing
    /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,
    /// you must call it with secondsAgos = [3600, 0].
    /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in
    /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.
    /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned
    /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp
    /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block
    /// timestamp
    function observe(uint32[] calldata secondsAgos)
        external
        view
        returns (
            int56[] memory tickCumulatives,
            uint160[] memory secondsPerLiquidityCumulativeX128s
        );
}


// File contracts/interfaces/IERC20.sol

interface IERC20 {
    function totalSupply() external view returns (uint256);

    function balanceOf(address account) external view returns (uint256);

    function transfer(address recipient, uint256 amount)
        external
        returns (bool);

    function allowance(address owner, address spender)
        external
        view
        returns (uint256);

    function approve(address spender, uint256 amount) external returns (bool);

    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(
        address indexed owner,
        address indexed spender,
        uint256 value
    );
}


// File contracts/libraries/ERC20.sol

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is IERC20 {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private _decimals;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(
        string memory name_,
        string memory symbol_,
        uint8 decimals_
    ) {
        _name = name_;
        _symbol = symbol_;
        _decimals = decimals_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless this function is
     * overridden;
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual returns (uint8) {
        return _decimals;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account)
        public
        view
        virtual
        override
        returns (uint256)
    {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount)
        public
        virtual
        override
        returns (bool)
    {
        _transfer(msg.sender, recipient, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender)
        public
        view
        virtual
        override
        returns (uint256)
    {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount)
        public
        virtual
        override
        returns (bool)
    {
        _approve(msg.sender, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) public virtual override returns (bool) {
        uint256 currentAllowance = _allowances[sender][msg.sender];
        if (currentAllowance != type(uint256).max) {
            require(
                currentAllowance >= amount,
                "ERC20: transfer amount exceeds allowance"
            );
            unchecked {
                _approve(sender, msg.sender, currentAllowance - amount);
            }
        }

        _transfer(sender, recipient, amount);

        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue)
        public
        virtual
        returns (bool)
    {
        _approve(
            msg.sender,
            spender,
            _allowances[msg.sender][spender] + addedValue
        );
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue)
        public
        virtual
        returns (bool)
    {
        uint256 currentAllowance = _allowances[msg.sender][spender];
        require(
            currentAllowance >= subtractedValue,
            "ERC20: decreased allowance below zero"
        );
        unchecked {
            _approve(msg.sender, spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `sender` to `recipient`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(
        address sender,
        address recipient,
        uint256 amount
    ) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        uint256 senderBalance = _balances[sender];
        require(
            senderBalance >= amount,
            "ERC20: transfer amount exceeds balance"
        );
        unchecked {
            _balances[sender] = senderBalance - amount;
        }
        _balances[recipient] += amount;

        emit Transfer(sender, recipient, amount);

        _afterTokenTransfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
        }
        _totalSupply -= amount;

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}
}


// File contracts/libraries/TickMath.sol

/// @title Math library for computing sqrt prices from ticks and vice versa
/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports
/// prices between 2**-128 and 2**128
library TickMath {
    /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128
    int24 internal constant MIN_TICK = -887272;
    /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128
    int24 internal constant MAX_TICK = -MIN_TICK;

    /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)
    uint160 internal constant MIN_SQRT_RATIO = 4295128739;
    /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)
    uint160 internal constant MAX_SQRT_RATIO =
        1461446703485210103287273052203988822378723970342;

    /// @notice Calculates sqrt(1.0001^tick) * 2^96
    /// @dev Throws if |tick| > max tick
    /// @param tick The input tick for the above formula
    /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
    /// at the given tick
    function getSqrtRatioAtTick(int24 tick)
        internal
        pure
        returns (uint160 sqrtPriceX96)
    {
        uint256 absTick = tick < 0
            ? uint256(-int256(tick))
            : uint256(int256(tick));
        require(absTick <= uint256(int256(MAX_TICK)), "T");

        uint256 ratio = absTick & 0x1 != 0
            ? 0xfffcb933bd6fad37aa2d162d1a594001
            : 0x100000000000000000000000000000000;
        if (absTick & 0x2 != 0)
            ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;
        if (absTick & 0x4 != 0)
            ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;
        if (absTick & 0x8 != 0)
            ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;
        if (absTick & 0x10 != 0)
            ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;
        if (absTick & 0x20 != 0)
            ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;
        if (absTick & 0x40 != 0)
            ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;
        if (absTick & 0x80 != 0)
            ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;
        if (absTick & 0x100 != 0)
            ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;
        if (absTick & 0x200 != 0)
            ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;
        if (absTick & 0x400 != 0)
            ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;
        if (absTick & 0x800 != 0)
            ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;
        if (absTick & 0x1000 != 0)
            ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;
        if (absTick & 0x2000 != 0)
            ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;
        if (absTick & 0x4000 != 0)
            ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;
        if (absTick & 0x8000 != 0)
            ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;
        if (absTick & 0x10000 != 0)
            ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;
        if (absTick & 0x20000 != 0)
            ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;
        if (absTick & 0x40000 != 0)
            ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;
        if (absTick & 0x80000 != 0)
            ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;

        if (tick > 0) ratio = type(uint256).max / ratio;

        // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.
        // we then downcast because we know the result always fits within 160 bits due to our tick input constraint
        // we round up in the division so getTickAtSqrtRatio of the output price is always consistent
        sqrtPriceX96 = uint160(
            (ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1)
        );
    }

    /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio
    /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may
    /// ever return.
    /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96
    /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio
    function getTickAtSqrtRatio(uint160 sqrtPriceX96)
        internal
        pure
        returns (int24 tick)
    {
        // second inequality must be < because the price can never reach the price at the max tick
        require(
            sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO,
            "R"
        );
        uint256 ratio = uint256(sqrtPriceX96) << 32;

        uint256 r = ratio;
        uint256 msb = 0;

        assembly {
            let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(5, gt(r, 0xFFFFFFFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(4, gt(r, 0xFFFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(3, gt(r, 0xFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(2, gt(r, 0xF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(1, gt(r, 0x3))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := gt(r, 0x1)
            msb := or(msb, f)
        }

        if (msb >= 128) r = ratio >> (msb - 127);
        else r = ratio << (127 - msb);

        int256 log_2 = (int256(msb) - 128) << 64;

        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(63, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(62, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(61, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(60, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(59, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(58, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(57, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(56, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(55, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(54, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(53, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(52, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(51, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(50, f))
        }

        int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number

        int24 tickLow = int24(
            (log_sqrt10001 - 3402992956809132418596140100660247210) >> 128
        );
        int24 tickHi = int24(
            (log_sqrt10001 + 291339464771989622907027621153398088495) >> 128
        );

        tick = tickLow == tickHi
            ? tickLow
            : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96
            ? tickHi
            : tickLow;
    }
}


// File contracts/Const.sol

int24 constant INITIAL_QLT_PRICE_TICK = -23000; // QLT_USDC price ~ 100.0

// initial values
uint24 constant UNISWAP_POOL_FEE = 10000;
int24 constant UNISWAP_POOL_TICK_SPACING = 200;
uint16 constant UNISWAP_POOL_OBSERVATION_CADINALITY = 64;

// default values
uint256 constant DEFAULT_MIN_MINT_PRICE_X96 = 100 * Q96;
uint32 constant DEFAULT_TWAP_DURATION = 1 hours;
uint32 constant DEFAULT_UNSTAKE_LOCKUP_PERIOD = 3 days;

// floating point math
uint256 constant Q96 = 2**96;
uint256 constant MX96 = Q96 / 10**6;
uint256 constant TX96 = Q96 / 10**12;

// ERC-20 contract addresses
address constant WETH = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
address constant USDC = address(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48);
address constant USDT = address(0xdAC17F958D2ee523a2206206994597C13D831ec7);
address constant DAI = address(0x6B175474E89094C44Da98b954EedeAC495271d0F);
address constant BUSD = address(0x4Fabb145d64652a948d72533023f6E7A623C7C53);
address constant FRAX = address(0x853d955aCEf822Db058eb8505911ED77F175b99e);
address constant WBTC = address(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599);

// Uniswap, see `https://docs.uniswap.org/protocol/reference/deployments`
address constant UNISWAP_FACTORY = address(
    0x1F98431c8aD98523631AE4a59f267346ea31F984
);
address constant UNISWAP_ROUTER = address(
    0xE592427A0AEce92De3Edee1F18E0157C05861564
);
address constant UNISWAP_NFP_MGR = address(
    0xC36442b4a4522E871399CD717aBDD847Ab11FE88
);


// File contracts/QLT.sol

contract QLT is ERC20, Ownable {
    event Mint(address indexed account, uint256 amount);
    event Burn(uint256 amount);

    mapping(address => bool) public authorizedMinters;

    constructor() ERC20("Quantland", "QLT", 9) {
        require(
            address(this) < USDC,
            "QLT contract address must be smaller than USDC token contract address"
        );
        authorizedMinters[msg.sender] = true;

        // deploy uniswap pool
        IUniswapV3Pool pool = IUniswapV3Pool(
            IUniswapV3Factory(UNISWAP_FACTORY).createPool(
                address(this),
                USDC,
                UNISWAP_POOL_FEE
            )
        );
        pool.initialize(TickMath.getSqrtRatioAtTick(INITIAL_QLT_PRICE_TICK));
        pool.increaseObservationCardinalityNext(
            UNISWAP_POOL_OBSERVATION_CADINALITY
        );
    }

    function mint(address account, uint256 amount)
        external
        onlyAuthorizedMinter
    {
        _mint(account, amount);

        emit Mint(account, amount);
    }

    function burn(uint256 amount) external onlyOwner {
        _burn(msg.sender, amount);

        emit Burn(amount);
    }

    /* Access Control */
    modifier onlyAuthorizedMinter() {
        require(authorizedMinters[msg.sender], "not authorized minter");
        _;
    }

    function addAuthorizedMinter(address account) external onlyOwner {
        authorizedMinters[account] = true;
    }

    function removeAuthorizedMinter(address account) external onlyOwner {
        authorizedMinters[account] = false;
    }
}


// File contracts/StakedQLT.sol

struct StakingInfo {
    bytes32 stakingPlan;
    uint256 stakedAmount;
    uint64 stakeTime;
    uint64 unstakeTime;
    uint64 redeemTime;
    uint64 lastHarvestTime;
    uint256 accumulatedStakingReward;
}

struct StakingRewardRate {
    uint256 rewardRateX96;
    uint64 startTime;
}

struct StakingPowerMultiplier {
    uint64 multiplier;
    uint64 startTime;
}

struct StakingPlan {
    bytes32 name;
    uint256 stakingAmount;
    uint256 accumulatedStakingReward;
    StakingRewardRate[] rewardRates;
    StakingPowerMultiplier[] multipliers;
    uint64 lockupPeriod;
    uint64 createdAt;
    uint64 deactivatedAt;
}

contract StakedQLT is ERC721Enumerable, Ownable {
    using Math for uint256;

    event Stake(
        uint256 indexed tokenId,
        address staker,
        bytes32 stakingPlan,
        uint256 amount
    );
    event Unstake(uint256 indexed tokenId);
    event Redeem(uint256 indexed tokenId, uint256 amount);
    event Harvest(uint256 indexed tokenId, uint256 rewardAmount);
    event HarvestAll(uint256[] tokenIds, uint256 rewardAmount);
    event StakingPlanCreated(bytes32 name);
    event StakingPlanDeactivated(bytes32 name);
    event StakingRewardRateUpdated(bytes32 name, uint256 rewardRateX96);
    event StakingPowerMultiplierUpdated(bytes32 name, uint256 multiplier);

    QLT private immutable QLTContract;

    uint256 public tokenIdCounter;
    uint64 public harvestStartTime;
    uint64 public unstakeLockupPeriod;

    uint256 public totalStakingAmount;
    address public treasuryAddress;
    mapping(uint256 => StakingInfo) public stakingInfos;
    mapping(bytes32 => StakingPlan) public stakingPlans;

    mapping(address => bool) public authorizedOperators;

    constructor(address _QLTContract)
        ERC721("Staked QLT", "sQLT", "https://staked.quantland.finance/")
    {
        addAuthorizedOperator(msg.sender);
        harvestStartTime = type(uint64).max;
        unstakeLockupPeriod = DEFAULT_UNSTAKE_LOCKUP_PERIOD;

        addStakingPlan("gold", 7 days, (100040 * Q96) / 100000, 1); // APY 3,222 %
        addStakingPlan("platinum", 30 days, (100060 * Q96) / 100000, 3); // APY 19,041 %
        addStakingPlan("diamond", 90 days, (100080 * Q96) / 100000, 5); // APY 110,200 %

        QLTContract = QLT(_QLTContract);
    }

    /* Staking Plan Governance Functions */
    function addStakingPlan(
        bytes32 name,
        uint64 lockupPeriod,
        uint256 rewardRateX96,
        uint64 multiplier
    ) public onlyOwner {
        require(stakingPlans[name].createdAt == 0, "already created");
        StakingPlan storage stakingPlan = stakingPlans[name];
        stakingPlan.name = name;
        stakingPlan.rewardRates.push(
            StakingRewardRate({
                rewardRateX96: rewardRateX96,
                startTime: Time.current_hour_timestamp()
            })
        );
        stakingPlan.multipliers.push(
            StakingPowerMultiplier({
                multiplier: multiplier,
                startTime: Time.block_timestamp()
            })
        );
        stakingPlan.lockupPeriod = lockupPeriod;
        stakingPlan.createdAt = Time.block_timestamp();

        emit StakingPlanCreated(name);
    }

    function deactivateStakingPlan(bytes32 name) public onlyOwner {
        _checkStakingPlanActive(name);

        StakingPlan storage stakingPlan = stakingPlans[name];
        stakingPlan.deactivatedAt = Time.block_timestamp();

        emit StakingPlanDeactivated(name);
    }

    function updateStakingRewardRate(bytes32 name, uint256 rewardRateX96)
        public
        onlyOperator
    {
        _checkStakingPlanActive(name);

        StakingPlan storage stakingPlan = stakingPlans[name];
        stakingPlan.rewardRates.push(
            StakingRewardRate({
                rewardRateX96: rewardRateX96,
                startTime: Time.current_hour_timestamp()
            })
        );

        emit StakingRewardRateUpdated(name, rewardRateX96);
    }

    function updateStakingPowerMultiplier(bytes32 name, uint64 multiplier)
        public
        onlyOperator
    {
        _checkStakingPlanActive(name);

        StakingPlan storage stakingPlan = stakingPlans[name];
        stakingPlan.multipliers.push(
            StakingPowerMultiplier({
                multiplier: multiplier,
                startTime: Time.block_timestamp()
            })
        );

        emit StakingPowerMultiplierUpdated(name, multiplier);
    }

    /* Staking-Related Functions */
    function stake(
        address recipient,
        bytes32 stakingPlan,
        uint256 amount
    ) external returns (uint256 tokenId) {
        require(amount > 0, "amount is 0");
        _checkStakingPlanActive(stakingPlan);

        // transfer QLT
        QLTContract.transferFrom(msg.sender, address(this), amount);

        // mint
        tokenIdCounter += 1;
        tokenId = tokenIdCounter;
        _mint(recipient, tokenId);
        _approve(address(this), tokenId);

        // update staking info
        StakingInfo storage stakingInfo = stakingInfos[tokenId];
        stakingInfo.stakingPlan = stakingPlan;
        stakingInfo.stakedAmount = amount;
        stakingInfo.stakeTime = Time.block_timestamp();
        stakingInfo.lastHarvestTime = Time.current_hour_timestamp();

        // update staking plan info
        stakingPlans[stakingPlan].stakingAmount += amount;
        totalStakingAmount += amount;

        emit Stake(tokenId, recipient, stakingPlan, amount);
    }

    function unstake(uint256 tokenId) external returns (uint256 rewardAmount) {
        _checkOwnershipOfStakingToken(tokenId);

        StakingInfo storage stakingInfo = stakingInfos[tokenId];
        uint64 lockupPeriod = stakingPlans[stakingInfo.stakingPlan]
            .lockupPeriod;
        uint64 stakeTime = stakingInfo.stakeTime;
        uint64 unstakeTime = stakingInfo.unstakeTime;

        if (msg.sender == treasuryAddress) {
            lockupPeriod = 0;
        }

        require(unstakeTime == 0, "already unstaked");
        require(
            Time.block_timestamp() >= (stakeTime + lockupPeriod),
            "still in lockup"
        );

        // harvest first
        rewardAmount = harvestInternal(tokenId);

        // update staking info
        uint256 unstakedAmount = stakingInfo.stakedAmount;
        stakingInfo.unstakeTime = Time.block_timestamp();

        // update staking plan info
        stakingPlans[stakingInfo.stakingPlan].stakingAmount -= unstakedAmount;
        totalStakingAmount -= unstakedAmount;

        emit Unstake(tokenId);
    }

    function redeem(uint256 tokenId) external returns (uint256 redeemedAmount) {
        _checkOwnershipOfStakingToken(tokenId);

        StakingInfo storage stakingInfo = stakingInfos[tokenId];
        uint64 unstakeTime = stakingInfo.unstakeTime;
        uint64 redeemTime = stakingInfo.redeemTime;
        uint64 _unstakeLockupPeriod = unstakeLockupPeriod;

        if (msg.sender == treasuryAddress) {
            _unstakeLockupPeriod = 0;
        }

        // check if can unstake
        require(unstakeTime > 0, "not unstaked");
        require(
            Time.block_timestamp() >= (unstakeTime + _unstakeLockupPeriod),
            "still in lockup"
        );
        require(redeemTime == 0, "already redeemed");

        // recycle and burn staking NFT
        address staker = ownerOf(tokenId);
        transferFrom(msg.sender, address(this), tokenId);
        _burn(tokenId);

        // transfer QLT back to staker
        redeemedAmount = stakingInfo.stakedAmount;
        QLTContract.transfer(staker, redeemedAmount);

        // update staking info
        stakingInfo.redeemTime = Time.block_timestamp();

        emit Redeem(tokenId, redeemedAmount);
    }

    function harvest(uint256 tokenId) external returns (uint256 rewardAmount) {
        return harvestInternal(tokenId);
    }

    function harvestAll(uint256[] calldata tokenIds)
        external
        returns (uint256 rewardAmount)
    {
        for (uint256 i = 0; i < tokenIds.length; i++) {
            rewardAmount += harvestInternal(tokenIds[i]);
        }

        emit HarvestAll(tokenIds, rewardAmount);
    }

    function harvestInternal(uint256 tokenId)
        internal
        returns (uint256 rewardAmount)
    {
        require(Time.block_timestamp() >= harvestStartTime, "come back later");
        _checkOwnershipOfStakingToken(tokenId);

        rewardAmount = getRewardsToHarvest(tokenId);

        if (rewardAmount > 0) {
            // mint QLT to recipient
            QLTContract.mint(ownerOf(tokenId), rewardAmount);

            // update staking info
            StakingInfo storage stakingInfo = stakingInfos[tokenId];
            stakingInfo.lastHarvestTime = Time.current_hour_timestamp();
            stakingInfo.accumulatedStakingReward += rewardAmount;

            // update staking plan info
            StakingPlan storage stakingPlan = stakingPlans[
                stakingInfo.stakingPlan
            ];
            stakingPlan.accumulatedStakingReward += rewardAmount;

            emit Harvest(tokenId, rewardAmount);
        }
    }

    /* Staking State View Functions */
    function getRewardsToHarvest(uint256 tokenId)
        public
        view
        returns (uint256 rewardAmount)
    {
        require(tokenId <= tokenIdCounter, "not existent");

        StakingInfo storage stakingInfo = stakingInfos[tokenId];

        if (stakingInfo.unstakeTime > 0) {
            return 0;
        }

        StakingPlan storage stakingPlan = stakingPlans[stakingInfo.stakingPlan];

        // calculate compounded rewards of QLT
        uint256 stakedAmountX96 = stakingInfo.stakedAmount * Q96;
        uint256 compoundedAmountX96 = stakedAmountX96;
        uint64 rewardEndTime = Time.current_hour_timestamp();
        uint64 lastHarvestTime = stakingInfo.lastHarvestTime;

        StakingRewardRate[] storage rewardRates = stakingPlan.rewardRates;
        uint256 i = rewardRates.length;
        while (i > 0) {
            i--;

            uint64 rewardStartTime = rewardRates[i].startTime;
            uint256 rewardRateX96 = rewardRates[i].rewardRateX96;
            uint256 nCompounds;

            if (rewardEndTime < rewardStartTime) {
                continue;
            }

            if (rewardStartTime >= lastHarvestTime) {
                nCompounds = (rewardEndTime - rewardStartTime) / 1 hours;
                compoundedAmountX96 = compoundedAmountX96.mulX96(
                    Math.compound(rewardRateX96, nCompounds)
                );
                rewardEndTime = rewardStartTime;
            } else {
                nCompounds = (rewardEndTime - lastHarvestTime) / 1 hours;
                compoundedAmountX96 = compoundedAmountX96.mulX96(
                    Math.compound(rewardRateX96, nCompounds)
                );
                break;
            }
        }

        rewardAmount = (compoundedAmountX96 - stakedAmountX96) / Q96;
    }

    function getAllRewardsToHarvest(uint256[] calldata tokenIds)
        public
        view
        returns (uint256 rewardAmount)
    {
        for (uint256 i = 0; i < tokenIds.length; i++) {
            rewardAmount += getRewardsToHarvest(tokenIds[i]);
        }
    }

    function getStakingPower(
        uint256 tokenId,
        uint64 startTime,
        uint64 endTime
    ) public view returns (uint256 stakingPower) {
        require(tokenId <= tokenIdCounter, "not existent");

        StakingInfo storage stakingInfo = stakingInfos[tokenId];
        if (stakingInfo.stakeTime >= endTime || stakingInfo.unstakeTime > 0) {
            return 0;
        }
        if (stakingInfo.stakeTime > startTime) {
            startTime = stakingInfo.stakeTime;
        }

        StakingPlan storage stakingPlan = stakingPlans[stakingInfo.stakingPlan];
        uint256 stakedAmount = stakingInfo.stakedAmount;
        StakingPowerMultiplier[] storage multipliers = stakingPlan.multipliers;
        uint256 i = multipliers.length;
        while (i > 0) {
            i--;

            uint64 rewardStartTime = multipliers[i].startTime;
            uint256 multiplier = multipliers[i].multiplier;

            if (rewardStartTime >= endTime) {
                continue;
            }

            if (rewardStartTime >= startTime) {
                stakingPower +=
                    stakedAmount *
                    (endTime - rewardStartTime) *
                    multiplier;
                endTime = rewardStartTime;
            } else {
                stakingPower +=
                    stakedAmount *
                    (endTime - startTime) *
                    multiplier;
                break;
            }
        }
    }

    function getAllStakingPower(
        uint256[] calldata tokenIds,
        uint64 startTime,
        uint64 endTime
    ) public view returns (uint256 stakingPower) {
        for (uint256 i = 0; i < tokenIds.length; i++) {
            stakingPower += getStakingPower(tokenIds[i], startTime, endTime);
        }
    }

    /* Config Setters */
    function setHarvestStartTime(uint64 _harvestStartTime) external onlyOwner {
        harvestStartTime = _harvestStartTime;
    }

    function setUnstakeLockupPeriod(uint64 _unstakeLockupPeriod)
        external
        onlyOwner
    {
        unstakeLockupPeriod = _unstakeLockupPeriod;
    }

    function setTreasuryAddress(address _treasuryAddress) external onlyOwner {
        treasuryAddress = _treasuryAddress;
    }

    /* Helper Functions */
    function _checkOwnershipOfStakingToken(uint256 tokenId) internal view {
        require(ownerOf(tokenId) == msg.sender, "not owner");
    }

    function _checkStakingPlanActive(bytes32 stakingPlan) internal view {
        require(
            stakingPlans[stakingPlan].deactivatedAt == 0,
            "staking plan not active"
        );
    }

    /* Access Control */
    function addAuthorizedOperator(address account) public onlyOwner {
        authorizedOperators[account] = true;
    }

    function removeAuthorizedOperator(address account) external onlyOwner {
        authorizedOperators[account] = false;
    }

    modifier onlyOperator() {
        require(authorizedOperators[msg.sender], "not authorized");
        _;
    }
}


// File contracts/RewardDistributor.sol

address constant USDC_ADDR = address(
    0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
);
StakedQLT constant STAKED_QLT_CONTRACT = StakedQLT(
    0x9D7977891e0d4D3Bc84456DD2838beE6ad484D87
);
uint256 constant MASK = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00;

struct Campaign {
    bytes32 name;
    uint256 totalReward;
    uint256 totalStakingPower;
    uint128 rewardRate;
    uint64 startTime;
    uint64 endTime;
}

contract RewardDistributor is Ownable {
    event NewCampaign(
        uint256 indexed campaignId,
        uint256 indexed createdAt,
        uint256 totalReward,
        uint256 totalStakingPower,
        uint64 startTime,
        uint64 endTime
    );
    event ClaimReward(
        uint256 indexed campaignId,
        uint256 indexed tokenId,
        uint256 indexed timestamp,
        address receiver,
        uint256 rewardAmount
    );

    uint256 public campaignCount;
    uint256 public accumulatedRewards;
    mapping(uint256 => Campaign) public campaigns;
    mapping(uint256 => mapping(uint256 => uint256)) public claimed;
    bool public rewardClaimEnabled;

    constructor() {}

    function addCampaign(
        bytes32 name,
        uint256 totalReward,
        uint256 totalStakingPower,
        uint64 startTime,
        uint64 endTime
    ) external onlyOwner {
        campaignCount++;
        accumulatedRewards += totalReward;

        campaigns[campaignCount] = Campaign({
            name: name,
            totalReward: totalReward,
            totalStakingPower: totalStakingPower,
            rewardRate: uint128(totalStakingPower / totalReward),
            startTime: startTime,
            endTime: endTime
        });

        emit NewCampaign(
            campaignCount,
            block.timestamp,
            totalReward,
            totalStakingPower,
            startTime,
            endTime
        );
    }

    function setRewardClaimEnabled(bool _rewardClaimEnabled) external onlyOwner {
        rewardClaimEnabled = _rewardClaimEnabled;
    }

    function claimAllRewards(
        uint256[] calldata campaignIds,
        uint256[] calldata tokenIds
    ) external {
        require(rewardClaimEnabled, "come back later");

        uint256 totalRewardAmount = 0;

        for (uint256 j = 0; j < tokenIds.length; j++) {
            require(
                STAKED_QLT_CONTRACT.ownerOf(tokenIds[j]) == msg.sender,
                "not owner"
            );
        }

        for (uint256 i = 0; i < campaignIds.length; i++) {
            uint256 campaignId = campaignIds[i];
            Campaign storage campaign = campaigns[campaignId];
            uint128 rewardRate = campaign.rewardRate;
            uint64 startTime = campaign.startTime;
            uint64 endTime = campaign.endTime;
            for (uint256 j = 0; j < tokenIds.length; j++) {
                uint256 tokenId = tokenIds[j];
                uint256 flag = (1 << (tokenId & 0xff));

                if (claimed[campaignId][tokenId & MASK] & flag > 0) {
                    continue;
                }

                uint256 stakingPower = STAKED_QLT_CONTRACT.getStakingPower(
                    tokenId,
                    startTime,
                    endTime
                );
                uint256 rewardAmount = stakingPower / rewardRate;

                if (rewardAmount > 0) {
                    claimed[campaignId][tokenId & MASK] |= flag;

                    totalRewardAmount += rewardAmount;

                    emit ClaimReward(
                        campaignId,
                        tokenId,
                        block.timestamp,
                        msg.sender,
                        rewardAmount
                    );
                }
            }
        }

        require((totalRewardAmount > 0), "no claimable reward");

        TransferHelper.safeTransfer(USDC_ADDR, msg.sender, totalRewardAmount);
    }

    function getClaimableCampaigns(uint256[] calldata tokenIds)
        public
        view
        returns (bool[] memory campaignIds)
    {
        bool[] memory ids = new bool[](campaignCount);
        for (
            uint256 campaignId = 1;
            campaignId <= campaignCount;
            campaignId++
        ) {
            for (uint256 i = 0; i < tokenIds.length; i++) {
                if (getClaimableRewards(campaignId, tokenIds[i]) > 0) {
                    ids[campaignId - 1] = true;
                    break;
                }
            }
        }
        return ids;
    }

    function getAllClaimableRewards(
        uint256[] calldata campaignIds,
        uint256[] calldata tokenIds
    ) public view returns (uint256 rewardAmount) {
        rewardAmount = 0;

        for (uint256 i = 0; i < campaignIds.length; i++) {
            for (uint256 j = 0; j < tokenIds.length; j++) {
                rewardAmount += getClaimableRewards(
                    campaignIds[i],
                    tokenIds[j]
                );
            }
        }
    }

    function getClaimableRewards(uint256 campaignId, uint256 tokenId)
        public
        view
        returns (uint256 rewardAmount)
    {
        if (claimed[campaignId][tokenId & MASK] & (1 << (tokenId & 0xff)) > 0) {
            return 0;
        }

        Campaign storage campaign = campaigns[campaignId];
        uint256 stakingPower = STAKED_QLT_CONTRACT.getStakingPower(
            tokenId,
            campaign.startTime,
            campaign.endTime
        );
        rewardAmount = stakingPower / campaign.rewardRate;
    }

    function transferToken(
        address token,
        address to,
        uint256 value
    ) external onlyOwner {
        TransferHelper.safeTransfer(token, to, value);
    }

    function call(address target, bytes calldata payload) external onlyOwner {
        (bool success, ) = target.call(payload);
        require(success);
    }
}

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"campaignId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"rewardAmount","type":"uint256"}],"name":"ClaimReward","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"campaignId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"createdAt","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalReward","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalStakingPower","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"startTime","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"endTime","type":"uint64"}],"name":"NewCampaign","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"accumulatedRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"name","type":"bytes32"},{"internalType":"uint256","name":"totalReward","type":"uint256"},{"internalType":"uint256","name":"totalStakingPower","type":"uint256"},{"internalType":"uint64","name":"startTime","type":"uint64"},{"internalType":"uint64","name":"endTime","type":"uint64"}],"name":"addCampaign","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"payload","type":"bytes"}],"name":"call","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"campaignCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"campaigns","outputs":[{"internalType":"bytes32","name":"name","type":"bytes32"},{"internalType":"uint256","name":"totalReward","type":"uint256"},{"internalType":"uint256","name":"totalStakingPower","type":"uint256"},{"internalType":"uint128","name":"rewardRate","type":"uint128"},{"internalType":"uint64","name":"startTime","type":"uint64"},{"internalType":"uint64","name":"endTime","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"campaignIds","type":"uint256[]"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"claimAllRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"claimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"campaignIds","type":"uint256[]"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"getAllClaimableRewards","outputs":[{"internalType":"uint256","name":"rewardAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"getClaimableCampaigns","outputs":[{"internalType":"bool[]","name":"campaignIds","type":"bool[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"campaignId","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getClaimableRewards","outputs":[{"internalType":"uint256","name":"rewardAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardClaimEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"_rewardClaimEnabled","type":"bool"}],"name":"setRewardClaimEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferToken","outputs":[],"stateMutability":"nonpayable","type":"function"}]

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101005760003560e01c80639c81ff6b11610097578063dabaed0411610066578063dabaed04146102a3578063e9915f08146102b6578063f2fde38b146102c9578063f5537ede146102dc57600080fd5b80639c81ff6b1461023c578063a54ab45714610245578063cbbbdf2b14610270578063cd2d2d0c1461029057600080fd5b80637274e30d116100d35780637274e30d146101da5780637e5fee51146101f15780638da5cb5b1461020e5780639605f5d21461022957600080fd5b8063141961bc146101055780631b8b921d146101aa5780631f1aea42146101bf578063715018a6146101d2575b600080fd5b610162610113366004611107565b60036020819052600091825260409091208054600182015460028301549290930154909291906001600160801b0381169067ffffffffffffffff600160801b8204811691600160c01b90041686565b604080519687526020870195909552938501929092526001600160801b0316606084015267ffffffffffffffff90811660808401521660a082015260c0015b60405180910390f35b6101bd6101b8366004610f4a565b6102ef565b005b6101bd6101cd366004611011565b6103a3565b6101bd61077a565b6101e360015481565b6040519081526020016101a1565b6005546101fe9060ff1681565b60405190151581526020016101a1565b6000546040516001600160a01b0390911681526020016101a1565b6101e3610237366004611011565b6107bf565b6101e360025481565b6101e3610253366004611139565b600460209081526000928352604080842090915290825290205481565b61028361027e366004610fcf565b61084a565b6040516101a191906111a6565b6101bd61029e36600461107d565b61092b565b6101bd6102b13660046110b7565b610977565b6101e36102c4366004611139565b610af9565b6101bd6102d7366004610ec8565b610c11565b6101bd6102ea366004610f09565b610cbb565b336103026000546001600160a01b031690565b6001600160a01b0316146103315760405162461bcd60e51b8152600401610328906111ec565b60405180910390fd5b6000836001600160a01b0316838360405161034d92919061115b565b6000604051808303816000865af19150503d806000811461038a576040519150601f19603f3d011682016040523d82523d6000602084013e61038f565b606091505b505090508061039d57600080fd5b50505050565b60055460ff166103e75760405162461bcd60e51b815260206004820152600f60248201526e31b7b6b2903130b1b5903630ba32b960891b6044820152606401610328565b6000805b828110156104e95733739d7977891e0d4d3bc84456dd2838bee6ad484d87636352211e868685818110610420576104206112a3565b905060200201356040518263ffffffff1660e01b815260040161044591815260200190565b60206040518083038186803b15801561045d57600080fd5b505afa158015610471573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104959190610eec565b6001600160a01b0316146104d75760405162461bcd60e51b81526020600482015260096024820152683737ba1037bbb732b960b91b6044820152606401610328565b806104e181611272565b9150506103eb565b5060005b8481101561070d576000868683818110610509576105096112a3565b60209081029290920135600081815260039384905260408120938401549194506001600160801b038216925067ffffffffffffffff600160801b8304811692600160c01b900416905b888110156106f45760008a8a8381811061056e5761056e6112a3565b60008a8152600460209081526040808320938202959095013560ff1981168352929052929092205491925050600160ff83161b908116156105b05750506106e2565b604051632cec461760e11b81526004810183905267ffffffffffffffff808716602483015285166044820152600090739d7977891e0d4d3bc84456dd2838bee6ad484d87906359d88c2e9060640160206040518083038186803b15801561061657600080fd5b505afa15801561062a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061064e9190611120565b905060006106656001600160801b03891683611239565b905080156106dd5760008a815260046020908152604080832060ff1988168452909152902080548417905561069a818d611221565b6040805133815260208101849052919d50429186918d917f0baa5357a7c639d804d0800b155e7b9ac7f427fec319f137da0fd74479ecce16910160405180910390a45b505050505b806106ec81611272565b915050610552565b505050505050808061070590611272565b9150506104ed565b50600081116107545760405162461bcd60e51b81526020600482015260136024820152721b9bc818db185a5b58589b19481c995dd85c99606a1b6044820152606401610328565b61077373a0b86991c6218b36c1d19d4a2e9eb0ce3606eb483383610d04565b5050505050565b3361078d6000546001600160a01b031690565b6001600160a01b0316146107b35760405162461bcd60e51b8152600401610328906111ec565b6107bd6000610e0f565b565b6000805b848110156108415760005b8381101561082e576108108787848181106107eb576107eb6112a3565b90506020020135868684818110610804576108046112a3565b90506020020135610af9565b61081a9084611221565b92508061082681611272565b9150506107ce565b508061083981611272565b9150506107c3565b50949350505050565b6060600060015467ffffffffffffffff811115610869576108696112b9565b604051908082528060200260200182016040528015610892578160200160208202803683370190505b50905060015b60015481116109215760005b8481101561090e5760006108c483888885818110610804576108046112a3565b11156108fc576001836108d7828561125b565b815181106108e7576108e76112a3565b9115156020928302919091019091015261090e565b8061090681611272565b9150506108a4565b508061091981611272565b915050610898565b5090505b92915050565b3361093e6000546001600160a01b031690565b6001600160a01b0316146109645760405162461bcd60e51b8152600401610328906111ec565b6005805460ff1916911515919091179055565b3361098a6000546001600160a01b031690565b6001600160a01b0316146109b05760405162461bcd60e51b8152600401610328906111ec565b600180549060006109c083611272565b919050555083600260008282546109d79190611221565b90915550506040805160c0810182528681526020810186905290810184905260608101610a048686611239565b6001600160801b03908116825267ffffffffffffffff858116602080850182905286831660409586018190526001805460009081526003808552908890208951815589850151818401558989015160028201556060808b01519190920180546080808d015160a0909d015193909a166001600160c01b031990911617600160801b9b89169b909b029a909a176001600160c01b0316600160c01b919097160295909517909755955485518b81529182018a9052948101919091529081019390935242927fc71ae009934a69f1f2b93ae06d680ce14dc44cc28794a3838b02470380218360910160405180910390a35050505050565b600082815260046020908152604080832060ff1985168452909152812054600160ff84161b1615610b2c57506000610925565b6000838152600360208190526040808320918201549051632cec461760e11b81526004810186905267ffffffffffffffff600160801b830481166024830152600160c01b9092049091166044820152909190739d7977891e0d4d3bc84456dd2838bee6ad484d87906359d88c2e9060640160206040518083038186803b158015610bb557600080fd5b505afa158015610bc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bed9190611120565b6003830154909150610c08906001600160801b031682611239565b95945050505050565b33610c246000546001600160a01b031690565b6001600160a01b031614610c4a5760405162461bcd60e51b8152600401610328906111ec565b6001600160a01b038116610caf5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610328565b610cb881610e0f565b50565b33610cce6000546001600160a01b031690565b6001600160a01b031614610cf45760405162461bcd60e51b8152600401610328906111ec565b610cff838383610d04565b505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b1790529151600092839290871691610d60919061116b565b6000604051808303816000865af19150503d8060008114610d9d576040519150601f19603f3d011682016040523d82523d6000602084013e610da2565b606091505b5091509150818015610dcc575080511580610dcc575080806020019051810190610dcc919061109a565b6107735760405162461bcd60e51b81526020600482015260146024820152731cd85999481d1c985b9cd9995c8819985a5b195960621b6044820152606401610328565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008083601f840112610e7157600080fd5b50813567ffffffffffffffff811115610e8957600080fd5b6020830191508360208260051b8501011115610ea457600080fd5b9250929050565b803567ffffffffffffffff81168114610ec357600080fd5b919050565b600060208284031215610eda57600080fd5b8135610ee5816112cf565b9392505050565b600060208284031215610efe57600080fd5b8151610ee5816112cf565b600080600060608486031215610f1e57600080fd5b8335610f29816112cf565b92506020840135610f39816112cf565b929592945050506040919091013590565b600080600060408486031215610f5f57600080fd5b8335610f6a816112cf565b9250602084013567ffffffffffffffff80821115610f8757600080fd5b818601915086601f830112610f9b57600080fd5b813581811115610faa57600080fd5b876020828501011115610fbc57600080fd5b6020830194508093505050509250925092565b60008060208385031215610fe257600080fd5b823567ffffffffffffffff811115610ff957600080fd5b61100585828601610e5f565b90969095509350505050565b6000806000806040858703121561102757600080fd5b843567ffffffffffffffff8082111561103f57600080fd5b61104b88838901610e5f565b9096509450602087013591508082111561106457600080fd5b5061107187828801610e5f565b95989497509550505050565b60006020828403121561108f57600080fd5b8135610ee5816112e4565b6000602082840312156110ac57600080fd5b8151610ee5816112e4565b600080600080600060a086880312156110cf57600080fd5b8535945060208601359350604086013592506110ed60608701610eab565b91506110fb60808701610eab565b90509295509295909350565b60006020828403121561111957600080fd5b5035919050565b60006020828403121561113257600080fd5b5051919050565b6000806040838503121561114c57600080fd5b50508035926020909101359150565b8183823760009101908152919050565b6000825160005b8181101561118c5760208186018101518583015201611172565b8181111561119b576000828501525b509190910192915050565b6020808252825182820181905260009190848201906040850190845b818110156111e05783511515835292840192918401916001016111c2565b50909695505050505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600082198211156112345761123461128d565b500190565b60008261125657634e487b7160e01b600052601260045260246000fd5b500490565b60008282101561126d5761126d61128d565b500390565b60006000198214156112865761128661128d565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610cb857600080fd5b8015158114610cb857600080fdfea264697066735822122021e636f54da20693e22b08f7621069f45e8d7b90edb10b9216a2d6d7d23eb46464736f6c63430008070033

Deployed Bytecode Sourcemap

76393:5620:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;76933:45;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;76933:45:0;;;;-1:-1:-1;;;76933:45:0;;;;;-1:-1:-1;;;76933:45:0;;;;;;;;;7388:25:1;;;7444:2;7429:18;;7422:34;;;;7472:18;;;7465:34;;;;-1:-1:-1;;;;;7535:47:1;7530:2;7515:18;;7508:75;7602:18;7657:15;;;7651:3;7636:19;;7629:44;7710:15;7704:3;7689:19;;7682:44;7375:3;7360:19;76933:45:0;;;;;;;;81852:158;;;;;;:::i;:::-;;:::i;:::-;;78045:1929;;;;;;:::i;:::-;;:::i;3565:103::-;;;:::i;76858:28::-;;;;;;;;;10029:25:1;;;10017:2;10002:18;76858:28:0;9883:177:1;77054:30:0;;;;;;;;;;;;7078:14:1;;7071:22;7053:41;;7041:2;7026:18;77054:30:0;6913:187:1;2916:87:0;2962:7;2989:6;2916:87;;-1:-1:-1;;;;;2989:6:0;;;5925:51:1;;5913:2;5898:18;2916:87:0;5779:203:1;80604:489:0;;;;;;:::i;:::-;;:::i;76893:33::-;;;;;;76985:62;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;79982:614;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;77902:135::-;;;;;;:::i;:::-;;:::i;77117:777::-;;;;;;:::i;:::-;;:::i;81101:553::-;;;;;;:::i;:::-;;:::i;3823:238::-;;;;;;:::i;:::-;;:::i;81662:182::-;;;;;;:::i;:::-;;:::i;81852:158::-;3147:10;3136:7;2962;2989:6;-1:-1:-1;;;;;2989:6:0;;2916:87;3136:7;-1:-1:-1;;;;;3136:21:0;;3128:66;;;;-1:-1:-1;;;3128:66:0;;;;;;;:::i;:::-;;;;;;;;;81937:12:::1;81955:6;-1:-1:-1::0;;;;;81955:11:0::1;81967:7;;81955:20;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;81936:39;;;81994:7;81986:16;;;::::0;::::1;;81925:85;81852:158:::0;;;:::o;78045:1929::-;78184:18;;;;78176:46;;;;-1:-1:-1;;;78176:46:0;;9404:2:1;78176:46:0;;;9386:21:1;9443:2;9423:18;;;9416:30;-1:-1:-1;;;9462:18:1;;;9455:45;9517:18;;78176:46:0;9202:339:1;78176:46:0;78235:25;78282:9;78277:198;78297:19;;;78277:198;;;78408:10;76080:42;78364:27;78392:8;;78401:1;78392:11;;;;;;;:::i;:::-;;;;;;;78364:40;;;;;;;;;;;;;10029:25:1;;10017:2;10002:18;;9883:177;78364:40:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;-1:-1:-1;;;;;78364:54:0;;78338:125;;;;-1:-1:-1;;;78338:125:0;;9748:2:1;78338:125:0;;;9730:21:1;9787:1;9767:18;;;9760:29;-1:-1:-1;;;9805:18:1;;;9798:39;9854:18;;78338:125:0;9546:332:1;78338:125:0;78318:3;;;;:::i;:::-;;;;78277:198;;;;78492:9;78487:1330;78507:22;;;78487:1330;;;78551:18;78572:11;;78584:1;78572:14;;;;;;;:::i;:::-;;;;;;;;;;78601:25;78629:21;;;:9;:21;;;;;;;78686:19;;;;78572:14;;-1:-1:-1;;;;;;78686:19:0;;;-1:-1:-1;78739:18:0;-1:-1:-1;;;78739:18:0;;;;;-1:-1:-1;;;78789:16:0;;;;78820:986;78840:19;;;78820:986;;;78885:15;78903:8;;78912:1;78903:11;;;;;;;:::i;:::-;78933:12;78996:19;;;:7;78903:11;78996:19;;;;;;;78903:11;;;;;;;;-1:-1:-1;;79016:14:0;;78996:35;;;;;;;;;;78903:11;;-1:-1:-1;;78949:1:0;78965:4;78955:14;;78949:21;;78996:42;;:46;78992:103;;79067:8;;;;78992:103;79138:146;;-1:-1:-1;;;79138:146:0;;;;;10710:25:1;;;10754:18;10808:15;;;10788:18;;;10781:43;10860:15;;10840:18;;;10833:43;79115:20:0;;76080:42;;79138:35;;10683:18:1;;79138:146:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;79115:169;-1:-1:-1;79303:20:0;79326:25;-1:-1:-1;;;;;79326:25:0;;79115:169;79326:25;:::i;:::-;79303:48;-1:-1:-1;79376:16:0;;79372:419;;79417:19;;;;:7;:19;;;;;;;;-1:-1:-1;;79437:14:0;;79417:35;;;;;;;:43;;;;;;79485:33;79506:12;79485:33;;:::i;:::-;79548:223;;;79699:10;6161:51:1;;6243:2;6228:18;;6221:34;;;79485:33:0;;-1:-1:-1;79657:15:0;;79623:7;;79586:10;;79548:223;;6134:18:1;79548:223:0;;;;;;;79372:419;78866:940;;;;78820:986;78861:3;;;;:::i;:::-;;;;78820:986;;;;78536:1281;;;;;78531:3;;;;;:::i;:::-;;;;78487:1330;;;;79858:1;79838:17;:21;79829:55;;;;-1:-1:-1;;;79829:55:0;;9056:2:1;79829:55:0;;;9038:21:1;9095:2;9075:18;;;9068:30;-1:-1:-1;;;9114:18:1;;;9107:49;9173:18;;79829:55:0;8854:343:1;79829:55:0;79897:69;75975:42;79936:10;79948:17;79897:27;:69::i;:::-;78165:1809;78045:1929;;;;:::o;3565:103::-;3147:10;3136:7;2962;2989:6;-1:-1:-1;;;;;2989:6:0;;2916:87;3136:7;-1:-1:-1;;;;;3136:21:0;;3128:66;;;;-1:-1:-1;;;3128:66:0;;;;;;;:::i;:::-;3630:30:::1;3657:1;3630:18;:30::i;:::-;3565:103::o:0;80604:489::-;80743:20;80810:9;80805:281;80825:22;;;80805:281;;;80874:9;80869:206;80889:19;;;80869:206;;;80950:109;80992:11;;81004:1;80992:14;;;;;;;:::i;:::-;;;;;;;81029:8;;81038:1;81029:11;;;;;;;:::i;:::-;;;;;;;80950:19;:109::i;:::-;80934:125;;;;:::i;:::-;;-1:-1:-1;80910:3:0;;;;:::i;:::-;;;;80869:206;;;-1:-1:-1;80849:3:0;;;;:::i;:::-;;;;80805:281;;;;80604:489;;;;;;:::o;79982:614::-;80090:25;80133:17;80164:13;;80153:25;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;80153:25:0;-1:-1:-1;80133:45:0;-1:-1:-1;80229:1:0;80189:379;80259:13;;80245:10;:27;80189:379;;80331:9;80326:231;80346:19;;;80326:231;;;80442:1;80395:44;80415:10;80427:8;;80436:1;80427:11;;;;;;;:::i;80395:44::-;:48;80391:151;;;80490:4;80468:3;80472:14;80490:4;80472:10;:14;:::i;:::-;80468:19;;;;;;;;:::i;:::-;:26;;;:19;;;;;;;;;;;:26;80517:5;;80391:151;80367:3;;;;:::i;:::-;;;;80326:231;;;-1:-1:-1;80287:12:0;;;;:::i;:::-;;;;80189:379;;;-1:-1:-1;80585:3:0;-1:-1:-1;79982:614:0;;;;;:::o;77902:135::-;3147:10;3136:7;2962;2989:6;-1:-1:-1;;;;;2989:6:0;;2916:87;3136:7;-1:-1:-1;;;;;3136:21:0;;3128:66;;;;-1:-1:-1;;;3128:66:0;;;;;;;:::i;:::-;77989:18:::1;:40:::0;;-1:-1:-1;;77989:40:0::1;::::0;::::1;;::::0;;;::::1;::::0;;77902:135::o;77117:777::-;3147:10;3136:7;2962;2989:6;-1:-1:-1;;;;;2989:6:0;;2916:87;3136:7;-1:-1:-1;;;;;3136:21:0;;3128:66;;;;-1:-1:-1;;;3128:66:0;;;;;;;:::i;:::-;77316:13:::1;:15:::0;;;:13:::1;:15;::::0;::::1;:::i;:::-;;;;;;77364:11;77342:18;;:33;;;;;;;:::i;:::-;::::0;;;-1:-1:-1;;77415:269:0::1;::::0;;::::1;::::0;::::1;::::0;;;;;::::1;::::0;::::1;::::0;;;;;;;;;;;;77574:31:::1;77477:11:::0;77522:17;77574:31:::1;:::i;:::-;-1:-1:-1::0;;;;;77415:269:0;;::::1;::::0;;::::1;::::0;;::::1;;::::0;;::::1;::::0;;;;;::::1;::::0;;;;;;;77398:13:::1;::::0;;-1:-1:-1;77388:24:0;;;:9:::1;:24:::0;;;;;;;:296;;;;;;::::1;::::0;;;::::1;::::0;;;::::1;::::0;::::1;::::0;::::1;::::0;::::1;::::0;;::::1;::::0;;;;::::1;::::0;;::::1;::::0;;::::1;::::0;::::1;::::0;;::::1;::::0;;;;::::1;-1:-1:-1::0;;;;;;77388:296:0;;;;-1:-1:-1;;;77388:296:0;;::::1;::::0;;;::::1;::::0;;;::::1;-1:-1:-1::0;;;;;77388:296:0::1;-1:-1:-1::0;;;77388:296:0;;;::::1;;::::0;;;::::1;::::0;;;77728:13;;77702:184;;10292:25:1;;;10333:18;;;10326:34;;;10413:18;;;10406:43;;;;10465:18;;;10458:43;;;;77756:15:0::1;::::0;77702:184:::1;::::0;10264:19:1;77702:184:0::1;;;;;;;77117:777:::0;;;;;:::o;81101:553::-;81215:20;81257:19;;;:7;:19;;;;;;;;-1:-1:-1;;81277:14:0;;81257:35;;;;;;;;81296:1;81312:4;81302:14;;81296:21;81257:61;:65;81253:106;;-1:-1:-1;81346:1:0;81339:8;;81253:106;81371:25;81399:21;;;:9;:21;;;;;;;;81526:18;;;;81454:132;;-1:-1:-1;;;81454:132:0;;;;;10710:25:1;;;81526:18:0;-1:-1:-1;;;81526:18:0;;;;10788::1;;;10781:43;-1:-1:-1;;;81559:16:0;;;;;;10840:18:1;;;10833:43;81399:21:0;;81371:25;76080:42;;81454:35;;10683:18:1;;81454:132:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;81627:19;;;;81431:155;;-1:-1:-1;81612:34:0;;-1:-1:-1;;;;;81627:19:0;81431:155;81612:34;:::i;:::-;81597:49;81101:553;-1:-1:-1;;;;;81101:553:0:o;3823:238::-;3147:10;3136:7;2962;2989:6;-1:-1:-1;;;;;2989:6:0;;2916:87;3136:7;-1:-1:-1;;;;;3136:21:0;;3128:66;;;;-1:-1:-1;;;3128:66:0;;;;;;;:::i;:::-;-1:-1:-1;;;;;3926:22:0;::::1;3904:110;;;::::0;-1:-1:-1;;;3904:110:0;;7939:2:1;3904:110:0::1;::::0;::::1;7921:21:1::0;7978:2;7958:18;;;7951:30;8017:34;7997:18;;;7990:62;-1:-1:-1;;;8068:18:1;;;8061:36;8114:19;;3904:110:0::1;7737:402:1::0;3904:110:0::1;4025:28;4044:8;4025:18;:28::i;:::-;3823:238:::0;:::o;81662:182::-;3147:10;3136:7;2962;2989:6;-1:-1:-1;;;;;2989:6:0;;2916:87;3136:7;-1:-1:-1;;;;;3136:21:0;;3128:66;;;;-1:-1:-1;;;3128:66:0;;;;;;;:::i;:::-;81791:45:::1;81819:5;81826:2;81830:5;81791:27;:45::i;:::-;81662:182:::0;;;:::o;782:448::-;1028:45;;;-1:-1:-1;;;;;6179:32:1;;;1028:45:0;;;6161:51:1;6228:18;;;;6221:34;;;1028:45:0;;;;;;;;;;6134:18:1;;;;1028:45:0;;;;;;;-1:-1:-1;;;;;1028:45:0;-1:-1:-1;;;1028:45:0;;;1003:81;;-1:-1:-1;;;;1003:10:0;;;;:81;;1028:45;1003:81;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;967:117;;;;1117:7;:57;;;;-1:-1:-1;1129:11:0;;:16;;:44;;;1160:4;1149:24;;;;;;;;;;;;:::i;:::-;1095:127;;;;-1:-1:-1;;;1095:127:0;;8346:2:1;1095:127:0;;;8328:21:1;8385:2;8365:18;;;8358:30;-1:-1:-1;;;8404:18:1;;;8397:50;8464:18;;1095:127:0;8144:344:1;4221:191:0;4295:16;4314:6;;-1:-1:-1;;;;;4331:17:0;;;-1:-1:-1;;;;;;4331:17:0;;;;;;4364:40;;4314:6;;;;;;;4364:40;;4295:16;4364:40;4284:128;4221:191;:::o;14:367:1:-;77:8;87:6;141:3;134:4;126:6;122:17;118:27;108:55;;159:1;156;149:12;108:55;-1:-1:-1;182:20:1;;225:18;214:30;;211:50;;;257:1;254;247:12;211:50;294:4;286:6;282:17;270:29;;354:3;347:4;337:6;334:1;330:14;322:6;318:27;314:38;311:47;308:67;;;371:1;368;361:12;308:67;14:367;;;;;:::o;386:171::-;453:20;;513:18;502:30;;492:41;;482:69;;547:1;544;537:12;482:69;386:171;;;:::o;562:247::-;621:6;674:2;662:9;653:7;649:23;645:32;642:52;;;690:1;687;680:12;642:52;729:9;716:23;748:31;773:5;748:31;:::i;:::-;798:5;562:247;-1:-1:-1;;;562:247:1:o;814:251::-;884:6;937:2;925:9;916:7;912:23;908:32;905:52;;;953:1;950;943:12;905:52;985:9;979:16;1004:31;1029:5;1004:31;:::i;1070:456::-;1147:6;1155;1163;1216:2;1204:9;1195:7;1191:23;1187:32;1184:52;;;1232:1;1229;1222:12;1184:52;1271:9;1258:23;1290:31;1315:5;1290:31;:::i;:::-;1340:5;-1:-1:-1;1397:2:1;1382:18;;1369:32;1410:33;1369:32;1410:33;:::i;:::-;1070:456;;1462:7;;-1:-1:-1;;;1516:2:1;1501:18;;;;1488:32;;1070:456::o;1531:726::-;1610:6;1618;1626;1679:2;1667:9;1658:7;1654:23;1650:32;1647:52;;;1695:1;1692;1685:12;1647:52;1734:9;1721:23;1753:31;1778:5;1753:31;:::i;:::-;1803:5;-1:-1:-1;1859:2:1;1844:18;;1831:32;1882:18;1912:14;;;1909:34;;;1939:1;1936;1929:12;1909:34;1977:6;1966:9;1962:22;1952:32;;2022:7;2015:4;2011:2;2007:13;2003:27;1993:55;;2044:1;2041;2034:12;1993:55;2084:2;2071:16;2110:2;2102:6;2099:14;2096:34;;;2126:1;2123;2116:12;2096:34;2171:7;2166:2;2157:6;2153:2;2149:15;2145:24;2142:37;2139:57;;;2192:1;2189;2182:12;2139:57;2223:2;2219;2215:11;2205:21;;2245:6;2235:16;;;;;1531:726;;;;;:::o;2262:437::-;2348:6;2356;2409:2;2397:9;2388:7;2384:23;2380:32;2377:52;;;2425:1;2422;2415:12;2377:52;2465:9;2452:23;2498:18;2490:6;2487:30;2484:50;;;2530:1;2527;2520:12;2484:50;2569:70;2631:7;2622:6;2611:9;2607:22;2569:70;:::i;:::-;2658:8;;2543:96;;-1:-1:-1;2262:437:1;-1:-1:-1;;;;2262:437:1:o;2704:773::-;2826:6;2834;2842;2850;2903:2;2891:9;2882:7;2878:23;2874:32;2871:52;;;2919:1;2916;2909:12;2871:52;2959:9;2946:23;2988:18;3029:2;3021:6;3018:14;3015:34;;;3045:1;3042;3035:12;3015:34;3084:70;3146:7;3137:6;3126:9;3122:22;3084:70;:::i;:::-;3173:8;;-1:-1:-1;3058:96:1;-1:-1:-1;3261:2:1;3246:18;;3233:32;;-1:-1:-1;3277:16:1;;;3274:36;;;3306:1;3303;3296:12;3274:36;;3345:72;3409:7;3398:8;3387:9;3383:24;3345:72;:::i;:::-;2704:773;;;;-1:-1:-1;3436:8:1;-1:-1:-1;;;;2704:773:1:o;3482:241::-;3538:6;3591:2;3579:9;3570:7;3566:23;3562:32;3559:52;;;3607:1;3604;3597:12;3559:52;3646:9;3633:23;3665:28;3687:5;3665:28;:::i;3728:245::-;3795:6;3848:2;3836:9;3827:7;3823:23;3819:32;3816:52;;;3864:1;3861;3854:12;3816:52;3896:9;3890:16;3915:28;3937:5;3915:28;:::i;3978:462::-;4071:6;4079;4087;4095;4103;4156:3;4144:9;4135:7;4131:23;4127:33;4124:53;;;4173:1;4170;4163:12;4124:53;4209:9;4196:23;4186:33;;4266:2;4255:9;4251:18;4238:32;4228:42;;4317:2;4306:9;4302:18;4289:32;4279:42;;4340:37;4373:2;4362:9;4358:18;4340:37;:::i;:::-;4330:47;;4396:38;4429:3;4418:9;4414:19;4396:38;:::i;:::-;4386:48;;3978:462;;;;;;;;:::o;4445:180::-;4504:6;4557:2;4545:9;4536:7;4532:23;4528:32;4525:52;;;4573:1;4570;4563:12;4525:52;-1:-1:-1;4596:23:1;;4445:180;-1:-1:-1;4445:180:1:o;4630:184::-;4700:6;4753:2;4741:9;4732:7;4728:23;4724:32;4721:52;;;4769:1;4766;4759:12;4721:52;-1:-1:-1;4792:16:1;;4630:184;-1:-1:-1;4630:184:1:o;4819:248::-;4887:6;4895;4948:2;4936:9;4927:7;4923:23;4919:32;4916:52;;;4964:1;4961;4954:12;4916:52;-1:-1:-1;;4987:23:1;;;5057:2;5042:18;;;5029:32;;-1:-1:-1;4819:248:1:o;5072:271::-;5255:6;5247;5242:3;5229:33;5211:3;5281:16;;5306:13;;;5281:16;5072:271;-1:-1:-1;5072:271:1:o;5348:426::-;5477:3;5515:6;5509:13;5540:1;5550:129;5564:6;5561:1;5558:13;5550:129;;;5662:4;5646:14;;;5642:25;;5636:32;5623:11;;;5616:53;5579:12;5550:129;;;5697:6;5694:1;5691:13;5688:48;;;5732:1;5723:6;5718:3;5714:16;5707:27;5688:48;-1:-1:-1;5752:16:1;;;;;5348:426;-1:-1:-1;;5348:426:1:o;6266:642::-;6431:2;6483:21;;;6553:13;;6456:18;;;6575:22;;;6402:4;;6431:2;6654:15;;;;6628:2;6613:18;;;6402:4;6697:185;6711:6;6708:1;6705:13;6697:185;;;6786:13;;6779:21;6772:29;6760:42;;6857:15;;;;6822:12;;;;6733:1;6726:9;6697:185;;;-1:-1:-1;6899:3:1;;6266:642;-1:-1:-1;;;;;;6266:642:1:o;8493:356::-;8695:2;8677:21;;;8714:18;;;8707:30;8773:34;8768:2;8753:18;;8746:62;8840:2;8825:18;;8493:356::o;10887:128::-;10927:3;10958:1;10954:6;10951:1;10948:13;10945:39;;;10964:18;;:::i;:::-;-1:-1:-1;11000:9:1;;10887:128::o;11020:217::-;11060:1;11086;11076:132;;11130:10;11125:3;11121:20;11118:1;11111:31;11165:4;11162:1;11155:15;11193:4;11190:1;11183:15;11076:132;-1:-1:-1;11222:9:1;;11020:217::o;11242:125::-;11282:4;11310:1;11307;11304:8;11301:34;;;11315:18;;:::i;:::-;-1:-1:-1;11352:9:1;;11242:125::o;11372:135::-;11411:3;-1:-1:-1;;11432:17:1;;11429:43;;;11452:18;;:::i;:::-;-1:-1:-1;11499:1:1;11488:13;;11372:135::o;11512:127::-;11573:10;11568:3;11564:20;11561:1;11554:31;11604:4;11601:1;11594:15;11628:4;11625:1;11618:15;11644:127;11705:10;11700:3;11696:20;11693:1;11686:31;11736:4;11733:1;11726:15;11760:4;11757:1;11750:15;11776:127;11837:10;11832:3;11828:20;11825:1;11818:31;11868:4;11865:1;11858:15;11892:4;11889:1;11882:15;11908:131;-1:-1:-1;;;;;11983:31:1;;11973:42;;11963:70;;12029:1;12026;12019:12;12044:118;12130:5;12123:13;12116:21;12109:5;12106:32;12096:60;;12152:1;12149;12142:12

Swarm Source

ipfs://21e636f54da20693e22b08f7621069f45e8d7b90edb10b9216a2d6d7d23eb464

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.