generated from PaulRBerg/hardhat-template
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from VenusProtocol/develop
New release
- Loading branch information
Showing
84 changed files
with
37,690 additions
and
3,772 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
pragma solidity 0.8.25; | ||
|
||
interface IERC4626 { | ||
function convertToAssets(uint256 shares) external view returns (uint256); | ||
function decimals() external view returns (uint8); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
pragma solidity 0.8.25; | ||
|
||
import { IERC4626 } from "../interfaces/IERC4626.sol"; | ||
import { CorrelatedTokenOracle } from "./common/CorrelatedTokenOracle.sol"; | ||
import { EXP_SCALE } from "@venusprotocol/solidity-utilities/contracts/constants.sol"; | ||
|
||
/** | ||
* @title ERC4626Oracle | ||
* @author Venus | ||
* @notice This oracle fetches the price of ERC4626 tokens | ||
*/ | ||
contract ERC4626Oracle is CorrelatedTokenOracle { | ||
/// @notice Constructor for the implementation contract. | ||
/// @custom:oz-upgrades-unsafe-allow constructor | ||
constructor( | ||
address correlatedToken, | ||
address underlyingToken, | ||
address resilientOracle | ||
) CorrelatedTokenOracle(correlatedToken, underlyingToken, resilientOracle) {} | ||
|
||
/** | ||
* @notice Fetches the amount of underlying token for 1 correlated token | ||
* @return amount The amount of underlying token for correlated token | ||
*/ | ||
function _getUnderlyingAmount() internal view override returns (uint256) { | ||
return IERC4626(CORRELATED_TOKEN).convertToAssets(EXP_SCALE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// 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 EtherfiAccountantOracle | ||
* @author Venus | ||
* @notice This oracle fetches the price of any Ether.fi asset that uses | ||
* Accountant contracts to derive the underlying price | ||
*/ | ||
contract EtherfiAccountantOracle 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 correlatedToken, | ||
address underlyingToken, | ||
address resilientOracle | ||
) CorrelatedTokenOracle(correlatedToken, underlyingToken, resilientOracle) { | ||
ensureNonzeroAddress(accountant); | ||
ACCOUNTANT = IAccountant(accountant); | ||
} | ||
|
||
/** | ||
* @notice Fetches the conversion rate from the ACCOUNTANT contract | ||
* @return amount Amount of WBTC | ||
*/ | ||
function _getUnderlyingAmount() internal view override returns (uint256) { | ||
return ACCOUNTANT.getRateSafe(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_eBTC", { | ||
from: deployer, | ||
contract: "MockAccountant", | ||
args: [], | ||
log: true, | ||
autoMine: true, | ||
skipIfAlreadyDeployed: true, | ||
}); | ||
|
||
const mockAccountant = await ethers.getContract("MockAccountant_eBTC"); | ||
await mockAccountant.transferOwnership(proxyOwnerAddress); | ||
}; | ||
|
||
export default func; | ||
func.tags = ["eBTCAccountantOracle"]; | ||
func.skip = async (hre: HardhatRuntimeEnvironment) => hre.network.name !== "sepolia"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { eBTC_Accountant } = ADDRESSES[network.name]; | ||
const { WBTC, eBTC } = ADDRESSES[network.name]; | ||
|
||
eBTC_Accountant = eBTC_Accountant || (await ethers.getContract("MockAccountant_eBTC")).address; | ||
|
||
await deploy("eBTCAccountantOracle", { | ||
contract: "EtherfiAccountantOracle", | ||
from: deployer, | ||
log: true, | ||
deterministicDeployment: false, | ||
args: [eBTC_Accountant, eBTC, WBTC, resilientOracle.address], | ||
proxy: { | ||
owner: proxyOwnerAddress, | ||
proxyContract: "OptimizedTransparentUpgradeableProxy", | ||
viaAdminContract: { | ||
name: "DefaultProxyAdmin", | ||
artifact: defaultProxyAdmin, | ||
}, | ||
}, | ||
skipIfAlreadyDeployed: true, | ||
}); | ||
}; | ||
|
||
export default func; | ||
func.tags = ["eBTCAccountantOracle"]; | ||
func.skip = async (hre: HardhatRuntimeEnvironment) => hre.network.name !== "ethereum" && hre.network.name !== "sepolia"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import hre from "hardhat"; | ||
import { DeployFunction } from "hardhat-deploy/dist/types"; | ||
import { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
|
||
import { ADDRESSES } from "../helpers/deploymentConfig"; | ||
|
||
const func: DeployFunction = async function ({ getNamedAccounts, deployments, network }: HardhatRuntimeEnvironment) { | ||
const { deploy } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
const proxyOwnerAddress = ADDRESSES[network.name].timelock; | ||
const { pufETH, WETH } = ADDRESSES[network.name]; | ||
|
||
const redStoneOracle = await hre.ethers.getContract("RedStoneOracle"); | ||
const resilientOracle = await hre.ethers.getContract("ResilientOracle"); | ||
|
||
await deploy("pufETHOneJumpRedStoneOracle", { | ||
contract: "OneJumpOracle", | ||
from: deployer, | ||
log: true, | ||
deterministicDeployment: false, | ||
args: [pufETH, WETH, resilientOracle.address, redStoneOracle.address], | ||
proxy: { | ||
owner: proxyOwnerAddress, | ||
proxyContract: "OptimizedTransparentProxy", | ||
}, | ||
skipIfAlreadyDeployed: true, | ||
}); | ||
}; | ||
|
||
func.skip = async () => hre.network.name !== "ethereum" && hre.network.name !== "sepolia"; | ||
func.tags = ["pufETHOneJumpRedStoneOracle"]; | ||
export default func; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import hre from "hardhat"; | ||
import { DeployFunction } from "hardhat-deploy/dist/types"; | ||
import { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
|
||
import { ADDRESSES } from "../helpers/deploymentConfig"; | ||
|
||
const func: DeployFunction = async function ({ getNamedAccounts, deployments, network }: HardhatRuntimeEnvironment) { | ||
const { deploy } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
const proxyOwnerAddress = ADDRESSES[network.name].timelock; | ||
const { LBTC, WBTC } = ADDRESSES[network.name]; | ||
|
||
const redstoneOracle = await hre.ethers.getContract("RedStoneOracle"); | ||
const resilientOracle = await hre.ethers.getContract("ResilientOracle"); | ||
|
||
await deploy("LBTCOneJumpRedStoneOracle", { | ||
contract: "OneJumpOracle", | ||
from: deployer, | ||
log: true, | ||
deterministicDeployment: false, | ||
args: [LBTC, WBTC, resilientOracle.address, redstoneOracle.address], | ||
proxy: { | ||
owner: proxyOwnerAddress, | ||
proxyContract: "OptimizedTransparentProxy", | ||
}, | ||
skipIfAlreadyDeployed: true, | ||
}); | ||
}; | ||
|
||
func.skip = async () => hre.network.name !== "ethereum" && hre.network.name !== "sepolia"; | ||
func.tags = ["LBTCOneJumpRedStoneOracle"]; | ||
export default func; |
Oops, something went wrong.