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:0x12455ba1433df897b1b4b79279c19c14f4540d9c|verified:true|block:23544066|tx:0x9d918710d563035849072bf1a97bfad40de67e6589ca4b640355e3cd0a377d1b|first_check:1760082557

Submitted on: 2025-10-10 09:49:17

Comments

Log in to comment.

No comments yet.