File size: 17,724 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
{
  "language": "Solidity",
  "sources": {
    "src/contracts/oracles/FPIOracle.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.17;\n\nimport \"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol\";\nimport \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\nimport \"../interfaces/IFPIControllerPool.sol\";\n\ncontract FPIOracle is AggregatorV3Interface {\n    using SafeCast for uint256;\n\n    IFPIControllerPool public immutable fpiControllerPool;\n    uint8 public immutable FPI_ORACLE_DECIMALS;\n\n    constructor(address _fpiControllerPoolAddress, uint8 _fpiOracleDecimals) {\n        fpiControllerPool = IFPIControllerPool(_fpiControllerPoolAddress);\n        FPI_ORACLE_DECIMALS = _fpiOracleDecimals;\n    }\n\n    /// @notice The ```decimals``` function represents the number of decimals the aggregator responses represent.\n    function decimals() external view returns (uint8) {\n        return FPI_ORACLE_DECIMALS;\n    }\n\n    /// @notice The ```description``` function retuns the items represented as Item / Units\n    function description() external pure returns (string memory) {\n        return \"FPI / USD\";\n    }\n\n    function version() external pure returns (uint256) {\n        return 1;\n    }\n\n    function getRoundData(uint80 _roundId)\n        external\n        pure\n        returns (\n            uint80 roundId,\n            int256 answer,\n            uint256 startedAt,\n            uint256 updatedAt,\n            uint80 answeredInRound\n        )\n    {\n        revert(\"No Implementation for getRoundData\");\n    }\n\n    function latestRoundData()\n        external\n        view\n        returns (\n            uint80 roundId,\n            int256 answer,\n            uint256 startedAt,\n            uint256 updatedAt,\n            uint80 answeredInRound\n        )\n    {\n        roundId = 0;\n        startedAt = 0;\n        updatedAt = 0;\n        answeredInRound = 0;\n\n        answer = fpiControllerPool.getFPIPriceE18().toInt256();\n    }\n}\n"
    },
    "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface AggregatorV3Interface {\n  function decimals() external view returns (uint8);\n\n  function description() external view returns (string memory);\n\n  function version() external view returns (uint256);\n\n  // getRoundData and latestRoundData should both raise \"No data present\"\n  // if they do not have data to report, instead of returning unset values\n  // which could be misinterpreted as actual reported values.\n  function getRoundData(uint80 _roundId)\n    external\n    view\n    returns (\n      uint80 roundId,\n      int256 answer,\n      uint256 startedAt,\n      uint256 updatedAt,\n      uint80 answeredInRound\n    );\n\n  function latestRoundData()\n    external\n    view\n    returns (\n      uint80 roundId,\n      int256 answer,\n      uint256 startedAt,\n      uint256 updatedAt,\n      uint80 answeredInRound\n    );\n}\n"
    },
    "@openzeppelin/contracts/utils/math/SafeCast.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n *\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\n * all math on `uint256` and `int256` and then downcasting.\n */\nlibrary SafeCast {\n    /**\n     * @dev Returns the downcasted uint224 from uint256, reverting on\n     * overflow (when the input is greater than largest uint224).\n     *\n     * Counterpart to Solidity's `uint224` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 224 bits\n     */\n    function toUint224(uint256 value) internal pure returns (uint224) {\n        require(value <= type(uint224).max, \"SafeCast: value doesn't fit in 224 bits\");\n        return uint224(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint128 from uint256, reverting on\n     * overflow (when the input is greater than largest uint128).\n     *\n     * Counterpart to Solidity's `uint128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     */\n    function toUint128(uint256 value) internal pure returns (uint128) {\n        require(value <= type(uint128).max, \"SafeCast: value doesn't fit in 128 bits\");\n        return uint128(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint96 from uint256, reverting on\n     * overflow (when the input is greater than largest uint96).\n     *\n     * Counterpart to Solidity's `uint96` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 96 bits\n     */\n    function toUint96(uint256 value) internal pure returns (uint96) {\n        require(value <= type(uint96).max, \"SafeCast: value doesn't fit in 96 bits\");\n        return uint96(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint64 from uint256, reverting on\n     * overflow (when the input is greater than largest uint64).\n     *\n     * Counterpart to Solidity's `uint64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     */\n    function toUint64(uint256 value) internal pure returns (uint64) {\n        require(value <= type(uint64).max, \"SafeCast: value doesn't fit in 64 bits\");\n        return uint64(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint32 from uint256, reverting on\n     * overflow (when the input is greater than largest uint32).\n     *\n     * Counterpart to Solidity's `uint32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     */\n    function toUint32(uint256 value) internal pure returns (uint32) {\n        require(value <= type(uint32).max, \"SafeCast: value doesn't fit in 32 bits\");\n        return uint32(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint16 from uint256, reverting on\n     * overflow (when the input is greater than largest uint16).\n     *\n     * Counterpart to Solidity's `uint16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     */\n    function toUint16(uint256 value) internal pure returns (uint16) {\n        require(value <= type(uint16).max, \"SafeCast: value doesn't fit in 16 bits\");\n        return uint16(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint8 from uint256, reverting on\n     * overflow (when the input is greater than largest uint8).\n     *\n     * Counterpart to Solidity's `uint8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits.\n     */\n    function toUint8(uint256 value) internal pure returns (uint8) {\n        require(value <= type(uint8).max, \"SafeCast: value doesn't fit in 8 bits\");\n        return uint8(value);\n    }\n\n    /**\n     * @dev Converts a signed int256 into an unsigned uint256.\n     *\n     * Requirements:\n     *\n     * - input must be greater than or equal to 0.\n     */\n    function toUint256(int256 value) internal pure returns (uint256) {\n        require(value >= 0, \"SafeCast: value must be positive\");\n        return uint256(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int128 from int256, reverting on\n     * overflow (when the input is less than smallest int128 or\n     * greater than largest int128).\n     *\n     * Counterpart to Solidity's `int128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt128(int256 value) internal pure returns (int128) {\n        require(value >= type(int128).min && value <= type(int128).max, \"SafeCast: value doesn't fit in 128 bits\");\n        return int128(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int64 from int256, reverting on\n     * overflow (when the input is less than smallest int64 or\n     * greater than largest int64).\n     *\n     * Counterpart to Solidity's `int64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt64(int256 value) internal pure returns (int64) {\n        require(value >= type(int64).min && value <= type(int64).max, \"SafeCast: value doesn't fit in 64 bits\");\n        return int64(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int32 from int256, reverting on\n     * overflow (when the input is less than smallest int32 or\n     * greater than largest int32).\n     *\n     * Counterpart to Solidity's `int32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt32(int256 value) internal pure returns (int32) {\n        require(value >= type(int32).min && value <= type(int32).max, \"SafeCast: value doesn't fit in 32 bits\");\n        return int32(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int16 from int256, reverting on\n     * overflow (when the input is less than smallest int16 or\n     * greater than largest int16).\n     *\n     * Counterpart to Solidity's `int16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     *\n     * _Available since v3.1._\n     */\n    function toInt16(int256 value) internal pure returns (int16) {\n        require(value >= type(int16).min && value <= type(int16).max, \"SafeCast: value doesn't fit in 16 bits\");\n        return int16(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int8 from int256, reverting on\n     * overflow (when the input is less than smallest int8 or\n     * greater than largest int8).\n     *\n     * Counterpart to Solidity's `int8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits.\n     *\n     * _Available since v3.1._\n     */\n    function toInt8(int256 value) internal pure returns (int8) {\n        require(value >= type(int8).min && value <= type(int8).max, \"SafeCast: value doesn't fit in 8 bits\");\n        return int8(value);\n    }\n\n    /**\n     * @dev Converts an unsigned uint256 into a signed int256.\n     *\n     * Requirements:\n     *\n     * - input must be less than or equal to maxInt256.\n     */\n    function toInt256(uint256 value) internal pure returns (int256) {\n        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n        require(value <= uint256(type(int256).max), \"SafeCast: value doesn't fit in an int256\");\n        return int256(value);\n    }\n}\n"
    },
    "src/contracts/interfaces/IFPIControllerPool.sol": {
      "content": "// SPDX-License-Identifier: ISC\npragma solidity >=0.8.17;\n\n// NOTE: This file generated from FPIController contract at https://etherscan.io/address/0x2397321b301B80A1C0911d6f9ED4b6033d43cF51#code\n\ninterface IFPIControllerPool {\n    function FEE_PRECISION() external view returns (uint256);\n\n    function FPI_TKN() external view returns (address);\n\n    function FRAX() external view returns (address);\n\n    function PEG_BAND_PRECISION() external view returns (uint256);\n\n    function PRICE_PRECISION() external view returns (uint256);\n\n    function TWAMM() external view returns (address);\n\n    function acceptOwnership() external;\n\n    function addAMO(address amo_address) external;\n\n    function amos(address) external view returns (bool);\n\n    function amos_array(uint256) external view returns (address);\n\n    function burnFPI(bool burn_all, uint256 fpi_amount) external;\n\n    function calcMintFPI(uint256 frax_in, uint256 min_fpi_out) external view returns (uint256 fpi_out);\n\n    function calcRedeemFPI(uint256 fpi_in, uint256 min_frax_out) external view returns (uint256 frax_out);\n\n    function cancelCurrTWAMMOrder(uint256 order_id_override) external;\n\n    function chainlink_fpi_usd_decimals() external view returns (uint256);\n\n    function chainlink_frax_usd_decimals() external view returns (uint256);\n\n    function collectCurrTWAMMProceeds(uint256 order_id_override) external;\n\n    function cpiTracker() external view returns (address);\n\n    function dollarBalances() external view returns (uint256 frax_val_e18, uint256 collat_val_e18);\n\n    function fpi_mint_cap() external view returns (uint256);\n\n    function frax_borrow_cap() external view returns (int256);\n\n    function frax_borrowed_balances(address) external view returns (int256);\n\n    function frax_borrowed_sum() external view returns (int256);\n\n    function frax_is_token0() external view returns (bool);\n\n    function getFPIPriceE18() external view returns (uint256);\n\n    function getFRAXPriceE18() external view returns (uint256);\n\n    function getReservesAndFPISpot()\n        external\n        returns (\n            uint256 reserveFRAX,\n            uint256 reserveFPI,\n            uint256 fpi_price\n        );\n\n    function giveFRAXToAMO(address destination_amo, uint256 frax_amount) external;\n\n    function last_order_id_twamm() external view returns (uint256);\n\n    function max_swap_fpi_amt_in() external view returns (uint256);\n\n    function max_swap_frax_amt_in() external view returns (uint256);\n\n    function mintFPI(uint256 frax_in, uint256 min_fpi_out) external returns (uint256 fpi_out);\n\n    function mint_fee() external view returns (uint256 fee);\n\n    function mint_fee_manual() external view returns (uint256);\n\n    function mint_fee_multiplier() external view returns (uint256);\n\n    function mints_paused() external view returns (bool);\n\n    function nominateNewOwner(address _owner) external;\n\n    function nominatedOwner() external view returns (address);\n\n    function num_twamm_intervals() external view returns (uint256);\n\n    function owner() external view returns (address);\n\n    function pegStatusMntRdm()\n        external\n        view\n        returns (\n            uint256 cpi_peg_price,\n            uint256 diff_frac_abs,\n            bool within_range\n        );\n\n    function peg_band_mint_redeem() external view returns (uint256);\n\n    function peg_band_twamm() external view returns (uint256);\n\n    function pending_twamm_order() external view returns (bool);\n\n    function priceFeedFPIUSD() external view returns (address);\n\n    function priceFeedFRAXUSD() external view returns (address);\n\n    function price_info()\n        external\n        view\n        returns (\n            int256 collat_imbalance,\n            uint256 cpi_peg_price,\n            uint256 fpi_price,\n            uint256 price_diff_frac_abs\n        );\n\n    function receiveFRAXFromAMO(uint256 frax_amount) external;\n\n    function recoverERC20(address tokenAddress, uint256 tokenAmount) external;\n\n    function redeemFPI(uint256 fpi_in, uint256 min_frax_out) external returns (uint256 frax_out);\n\n    function redeem_fee() external view returns (uint256 fee);\n\n    function redeem_fee_manual() external view returns (uint256);\n\n    function redeem_fee_multiplier() external view returns (uint256);\n\n    function redeems_paused() external view returns (bool);\n\n    function removeAMO(address amo_address) external;\n\n    function setFraxBorrowCap(int256 _frax_borrow_cap) external;\n\n    function setMintCap(uint256 _fpi_mint_cap) external;\n\n    function setMintRedeemFees(\n        bool _use_manual_mint_fee,\n        uint256 _mint_fee_manual,\n        uint256 _mint_fee_multiplier,\n        bool _use_manual_redeem_fee,\n        uint256 _redeem_fee_manual,\n        uint256 _redeem_fee_multiplier\n    ) external;\n\n    function setOracles(\n        address _frax_oracle,\n        address _fpi_oracle,\n        address _cpi_oracle\n    ) external;\n\n    function setPegBands(uint256 _peg_band_mint_redeem, uint256 _peg_band_twamm) external;\n\n    function setTWAMMAndSwapPeriod(address _twamm_addr, uint256 _swap_period) external;\n\n    function setTWAMMMaxSwapIn(uint256 _max_swap_frax_amt_in, uint256 _max_swap_fpi_amt_in) external;\n\n    function setTimelock(address _new_timelock_address) external;\n\n    function swap_period() external view returns (uint256);\n\n    function timelock_address() external view returns (address);\n\n    function toggleMints() external;\n\n    function toggleRedeems() external;\n\n    function twammManual(\n        uint256 frax_sell_amt,\n        uint256 fpi_sell_amt,\n        uint256 override_intervals\n    ) external returns (uint256 frax_to_use, uint256 fpi_to_use);\n\n    function use_manual_mint_fee() external view returns (bool);\n\n    function use_manual_redeem_fee() external view returns (bool);\n}\n"
    }
  },
  "settings": {
    "metadata": {
      "bytecodeHash": "none"
    },
    "optimizer": {
      "enabled": true,
      "runs": 10000
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "libraries": {}
  }
}