creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "src/stats/ChainlinkStatsUpkeepV3.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n// Copyright (c) 2023 Tokemak Foundation. All rights reserved.\npragma solidity 0.8.17;\n\nimport { IStatsCalculator } from \"src/interfaces/stats/IStatsCalculator.sol\";\n\ncontract ChainlinkStatsUpkeepV3 {\n    function checkUpkeep(bytes calldata checkData)\n        external\n        view\n        returns (bool upkeepNeeded, bytes memory performData)\n    {\n        (address[] memory addrs) = abi.decode(checkData, (address[]));\n        address[] memory found = new address[](addrs.length);\n        uint256 count = 0;\n\n        for (uint256 i = 0; i < addrs.length; i++) {\n            IStatsCalculator calc = IStatsCalculator(addrs[i]);\n\n            try calc.shouldSnapshot() returns (bool shouldSnapshot) {\n                if (shouldSnapshot) {\n                    ++count;\n                    found[i] = address(addrs[i]);\n                }\n            } catch { }\n        }\n\n        address[] memory trimmed = new address[](count);\n        uint256 ix = 0;\n        for (uint256 i = 0; i < addrs.length; i++) {\n            if (found[i] != address(0)) {\n                trimmed[ix] = found[i];\n                ix++;\n            }\n        }\n        upkeepNeeded = count > 0;\n        performData = abi.encode(trimmed);\n    }\n\n    function performUpkeep(bytes calldata performData) external {\n        (address[] memory addrs) = abi.decode(performData, (address[]));\n        for (uint256 i = 0; i < addrs.length; i++) {\n            IStatsCalculator calc = IStatsCalculator(addrs[i]);\n            calc.snapshot();\n        }\n    }\n}\n"
      },
      "src/interfaces/stats/IStatsCalculator.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n// Copyright (c) 2023 Tokemak Foundation. All rights reserved.\npragma solidity 0.8.17;\n\n/// @title Capture information about a pool or destination\ninterface IStatsCalculator {\n    /// @notice thrown when no snapshot is taken\n    error NoSnapshotTaken();\n\n    /// @notice The id for this instance of a calculator\n    function getAprId() external view returns (bytes32);\n\n    /// @notice The id of the underlying asset/pool/destination this calculator represents\n    /// @dev This may be a generated address\n    function getAddressId() external view returns (address);\n\n    /// @notice Setup the calculator after it has been copied\n    /// @dev Should only be executed one time\n    /// @param dependentAprIds apr ids that cover the dependencies of this calculator\n    /// @param initData setup data specific to this type of calculator\n    function initialize(bytes32[] calldata dependentAprIds, bytes calldata initData) external;\n\n    /// @notice Capture stat data about this setup\n    function snapshot() external;\n\n    /// @notice Indicates if a snapshot should be taken\n    /// @return takeSnapshot if true then a snapshot should be taken. If false, calling snapshot will do nothing\n    function shouldSnapshot() external view returns (bool takeSnapshot);\n\n    /// @dev Enum representing the snapshot status for a given rewarder (Convex and Aura) or reward token (Maverick)\n    enum SnapshotStatus {\n        noSnapshot, // Indicates that no snapshot has been taken yet for the rewarder.\n        tooSoon, // Indicates that it's too soon to take another snapshot since the last one.\n        shouldFinalize, // Indicates that the conditions are met for finalizing a snapshot.\n        shouldRestart // Indicates that the conditions are met for restarting a snapshot.\n\n    }\n}\n"
      }
    },
    "settings": {
      "remappings": [
        "forge-std/=lib/forge-std/src/",
        "ds-test/=lib/forge-std/lib/ds-test/src/",
        "src/=src/",
        "test/=test/",
        "openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/",
        "erc4626-tests/=lib/erc4626-tests/",
        "prb-math/=lib/prb-math/",
        "crytic/properties/=lib/properties/",
        "ERC4626/=lib/properties/lib/ERC4626/contracts/",
        "properties/=lib/properties/contracts/",
        "solmate/=lib/properties/lib/solmate/src/",
        "usingtellor/=lib/usingtellor/contracts/"
      ],
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "metadata": {
        "useLiteralContent": false,
        "bytecodeHash": "ipfs"
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "evmVersion": "london",
      "viaIR": false,
      "libraries": {}
    }
  }}