creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "src/RewardLoaderLock.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\n// contracts\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n// interfaces\nimport \"./interfaces/IRewardLoaderLock.sol\";\nimport \"./interfaces/IStandardRewardInterface.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\n/**\n@title RewardLoaderLock\n@notice Contract for distributing rewards to the lock pool with USA tokens and DEDPRZ NFTS. Passive and gas efficient rewards farming.\n@author github @bullishpaisa\n */\ncontract RewardLoaderLock is IRewardLoaderLock, Ownable {\n    string public constant LABEL_CONTRACT = \"RewardLoaderLock NFT\";\n\n    IERC20 public immutable rewardToken_USA_1;\n\n    IERC20 public immutable rewardToken_WETH_2;\n\n    IERC20 public immutable rewardToken_Stable_3;\n\n    // reward contracts\n    IStandardRewardInterface public immutable rewardContract;\n\n    mapping(address => bool) public onlyDistributor;\n\n    // Modifiers\n\n    modifier onlyDistributorAllowed() {\n        require(\n            onlyDistributor[msg.sender],\n            \"RewardLoaderLock: caller not allowed\"\n        );\n        _;\n    }\n\n    constructor(\n        address _rewardToken_USA_1,\n        address _rewardToken_WETH_2,\n        address _rewardToken_Stable_3,\n        address _owner,\n        address _erc20LockUSA\n    ) Ownable(_owner) {\n        rewardToken_USA_1 = IERC20(_rewardToken_USA_1);\n        rewardToken_WETH_2 = IERC20(_rewardToken_WETH_2);\n        rewardToken_Stable_3 = IERC20(_rewardToken_Stable_3);\n        onlyDistributor[_owner] = true;\n        rewardContract = IStandardRewardInterface(_erc20LockUSA);\n    }\n\n    function transferRewardToUsaLockStake() external onlyDistributorAllowed {\n        // check that the contract has been set\n        require(\n            address(rewardContract) != address(0),\n            \"RewardLoaderLock: rewardContract not set\"\n        );\n\n        // transfer the complete balance of the reward tokens to the reward contract\n        uint256 amount_usa_1 = rewardToken_USA_1.balanceOf(address(this));\n        uint256 amount_weth_2 = rewardToken_WETH_2.balanceOf(address(this));\n        uint256 amount_stable_3 = rewardToken_Stable_3.balanceOf(address(this));\n\n        if (amount_usa_1 == 0 && amount_weth_2 == 0 && amount_stable_3 == 0) {\n            return;\n        }\n\n        // if the amount is not 0, approve the reward contract to spend the amount for usa\n        if (amount_usa_1 > 0) {\n            rewardToken_USA_1.approve(address(rewardContract), amount_usa_1);\n        }\n\n        if (amount_weth_2 > 0) {\n            rewardToken_WETH_2.approve(address(rewardContract), amount_weth_2);\n        }\n\n        if (amount_stable_3 > 0) {\n            rewardToken_Stable_3.approve(\n                address(rewardContract),\n                amount_stable_3\n            );\n        }\n\n        rewardContract.distributeRewardsForLatestPeriod(\n            amount_usa_1,\n            amount_weth_2,\n            amount_stable_3\n        );\n\n        emit TransferRewardToUsaLockStake(\n            amount_usa_1,\n            amount_weth_2,\n            amount_stable_3\n        );\n    }\n\n    function finalizePeriodNoRewards() external onlyDistributorAllowed {\n        // check that the contract has been set\n        require(\n            address(rewardContract) != address(0),\n            \"RewardLoaderLock: rewardContract not set\"\n        );\n\n        rewardContract.distributeRewardsForLatestPeriod(0, 0, 0);\n\n        emit TransferRewardToUsaLockStake(0, 0, 0);\n    }\n\n    // withdaw all rewards from the contract\n    function withdrawAllRewards() external onlyDistributorAllowed {\n        // transfer the amount to the owner\n\n        uint256 amount_usa_1_ = rewardToken_USA_1.balanceOf(address(this));\n\n        rewardToken_USA_1.transfer(owner(), amount_usa_1_);\n\n        uint256 amount_weth_2_ = rewardToken_WETH_2.balanceOf(address(this));\n\n        rewardToken_WETH_2.transfer(owner(), amount_weth_2_);\n\n        uint256 amount_stable_3_ = rewardToken_Stable_3.balanceOf(\n            address(this)\n        );\n\n        rewardToken_Stable_3.transfer(owner(), amount_stable_3_);\n\n        emit RewardsWithdrawnToOwner(\n            amount_usa_1_,\n            amount_weth_2_,\n            amount_stable_3_\n        );\n    }\n\n    // function that withdraws any token from the contract (all of them)\n    function withdrawToken(address token) external onlyOwner {\n        IERC20 _token = IERC20(token);\n        _token.transfer(owner(), _token.balanceOf(address(this)));\n\n        emit TokenWithdrawnManualAllToOwner(\n            token,\n            _token.balanceOf(address(this))\n        );\n    }\n\n    // Configuration functions\n\n    function addDistributor(\n        address _distributor,\n        bool _setting\n    ) external onlyOwner {\n        onlyDistributor[_distributor] = _setting;\n        emit DistributorAdded(_distributor, _setting);\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/access/Ownable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n    address private _owner;\n\n    /**\n     * @dev The caller account is not authorized to perform an operation.\n     */\n    error OwnableUnauthorizedAccount(address account);\n\n    /**\n     * @dev The owner is not a valid owner account. (eg. `address(0)`)\n     */\n    error OwnableInvalidOwner(address owner);\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n     */\n    constructor(address initialOwner) {\n        if (initialOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(initialOwner);\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        if (owner() != _msgSender()) {\n            revert OwnableUnauthorizedAccount(_msgSender());\n        }\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby disabling any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        if (newOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
      },
      "src/interfaces/IRewardLoaderLock.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\ninterface IRewardLoaderLock {\n    event TransferRewardToUsaLockStake(\n        uint256 amount_usa_1,\n        uint256 amount_weth_2,\n        uint256 amount_stable_3\n    );\n\n    event RewardsWithdrawnToOwner(\n        uint256 amount_usa_1,\n        uint256 amount_weth_2,\n        uint256 amount_stable_3\n    );\n\n    event TokenWithdrawnManualAllToOwner(address token, uint256 amount);\n\n    event DistributorAdded(address distributor, bool setting);\n}\n"
      },
      "src/interfaces/IStandardRewardInterface.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\ninterface IStandardRewardInterface {\n    function distributeRewardsForLatestPeriod(\n        uint256 _amountReward_USA_1,\n        uint256 _amountReward_WETH_2,\n        uint256 _amountReward_Stable_3\n    ) external;\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC-20 standard as defined in the ERC.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the value of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the value of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 value) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n     * caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 value) external returns (bool);\n\n    /**\n     * @dev Moves a `value` amount of tokens from `from` to `to` using the\n     * allowance mechanism. `value` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/Context.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    function _contextSuffixLength() internal view virtual returns (uint256) {\n        return 0;\n    }\n}\n"
      }
    },
    "settings": {
      "remappings": [
        "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
        "forge-std/=lib/forge-std/src/",
        "@delta/=lib/ERC1155Delta/contracts/",
        "solady/=lib/solady/",
        "@chainlink/=lib/ERC1155Delta/node_modules/@chainlink/",
        "@ensdomains/=lib/ERC1155Delta/node_modules/@ensdomains/",
        "@eth-optimism/=lib/ERC1155Delta/node_modules/@eth-optimism/contracts/",
        "ERC1155Delta/=lib/ERC1155Delta/contracts/",
        "closedsea/=lib/ERC1155Delta/node_modules/closedsea/src/",
        "ds-test/=lib/forge-std/lib/ds-test/src/",
        "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
        "erc721a/=lib/ERC1155Delta/node_modules/erc721a/contracts/",
        "erc721psi/=lib/ERC1155Delta/node_modules/erc721psi/contracts/",
        "eth-gas-reporter/=lib/ERC1155Delta/node_modules/eth-gas-reporter/",
        "hardhat/=lib/ERC1155Delta/node_modules/hardhat/",
        "openzeppelin-contracts/=lib/openzeppelin-contracts/",
        "solidity-bits/=lib/ERC1155Delta/node_modules/solidity-bits/contracts/"
      ],
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "metadata": {
        "useLiteralContent": false,
        "bytecodeHash": "ipfs",
        "appendCBOR": true
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "evmVersion": "paris",
      "viaIR": false,
      "libraries": {}
    }
  }}