Skip to content
Verified contractExactGPL-3.0-or-later

ConstPriceOracle

Address0x5afd582205fa12a4a4fd9aa8e1d072f7faae7a4c
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.6.12

 

Same code

Only this contract

 

Details

Compiler
solc 0.6.12+commit.27d51765
Language
solidity
Optimization
Yes, 200 runs
License
GPL-3.0-or-later
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
21,791,880
Creation transaction
0xa18df136e0…081637642d

contracts/oracle/ConstPriceOracle.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.6.10 <0.8.0;

import "../interfaces/ITwapOracleV2.sol";

/// @title Constant Price oracle
/// @author Tranchess
contract ConstPriceOracle is ITwapOracleV2 {
    uint256 public immutable price;

    constructor(uint256 price_) public {
        price = price_;
    }

    /// @notice Return the constant price with 18 decimal places.
    function getLatest() external view override returns (uint256) {
        return price;
    }

    /// @notice For constant price oracle, we keep the `getTwap` interface
    ///         compatible but it only returns the constant price.
    function getTwap(uint256) external view override returns (uint256) {
        return price;
    }
}

contracts/interfaces/ITwapOracle.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.6.10 <0.8.0;

interface ITwapOracle {
    enum UpdateType {
        PRIMARY,
        SECONDARY,
        OWNER,
        CHAINLINK,
        UNISWAP_V2
    }

    function getTwap(uint256 timestamp) external view returns (uint256);
}

contracts/interfaces/ITwapOracleV2.sol

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.6.10 <0.8.0;

import "./ITwapOracle.sol";

interface ITwapOracleV2 is ITwapOracle {
    function getLatest() external view returns (uint256);
}
Compiler settingsShow
{
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  }
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.