DIAOracle

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/DIAOracle.sol

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

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

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

        uint256 oracleScalar = 10 ** (36 - decimals);

        return currPrice * oracleScalar;
    }
}

Tags:
DeFi, Oracle|addr:0xd218cf7c4367e27bd709b6b40c562e01e9de6e2c|verified:true|block:23544001|tx:0x36d1f3bd4992be58866658c01b6783b0477c9e543b76641210320dccc9286477|first_check:1760082286

Submitted on: 2025-10-10 09:44:46

Comments

Log in to comment.

No comments yet.