Address Details
contract

0x900c48184022c5f9Dc9D1aB2202811Ee81bf1C24

Contract Name
Collectionstaker
Creator
0x8626f6–9c1199 at 0x14e68b–f9ef5c
Balance
0 CELO ( )
Locked CELO Balance
0.00 CELO
Voting CELO Balance
0.00 CELO
Pending Unlocked Gold
0.00 CELO
Tokens
Fetching tokens...
Transactions
41 Transactions
Transfers
0 Transfers
Gas Used
84,237,869
Last Balance Update
14824845
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
Collectionstaker




Optimization enabled
true
Compiler version
v0.8.17+commit.8df45f5f




Optimization runs
200
EVM Version
london




Verified at
2023-01-31T00:34:28.244716Z

contracts/Collectionstaker.sol

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import "./ICollectionswap.sol";
import "./RewardPoolETH.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

contract Collectionstaker is Ownable {
    using SafeERC20 for IERC20;

    ICollectionswap lpToken;
    uint256 public constant MAX_REWARD_TOKENS = 5;

    /// @notice Event emitted when a liquidity mining incentive has been created
    /// @param poolAddress The Reward pool address
    /// @param rewardTokens The tokens being distributed as a reward
    /// @param rewards The amount of reward tokens to be distributed
    /// @param startTime The time when the incentive program begins
    /// @param endTime The time when rewards stop accruing
    event IncentiveETHCreated(
        address poolAddress,
        IERC20[] rewardTokens,
        uint256[] rewards,
        uint256 startTime,
        uint256 endTime
    );

    constructor(ICollectionswap _lpToken) {
        lpToken = _lpToken;
    }

    function createIncentiveETH(
        IERC721 nft,
        address bondingCurve,
        uint128 delta,
        uint96 fee,
        IERC20[] calldata rewardTokens,
        uint256[] calldata rewards,
        uint256 startTime,
        uint256 endTime
    ) external {
        require(startTime > block.timestamp, "cannot backdate");
        uint256 rewardTokensLength = rewardTokens.length;
        require(rewardTokensLength <= MAX_REWARD_TOKENS, "too many reward tokens");
        require(rewardTokensLength == rewards.length, "unequal lengths");
        uint256[] memory rewardRates = new uint256[](rewardTokensLength);
        for (uint i; i < rewardTokensLength; ) {
            rewardRates[i] = rewards[i] / (endTime - startTime); // guaranteed endTime > startTime
            require(rewardRates[i] != 0, "0 reward rate");
            unchecked {
                ++i;
            }
        }

        RewardPoolETH rewardPool = new RewardPoolETH(
            owner(),
            msg.sender,
            lpToken,
            nft,
            bondingCurve,
            delta,
            fee,
            rewardTokens,
            rewardRates,
            startTime,
            endTime  
        );

        // transfer reward tokens to RewardPool
        for (uint i; i < rewardTokensLength; ) {
            rewardTokens[i].safeTransferFrom(
                msg.sender,
                address(rewardPool),
                rewards[i]
            );
            
            unchecked {
                ++i;
            }
        }

        emit IncentiveETHCreated(address(rewardPool), rewardTokens, rewards, startTime, endTime);
    }
}
        

/_openzeppelin/contracts/access/Ownable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.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 is Context {
    address private _owner;

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

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "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);
    }
}
          

/_openzeppelin/contracts/token/ERC1155/IERC1155.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
        external
        view
        returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}
          

/_openzeppelin/contracts/token/ERC20/IERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

/_openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

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

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}
          

/_openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

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

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

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

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

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

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

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

/_openzeppelin/contracts/token/ERC721/IERC721.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: 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 Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

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

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}
          

/_openzeppelin/contracts/token/ERC721/IERC721Receiver.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}
          

/_openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

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

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

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

/_openzeppelin/contracts/utils/Address.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}
          

/_openzeppelin/contracts/utils/Context.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}
          

/_openzeppelin/contracts/utils/introspection/IERC165.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

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

