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:0x4450a2a20159d2c57073ca2ecf73406eb8f7832d|verified:true|block:23386429|tx:0x0a53f62db066c0680683a35ed93e87a9750a038b047fb41a66c7c36643e9126d|first_check:1758187891

Submitted on: 2025-09-18 11:31:32

Comments

Log in to comment.

No comments yet.