File size: 8,554 Bytes
f998fcd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{
  "language": "Solidity",
  "sources": {
    "contracts/oracle/adapter/CurveLPMetaPoolAdapter.sol": {
      "content": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.1;\r\n\r\nimport \"./NormalizingOracleAdapter.sol\";\r\nimport \"../../interfaces/ICurvePool.sol\";\r\n\r\ncontract CurveLPMetaPoolAdapter is NormalizingOracleAdapter {\r\n    ICurvePool public immutable curvePool;\r\n\r\n    constructor(\r\n        string memory _assetName,\r\n        string memory _assetSymbol,\r\n        address _asset,\r\n        address _curvePool\r\n    ) NormalizingOracleAdapter(_assetName, _assetSymbol, _asset, 18, 8) {\r\n        require(address(_curvePool) != address(0), \"invalid oracle\");\r\n        curvePool = ICurvePool(_curvePool);\r\n    }\r\n\r\n    function latestAnswer() external view override returns (int256) {\r\n        uint256 price = _normalize(curvePool.get_virtual_price());\r\n        return int256(price);\r\n    }\r\n}\r\n"
    },
    "contracts/oracle/adapter/NormalizingOracleAdapter.sol": {
      "content": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.1;\r\nimport \"./AssetOracleAdapter.sol\";\r\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\r\nimport \"../../token/IERC20Details.sol\";\r\n\r\nabstract contract NormalizingOracleAdapter is AssetOracleAdapter, Ownable {\r\n    uint256 public _inputDecimals;\r\n    uint256 public _outputDecimals;\r\n\r\n    constructor(\r\n        string memory _assetName,\r\n        string memory _assetSymbol,\r\n        address _asset,\r\n        uint256 __inputDecimals,\r\n        uint256 __outputDecimlas\r\n    ) AssetOracleAdapter(_assetName, _assetSymbol, _asset) {\r\n        _inputDecimals = __inputDecimals;\r\n        _outputDecimals = __outputDecimlas;\r\n    }\r\n\r\n    function getInputDecimals() public view returns (uint256) {\r\n        return _inputDecimals;\r\n    }\r\n\r\n    function setInputDecimals(uint256 __inputDecimals) public onlyOwner {\r\n        _inputDecimals = __inputDecimals;\r\n    }\r\n\r\n    function getOutputDecimals() public view returns (uint256) {\r\n        return _outputDecimals;\r\n    }\r\n\r\n    function setOutputDecimals(uint256 __outputDecimals) public onlyOwner {\r\n        _outputDecimals = __outputDecimals;\r\n    }\r\n\r\n    /// @dev scales the input to from `_inputDecimals` to `_outputDecimals` decimal places\r\n    function _normalize(uint256 _amount) internal view returns (uint256) {\r\n        if (_inputDecimals >= _outputDecimals) {\r\n            return _amount / 10**(_inputDecimals - _outputDecimals);\r\n        } else {\r\n            return _amount * (10**(_outputDecimals - _inputDecimals));\r\n        }\r\n    }\r\n}\r\n"
    },
    "contracts/interfaces/ICurvePool.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.1;\n\n// solhint-disable\n\ninterface ICurvePool {\n    function get_virtual_price() external view returns (uint256);\n\n    function balances(uint256 arg0) external view returns (uint256);\n\n    function price_oracle(uint256) external view returns (uint256);\n}\n"
    },
    "contracts/oracle/adapter/AssetOracleAdapter.sol": {
      "content": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.1;\r\nimport \"../../interfaces/IOracle.sol\";\r\n\r\nabstract contract AssetOracleAdapter is IOracle {\r\n    string public assetName;\r\n    /// @dev asset symbol\r\n    string public assetSymbol;\r\n    /// @dev admin allowed to update price oracle\r\n    /// @notice the asset with the price oracle\r\n    address public immutable asset;\r\n\r\n    constructor(\r\n        string memory _assetName,\r\n        string memory _assetSymbol,\r\n        address _asset\r\n    ) {\r\n        require(_asset != address(0), \"invalid asset\");\r\n        assetName = _assetName;\r\n        assetSymbol = _assetSymbol;\r\n        asset = _asset;\r\n    }\r\n}\r\n"
    },
    "@openzeppelin/contracts/access/Ownable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\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 * By default, the owner account will be the one that deploys the contract. This\n * can 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    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    constructor () {\n        address msgSender = _msgSender();\n        _owner = msgSender;\n        emit OwnershipTransferred(address(0), msgSender);\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 called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n        _;\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        emit OwnershipTransferred(_owner, address(0));\n        _owner = 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        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        emit OwnershipTransferred(_owner, newOwner);\n        _owner = newOwner;\n    }\n}\n"
    },
    "contracts/token/IERC20Details.sol": {
      "content": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.1;\r\n\r\ninterface IERC20Details {\r\n    function name() external view returns (string memory);\r\n\r\n    function symbol() external view returns (string memory);\r\n\r\n    function decimals() external view returns (uint8);\r\n}\r\n"
    },
    "contracts/interfaces/IOracle.sol": {
      "content": "// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.1;\r\n\r\ninterface IOracle {\r\n    /// @notice Price update event\r\n    /// @param asset the asset\r\n    /// @param newPrice price of the asset\r\n    event PriceUpdated(address asset, uint256 newPrice);\r\n\r\n    /// @dev returns latest answer\r\n    function latestAnswer() external view returns (int256);\r\n\r\n}\r\n"
    },
    "@openzeppelin/contracts/utils/Context.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\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        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n        return msg.data;\n    }\n}\n"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 500
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "metadata": {
      "useLiteralContent": true
    },
    "libraries": {}
  }
}