creation_sourcecode: {{
    "language": "Solidity",
    "settings": {
      "evmVersion": "paris",
      "libraries": {},
      "metadata": {
        "bytecodeHash": "ipfs",
        "useLiteralContent": true
      },
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "remappings": [],
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      }
    },
    "sources": {
      "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\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 amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` 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 amount) external returns (bool);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the symbol of the token.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the decimals places of the token.\n     */\n    function decimals() external view returns (uint8);\n}\n"
      },
      "@venusprotocol/solidity-utilities/contracts/validators.sol": {
        "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\n/// @notice Thrown if the supplied address is a zero address where it is not allowed\nerror ZeroAddressNotAllowed();\n\n/// @notice Thrown if the supplied value is 0 where it is not allowed\nerror ZeroValueNotAllowed();\n\n/// @notice Checks if the provided address is nonzero, reverts otherwise\n/// @param address_ Address to check\n/// @custom:error ZeroAddressNotAllowed is thrown if the provided address is a zero address\nfunction ensureNonzeroAddress(address address_) pure {\n    if (address_ == address(0)) {\n        revert ZeroAddressNotAllowed();\n    }\n}\n\n/// @notice Checks if the provided value is nonzero, reverts otherwise\n/// @param value_ Value to check\n/// @custom:error ZeroValueNotAllowed is thrown if the provided value is 0\nfunction ensureNonzeroValue(uint256 value_) pure {\n    if (value_ == 0) {\n        revert ZeroValueNotAllowed();\n    }\n}\n"
      },
      "contracts/interfaces/OracleInterface.sol": {
        "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\ninterface OracleInterface {\n    function getPrice(address asset) external view returns (uint256);\n}\n\ninterface ResilientOracleInterface is OracleInterface {\n    function updatePrice(address vToken) external;\n\n    function updateAssetPrice(address asset) external;\n\n    function getUnderlyingPrice(address vToken) external view returns (uint256);\n}\n\ninterface TwapInterface is OracleInterface {\n    function updateTwap(address asset) external returns (uint256);\n}\n\ninterface BoundValidatorInterface {\n    function validatePriceWithAnchorPrice(\n        address asset,\n        uint256 reporterPrice,\n        uint256 anchorPrice\n    ) external view returns (bool);\n}\n"
      },
      "contracts/oracles/OneJumpOracle.sol": {
        "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { CorrelatedTokenOracle } from \"./common/CorrelatedTokenOracle.sol\";\nimport { ensureNonzeroAddress } from \"@venusprotocol/solidity-utilities/contracts/validators.sol\";\nimport { OracleInterface } from \"../interfaces/OracleInterface.sol\";\nimport { IERC20Metadata } from \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\n\n/**\n * @title OneJumpOracle\n * @author Venus\n * @notice This oracle fetches the price of an asset in through an intermediate asset\n */\ncontract OneJumpOracle is CorrelatedTokenOracle {\n    /// @notice Address of the intermediate oracle\n    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n    OracleInterface public immutable INTERMEDIATE_ORACLE;\n\n    /// @notice Constructor for the implementation contract.\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor(\n        address correlatedToken,\n        address underlyingToken,\n        address resilientOracle,\n        address intermediateOracle\n    ) CorrelatedTokenOracle(correlatedToken, underlyingToken, resilientOracle) {\n        ensureNonzeroAddress(intermediateOracle);\n        INTERMEDIATE_ORACLE = OracleInterface(intermediateOracle);\n    }\n\n    /**\n     * @notice Fetches the amount of the underlying token for 1 correlated token, using the intermediate oracle\n     * @return amount The amount of the underlying token for 1 correlated token scaled by the underlying token decimals\n     */\n    function _getUnderlyingAmount() internal view override returns (uint256) {\n        uint256 underlyingDecimals = IERC20Metadata(UNDERLYING_TOKEN).decimals();\n        uint256 correlatedDecimals = IERC20Metadata(CORRELATED_TOKEN).decimals();\n\n        uint256 underlyingAmount = INTERMEDIATE_ORACLE.getPrice(CORRELATED_TOKEN);\n\n        return (underlyingAmount * (10 ** correlatedDecimals)) / (10 ** (36 - underlyingDecimals));\n    }\n}\n"
      },
      "contracts/oracles/common/CorrelatedTokenOracle.sol": {
        "content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { OracleInterface } from \"../../interfaces/OracleInterface.sol\";\nimport { ensureNonzeroAddress } from \"@venusprotocol/solidity-utilities/contracts/validators.sol\";\nimport { IERC20Metadata } from \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\n\n/**\n * @title CorrelatedTokenOracle\n * @notice This oracle fetches the price of a token that is correlated to another token.\n */\nabstract contract CorrelatedTokenOracle is OracleInterface {\n    /// @notice Address of the correlated token\n    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n    address public immutable CORRELATED_TOKEN;\n\n    /// @notice Address of the underlying token\n    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n    address public immutable UNDERLYING_TOKEN;\n\n    /// @notice Address of Resilient Oracle\n    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n    OracleInterface public immutable RESILIENT_ORACLE;\n\n    /// @notice Thrown if the token address is invalid\n    error InvalidTokenAddress();\n\n    /// @notice Constructor for the implementation contract.\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor(address correlatedToken, address underlyingToken, address resilientOracle) {\n        ensureNonzeroAddress(correlatedToken);\n        ensureNonzeroAddress(underlyingToken);\n        ensureNonzeroAddress(resilientOracle);\n        CORRELATED_TOKEN = correlatedToken;\n        UNDERLYING_TOKEN = underlyingToken;\n        RESILIENT_ORACLE = OracleInterface(resilientOracle);\n    }\n\n    /**\n     * @notice Fetches the price of the correlated token\n     * @param asset Address of the correlated token\n     * @return price The price of the correlated token in scaled decimal places\n     */\n    function getPrice(address asset) external view override returns (uint256) {\n        if (asset != CORRELATED_TOKEN) revert InvalidTokenAddress();\n\n        // get underlying token amount for 1 correlated token scaled by underlying token decimals\n        uint256 underlyingAmount = _getUnderlyingAmount();\n\n        // oracle returns (36 - asset decimal) scaled price\n        uint256 underlyingUSDPrice = RESILIENT_ORACLE.getPrice(UNDERLYING_TOKEN);\n\n        IERC20Metadata token = IERC20Metadata(CORRELATED_TOKEN);\n        uint256 decimals = token.decimals();\n\n        // underlyingAmount (for 1 correlated token) * underlyingUSDPrice / decimals(correlated token)\n        return (underlyingAmount * underlyingUSDPrice) / (10 ** decimals);\n    }\n\n    /**\n     * @notice Gets the underlying amount for correlated token\n     * @return underlyingAmount Amount of underlying token\n     */\n    function _getUnderlyingAmount() internal view virtual returns (uint256);\n}\n"
      }
    }
  }}