Skip to content

Commit

Permalink
Merge pull request #178 from VenusProtocol/develop
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
chechu authored Apr 10, 2024
2 parents eeabd90 + 6c29284 commit f4bc88f
Show file tree
Hide file tree
Showing 31 changed files with 228 additions and 58 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
## [2.0.0-dev.1](https://github.com/VenusProtocol/oracle/compare/v1.11.0-dev.1...v2.0.0-dev.1) (2024-04-10)


### ⚠ BREAKING CHANGES

* migrate to Solidity 0.8.25

### Features

* migrate to Solidity 0.8.25 ([00d4cd0](https://github.com/VenusProtocol/oracle/commit/00d4cd0fa799ed9b15342f1f66c15c5e8e234b5f))

## [1.11.0-dev.1](https://github.com/VenusProtocol/oracle/compare/v1.10.0...v1.11.0-dev.1) (2024-03-22)


### Features

* add Chainlink Oracle for Arbitrum checking Sequencer uptime. ([2ab8e8d](https://github.com/VenusProtocol/oracle/commit/2ab8e8d64fc3d2d8ce86464c48ba2eb4da0ff5a8))


### Bug Fixes

* VTIME-3 ([82f1e42](https://github.com/VenusProtocol/oracle/commit/82f1e429aa887ba1fdd7787cfe77bee41e4a79f4))

## [1.10.0](https://github.com/VenusProtocol/oracle/compare/v1.9.0...v1.10.0) (2024-02-22)


Expand Down
2 changes: 1 addition & 1 deletion contracts/ResilientOracle.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: 2022 Venus
pragma solidity 0.8.13;
pragma solidity 0.8.25;

import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "./interfaces/VBep20Interface.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/FeedRegistryInterface.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;
pragma solidity ^0.8.25;

interface FeedRegistryInterface {
function latestRoundDataByName(
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IStETH.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;
pragma solidity ^0.8.25;

interface IStETH {
function getPooledEthByShares(uint256 _sharesAmount) external view returns (uint256);
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/OracleInterface.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;
pragma solidity ^0.8.25;

Check warning on line 2 in contracts/interfaces/OracleInterface.sol

View workflow job for this annotation

GitHub Actions / Lint

Found more than One contract per file. 4 contracts found!

Check warning on line 2 in contracts/interfaces/OracleInterface.sol

View workflow job for this annotation

GitHub Actions / Lint

Found more than One contract per file. 4 contracts found!

interface OracleInterface {
function getPrice(address asset) external view returns (uint256);
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/PublicResolverInterface.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: 2022 Venus
pragma solidity 0.8.13;
pragma solidity ^0.8.25;

interface PublicResolverInterface {
function addr(bytes32 node) external view returns (address payable);
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/PythInterface.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2021 Pyth Data Foundation
pragma solidity 0.8.13;
pragma solidity ^0.8.25;

contract PythStructs {
// A price with a degree of uncertainty, represented as a price +- a confidence interval.
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/SIDRegistryInterface.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: 2022 Venus
pragma solidity 0.8.13;
pragma solidity ^0.8.25;

interface SIDRegistryInterface {
function resolver(bytes32 node) external view returns (address);
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/VBep20Interface.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;
pragma solidity ^0.8.25;

import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";

Check warning on line 4 in contracts/interfaces/VBep20Interface.sol

View workflow job for this annotation

GitHub Actions / Lint

global import of path @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)

Check warning on line 4 in contracts/interfaces/VBep20Interface.sol

View workflow job for this annotation

GitHub Actions / Lint

global import of path @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)

Expand Down
2 changes: 1 addition & 1 deletion contracts/oracles/BinanceOracle.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;
pragma solidity 0.8.25;

import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";

Check warning on line 4 in contracts/oracles/BinanceOracle.sol

View workflow job for this annotation

GitHub Actions / Lint

global import of path @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)

Check warning on line 4 in contracts/oracles/BinanceOracle.sol

View workflow job for this annotation

GitHub Actions / Lint

global import of path @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)
import "../interfaces/VBep20Interface.sol";

Check warning on line 5 in contracts/oracles/BinanceOracle.sol

View workflow job for this annotation

GitHub Actions / Lint

global import of path ../interfaces/VBep20Interface.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)

Check warning on line 5 in contracts/oracles/BinanceOracle.sol

View workflow job for this annotation

GitHub Actions / Lint

global import of path ../interfaces/VBep20Interface.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)
Expand Down
2 changes: 1 addition & 1 deletion contracts/oracles/BoundValidator.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;
pragma solidity 0.8.25;

import "../interfaces/VBep20Interface.sol";
import "../interfaces/OracleInterface.sol";
Expand Down
4 changes: 2 additions & 2 deletions contracts/oracles/ChainlinkOracle.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;
pragma solidity 0.8.25;

import "../interfaces/VBep20Interface.sol";
import "../interfaces/OracleInterface.sol";
Expand Down Expand Up @@ -115,7 +115,7 @@ contract ChainlinkOracle is AccessControlledV8, OracleInterface {
* @param asset Address of the asset
* @return Price in USD from Chainlink or a manually set price for the asset
*/
function getPrice(address asset) public view returns (uint256) {
function getPrice(address asset) public view virtual returns (uint256) {
uint256 decimals;

if (asset == NATIVE_TOKEN_ADDR) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/oracles/PythOracle.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;
pragma solidity 0.8.25;

import "@openzeppelin/contracts/utils/math/SafeCast.sol";
import "@openzeppelin/contracts/utils/math/SignedMath.sol";
Expand Down
45 changes: 45 additions & 0 deletions contracts/oracles/SequencerChainlinkOracle.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import { ChainlinkOracle } from "./ChainlinkOracle.sol";
import { AggregatorV3Interface } from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

/**
@title Sequencer Chain Link Oracle
@notice Oracle to fetch price using chainlink oracles on L2s with sequencer
*/
contract SequencerChainlinkOracle is ChainlinkOracle {
/// @notice L2 Sequencer feed
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
AggregatorV3Interface public immutable sequencer;

/// @notice L2 Sequencer grace period
uint256 public constant GRACE_PERIOD_TIME = 3600;

/**
@notice Contract constructor
@param _sequencer L2 sequencer
@custom:oz-upgrades-unsafe-allow constructor
*/
constructor(AggregatorV3Interface _sequencer) ChainlinkOracle() {
require(address(_sequencer) != address(0), "zero address");

sequencer = _sequencer;
}

/// @inheritdoc ChainlinkOracle
function getPrice(address asset) public view override returns (uint) {
if (!isSequencerActive()) revert("L2 sequencer unavailable");
return super.getPrice(asset);
}

function isSequencerActive() internal view returns (bool) {
// answer from oracle is a variable with a value of either 1 or 0
// 0: The sequencer is up
// 1: The sequencer is down
// startedAt: This timestamp indicates when the sequencer changed status
(, int256 answer, uint256 startedAt, , ) = sequencer.latestRoundData();
if (block.timestamp - startedAt <= GRACE_PERIOD_TIME || answer == 1) return false;
return true;
}
}
2 changes: 1 addition & 1 deletion contracts/oracles/WstETHOracle.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;
pragma solidity 0.8.25;

import { OracleInterface } from "../interfaces/OracleInterface.sol";
import { IStETH } from "../interfaces/IStETH.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/oracles/mocks/MockBinanceFeedRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;
pragma solidity 0.8.25;

import "../../interfaces/FeedRegistryInterface.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/oracles/mocks/MockBinanceOracle.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;
pragma solidity 0.8.25;

import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import { OracleInterface } from "../../interfaces/OracleInterface.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/oracles/mocks/MockChainlinkOracle.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;
pragma solidity 0.8.25;

import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import { OracleInterface } from "../../interfaces/OracleInterface.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/oracles/mocks/MockPythOracle.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;
pragma solidity 0.8.25;

import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import { IPyth } from "../PythOracle.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/AccessControlManager.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;
pragma solidity 0.8.25;
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@venusprotocol/governance-contracts/contracts/Governance/AccessControlManager.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/test/BEP20Harness.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;
pragma solidity 0.8.25;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/test/MockPyth.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;
pragma solidity 0.8.25;

import "../interfaces/PythInterface.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/test/MockSimpleOracle.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;
pragma solidity 0.8.25;

import "../interfaces/OracleInterface.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/test/MockV3Aggregator.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;
pragma solidity 0.8.25;

import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV2V3Interface.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/test/PancakePairHarness.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;
pragma solidity 0.8.25;

// a library for performing various math operations

Expand Down
2 changes: 1 addition & 1 deletion contracts/test/VBEP20Harness.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.13;
pragma solidity 0.8.25;

import "./BEP20Harness.sol";

Expand Down
48 changes: 34 additions & 14 deletions deploy/1-deploy-oracles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { HardhatRuntimeEnvironment } from "hardhat/types";

import { ADDRESSES } from "../helpers/deploymentConfig";

const ARBITRUM_SEQUENCER = "0xFdB631F5EE196F0ed6FAa767959853A9F217697D";

const func: DeployFunction = async function ({ getNamedAccounts, deployments, network }: HardhatRuntimeEnvironment) {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();
Expand Down Expand Up @@ -61,21 +63,39 @@ const func: DeployFunction = async function ({ getNamedAccounts, deployments, ne
},
});

await deploy("ChainlinkOracle", {
contract: network.live ? "ChainlinkOracle" : "MockChainlinkOracle",
from: deployer,
log: true,
deterministicDeployment: false,
args: [],
proxy: {
owner: proxyOwnerAddress,
proxyContract: "OptimizedTransparentProxy",
execute: {
methodName: "initialize",
args: network.live ? [accessControlManagerAddress] : [],
if (network.name === "arbitrum") {
await deploy("SequencerChainlinkOracle", {
contract: "SequencerChainlinkOracle",
from: deployer,
log: true,
deterministicDeployment: false,
args: [ARBITRUM_SEQUENCER],
proxy: {
owner: proxyOwnerAddress,
proxyContract: "OptimizedTransparentProxy",
execute: {
methodName: "initialize",
args: [accessControlManagerAddress],
},
},
},
});
});
} else {
await deploy("ChainlinkOracle", {
contract: network.live ? "ChainlinkOracle" : "MockChainlinkOracle",
from: deployer,
log: true,
deterministicDeployment: false,
args: [],
proxy: {
owner: proxyOwnerAddress,
proxyContract: "OptimizedTransparentProxy",
execute: {
methodName: "initialize",
args: network.live ? [accessControlManagerAddress] : [],
},
},
});
}

const { pythOracleAddress } = ADDRESSES[networkName];

Expand Down
11 changes: 10 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: "0.8.13",
version: "0.8.25",
settings: {
optimizer: {
enabled: true,
Expand Down Expand Up @@ -129,6 +129,15 @@ const config: HardhatUserConfig = {
live: true,
accounts: process.env.DEPLOYER_PRIVATE_KEY ? [`0x${process.env.DEPLOYER_PRIVATE_KEY}`] : [],
},
arbitrum: {
url: "https://arbitrum.llamarpc.com/",
chainId: 42161,
live: true,
timeout: 1200000,
accounts: {
mnemonic: process.env.MNEMONIC || "",
},
},
},
gasReporter: {
enabled: process.env.REPORT_GAS !== undefined,
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@venusprotocol/oracle",
"description": "Venus Protocol Price Oracle",
"version": "1.10.0",
"version": "2.0.0-dev.1",
"author": "Venus",
"engines": {
"node": ">=18.x.x"
Expand Down Expand Up @@ -38,8 +38,8 @@
"@nomicfoundation/hardhat-network-helpers": "^1.0.8",
"@openzeppelin/contracts": "^4.6.0",
"@openzeppelin/contracts-upgradeable": "^4.7.3",
"@venusprotocol/governance-contracts": "^1.4.0",
"@venusprotocol/solidity-utilities": "1.3.0",
"@venusprotocol/governance-contracts": "^2.0.0",
"@venusprotocol/solidity-utilities": "^2.0.0",
"@venusprotocol/venus-protocol": "^6.0.0",
"ethers": "^5.6.8",
"hardhat": "^2.16.1",
Expand Down
Loading

0 comments on commit f4bc88f

Please sign in to comment.