/_openzeppelin/contracts/utils/math/Math.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. It the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`.
        // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.
        // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.
        // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a
        // good first aproximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1;
        uint256 x = a;
        if (x >> 128 > 0) {
            x >>= 128;
            result <<= 64;
        }
        if (x >> 64 > 0) {
            x >>= 64;
            result <<= 32;
        }
        if (x >> 32 > 0) {
            x >>= 32;
            result <<= 16;
        }
        if (x >> 16 > 0) {
            x >>= 16;
            result <<= 8;
        }
        if (x >> 8 > 0) {
            x >>= 8;
            result <<= 4;
        }
        if (x >> 4 > 0) {
            x >>= 4;
            result <<= 2;
        }
        if (x >> 2 > 0) {
            result <<= 1;
        }

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        uint256 result = sqrt(a);
        if (rounding == Rounding.Up && result * result < a) {
            result += 1;
        }
        return result;
    }
}
          

/contracts/CurveErrorCodes.sol

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

contract CurveErrorCodes {
    enum Error {
        OK, // No error
        INVALID_NUMITEMS, // The numItem value is 0
        SPOT_PRICE_OVERFLOW // The updated spot price doesn't fit into 128 bits
    }
}
          

/contracts/ICollectionswap.sol

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {IERC721Enumerable} from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";

interface ICollectionswap is IERC721, IERC721Enumerable {
    struct LPTokenParams721ETH {
        address nftAddress;
        address bondingCurveAddress;
        address payable poolAddress;
        uint96 fee;
        uint128 delta;
        uint128 initialSpotPrice;
        uint256 initialPoolBalance;
        uint256 initialNFTIDsLength;
    }

    function viewPoolParams(uint256 tokenId)
        external
        view
        returns (LPTokenParams721ETH memory poolParams);

    function validatePoolParamsLte(
        uint256 tokenId,
        address nftAddress,
        address bondingCurveAddress,
        uint96 fee,
        uint128 delta
    )
        external
        view
        returns (bool);

    function validatePoolParamsEq(
        uint256 tokenId,
        address nftAddress,
        address bondingCurveAddress,
        uint96 fee,
        uint128 delta
    )
        external
        view
        returns (bool);
}
          

/contracts/ICurve.sol

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import {CurveErrorCodes} from "./CurveErrorCodes.sol";

interface ICurve {
    /**
        @notice Validates if a delta value is valid for the curve. The criteria for
        validity can be different for each type of curve, for instance ExponentialCurve
        requires delta to be greater than 1.
        @param delta The delta value to be validated
        @return valid True if delta is valid, false otherwise
     */
    function validateDelta(uint128 delta) external pure returns (bool valid);

    /**
        @notice Validates if a new spot price is valid for the curve. Spot price is generally assumed to be the immediate sell price of 1 NFT to the pool, in units of the pool's paired token.
        @param newSpotPrice The new spot price to be set
        @return valid True if the new spot price is valid, false otherwise
     */
    function validateSpotPrice(uint128 newSpotPrice)
        external
        view
        returns (bool valid);

    /**
        @notice Given the current state of the pair and the trade, computes how much the user
        should pay to purchase an NFT from the pair, the new spot price, and other values.
        @param spotPrice The current selling spot price of the pair, in tokens
        @param delta The delta parameter of the pair, what it means depends on the curve
        @param numItems The number of NFTs the user is buying from the pair
        @param feeMultiplier Determines how much fee the LP takes from this trade, 18 decimals
        @param protocolFeeMultiplier Determines how much fee the protocol takes from this trade, 18 decimals
        @return error Any math calculation errors, only Error.OK means the returned values are valid
        @return newSpotPrice The updated selling spot price, in tokens
        @return newDelta The updated delta, used to parameterize the bonding curve
        @return inputValue The amount that the user should pay, in tokens
        @return protocolFee The amount of fee to send to the protocol, in tokens
     */
    function getBuyInfo(
        uint128 spotPrice,
        uint128 delta,
        uint256 numItems,
        uint256 feeMultiplier,
        uint256 protocolFeeMultiplier
    )
        external
        view
        returns (
            CurveErrorCodes.Error error,
            uint128 newSpotPrice,
            uint128 newDelta,
            uint256 inputValue,
            uint256 protocolFee
        );

    /**
        @notice Given the current state of the pair and the trade, computes how much the user
        should receive when selling NFTs to the pair, the new spot price, and other values.
        @param spotPrice The current selling spot price of the pair, in tokens
        @param delta The delta parameter of the pair, what it means depends on the curve
        @param numItems The number of NFTs the user is selling to the pair
        @param feeMultiplier Determines how much fee the LP takes from this trade, 18 decimals
        @param protocolFeeMultiplier Determines how much fee the protocol takes from this trade, 18 decimals
        @return error Any math calculation errors, only Error.OK means the returned values are valid
        @return newSpotPrice The updated selling spot price, in tokens
        @return newDelta The updated delta, used to parameterize the bonding curve
        @return outputValue The amount that the user should receive, in tokens
        @return protocolFee The amount of fee to send to the protocol, in tokens
     */
    function getSellInfo(
        uint128 spotPrice,
        uint128 delta,
        uint256 numItems,
        uint256 feeMultiplier,
        uint256 protocolFeeMultiplier
    )
        external
        view
        returns (
            CurveErrorCodes.Error error,
            uint128 newSpotPrice,
            uint128 newDelta,
            uint256 outputValue,
            uint256 protocolFee
        );
}
          

/contracts/ILSSVMPair.sol

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import {ICurve} from "./ICurve.sol";
import {CurveErrorCodes} from "./CurveErrorCodes.sol";

interface ILSSVMPair {
    enum PoolType {
        TOKEN,
        NFT,
        TRADE
    }

    function bondingCurve() external view returns (ICurve);

    function getAllHeldIds() external view returns (uint256[] memory);

    function delta() external view returns (uint128);

    function fee() external view returns (uint96);

    function nft() external view returns (IERC721);

    function spotPrice() external view returns (uint128);

    function withdrawERC721(IERC721 a, uint256[] calldata nftIds) external;

    function withdrawERC20(IERC20 a, uint256 amount) external;

    function withdrawERC1155(IERC1155 a, uint256[] calldata ids, uint256[] calldata amounts) external;

    function getSellNFTQuote(uint256 numNFTs) external view
    returns (
        CurveErrorCodes.Error error,
        uint256 newSpotPrice,
        uint256 newDelta,
        uint256 outputAmount,
        uint256 protocolFee
    );
}

interface ILSSVMPairETH is ILSSVMPair {
    function withdrawAllETH() external;
}
          

/contracts/RewardPoolETH.sol

// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import "./ICollectionswap.sol";
import "./ILSSVMPair.sol";

contract RewardPoolETH is IERC721Receiver {
    using SafeERC20 for IERC20;

    struct LPTokenInfo {
        uint256 amount0;
        uint256 amount1;
        uint256 amount;
        address owner;
    }

    uint128 private reserve0; // uses single storage slot, accessible via getReserves
    uint128 private reserve1; // uses single storage slot, accessible via getReserves

    address protocolOwner;
    address deployer;
    ICollectionswap public lpToken;
    IERC721 nft;
    address bondingCurve;
    uint128 delta;
    uint96 fee;

    uint256 public constant MAX_REWARD_TOKENS = 5;

    uint256 private _totalSupply;
    mapping(address => uint256) private _balances;
    mapping(uint256 => LPTokenInfo) public lpTokenInfo;

    IERC20[] public rewardTokens;
    mapping(IERC20 => bool) public rewardTokenValid;

    uint256 public periodFinish;
    uint256 public rewardSweepTime;
    mapping(IERC20 => uint256) public rewardRates;
    uint256 public lastUpdateTime;
    mapping(IERC20 => uint256) public rewardPerTokenStored;
    mapping(IERC20 => mapping(address => uint256)) public userRewardPerTokenPaid;
    mapping(IERC20 => mapping(address => uint256)) public rewards;

    event RewardAdded(uint256 reward);
    event Staked(address indexed user, uint256 tokenId, uint256 amount);
    event Withdrawn(address indexed user, uint256 tokenId, uint256 amount);
    event RewardPaid(IERC20 indexed rewardToken, address indexed user, uint256 reward);
    event RewardSwept();
    event RewardPoolRecharged(IERC20[] rewardTokens, uint256[] rewards, uint256 startTime, uint256 endTime);

    modifier updateReward(address account) {
        // skip update after rewards program starts
        // cannot include equality because 
        // multiple accounts can perform actions in the same block
        // and we have to update account's rewards and userRewardPerTokenPaid values
        if (block.timestamp < lastUpdateTime) {
            _;
            return;
        }

        uint256 rewardTokensLength = rewardTokens.length;
        // lastUpdateTime is set to startTime in constructor
        if (block.timestamp > lastUpdateTime) {
            for (uint i; i < rewardTokensLength; ) {
                IERC20 rewardToken = rewardTokens[i];
                rewardPerTokenStored[rewardToken] = rewardPerToken(rewardToken);
                unchecked {
                    ++i;
                }
            }
            lastUpdateTime = lastTimeRewardApplicable();
        }
        if (account != address(0)) {
            for (uint i; i < rewardTokensLength; ) {
                IERC20 rewardToken = rewardTokens[i];
                rewards[rewardToken][account] = earned(account, rewardToken);
                userRewardPerTokenPaid[rewardToken][account] = rewardPerTokenStored[rewardToken];
                unchecked {
                    ++i;
                }
            }
        }
        _;
    }

    constructor(
        address _protocolOwner,
        address _deployer,
        ICollectionswap _lpToken,
        IERC721 _nft,
        address _bondingCurve,
        uint128 _delta,
        uint96 _fee,
        IERC20[] memory _rewardTokens,
        uint256[] memory _rewardRates,
        uint256 _startTime,
        uint256 _periodFinish
    ) {
        protocolOwner = _protocolOwner;
        require(_nft.supportsInterface(0x80ac58cd), "NFT should be ERC721"); // check if it supports ERC721
        deployer = _deployer;
        lpToken = _lpToken;
        nft = _nft;
        bondingCurve = _bondingCurve;
        delta = _delta;
        fee = _fee;
        rewardTokens = _rewardTokens;
        for (uint i; i < rewardTokens.length;) {
            require(!rewardTokenValid[_rewardTokens[i]], "Duplicate reward token");
            rewardRates[_rewardTokens[i]] = _rewardRates[i];
            rewardTokenValid[_rewardTokens[i]] = true;
            unchecked {
                ++i;
            }
        }
        lastUpdateTime = _startTime;
        periodFinish = _periodFinish;
        rewardSweepTime = _periodFinish + 180 days;
    }

    function rechargeRewardPool(        
        IERC20[] memory inputRewardTokens,
        uint256[] memory inputRewardAmounts,
        uint256 _newPeriodFinish
        ) external updateReward(address(0)) {
        
        require(msg.sender == deployer || msg.sender == protocolOwner , "Not authorized");
        require(_newPeriodFinish > block.timestamp, "Invalid period finish");
        require(block.timestamp > periodFinish, "Cannot recharge before period finish");
        require(inputRewardTokens.length == inputRewardAmounts.length, "Inconsistent length");

        uint256 newTokens = 0;
        for (uint i; i < inputRewardTokens.length;) {
            IERC20 inputRewardToken = inputRewardTokens[i];
            if (!rewardTokenValid[inputRewardToken]) {
                newTokens = newTokens + 1;
            }
            for (uint j; j < i;) {
                require(address(inputRewardToken) != address(inputRewardTokens[j]), "Duplicate reward token");
                unchecked {
                    ++j;
                }
            }
            unchecked {
                ++i;
            }
        }
        uint256 rewardTokensLength = rewardTokens.length;
        require(newTokens+rewardTokensLength <= MAX_REWARD_TOKENS, "Too many reward tokens");

        IERC20[MAX_REWARD_TOKENS] memory newRewardTokens;
        for (uint j; j < rewardTokens.length;) {
            IERC20 rewardToken = rewardTokens[j];
            newRewardTokens[j] = rewardToken;
            rewardRates[rewardToken] = 0; // zero out memo-rates
            unchecked {
                ++j;
            }
        }

        for (uint i; i < inputRewardTokens.length;) {
            IERC20 inputRewardToken = inputRewardTokens[i];
            if (inputRewardAmounts[i]>0) {
                inputRewardToken.safeTransferFrom(msg.sender, address(this), inputRewardAmounts[i]);
                if (!rewardTokenValid[inputRewardToken]) {
                    newRewardTokens[rewardTokensLength] = inputRewardToken;
                    rewardTokensLength = rewardTokensLength + 1;
                    rewardTokenValid[inputRewardToken] = true;
                } 
                rewardRates[inputRewardToken] = inputRewardAmounts[i] / (_newPeriodFinish - block.timestamp);
                require(rewardRates[inputRewardToken] != 0, "0 reward rate");
            }
            unchecked {
                ++i;
            }
        }
        // make final array
        IERC20[] memory finalRewardTokens = new IERC20[](rewardTokensLength);
        for (uint k; k < rewardTokensLength;) {
            finalRewardTokens[k] = (newRewardTokens[k]);
            unchecked {
                ++k;
            }
        }
        rewardTokens = finalRewardTokens;

        lastUpdateTime = block.timestamp;
        periodFinish = _newPeriodFinish;
        rewardSweepTime = _newPeriodFinish + 180 days;

        emit RewardPoolRecharged(inputRewardTokens, inputRewardAmounts, block.timestamp, _newPeriodFinish);
    }

    function sweepRewards() external {
        require(msg.sender == deployer, "Not authorized");
        require(block.timestamp >= rewardSweepTime, "Too early");
        emit RewardSwept();
        uint256 rewardTokensLength = rewardTokens.length;
        for (uint i; i < rewardTokensLength; ) {
            IERC20 rewardToken = rewardTokens[i];
            rewardToken.safeTransfer(msg.sender, rewardToken.balanceOf(address(this)));
            unchecked {
                ++i;
            }
        }
    }

    function mint(uint256 tokenId) private returns (uint256 amount) {
        ICollectionswap _lpToken = lpToken;
        require(_lpToken.ownerOf(tokenId) == msg.sender, "Not owner");

        IERC721 _nft = nft;
        require(_lpToken.validatePoolParamsLte(tokenId, address(_nft), bondingCurve, fee, delta), "Wrong pool");

        ICollectionswap.LPTokenParams721ETH memory params = _lpToken
            .viewPoolParams(tokenId);
        ILSSVMPair _pair = ILSSVMPair(params.poolAddress);

        (uint128 _reserve0, uint128 _reserve1) = getReserves(); // gas savings
        uint256 amount0 = _nft.balanceOf(address(_pair));
        uint256 amount1 = address(_pair).balance;
        uint256 indicatorAtLeastOneBid = 1;
        ( , , ,uint256 bidPrice, ) = _pair.getSellNFTQuote(1);
        if (amount1 < bidPrice) {
            indicatorAtLeastOneBid = 0;
        }

        amount = Math.sqrt(amount0 * amount1 * indicatorAtLeastOneBid);

        uint256 balance0 = _reserve0 + amount0;
        uint256 balance1 = _reserve1 + amount1;
        require(
            balance0 <= type(uint128).max && balance1 <= type(uint128).max,
            "Balance overflow"
        );

        reserve0 = uint128(balance0);
        reserve1 = uint128(balance1);
        lpTokenInfo[tokenId] = LPTokenInfo({
            amount0: amount0,
            amount1: amount1,
            amount: amount,
            owner: msg.sender 
        });
    }

    function burn(uint256 tokenId) private returns (uint256 amount) {
        LPTokenInfo memory lpTokenIdInfo = lpTokenInfo[tokenId];
        require(lpTokenIdInfo.owner == msg.sender, "Not owner");
        amount = lpTokenIdInfo.amount;

        (uint128 _reserve0, uint128 _reserve1) = getReserves(); // gas savings

        uint256 balance0 = _reserve0 - lpTokenIdInfo.amount0;
        uint256 balance1 = _reserve1 - lpTokenIdInfo.amount1;

        reserve0 = uint128(balance0);
        reserve1 = uint128(balance1);

        delete lpTokenInfo[tokenId];
    }

    function onERC721Received(
        address,
        address,
        uint256,
        bytes memory
    ) external pure returns (bytes4) {
        return IERC721Receiver.onERC721Received.selector;
    }

    function totalSupply() public view returns (uint256) {
        return _totalSupply;
    }

    function balanceOf(address account) public view returns (uint256) {
        return _balances[account];
    }

    function lastTimeRewardApplicable() public view returns (uint256) {
        return Math.min(block.timestamp, periodFinish);
    }

    function rewardPerToken(IERC20 _rewardToken) public view returns (uint256) {
        uint256 lastRewardTime = lastTimeRewardApplicable();
        // latter condition required because calculations will revert when called externally
        // even though internally this function will only be called if lastRewardTime > lastUpdateTime
        if (totalSupply() == 0 || lastRewardTime <= lastUpdateTime) {
            return rewardPerTokenStored[_rewardToken];
        }
        return rewardPerTokenStored[_rewardToken] + (
                (lastRewardTime - lastUpdateTime) * rewardRates[_rewardToken] * 1e18 / totalSupply()
            );
    }

    function earned(address account, IERC20 _rewardToken) public view returns (uint256) {
        return balanceOf(account)
                * (rewardPerToken(_rewardToken) - userRewardPerTokenPaid[_rewardToken][account])
                / (1e18)
                + rewards[_rewardToken][account];
    }

    function stake(uint256 tokenId) public updateReward(msg.sender) {
        require(tx.origin == msg.sender, "Caller must be EOA");
        uint256 amount = mint(tokenId);
        require(amount > 0, "Cannot stake one-sided LPs");

        _totalSupply += amount;
        _balances[msg.sender] += amount;
        lpToken.safeTransferFrom(msg.sender, address(this), tokenId);
        emit Staked(msg.sender, tokenId, amount);
    }

    function withdraw(uint256 tokenId) public updateReward(msg.sender) {
        // amount will never be 0 because it is checked in stake() 
        uint256 amount = burn(tokenId);
        _totalSupply -= amount;
        _balances[msg.sender] -= amount;
        lpToken.safeTransferFrom(address(this), msg.sender, tokenId);
        emit Withdrawn(msg.sender, tokenId, amount);
    }

    function exit(uint256 tokenId) external {
        withdraw(tokenId);
        getReward();
    }

    function getReward() public updateReward(msg.sender) {
        uint256 rewardTokensLength = rewardTokens.length;
        for (uint i; i < rewardTokensLength; ) {
            IERC20 rewardToken = rewardTokens[i];
            uint256 reward = earned(msg.sender, rewardToken);
            if (reward > 0) {
                rewards[rewardToken][msg.sender] = 0;
                emit RewardPaid(rewardToken, msg.sender, reward);
                rewardToken.safeTransfer(msg.sender, reward);
            }
            unchecked {
                ++i;
            }
        }
    }

    function getReserves()
        public
        view
        returns (uint128 _reserve0, uint128 _reserve1)
    {
        _reserve0 = reserve0;
        _reserve1 = reserve1;
    }

    function getIncentivisationParams()
        external
        view
        returns (IERC721, address, uint128, uint96)
    {
        return (nft, bondingCurve, delta, fee);
    }
}
          

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_lpToken","internalType":"contract ICollectionswap"}]},{"type":"event","name":"IncentiveETHCreated","inputs":[{"type":"address","name":"poolAddress","internalType":"address","indexed":false},{"type":"address[]","name":"rewardTokens","internalType":"contract IERC20[]","indexed":false},{"type":"uint256[]","name":"rewards","internalType":"uint256[]","indexed":false},{"type":"uint256","name":"startTime","internalType":"uint256","indexed":false},{"type":"uint256","name":"endTime","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"MAX_REWARD_TOKENS","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"createIncentiveETH","inputs":[{"type":"address","name":"nft","internalType":"contract IERC721"},{"type":"address","name":"bondingCurve","internalType":"address"},{"type":"uint128","name":"delta","internalType":"uint128"},{"type":"uint96","name":"fee","internalType":"uint96"},{"type":"address[]","name":"rewardTokens","internalType":"contract IERC20[]"},{"type":"uint256[]","name":"rewards","internalType":"uint256[]"},{"type":"uint256","name":"startTime","internalType":"uint256"},{"type":"uint256","name":"endTime","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]}]
              

Contract Creation Code

0x6080346100a757601f61317038819003918201601f19168301916001600160401b038311848410176100ac578084926020946040528339810103126100a757516001600160a01b0390818116908190036100a75760005460018060a01b0319903382821617600055604051933391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a360015416176001556130ad90816100c38239f35b600080fd5b634e487b7160e01b600052604160045260246000fdfe60808060405260043610156200001457600080fd5b60003560e01c9081635d0cde97146200082457508063715018a614620007c75780638da5cb5b146200079c578063d2f721af146200012d5763f2fde38b146200005c57600080fd5b346200012857602036600319011262000128576004356001600160a01b038181169182900362000128576200009062000874565b8115620000d457600054826001600160601b0360a01b821617600055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b600080fd5b34620001285761010036600319011262000128576004356001600160a01b03811681036200012857602435906001600160a01b03821682036200012857604435916001600160801b03831683036200012857606435926001600160601b0384168403620001285760843567ffffffffffffffff81116200012857620001b790369060040162000840565b93909160a43567ffffffffffffffff81116200012857620001dd90369060040162000840565b9490964260c43511156200076557600587116200072757858703620006f0576200020787620008f0565b92620002176040519485620008cd565b878452601f196200022889620008f0565b0136602086013760005b888110620006355750600054600154604051966001600160a01b0391821695919092169291612663880180891167ffffffffffffffff90911117620005a457906001600160801b0392918897966001600160601b03969561266362000a158b396126638a0190815233602082015260408101919091526001600160a01b03918216606082015291166080820152911660a0820152911660c082015261016060e08201819052620002e59101878662000945565b61266383018103610100612663850101526020808351928381520192019060005b8181106200061b5750505060c4356101206126638401015260e4356101406126638401015203906000f09283156200060f5760005b818110620003cf57506040516001600160a01b03909416845260a0602085018190526200036d92908501919062000945565b8281036040840152818152906001600160fb1b03811162000128577f226f2a59c9d1db4a1f5738b36ef4ef6c24c1bef367c6d2931e9ad902e4909e2293602092849260051b80928583013760c435606084015260e435608084015201030190a1005b620003dc81838562000909565b356001600160a01b03811681036200012857620003fb82868962000909565b6040516323b872dd60e01b60208201523360248201526001600160a01b0388166044820152903560648083019190915281529067ffffffffffffffff60a0830190811190831117620005a45760a0820160e083011067ffffffffffffffff60e084011117620005a45760e08201604052602060a08301527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656460c08301526001600160a01b0381163b15620005ca578151600091829190602085019083906001600160a01b03165af13d15620005ba573d67ffffffffffffffff8111620005a45760a06200050f9360405192620004fc6020601f19601f8401160185620008cd565b83523d6000602085013e5b019162000995565b80518062000523575b50506001016200033b565b816020918101031262000128576020015180159081150362000128576200054c57868062000518565b60405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608490fd5b634e487b7160e01b600052604160045260246000fd5b6200050f9160a060609162000507565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b6040513d6000823e3d90fd5b825184528594506020938401939092019160010162000306565b6200064281898c62000909565b3560e43560c435810311620006da5760c43560e43514620006c45760c43560e43503900462000672828762000930565b526200067f818662000930565b51156200068f5760010162000232565b60405162461bcd60e51b815260206004820152600d60248201526c3020726577617264207261746560981b6044820152606490fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60405162461bcd60e51b815260206004820152600f60248201526e756e657175616c206c656e6774687360881b6044820152606490fd5b60405162461bcd60e51b8152602060048201526016602482015275746f6f206d616e792072657761726420746f6b656e7360501b6044820152606490fd5b60405162461bcd60e51b815260206004820152600f60248201526e63616e6e6f74206261636b6461746560881b6044820152606490fd5b346200012857600036600319011262000128576000546040516001600160a01b039091168152602090f35b34620001285760003660031901126200012857620007e462000874565b600080546001600160a01b0319811682556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b3462000128576000366003190112620001285780600560209252f35b9181601f84011215620001285782359167ffffffffffffffff831162000128576020808501948460051b0101116200012857565b6000546001600160a01b031633036200088957565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b90601f8019910116810190811067ffffffffffffffff821117620005a457604052565b67ffffffffffffffff8111620005a45760051b60200190565b91908110156200091a5760051b0190565b634e487b7160e01b600052603260045260246000fd5b80518210156200091a5760209160051b010190565b9190808252602080920192916000805b8382106200096557505050505090565b9091929394853560018060a01b0381168091036200099157815283019483019392916001019062000955565b8280fd5b90919015620009a2575090565b815115620009b35750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b828510620009fa575050604492506000838284010152601f80199101168101030190fd5b8481018201518686016044015293810193859350620009d656fe60806040523462000507576200266380380380916200002082608062000534565b6080396101608112620005075762000039608062000558565b6200004560a062000558565b60c05190916001600160a01b0382168203620005075760e051926001600160a01b038416840362000507576200007d61010062000558565b61012051906001600160801b0382168203620005075761014051906001600160601b03821682036200050757610160516001600160401b03811162000507576080019688608001601f890112156200050757875196620000dd886200056d565b97620000ed604051998a62000534565b8089526020890190819a8c60800160208360051b8301011162000507579160208301925b60208360051b82010184106200050c575050610180519150506001600160401b03811162000507576080019980608001601f8c01121562000507578a51906200015a826200056d565b9b6200016a6040519d8e62000534565b828d5260208d019160800160208460051b8301011162000507579060208201915b60208460051b8201018310620004f25750506101a0516101c051600180546001600160a01b0319166001600160a01b039c8d161790556040516301ffc9a760e01b81526380ac58cd60e01b6004820152909a9199935091506020908290602490829088165afa908115620004e6576000916200049d575b50156200045857600280546001600160a01b03199081166001600160a01b039384161790915560038054821693831693909317909255600480548316938216939093179092556005805490911692909116919091179055600680546001600160e01b0319166001600160801b039093169290921760809190911b600160801b600160e01b031617905582516001600160401b03811162000442576801000000000000000081116200044257600a94855482875580831062000416575b5085600052602060002060005b838110620003f8575050505060005b8454811015620003b9576001600160a01b03620002f8828662000585565b5116600052600b908160205260ff60406000205416620003745760019162000321828962000585565b51838060a01b0362000334848962000585565b5116600052600e602052604060002055828060a01b0362000356838862000585565b511660005260205260406000208260ff1982541617905501620002da565b60405162461bcd60e51b815260206004820152601660248201527f4475706c69636174652072657761726420746f6b656e000000000000000000006044820152606490fd5b50600f5580600c5562ed4e008101809111620003e257600d556040516120b29081620005b18239f35b634e487b7160e01b600052601160045260246000fd5b82516001600160a01b031681830155602090920191600101620002cb565b8660005282602060002091820191015b818110620004355750620002be565b6000815560010162000426565b634e487b7160e01b600052604160045260246000fd5b60405162461bcd60e51b815260206004820152601460248201527f4e46542073686f756c64206265204552433732310000000000000000000000006044820152606490fd5b6020813d602011620004dd575b81620004b96020938362000534565b81010312620004d95751908115158203620004d657503862000202565b80fd5b5080fd5b3d9150620004aa565b6040513d6000823e3d90fd5b6020808093855181520193019291506200018b565b600080fd5b8351916001600160a01b03831683036200050757602081819482935201940193915062000111565b601f909101601f19168101906001600160401b038211908210176200044257604052565b51906001600160a01b03821682036200050757565b6001600160401b038111620004425760051b60200190565b80518210156200059a5760209160051b010190565b634e487b7160e01b600052603260045260246000fdfe60806040908082526004908136101561001757600080fd5b600090813560e01c9081630902f1ac1461083057508063150b7a02146107a657806318160ddd14610787578063211dc32d146107595780632e1a7d4d1461073c57806332dd8179146106fe5780633d18b912146106e55780633d3b2603146106ad5780634b27c1c71461068e5780635d0cde97146106725780635fcbd285146106495780637035ab981461060057806370a08231146105c85780637bb7bed1146105825780637cfb7f07146104715780637f8661a11461044c57806380faa57d1461042f5780638ca65a97146103d95780639ce43f90146103a1578063a694fc3a14610381578063c1e4d03414610254578063c8f33c9114610235578063e70b9e27146101ec578063ebe2b12b146101cd578063f12297771461019c5763f3b229b51461014357600080fd5b34610199578060031936011261019957505460055460065483516001600160a01b0393841681529290911660208301526001600160801b038116928201929092526001600160601b03608092831c166060820152f35b80fd5b5082346101c95760203660031901126101c9576020906101c26101bd61085a565b611289565b9051908152f35b5080fd5b5082346101c957816003193601126101c957602090600c549051908152f35b5082346101c957806003193601126101c9578060209261020a61085a565b610212610875565b6001600160a01b0391821683526012865283832091168252845220549051908152f35b5082346101c957816003193601126101c957602090600f549051908152f35b50913461037d578260031936011261037d576002546001600160a01b03929061028090841633146109dc565b600d54421061034f577f4011ee9777d89c36ecbfe93d74c49c1053342bd06c36b7f19f531ed64c4fd7958480a1600a5492845b8481106102be578580f35b816102c8826108fb565b90549060031b1c169084516370a0823160e01b815230858201526020908181602481875afa918215610345578992610311575b505061030b906001933390611236565b016102b3565b90809250813d831161033e575b61032881836108bd565b8101031261033a57518261030b6102fb565b8780fd5b503d61031e565b87513d8b823e3d90fd5b6020606492519162461bcd60e51b83528201526009602482015268546f6f206561726c7960b81b6044820152fd5b8280fd5b5090346101c95760203660031901126101c95761039e90356113c3565b80f35b5082346101c95760203660031901126101c95760209181906001600160a01b036103c961085a565b1681526010845220549051908152f35b5091903461037d57602036600319011261037d573582526009602090815291819020805460018201546002830154600390930154845192835294820152918201526001600160a01b039091166060820152608090f35b5082346101c957816003193601126101c9576020906101c2611274565b5090346101c95760203660031901126101c9576104699035611c2f565b61039e611ecf565b5082346101c95760603660031901126101c95782359067ffffffffffffffff80831161057e573660238401121561057e5782850135946104b086610936565b936104bd845195866108bd565b86855260209660248887019160051b8301019136831161033a57602401905b82821061055b5750505060243591821161055757366023830112156105575781013561051361050a82610936565b935193846108bd565b80835260248684019160051b8301019136831161055357602401905b828210610544578561039e604435868861094e565b8135815290860190860161052f565b8580fd5b8480fd5b81356001600160a01b038116810361057a5781529088019088016104dc565b8880fd5b8380fd5b5091903461037d57602036600319011261037d5735600a5481101561037d57600a6020935260018060a01b039060008051602061205d8339815191520154169051908152f35b5082346101c95760203660031901126101c95760209181906001600160a01b036105f061085a565b1681526008845220549051908152f35b5082346101c957806003193601126101c9578060209261061e61085a565b610626610875565b6001600160a01b0391821683526011865283832091168252845220549051908152f35b5082346101c957816003193601126101c95760035490516001600160a01b039091168152602090f35b5082346101c957816003193601126101c9576020905160058152f35b5082346101c957816003193601126101c957602090600d549051908152f35b5082346101c95760203660031901126101c95760209181906001600160a01b036106d561085a565b168152600e845220549051908152f35b503461019957806003193601126101995761039e611ecf565b5082346101c95760203660031901126101c95760209160ff9082906001600160a01b0361072961085a565b168152600b855220541690519015158152f35b5090346101c95760203660031901126101c95761039e9035611c2f565b5082346101c957806003193601126101c9576020906101c261077961085a565b610781610875565b9061134c565b5082346101c957816003193601126101c9576020906007549051908152f35b50829034610199576080366003190112610199576107c261085a565b506107cb610875565b506064359267ffffffffffffffff84116101c957366023850112156101c9578301356107f6816108df565b93610803845195866108bd565b818552366024838301011161037d57906020948160248794018483013701015251630a85bd0160e11b8152f35b92505034610199578060031936011261019957546001600160801b038116825260801c6020820152f35b600435906001600160a01b038216820361087057565b600080fd5b602435906001600160a01b038216820361087057565b6080810190811067ffffffffffffffff8211176108a757604052565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176108a757604052565b67ffffffffffffffff81116108a757601f01601f191660200190565b600a5481101561092057600a60005260008051602061205d8339815191520190600090565b634e487b7160e01b600052603260045260246000fd5b67ffffffffffffffff81116108a75760051b60200190565b929190600f5442106109d257600a5493600f544211610975575b610973939450610aa1565b565b600094855b81811061099c575050610973939450610991611274565b600f55849350610968565b806109a86001926108fb565b838060a01b0391549060031b1c166109bf81611289565b908952601060205260408920550161097a565b6109739293610aa1565b156109e357565b60405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b6044820152606490fd5b80518210156109205760209160051b010190565b91908201809211610a3a57565b634e487b7160e01b600052601160045260246000fd5b9060058110156109205760051b0190565b91908203918211610a3a57565b8115610a78570490565b634e487b7160e01b600052601260045260246000fd5b81810292918115918404141715610a3a57565b92909160018060a01b0391826002541633148015611032575b610ac3906109dc565b42821115610ff557600c54421115610fa4578451845103610f6957600091825b8651811015610b955784610af78289610a19565b511680600052602090600b825260409060ff82600020541615610b83575b60005b848110610b2b5750505050600101610ae3565b88610b36828d610a19565b51168214610b4657600101610b18565b825162461bcd60e51b8152600481018590526016602482015275223ab83634b1b0ba32903932bbb0b932103a37b5b2b760511b6044820152606490fd5b9560018101809111610a3a5795610b15565b509291939093600a916005610bac84548094610a2d565b11610f2b5760409485519760a089019767ffffffffffffffff988a81108a8211176108a757885260a0368b3760005b8654811015610c1b5780808c610c068b610bf66001966108fb565b90549060031b1c16928392610a50565b52600052600e60205260008a81205501610bdb565b5090919396959294989760005b8351811015610d7b5784610c3c8286610a19565b5116610c488289610a19565b51610c57575b50600101610c28565b610c618289610a19565b5189516323b872dd60e01b602080830191909152336024808401919091523060448401526064808401949094529282529290610ca890610ca26084826108bd565b82611057565b80600052600b8084528d60ff8d600020541615610d2f575b5050610ce0610ccf858c610a19565b51610cda428c610a61565b90610a6e565b90600052600e83528a60002055896000205415610cfd5750610c4e565b90600d6064928b519262461bcd60e51b845260048401528201526c3020726577617264207261746560981b6044820152fd5b610d3c8e929e8492610a50565b52600190818101809111610d66579c8260005284528b6000209060ff19825416179055388d610cc0565b83634e487b7160e01b60005260116004526000fd5b50919395949890979296610d8e81610936565b610d9a875191826108bd565b818152610da682610936565b6020958287019391601f190136853760005b828110610f0a57505050519283116108a757600160401b83116108a7578154838355808410610edb575b509060005260005b828110610eb95750505042600f5583600c5562ed4e008401808511610a3a57600d92919255825194608086016080875282518091528360a088019301916000905b828210610ea057505050508481038286015281808851928381520197019160005b828110610e8c57505050509382917f4538a1aa4e8a09baa5b87edb3b48e349a0109adaef762e122bb696b227953b829495429084015260608301520390a1565b835189529781019792810192600101610e4c565b8351811685529385019392850192600190910190610e2b565b8151881660008051602061205d83398151915282015590830190600101610dea565b8360008051602061205d83398151915291820191015b818110610efe5750610de2565b60008155600101610ef1565b808c610f1860019385610a50565b5116610f248287610a19565b5201610db8565b60405162461bcd60e51b8152602060048201526016602482015275546f6f206d616e792072657761726420746f6b656e7360501b6044820152606490fd5b60405162461bcd60e51b8152602060048201526013602482015272092dcc6dedce6d2e6e8cadce840d8cadccee8d606b1b6044820152606490fd5b60405162461bcd60e51b8152602060048201526024808201527f43616e6e6f74207265636861726765206265666f726520706572696f642066696044820152630dcd2e6d60e31b6064820152608490fd5b60405162461bcd60e51b8152602060048201526015602482015274092dcecc2d8d2c840e0cae4d2dec840ccd2dcd2e6d605b1b6044820152606490fd5b5060015483163314610aba565b90816020910312610870575180151581036108705790565b60018060a01b03169060409081519082820182811067ffffffffffffffff8211176108a75783526020938483527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656485840152803b1561117757600082819282886110ee9796519301915af13d1561116f573d906110d3826108df565b916110e0865193846108bd565b82523d60008784013e6111bb565b805190816110fd575b50505050565b838061110d93830101910161103f565b156111195780806110f7565b60849250519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b6060906111bb565b835162461bcd60e51b815260048101869052601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b909190156111c7575090565b8151156111d75750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b82851061121d575050604492506000838284010152601f80199101168101030190fd5b84810182015186860160440152938101938593506111fa565b60405163a9059cbb60e01b60208201526001600160a01b0390921660248301526044808301939093529181526109739161126f8261088b565b611057565b600c5480421060001461128657504290565b90565b611291611274565b906007549081158015611340575b6113225760018060a01b03166112de60009180835260106020526112cb604084205495600f5490610a61565b908352600e602052604083205490610a8e565b90670de0b6b3a76400009182810292818404149015171561130e5750611286929161130891610a6e565b90610a2d565b634e487b7160e01b81526011600452602490fd5b6001600160a01b031660009081526010602052604090205492915050565b50600f5483111561129f565b9060406112869260018060a01b03809116670de0b6b3a76400006113a960009383855260086020526113a3868620549161138589611289565b98169788875260116020528787208688526020528787205490610a61565b90610a8e565b049382526012602052828220908252602052205490610a2d565b600f5442106114b257600a54600f54421161145f575b336113e9575b50610973906114b7565b60005b8181106113f957506113df565b806114056001926108fb565b838060a01b0391549060031b1c1661141d813361134c565b816000526020916012835260409182600020336000528452826000205560005260108252806000205491601181528160002090336000525260002055016113ec565b6000805b82811061147c575050611474611274565b600f556113d9565b806114886001926108fb565b838060a01b0391549060031b1c1661149f81611289565b9084526010602052604084205501611463565b610973905b90333203611a6757600354604080516331a9108f60e11b81526004808201869052602495936001600160a01b0390811692602092919083818a81885afa8015611a5c57600090611a26575b611510915082163314611ab5565b8082541681600554166006549587519162221e3160e31b83528986840152838c84015260448301526001600160601b0391828860801c1660648201526001600160801b038098166084820152868160a481855afa9081156119bf576000916119f9575b50156119ca578751809163cdb71d0d60e01b82528a87830152818d6101009485935afa9283156119bf579285928a928e956000936118e7575b5050500151169185600054918951938480926370a0823160e01b8252878a8301525afa9182156118dc576000926118ad575b508231928b60a06001928b5192838092630614af2b60e11b8252868c8301525afa9081156118a257600091611864575b50841061185c575b61162c611631916116278686610a8e565b610a8e565b611b01565b9661164b8461164285848616610a2d565b9360801c610a2d565b8183111580611852575b1561181d57911660809190911b6fffffffffffffffffffffffffffffffff191617600055865183916003919061168a8261088b565b815286810193845288810188815260608201943386528b600052600989528a60002092518355516001830155516002820155019151166001600160601b0360a01b82541617905583156117dc576116e384600754610a2d565b6007553360005260088352846000206116fd858254610a2d565b90556003541690813b15610870578451632142170760e11b81523382820190815230602082015260408101889052909260009184919082908490829060600103925af180156117d15761177f575b50507f1449c6dd7851abc30abf37f57715f492010519147cc2652fbc38202c18a6ee909394955082519485528401523392a2565b67ffffffffffffffff82116117bd5750835293945084937f1449c6dd7851abc30abf37f57715f492010519147cc2652fbc38202c18a6ee903861174b565b60418891634e487b7160e01b600052526000fd5b85513d6000823e3d90fd5b50601a8760649386519362461bcd60e51b85528401528201527f43616e6e6f74207374616b65206f6e652d7369646564204c50730000000000006044820152fd5b895162461bcd60e51b81528088018990526010818f01526f42616c616e6365206f766572666c6f7760801b6044820152606490fd5b5081811115611655565b506000611616565b9060a0823d821161189a575b8161187d60a093836108bd565b81010312610199576003825110156101995750606001513861160e565b3d9150611870565b8a513d6000823e3d90fd5b90918682813d83116118d5575b6118c481836108bd565b8101031261019957505190386115de565b503d6118ba565b88513d6000823e3d90fd5b9350818096508195503d83116119b8575b61190281836108bd565b8101031261019957895193840184811067ffffffffffffffff8211176119a6578a5261192d83611aa1565b845261193a888401611aa1565b888501528983015186811681036101c9578a8501526060830151918216820361019957508260e086938b938f966060015261197760808201611aed565b608084015261198860a08201611aed565b60a084015260c081015160c0840152015160e08201523880806115ac565b634e487b7160e01b8252604188528d82fd5b503d6118f8565b89513d6000823e3d90fd5b875162461bcd60e51b8152808601879052600a818d01526915dc9bdb99c81c1bdbdb60b21b6044820152606490fd5b611a199150873d8911611a1f575b611a1181836108bd565b81019061103f565b38611573565b503d611a07565b8482813d8311611a55575b611a3b81836108bd565b810103126101995750611a5061151091611aa1565b611502565b503d611a31565b86513d6000823e3d90fd5b60405162461bcd60e51b815260206004820152601260248201527143616c6c6572206d75737420626520454f4160701b6044820152606490fd5b51906001600160a01b038216820361087057565b15611abc57565b60405162461bcd60e51b81526020600482015260096024820152682737ba1037bbb732b960b91b6044820152606490fd5b51906001600160801b038216820361087057565b8015611c2957611bc06001828360801c80611c1a575b508060401c80611c0d575b508060201c80611c00575b508060101c80611bf3575b508060081c80611be6575b508060041c80611bd9575b5060021c611bd1575b611b618184610a6e565b0160011c611b6f8184610a6e565b0160011c611b7d8184610a6e565b0160011c611b8b8184610a6e565b0160011c611b998184610a6e565b0160011c611ba78184610a6e565b0160011c611bb58184610a6e565b0160011c8092610a6e565b80821015611bcc575090565b905090565b60011b611b57565b90509060021b9038611b4e565b90509060041b9038611b43565b90509060081b9038611b38565b90509060101b9038611b2d565b90509060201b9038611b22565b915050600160401b9038611b17565b50600090565b600f544210611d1e57600a54600f544211611ccb575b33611c55575b5061097390611d23565b60005b818110611c655750611c4b565b80611c716001926108fb565b838060a01b0391549060031b1c16611c89813361134c565b81600052602091601283526040918260002033600052845282600020556000526010825280600020549160118152816000209033600052526000205501611c58565b6000805b828110611ce8575050611ce0611274565b600f55611c45565b80611cf46001926108fb565b838060a01b0391549060031b1c16611d0b81611289565b9084526010602052604084205501611ccf565b610973905b906000918083526009602052604080842060038251611d418161088b565b8254815260018301549260208201938452611d7b60028201549186840192835260018060a01b039485910154168060608501523314611ab5565b51928754915190611dae611d996001600160801b0393848616610a61565b936001600160801b031992519060801c610a61565b60801b16911617865583865260096020528560038482208281558260018201558260028201550155611de282600754610a61565b6007553386526008602052828620611dfb838254610a61565b905560035416803b15610553578251632142170760e11b8152306004820152336024820152604481018590529086908290606490829084905af18015611ec557611e75575b507f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc692939450815193845260208401523392a2565b67ffffffffffffffff8111611eb157825292935083927f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc6611e40565b634e487b7160e01b86526041600452602486fd5b83513d88823e3d90fd5b600f544210611fbd57600a54600f544211611f6a575b33611ef4575b50610973611fc1565b60005b818110611f045750611eeb565b80611f106001926108fb565b838060a01b0391549060031b1c16611f28813361134c565b81600052602091601283526040918260002033600052845282600020556000526010825280600020549160118152816000209033600052526000205501611ef7565b6000805b828110611f87575050611f7f611274565b600f55611ee5565b80611f936001926108fb565b838060a01b0391549060031b1c16611faa81611289565b9084526010602052604084205501611f6e565b6109735b600a5460005b818110611fd2575050565b80611fde6001926108fb565b838060a01b0391549060031b1c16611ff6813361134c565b80612004575b505001611fc7565b8161205592600052602060128152817f540798df468d7b23d11f156fdb954cb19ad414d150722a7b6d55ba369dea792e60408060002033600052845260008181205551928584523393a33390611236565b3880611ffc56fec65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a8a2646970667358221220fd3d99808943ab7cbddfa1049201ad28aa8ef20ce7083efd6159c59467bef59d64736f6c63430008110033a2646970667358221220dd4a6f180755872fc93c43f1afa6413d391adbc7cad117a99c3770852498fec564736f6c63430008110033000000000000000000000000fc5af63f4b0247423a5aa4c0b755bc7991234190

Deployed ByteCode

0x60808060405260043610156200001457600080fd5b60003560e01c9081635d0cde97146200082457508063715018a614620007c75780638da5cb5b146200079c578063d2f721af146200012d5763f2fde38b146200005c57600080fd5b346200012857602036600319011262000128576004356001600160a01b038181169182900362000128576200009062000874565b8115620000d457600054826001600160601b0360a01b821617600055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b600080fd5b34620001285761010036600319011262000128576004356001600160a01b03811681036200012857602435906001600160a01b03821682036200012857604435916001600160801b03831683036200012857606435926001600160601b0384168403620001285760843567ffffffffffffffff81116200012857620001b790369060040162000840565b93909160a43567ffffffffffffffff81116200012857620001dd90369060040162000840565b9490964260c43511156200076557600587116200072757858703620006f0576200020787620008f0565b92620002176040519485620008cd565b878452601f196200022889620008f0565b0136602086013760005b888110620006355750600054600154604051966001600160a01b0391821695919092169291612663880180891167ffffffffffffffff90911117620005a457906001600160801b0392918897966001600160601b03969561266362000a158b396126638a0190815233602082015260408101919091526001600160a01b03918216606082015291166080820152911660a0820152911660c082015261016060e08201819052620002e59101878662000945565b61266383018103610100612663850101526020808351928381520192019060005b8181106200061b5750505060c4356101206126638401015260e4356101406126638401015203906000f09283156200060f5760005b818110620003cf57506040516001600160a01b03909416845260a0602085018190526200036d92908501919062000945565b8281036040840152818152906001600160fb1b03811162000128577f226f2a59c9d1db4a1f5738b36ef4ef6c24c1bef367c6d2931e9ad902e4909e2293602092849260051b80928583013760c435606084015260e435608084015201030190a1005b620003dc81838562000909565b356001600160a01b03811681036200012857620003fb82868962000909565b6040516323b872dd60e01b60208201523360248201526001600160a01b0388166044820152903560648083019190915281529067ffffffffffffffff60a0830190811190831117620005a45760a0820160e083011067ffffffffffffffff60e084011117620005a45760e08201604052602060a08301527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656460c08301526001600160a01b0381163b15620005ca578151600091829190602085019083906001600160a01b03165af13d15620005ba573d67ffffffffffffffff8111620005a45760a06200050f9360405192620004fc6020601f19601f8401160185620008cd565b83523d6000602085013e5b019162000995565b80518062000523575b50506001016200033b565b816020918101031262000128576020015180159081150362000128576200054c57868062000518565b60405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608490fd5b634e487b7160e01b600052604160045260246000fd5b6200050f9160a060609162000507565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b6040513d6000823e3d90fd5b825184528594506020938401939092019160010162000306565b6200064281898c62000909565b3560e43560c435810311620006da5760c43560e43514620006c45760c43560e43503900462000672828762000930565b526200067f818662000930565b51156200068f5760010162000232565b60405162461bcd60e51b815260206004820152600d60248201526c3020726577617264207261746560981b6044820152606490fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60405162461bcd60e51b815260206004820152600f60248201526e756e657175616c206c656e6774687360881b6044820152606490fd5b60405162461bcd60e51b8152602060048201526016602482015275746f6f206d616e792072657761726420746f6b656e7360501b6044820152606490fd5b60405162461bcd60e51b815260206004820152600f60248201526e63616e6e6f74206261636b6461746560881b6044820152606490fd5b346200012857600036600319011262000128576000546040516001600160a01b039091168152602090f35b34620001285760003660031901126200012857620007e462000874565b600080546001600160a01b0319811682556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b3462000128576000366003190112620001285780600560209252f35b9181601f84011215620001285782359167ffffffffffffffff831162000128576020808501948460051b0101116200012857565b6000546001600160a01b031633036200088957565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b90601f8019910116810190811067ffffffffffffffff821117620005a457604052565b67ffffffffffffffff8111620005a45760051b60200190565b91908110156200091a5760051b0190565b634e487b7160e01b600052603260045260246000fd5b80518210156200091a5760209160051b010190565b9190808252602080920192916000805b8382106200096557505050505090565b9091929394853560018060a01b0381168091036200099157815283019483019392916001019062000955565b8280fd5b90919015620009a2575090565b815115620009b35750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b828510620009fa575050604492506000838284010152601f80199101168101030190fd5b8481018201518686016044015293810193859350620009d656fe60806040523462000507576200266380380380916200002082608062000534565b6080396101608112620005075762000039608062000558565b6200004560a062000558565b60c05190916001600160a01b0382168203620005075760e051926001600160a01b038416840362000507576200007d61010062000558565b61012051906001600160801b0382168203620005075761014051906001600160601b03821682036200050757610160516001600160401b03811162000507576080019688608001601f890112156200050757875196620000dd886200056d565b97620000ed604051998a62000534565b8089526020890190819a8c60800160208360051b8301011162000507579160208301925b60208360051b82010184106200050c575050610180519150506001600160401b03811162000507576080019980608001601f8c01121562000507578a51906200015a826200056d565b9b6200016a6040519d8e62000534565b828d5260208d019160800160208460051b8301011162000507579060208201915b60208460051b8201018310620004f25750506101a0516101c051600180546001600160a01b0319166001600160a01b039c8d161790556040516301ffc9a760e01b81526380ac58cd60e01b6004820152909a9199935091506020908290602490829088165afa908115620004e6576000916200049d575b50156200045857600280546001600160a01b03199081166001600160a01b039384161790915560038054821693831693909317909255600480548316938216939093179092556005805490911692909116919091179055600680546001600160e01b0319166001600160801b039093169290921760809190911b600160801b600160e01b031617905582516001600160401b03811162000442576801000000000000000081116200044257600a94855482875580831062000416575b5085600052602060002060005b838110620003f8575050505060005b8454811015620003b9576001600160a01b03620002f8828662000585565b5116600052600b908160205260ff60406000205416620003745760019162000321828962000585565b51838060a01b0362000334848962000585565b5116600052600e602052604060002055828060a01b0362000356838862000585565b511660005260205260406000208260ff1982541617905501620002da565b60405162461bcd60e51b815260206004820152601660248201527f4475706c69636174652072657761726420746f6b656e000000000000000000006044820152606490fd5b50600f5580600c5562ed4e008101809111620003e257600d556040516120b29081620005b18239f35b634e487b7160e01b600052601160045260246000fd5b82516001600160a01b031681830155602090920191600101620002cb565b8660005282602060002091820191015b818110620004355750620002be565b6000815560010162000426565b634e487b7160e01b600052604160045260246000fd5b60405162461bcd60e51b815260206004820152601460248201527f4e46542073686f756c64206265204552433732310000000000000000000000006044820152606490fd5b6020813d602011620004dd575b81620004b96020938362000534565b81010312620004d95751908115158203620004d657503862000202565b80fd5b5080fd5b3d9150620004aa565b6040513d6000823e3d90fd5b6020808093855181520193019291506200018b565b600080fd5b8351916001600160a01b03831683036200050757602081819482935201940193915062000111565b601f909101601f19168101906001600160401b038211908210176200044257604052565b51906001600160a01b03821682036200050757565b6001600160401b038111620004425760051b60200190565b80518210156200059a5760209160051b010190565b634e487b7160e01b600052603260045260246000fdfe60806040908082526004908136101561001757600080fd5b600090813560e01c9081630902f1ac1461083057508063150b7a02146107a657806318160ddd14610787578063211dc32d146107595780632e1a7d4d1461073c57806332dd8179146106fe5780633d18b912146106e55780633d3b2603146106ad5780634b27c1c71461068e5780635d0cde97146106725780635fcbd285146106495780637035ab981461060057806370a08231146105c85780637bb7bed1146105825780637cfb7f07146104715780637f8661a11461044c57806380faa57d1461042f5780638ca65a97146103d95780639ce43f90146103a1578063a694fc3a14610381578063c1e4d03414610254578063c8f33c9114610235578063e70b9e27146101ec578063ebe2b12b146101cd578063f12297771461019c5763f3b229b51461014357600080fd5b34610199578060031936011261019957505460055460065483516001600160a01b0393841681529290911660208301526001600160801b038116928201929092526001600160601b03608092831c166060820152f35b80fd5b5082346101c95760203660031901126101c9576020906101c26101bd61085a565b611289565b9051908152f35b5080fd5b5082346101c957816003193601126101c957602090600c549051908152f35b5082346101c957806003193601126101c9578060209261020a61085a565b610212610875565b6001600160a01b0391821683526012865283832091168252845220549051908152f35b5082346101c957816003193601126101c957602090600f549051908152f35b50913461037d578260031936011261037d576002546001600160a01b03929061028090841633146109dc565b600d54421061034f577f4011ee9777d89c36ecbfe93d74c49c1053342bd06c36b7f19f531ed64c4fd7958480a1600a5492845b8481106102be578580f35b816102c8826108fb565b90549060031b1c169084516370a0823160e01b815230858201526020908181602481875afa918215610345578992610311575b505061030b906001933390611236565b016102b3565b90809250813d831161033e575b61032881836108bd565b8101031261033a57518261030b6102fb565b8780fd5b503d61031e565b87513d8b823e3d90fd5b6020606492519162461bcd60e51b83528201526009602482015268546f6f206561726c7960b81b6044820152fd5b8280fd5b5090346101c95760203660031901126101c95761039e90356113c3565b80f35b5082346101c95760203660031901126101c95760209181906001600160a01b036103c961085a565b1681526010845220549051908152f35b5091903461037d57602036600319011261037d573582526009602090815291819020805460018201546002830154600390930154845192835294820152918201526001600160a01b039091166060820152608090f35b5082346101c957816003193601126101c9576020906101c2611274565b5090346101c95760203660031901126101c9576104699035611c2f565b61039e611ecf565b5082346101c95760603660031901126101c95782359067ffffffffffffffff80831161057e573660238401121561057e5782850135946104b086610936565b936104bd845195866108bd565b86855260209660248887019160051b8301019136831161033a57602401905b82821061055b5750505060243591821161055757366023830112156105575781013561051361050a82610936565b935193846108bd565b80835260248684019160051b8301019136831161055357602401905b828210610544578561039e604435868861094e565b8135815290860190860161052f565b8580fd5b8480fd5b81356001600160a01b038116810361057a5781529088019088016104dc565b8880fd5b8380fd5b5091903461037d57602036600319011261037d5735600a5481101561037d57600a6020935260018060a01b039060008051602061205d8339815191520154169051908152f35b5082346101c95760203660031901126101c95760209181906001600160a01b036105f061085a565b1681526008845220549051908152f35b5082346101c957806003193601126101c9578060209261061e61085a565b610626610875565b6001600160a01b0391821683526011865283832091168252845220549051908152f35b5082346101c957816003193601126101c95760035490516001600160a01b039091168152602090f35b5082346101c957816003193601126101c9576020905160058152f35b5082346101c957816003193601126101c957602090600d549051908152f35b5082346101c95760203660031901126101c95760209181906001600160a01b036106d561085a565b168152600e845220549051908152f35b503461019957806003193601126101995761039e611ecf565b5082346101c95760203660031901126101c95760209160ff9082906001600160a01b0361072961085a565b168152600b855220541690519015158152f35b5090346101c95760203660031901126101c95761039e9035611c2f565b5082346101c957806003193601126101c9576020906101c261077961085a565b610781610875565b9061134c565b5082346101c957816003193601126101c9576020906007549051908152f35b50829034610199576080366003190112610199576107c261085a565b506107cb610875565b506064359267ffffffffffffffff84116101c957366023850112156101c9578301356107f6816108df565b93610803845195866108bd565b818552366024838301011161037d57906020948160248794018483013701015251630a85bd0160e11b8152f35b92505034610199578060031936011261019957546001600160801b038116825260801c6020820152f35b600435906001600160a01b038216820361087057565b600080fd5b602435906001600160a01b038216820361087057565b6080810190811067ffffffffffffffff8211176108a757604052565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff8211176108a757604052565b67ffffffffffffffff81116108a757601f01601f191660200190565b600a5481101561092057600a60005260008051602061205d8339815191520190600090565b634e487b7160e01b600052603260045260246000fd5b67ffffffffffffffff81116108a75760051b60200190565b929190600f5442106109d257600a5493600f544211610975575b610973939450610aa1565b565b600094855b81811061099c575050610973939450610991611274565b600f55849350610968565b806109a86001926108fb565b838060a01b0391549060031b1c166109bf81611289565b908952601060205260408920550161097a565b6109739293610aa1565b156109e357565b60405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b6044820152606490fd5b80518210156109205760209160051b010190565b91908201809211610a3a57565b634e487b7160e01b600052601160045260246000fd5b9060058110156109205760051b0190565b91908203918211610a3a57565b8115610a78570490565b634e487b7160e01b600052601260045260246000fd5b81810292918115918404141715610a3a57565b92909160018060a01b0391826002541633148015611032575b610ac3906109dc565b42821115610ff557600c54421115610fa4578451845103610f6957600091825b8651811015610b955784610af78289610a19565b511680600052602090600b825260409060ff82600020541615610b83575b60005b848110610b2b5750505050600101610ae3565b88610b36828d610a19565b51168214610b4657600101610b18565b825162461bcd60e51b8152600481018590526016602482015275223ab83634b1b0ba32903932bbb0b932103a37b5b2b760511b6044820152606490fd5b9560018101809111610a3a5795610b15565b509291939093600a916005610bac84548094610a2d565b11610f2b5760409485519760a089019767ffffffffffffffff988a81108a8211176108a757885260a0368b3760005b8654811015610c1b5780808c610c068b610bf66001966108fb565b90549060031b1c16928392610a50565b52600052600e60205260008a81205501610bdb565b5090919396959294989760005b8351811015610d7b5784610c3c8286610a19565b5116610c488289610a19565b51610c57575b50600101610c28565b610c618289610a19565b5189516323b872dd60e01b602080830191909152336024808401919091523060448401526064808401949094529282529290610ca890610ca26084826108bd565b82611057565b80600052600b8084528d60ff8d600020541615610d2f575b5050610ce0610ccf858c610a19565b51610cda428c610a61565b90610a6e565b90600052600e83528a60002055896000205415610cfd5750610c4e565b90600d6064928b519262461bcd60e51b845260048401528201526c3020726577617264207261746560981b6044820152fd5b610d3c8e929e8492610a50565b52600190818101809111610d66579c8260005284528b6000209060ff19825416179055388d610cc0565b83634e487b7160e01b60005260116004526000fd5b50919395949890979296610d8e81610936565b610d9a875191826108bd565b818152610da682610936565b6020958287019391601f190136853760005b828110610f0a57505050519283116108a757600160401b83116108a7578154838355808410610edb575b509060005260005b828110610eb95750505042600f5583600c5562ed4e008401808511610a3a57600d92919255825194608086016080875282518091528360a088019301916000905b828210610ea057505050508481038286015281808851928381520197019160005b828110610e8c57505050509382917f4538a1aa4e8a09baa5b87edb3b48e349a0109adaef762e122bb696b227953b829495429084015260608301520390a1565b835189529781019792810192600101610e4c565b8351811685529385019392850192600190910190610e2b565b8151881660008051602061205d83398151915282015590830190600101610dea565b8360008051602061205d83398151915291820191015b818110610efe5750610de2565b60008155600101610ef1565b808c610f1860019385610a50565b5116610f248287610a19565b5201610db8565b60405162461bcd60e51b8152602060048201526016602482015275546f6f206d616e792072657761726420746f6b656e7360501b6044820152606490fd5b60405162461bcd60e51b8152602060048201526013602482015272092dcc6dedce6d2e6e8cadce840d8cadccee8d606b1b6044820152606490fd5b60405162461bcd60e51b8152602060048201526024808201527f43616e6e6f74207265636861726765206265666f726520706572696f642066696044820152630dcd2e6d60e31b6064820152608490fd5b60405162461bcd60e51b8152602060048201526015602482015274092dcecc2d8d2c840e0cae4d2dec840ccd2dcd2e6d605b1b6044820152606490fd5b5060015483163314610aba565b90816020910312610870575180151581036108705790565b60018060a01b03169060409081519082820182811067ffffffffffffffff8211176108a75783526020938483527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656485840152803b1561117757600082819282886110ee9796519301915af13d1561116f573d906110d3826108df565b916110e0865193846108bd565b82523d60008784013e6111bb565b805190816110fd575b50505050565b838061110d93830101910161103f565b156111195780806110f7565b60849250519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b6060906111bb565b835162461bcd60e51b815260048101869052601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b909190156111c7575090565b8151156111d75750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b82851061121d575050604492506000838284010152601f80199101168101030190fd5b84810182015186860160440152938101938593506111fa565b60405163a9059cbb60e01b60208201526001600160a01b0390921660248301526044808301939093529181526109739161126f8261088b565b611057565b600c5480421060001461128657504290565b90565b611291611274565b906007549081158015611340575b6113225760018060a01b03166112de60009180835260106020526112cb604084205495600f5490610a61565b908352600e602052604083205490610a8e565b90670de0b6b3a76400009182810292818404149015171561130e5750611286929161130891610a6e565b90610a2d565b634e487b7160e01b81526011600452602490fd5b6001600160a01b031660009081526010602052604090205492915050565b50600f5483111561129f565b9060406112869260018060a01b03809116670de0b6b3a76400006113a960009383855260086020526113a3868620549161138589611289565b98169788875260116020528787208688526020528787205490610a61565b90610a8e565b049382526012602052828220908252602052205490610a2d565b600f5442106114b257600a54600f54421161145f575b336113e9575b50610973906114b7565b60005b8181106113f957506113df565b806114056001926108fb565b838060a01b0391549060031b1c1661141d813361134c565b816000526020916012835260409182600020336000528452826000205560005260108252806000205491601181528160002090336000525260002055016113ec565b6000805b82811061147c575050611474611274565b600f556113d9565b806114886001926108fb565b838060a01b0391549060031b1c1661149f81611289565b9084526010602052604084205501611463565b610973905b90333203611a6757600354604080516331a9108f60e11b81526004808201869052602495936001600160a01b0390811692602092919083818a81885afa8015611a5c57600090611a26575b611510915082163314611ab5565b8082541681600554166006549587519162221e3160e31b83528986840152838c84015260448301526001600160601b0391828860801c1660648201526001600160801b038098166084820152868160a481855afa9081156119bf576000916119f9575b50156119ca578751809163cdb71d0d60e01b82528a87830152818d6101009485935afa9283156119bf579285928a928e956000936118e7575b5050500151169185600054918951938480926370a0823160e01b8252878a8301525afa9182156118dc576000926118ad575b508231928b60a06001928b5192838092630614af2b60e11b8252868c8301525afa9081156118a257600091611864575b50841061185c575b61162c611631916116278686610a8e565b610a8e565b611b01565b9661164b8461164285848616610a2d565b9360801c610a2d565b8183111580611852575b1561181d57911660809190911b6fffffffffffffffffffffffffffffffff191617600055865183916003919061168a8261088b565b815286810193845288810188815260608201943386528b600052600989528a60002092518355516001830155516002820155019151166001600160601b0360a01b82541617905583156117dc576116e384600754610a2d565b6007553360005260088352846000206116fd858254610a2d565b90556003541690813b15610870578451632142170760e11b81523382820190815230602082015260408101889052909260009184919082908490829060600103925af180156117d15761177f575b50507f1449c6dd7851abc30abf37f57715f492010519147cc2652fbc38202c18a6ee909394955082519485528401523392a2565b67ffffffffffffffff82116117bd5750835293945084937f1449c6dd7851abc30abf37f57715f492010519147cc2652fbc38202c18a6ee903861174b565b60418891634e487b7160e01b600052526000fd5b85513d6000823e3d90fd5b50601a8760649386519362461bcd60e51b85528401528201527f43616e6e6f74207374616b65206f6e652d7369646564204c50730000000000006044820152fd5b895162461bcd60e51b81528088018990526010818f01526f42616c616e6365206f766572666c6f7760801b6044820152606490fd5b5081811115611655565b506000611616565b9060a0823d821161189a575b8161187d60a093836108bd565b81010312610199576003825110156101995750606001513861160e565b3d9150611870565b8a513d6000823e3d90fd5b90918682813d83116118d5575b6118c481836108bd565b8101031261019957505190386115de565b503d6118ba565b88513d6000823e3d90fd5b9350818096508195503d83116119b8575b61190281836108bd565b8101031261019957895193840184811067ffffffffffffffff8211176119a6578a5261192d83611aa1565b845261193a888401611aa1565b888501528983015186811681036101c9578a8501526060830151918216820361019957508260e086938b938f966060015261197760808201611aed565b608084015261198860a08201611aed565b60a084015260c081015160c0840152015160e08201523880806115ac565b634e487b7160e01b8252604188528d82fd5b503d6118f8565b89513d6000823e3d90fd5b875162461bcd60e51b8152808601879052600a818d01526915dc9bdb99c81c1bdbdb60b21b6044820152606490fd5b611a199150873d8911611a1f575b611a1181836108bd565b81019061103f565b38611573565b503d611a07565b8482813d8311611a55575b611a3b81836108bd565b810103126101995750611a5061151091611aa1565b611502565b503d611a31565b86513d6000823e3d90fd5b60405162461bcd60e51b815260206004820152601260248201527143616c6c6572206d75737420626520454f4160701b6044820152606490fd5b51906001600160a01b038216820361087057565b15611abc57565b60405162461bcd60e51b81526020600482015260096024820152682737ba1037bbb732b960b91b6044820152606490fd5b51906001600160801b038216820361087057565b8015611c2957611bc06001828360801c80611c1a575b508060401c80611c0d575b508060201c80611c00575b508060101c80611bf3575b508060081c80611be6575b508060041c80611bd9575b5060021c611bd1575b611b618184610a6e565b0160011c611b6f8184610a6e565b0160011c611b7d8184610a6e565b0160011c611b8b8184610a6e565b0160011c611b998184610a6e565b0160011c611ba78184610a6e565b0160011c611bb58184610a6e565b0160011c8092610a6e565b80821015611bcc575090565b905090565b60011b611b57565b90509060021b9038611b4e565b90509060041b9038611b43565b90509060081b9038611b38565b90509060101b9038611b2d565b90509060201b9038611b22565b915050600160401b9038611b17565b50600090565b600f544210611d1e57600a54600f544211611ccb575b33611c55575b5061097390611d23565b60005b818110611c655750611c4b565b80611c716001926108fb565b838060a01b0391549060031b1c16611c89813361134c565b81600052602091601283526040918260002033600052845282600020556000526010825280600020549160118152816000209033600052526000205501611c58565b6000805b828110611ce8575050611ce0611274565b600f55611c45565b80611cf46001926108fb565b838060a01b0391549060031b1c16611d0b81611289565b9084526010602052604084205501611ccf565b610973905b906000918083526009602052604080842060038251611d418161088b565b8254815260018301549260208201938452611d7b60028201549186840192835260018060a01b039485910154168060608501523314611ab5565b51928754915190611dae611d996001600160801b0393848616610a61565b936001600160801b031992519060801c610a61565b60801b16911617865583865260096020528560038482208281558260018201558260028201550155611de282600754610a61565b6007553386526008602052828620611dfb838254610a61565b905560035416803b15610553578251632142170760e11b8152306004820152336024820152604481018590529086908290606490829084905af18015611ec557611e75575b507f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc692939450815193845260208401523392a2565b67ffffffffffffffff8111611eb157825292935083927f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc6611e40565b634e487b7160e01b86526041600452602486fd5b83513d88823e3d90fd5b600f544210611fbd57600a54600f544211611f6a575b33611ef4575b50610973611fc1565b60005b818110611f045750611eeb565b80611f106001926108fb565b838060a01b0391549060031b1c16611f28813361134c565b81600052602091601283526040918260002033600052845282600020556000526010825280600020549160118152816000209033600052526000205501611ef7565b6000805b828110611f87575050611f7f611274565b600f55611ee5565b80611f936001926108fb565b838060a01b0391549060031b1c16611faa81611289565b9084526010602052604084205501611f6e565b6109735b600a5460005b818110611fd2575050565b80611fde6001926108fb565b838060a01b0391549060031b1c16611ff6813361134c565b80612004575b505001611fc7565b8161205592600052602060128152817f540798df468d7b23d11f156fdb954cb19ad414d150722a7b6d55ba369dea792e60408060002033600052845260008181205551928584523393a33390611236565b3880611ffc56fec65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a8a2646970667358221220fd3d99808943ab7cbddfa1049201ad28aa8ef20ce7083efd6159c59467bef59d64736f6c63430008110033a2646970667358221220dd4a6f180755872fc93c43f1afa6413d391adbc7cad117a99c3770852498fec564736f6c63430008110033