Skip to content

Commit

Permalink
Merge pull request #198 from VenusProtocol/develop
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
chechu authored May 31, 2024
2 parents fab050f + d995645 commit b4073d9
Show file tree
Hide file tree
Showing 61 changed files with 25,276 additions and 2,039 deletions.
85 changes: 85 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,88 @@
## [2.3.0-dev.6](https://github.com/VenusProtocol/oracle/compare/v2.3.0-dev.5...v2.3.0-dev.6) (2024-05-28)


### Features

* updating deployment files ([291ab9d](https://github.com/VenusProtocol/oracle/commit/291ab9db0a0bc641df3477bb6efaff33aa6c9cf0))
* updating deployment files ([3baf6f3](https://github.com/VenusProtocol/oracle/commit/3baf6f37d88091d6efc0c6dd4cde96119de169db))
* updating deployment files ([39ae403](https://github.com/VenusProtocol/oracle/commit/39ae4031db033cd14022e290f0bf2a57ee95e1d6))


### Bug Fixes

* deployment script to execute on arbitrumone ([99d067f](https://github.com/VenusProtocol/oracle/commit/99d067f4477b507dc933b0e4bb595249b3daac0b))
* pr comments ([3cd18f5](https://github.com/VenusProtocol/oracle/commit/3cd18f5b3be060eb9fcff1ec23a3f29203528d72))

## [2.3.0-dev.5](https://github.com/VenusProtocol/oracle/compare/v2.3.0-dev.4...v2.3.0-dev.5) (2024-05-24)


### Bug Fixes

* added bnb test ([b2908f5](https://github.com/VenusProtocol/oracle/commit/b2908f52281d721dee3bd36f4c35019e6da61701))
* btc fork tests ([ff0c1a0](https://github.com/VenusProtocol/oracle/commit/ff0c1a0da497344c1ef44eb80e6f56e26c796eaf))
* change lower bound ratio ([e62281d](https://github.com/VenusProtocol/oracle/commit/e62281df28d59e7bf3dffe248e00f726fa610745))
* remove logs ([826fbf6](https://github.com/VenusProtocol/oracle/commit/826fbf684ef061eea1270c9d02abcd3954876efe))
* reverted comment ([d07cb05](https://github.com/VenusProtocol/oracle/commit/d07cb05dfff5b925c2ea9bf60b3585f571930f4e))
* updated comment ([591fdf9](https://github.com/VenusProtocol/oracle/commit/591fdf9910228593b6078f6468d92a4319f9ed93))

## [2.3.0-dev.4](https://github.com/VenusProtocol/oracle/compare/v2.3.0-dev.3...v2.3.0-dev.4) (2024-05-20)


### Features

* updating deployment files ([cc264d3](https://github.com/VenusProtocol/oracle/commit/cc264d38ff7896ab7b79c6c391fa34cb753aa5e8))
* updating deployment files ([5ef59c9](https://github.com/VenusProtocol/oracle/commit/5ef59c99aeeec1c4e95b76f98ad76241e33d3f08))


### Bug Fixes

* deployed pendle oracle ([253d1ac](https://github.com/VenusProtocol/oracle/commit/253d1ac7e7cf48443e8ff2257ac36d74edf646fb))
* redeployed oracle ([e0d10fa](https://github.com/VenusProtocol/oracle/commit/e0d10fa29c8a63c010e0330105391f826c651f0e))
* removed deployment and changed oracle address ([a226a36](https://github.com/VenusProtocol/oracle/commit/a226a363d6520d246fddfcd64c9276a95e8a8160))

## [2.3.0-dev.3](https://github.com/VenusProtocol/oracle/compare/v2.3.0-dev.2...v2.3.0-dev.3) (2024-05-08)


### Features

* updating deployment files ([734bb3e](https://github.com/VenusProtocol/oracle/commit/734bb3ed4711047ad1dcbd8b05c861eb09bedf7b))


### Bug Fixes

* deployed sFrax oracle on ethereum ([5dd8b5a](https://github.com/VenusProtocol/oracle/commit/5dd8b5a3f1682a838a2b33ddaba787d8f2f5cd1c))

## [2.3.0-dev.2](https://github.com/VenusProtocol/oracle/compare/v2.3.0-dev.1...v2.3.0-dev.2) (2024-05-06)


### Features

* updating deployment files ([867c0fd](https://github.com/VenusProtocol/oracle/commit/867c0fd9110db39b8035b352ccec74fd4b724d9c))


### Bug Fixes

* added deployment script for sFrax ([c0a8c11](https://github.com/VenusProtocol/oracle/commit/c0a8c1122e843fed6b6e55d417ff04349c537303))
* deployed oracle ([92cfac4](https://github.com/VenusProtocol/oracle/commit/92cfac4d21b19843a6c68bb7352c201db317c953))
* fixed lint ([6080feb](https://github.com/VenusProtocol/oracle/commit/6080feb6d51a0bc759602b6081d48b3328fff03c))

## [2.3.0-dev.1](https://github.com/VenusProtocol/oracle/compare/v2.2.0...v2.3.0-dev.1) (2024-04-25)


### Features

* updating deployment files ([bae54ff](https://github.com/VenusProtocol/oracle/commit/bae54ff84ef2f6377fe4f04b7c65b21bf291014c))


### Bug Fixes

* added deployment script ([f2823f8](https://github.com/VenusProtocol/oracle/commit/f2823f8cb5d81ccb97d4f1bc2c57d1d88993e3e0))
* deployed pendle oracle ([c014ecc](https://github.com/VenusProtocol/oracle/commit/c014ecc7ffadd5008e72dfe425c7d32ba61be3bf))
* fixed addresses ([b7bcb58](https://github.com/VenusProtocol/oracle/commit/b7bcb58400205e89c7d490d58fc6385065feba67))
* fixed lint ([83671c8](https://github.com/VenusProtocol/oracle/commit/83671c8cb9e129deb24227eff2a11a57baa31791))
* fixed tests ([cd7c20a](https://github.com/VenusProtocol/oracle/commit/cd7c20a868e8d9c5e960ffa0880f0882a5fad065))
* renamed PTweETH to PTweETH_26DEC2024 ([3fb7355](https://github.com/VenusProtocol/oracle/commit/3fb73554d3a5901afed135a7831b1537ad789ee5))

## [2.2.0](https://github.com/VenusProtocol/oracle/compare/v2.1.0...v2.2.0) (2024-04-25)


Expand Down
30 changes: 30 additions & 0 deletions contracts/oracles/mocks/MockPendlePtOracle.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.25;

import "../../interfaces/IPendlePtOracle.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract MockPendlePtOracle is IPendlePtOracle, Ownable {
mapping(address => mapping(uint32 => uint256)) public ptToAssetRate;

constructor() Ownable() {}

function setPtToAssetRate(address market, uint32 duration, uint256 rate) external onlyOwner {
ptToAssetRate[market][duration] = rate;
}

function getPtToAssetRate(address market, uint32 duration) external view returns (uint256) {
return ptToAssetRate[market][duration];
}

function getOracleState(
address market,
uint32 duration
)
external
view
returns (bool increaseCardinalityRequired, uint16 cardinalityRequired, bool oldestObservationSatisfied)
{
return (false, 0, true);
}
}
33 changes: 33 additions & 0 deletions contracts/test/MockSFrax.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { ISFrax } from "../interfaces/ISFrax.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract MockSFrax is ERC20, Ownable, ISFrax {
uint8 private immutable _decimals;
uint256 public exchangeRate;

constructor(string memory name_, string memory symbol_, uint8 decimals_) ERC20(name_, symbol_) Ownable() {
_decimals = decimals_;
}

function faucet(uint256 amount) external {
_mint(msg.sender, amount);
}

function setRate(uint256 rate) external onlyOwner {
exchangeRate = rate;
}

function convertToAssets(uint256 shares) external view override returns (uint256) {
return (shares * exchangeRate) / (10 ** uint256(_decimals));
}

function decimals() public view virtual override(ERC20, ISFrax) returns (uint8) {
return _decimals;
}
}
56 changes: 20 additions & 36 deletions deploy/1-deploy-oracles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import hre from "hardhat";
import { DeployFunction } from "hardhat-deploy/dist/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

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

const ARBITRUM_SEQUENCER = "0xFdB631F5EE196F0ed6FAa767959853A9F217697D";
import { ADDRESSES, SEQUENCER } from "../helpers/deploymentConfig";

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

if (network.name === "arbitrumone") {
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 sequencer = SEQUENCER[network.name];
let contractName = "ChainlinkOracle";
if (sequencer !== undefined) contractName = "SequencerChainlinkOracle";

await deploy(contractName, {
contract: network.live ? contractName : "MockChainlinkOracle",
from: deployer,
log: true,
deterministicDeployment: false,
args: sequencer ? [sequencer] : [],
proxy: {
owner: proxyOwnerAddress,
proxyContract: "OptimizedTransparentProxy",
execute: {
methodName: "initialize",
args: network.live ? [accessControlManagerAddress] : [],
},
});
}
},
});

const { pythOracleAddress } = ADDRESSES[networkName];

Expand Down Expand Up @@ -161,7 +145,7 @@ const func: DeployFunction = async function ({ getNamedAccounts, deployments, ne
}

const resilientOracle = await hre.ethers.getContract("ResilientOracle");
const chainlinkOracle = await hre.ethers.getContract("ChainlinkOracle");
const chainlinkOracle = await hre.ethers.getContract(contractName);

await accessControlManager?.giveCallPermission(chainlinkOracle.address, "setTokenConfig(TokenConfig)", deployer);
await accessControlManager?.giveCallPermission(resilientOracle.address, "setTokenConfig(TokenConfig)", deployer);
Expand Down
14 changes: 10 additions & 4 deletions deploy/2-deploy-redstone-oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import hre from "hardhat";
import { DeployFunction } from "hardhat-deploy/dist/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

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

const func: DeployFunction = async function ({ getNamedAccounts, deployments, network }: HardhatRuntimeEnvironment) {
const { deploy } = deployments;
Expand All @@ -11,12 +11,16 @@ const func: DeployFunction = async function ({ getNamedAccounts, deployments, ne

console.log(`Timelock (${proxyOwnerAddress})`);

const sequencer = SEQUENCER[network.name];
let contractName = "ChainlinkOracle";
if (sequencer !== undefined) contractName = "SequencerChainlinkOracle";

await deploy("RedStoneOracle", {
contract: network.live ? "ChainlinkOracle" : "MockChainlinkOracle",
contract: network.live ? contractName : "MockChainlinkOracle",
from: deployer,
log: true,
deterministicDeployment: false,
args: [],
args: sequencer ? [sequencer] : [],
proxy: {
owner: proxyOwnerAddress,
proxyContract: "OptimizedTransparentProxy",
Expand All @@ -37,6 +41,8 @@ const func: DeployFunction = async function ({ getNamedAccounts, deployments, ne
};

func.skip = async ({ network }: HardhatRuntimeEnvironment) =>
!["hardhat", "bscmainnet", "bsctestnet", "sepolia", "ethereum"].includes(network.name);
!["hardhat", "bscmainnet", "bsctestnet", "sepolia", "ethereum", "arbitrumone", "arbitrumsepolia"].includes(
network.name,
);
func.tags = ["deploy-redstone"];
export default func;
59 changes: 59 additions & 0 deletions deploy/6-deploy-pendle-oracle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { ethers } from "hardhat";
import { DeployFunction } from "hardhat-deploy/dist/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

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

const func: DeployFunction = async ({ getNamedAccounts, deployments, network }: HardhatRuntimeEnvironment) => {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();

const oracle = await ethers.getContract("ResilientOracle");
const proxyOwnerAddress = network.live ? ADDRESSES[network.name].timelock : deployer;

const { PTweETH_26DEC2024, PTweETH_26DEC2024_Market, PTOracle, WETH } = ADDRESSES[network.name];

let ptOracleAddress = PTOracle;
if (!ptOracleAddress) {
// deploy MockAnkrBNB
await deploy("MockPendlePtOracle", {
contract: "MockPendlePtOracle",
from: deployer,
log: true,
autoMine: true, // speed up deployment on local network (ganache, hardhat), no effect on live networks
skipIfAlreadyDeployed: true,
args: [],
});

const pendleOracleContract = await ethers.getContract("MockPendlePtOracle");
ptOracleAddress = pendleOracleContract.address;

if ((await pendleOracleContract.owner()) === deployer) {
await pendleOracleContract.transferOwnership(proxyOwnerAddress);
}
}

await deploy("PendleOracle-PT-weETH-26DEC2024", {
contract: "PendleOracle",
from: deployer,
log: true,
deterministicDeployment: false,
args: [
PTweETH_26DEC2024_Market || "0x0000000000000000000000000000000000000001",
ptOracleAddress,
PTweETH_26DEC2024,
WETH,
oracle.address,
1800,
],
proxy: {
owner: proxyOwnerAddress,
proxyContract: "OptimizedTransparentProxy",
},
skipIfAlreadyDeployed: true,
});
};

export default func;
func.tags = ["pendle"];
func.skip = async (hre: HardhatRuntimeEnvironment) => hre.network.name !== "ethereum" && hre.network.name !== "sepolia";
51 changes: 51 additions & 0 deletions deploy/7-deploy-sfrax-oracle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { ethers } from "hardhat";
import { DeployFunction } from "hardhat-deploy/dist/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

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

const func: DeployFunction = async ({ getNamedAccounts, deployments, network }: HardhatRuntimeEnvironment) => {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();

const oracle = await ethers.getContract("ResilientOracle");
const proxyOwnerAddress = network.live ? ADDRESSES[network.name].timelock : deployer;

const { sFRAX, FRAX } = ADDRESSES[network.name];

let sFRAXAddress = sFRAX;
if (!sFRAXAddress) {
await deploy("MockSFrax", {
contract: "MockSFrax",
from: deployer,
log: true,
autoMine: true, // speed up deployment on local network (ganache, hardhat), no effect on live networks
skipIfAlreadyDeployed: true,
args: ["Staked FRAX", "sFRAX", 18],
});

const mockSFraxContract = await ethers.getContract("MockSFrax");
sFRAXAddress = mockSFraxContract.address;

if ((await mockSFraxContract.owner()) === deployer) {
await mockSFraxContract.transferOwnership(proxyOwnerAddress);
}
}

await deploy("SFraxOracle", {
contract: "SFraxOracle",
from: deployer,
log: true,
deterministicDeployment: false,
args: [sFRAXAddress, FRAX, oracle.address],
proxy: {
owner: proxyOwnerAddress,
proxyContract: "OptimizedTransparentProxy",
},
skipIfAlreadyDeployed: true,
});
};

export default func;
func.tags = ["sFraxOracle"];
func.skip = async (hre: HardhatRuntimeEnvironment) => hre.network.name !== "ethereum" && hre.network.name !== "sepolia";
Loading

0 comments on commit b4073d9

Please sign in to comment.