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:0xdb018e3b6f4af289b21a5760fcaa034185301a0a|verified:true|block:23437937|tx:0x8c955eb62c0780d9f14b4e4434ecca20d4cdb5e57800a02ca7f5fa9c667bad4c|first_check:1758792248

Submitted on: 2025-09-25 11:24:09

Comments

Log in to comment.

No comments yet.