DIAOracleConstantInversion

Description:

Decentralized Finance (DeFi) protocol contract providing Oracle functionality.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0 ^0.8.0;

// src/interfaces/IDIAOracleV2.sol

 
 interface IDIAOracleV2 {
     function getValue(string memory) external view returns (uint128, uint128);
 }

// src/interfaces/IOracle.sol

/// @title IOracle
/// @author an IMFer
/// @notice Interface that oracles used by Morpho must implement.
/// @dev It is the user's responsibility to select markets with safe oracles.
interface IOracle {
    /// @notice Returns the price of 1 asset of collateral token quoted in 1 asset of loan token, scaled by 1e36.
    /// @dev It corresponds to the price of 10**(collateral token decimals) assets of collateral token quoted in
    /// 10**(loan token decimals) assets of loan token with `36 + loan token decimals - collateral token decimals`
    /// decimals of precision.
    function price() external view returns (uint256);
}

// src/oracles/DIAOracleConstantInversion.sol

contract DIAOracleConstantInversion is IOracle {
    address public immutable oracle;
    uint256 public immutable decimals;
    string public pool;

    constructor(address _oracle, string memory _pool) {
        require(_oracle != address(0), "Invalid oracle address");
        oracle = _oracle;
        pool = _pool;
    }

    function price() external view returns (uint256) {
        (uint256 currPrice,) = IDIAOracleV2(oracle).getValue(pool);

        uint256 oracleScalar = 10 ** 36;

        return ((1 * 10 ** 12) * oracleScalar) / currPrice;
    }
}

Tags:
DeFi, Oracle|addr:0xbfc9022afbd219ce4f399dcecae96e0f6d96f8f2|verified:true|block:23532204|tx:0xf53fc20639b1a941da166de00d6deebb4efd9726fa131e77e29f75268e58ab8f|first_check:1759920042

Submitted on: 2025-10-08 12:40:42

Comments

Log in to comment.

No comments yet.