Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VEN-2715] WeETHAccountantOracle Oracle #213

Merged
merged 30 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ad46f7b
fix: added WeETHAccountantOracle oracle
web3rover Aug 20, 2024
77284dc
fix: updated netspec
web3rover Aug 20, 2024
aa2245f
fix: added deployment script
web3rover Aug 20, 2024
7319784
fix: deployed to sepolia
web3rover Aug 20, 2024
40bc057
feat: updating deployment files
Narayanprusty Aug 20, 2024
c75405f
fix: fixed netspec comment
web3rover Aug 20, 2024
51339a1
fix: fixed comments
web3rover Aug 20, 2024
02ad4f1
feat: updating deployment files
Narayanprusty Aug 20, 2024
5c31dac
fix: removed deployment files
web3rover Aug 20, 2024
7e02976
Merge branch 'fix/ven-2715' of github.com:VenusProtocol/oracle into f…
web3rover Aug 20, 2024
e89298d
fix: removed deployment
web3rover Aug 20, 2024
b2292e7
fix: redeployed oracle
web3rover Aug 20, 2024
a6a2431
fix: fixed lint
web3rover Aug 20, 2024
75d7f65
feat: updating deployment files
Narayanprusty Aug 20, 2024
4eab98a
fix: removed deployment
web3rover Aug 20, 2024
a148906
fix: removed deployment
web3rover Aug 20, 2024
baae710
feat: updating deployment files
Narayanprusty Aug 20, 2024
cc3556b
fix: removed deployments
web3rover Aug 20, 2024
716a530
fix: removed deployed
web3rover Aug 20, 2024
d31b76c
feat: updating deployment files
Narayanprusty Aug 20, 2024
1425759
fix: removed deployment
web3rover Aug 20, 2024
e725a06
feat: updating deployment files
Narayanprusty Aug 20, 2024
b6d9697
fix: removed deployment
web3rover Aug 20, 2024
bdf3ea7
fix: redeployed contracts
web3rover Aug 20, 2024
1449399
feat: updating deployment files
Narayanprusty Aug 20, 2024
4828f49
fix: wet-01
web3rover Aug 22, 2024
ef84741
Merge branch 'fix/ven-2715' of github.com:VenusProtocol/oracle into f…
web3rover Aug 22, 2024
57757e2
fix: deployed on ethereum
web3rover Aug 22, 2024
d82fa25
feat: updating deployment files
Narayanprusty Aug 22, 2024
26ef5da
fix: wet-01
chechu Aug 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions contracts/interfaces/IAccountant.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.25;

interface IAccountant {
function getRate() external view returns (uint256);
}
37 changes: 37 additions & 0 deletions contracts/oracles/WeETHAccountantOracle.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.25;

import { CorrelatedTokenOracle } from "./common/CorrelatedTokenOracle.sol";
import { IAccountant } from "../interfaces/IAccountant.sol";
import { ensureNonzeroAddress } from "@venusprotocol/solidity-utilities/contracts/validators.sol";

/**
* @title WeETHAccountantOracle
* @author Venus
* @notice This oracle fetches the price of weETH LRT
web3rover marked this conversation as resolved.
Show resolved Hide resolved
*/
contract WeETHAccountantOracle is CorrelatedTokenOracle {
/// @notice Address of Accountant
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
IAccountant public immutable ACCOUNTANT;

/// @notice Constructor for the implementation contract.
/// @custom:oz-upgrades-unsafe-allow constructor
constructor(
address accountant,
address weethLRT,
address eth,
chechu marked this conversation as resolved.
Show resolved Hide resolved
address resilientOracle
) CorrelatedTokenOracle(weethLRT, eth, resilientOracle) {
chechu marked this conversation as resolved.
Show resolved Hide resolved
ensureNonzeroAddress(accountant);
ACCOUNTANT = IAccountant(accountant);
}

/**
* @notice Gets the ETH for 1 weETH LRT
chechu marked this conversation as resolved.
Show resolved Hide resolved
* @return amount Amount of ETH
chechu marked this conversation as resolved.
Show resolved Hide resolved
*/
function _getUnderlyingAmount() internal view override returns (uint256) {
return ACCOUNTANT.getRate();
chechu marked this conversation as resolved.
Show resolved Hide resolved
}
}
19 changes: 19 additions & 0 deletions contracts/oracles/mocks/MockAccountant.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.25;

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

contract MockAccountant is IAccountant, Ownable {
uint256 public rate;

constructor() Ownable() {}

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

function getRate() external view override returns (uint256) {
return rate;
}
}
28 changes: 28 additions & 0 deletions deploy/13-dependencies-weETHAccountant-oracle.ts
chechu marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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 proxyOwnerAddress = network.live ? ADDRESSES[network.name].timelock : deployer;

await deploy("MockAccountant_weETHs", {
from: deployer,
contract: "MockAccountant",
args: [],
log: true,
autoMine: true,
skipIfAlreadyDeployed: true,
});

const mockAccountant = await ethers.getContract("MockAccountant_weETHs");
await mockAccountant.transferOwnership(proxyOwnerAddress);
chechu marked this conversation as resolved.
Show resolved Hide resolved
};

export default func;
func.tags = ["weETHAccountant"];
chechu marked this conversation as resolved.
Show resolved Hide resolved
func.skip = async (hre: HardhatRuntimeEnvironment) => hre.network.name !== "sepolia";
46 changes: 46 additions & 0 deletions deploy/13-deploy-weETHAccountant-oracle.ts
chechu marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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,
artifacts,
}: HardhatRuntimeEnvironment) => {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();

const resilientOracle = await ethers.getContract("ResilientOracle");
const proxyOwnerAddress = network.live ? ADDRESSES[network.name].timelock : deployer;
const defaultProxyAdmin = await artifacts.readArtifact(
"hardhat-deploy/solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol:ProxyAdmin",
);
let { weETHs_Accountant } = ADDRESSES[network.name];
const { weETHs, WETH } = ADDRESSES[network.name];

weETHs_Accountant = weETHs_Accountant || (await ethers.getContract("MockAccountant_weETHs")).address;

await deploy("WeETHAccountantOracle_weETHs", {
contract: "WeETHAccountantOracle",
from: deployer,
log: true,
deterministicDeployment: false,
args: [weETHs_Accountant, weETHs, WETH, resilientOracle.address],
proxy: {
owner: proxyOwnerAddress,
proxyContract: "OptimizedTransparentUpgradeableProxy",
viaAdminContract: {
name: "DefaultProxyAdmin",
artifact: defaultProxyAdmin,
},
},
skipIfAlreadyDeployed: true,
});
};

export default func;
func.tags = ["weETHAccountant"];
chechu marked this conversation as resolved.
Show resolved Hide resolved
func.skip = async (hre: HardhatRuntimeEnvironment) => hre.network.name !== "ethereum" && hre.network.name !== "sepolia";
Loading
Loading