Skip to content

Commit

Permalink
Merge pull request #253 from VenusProtocol/feat/ven-3041
Browse files Browse the repository at this point in the history
[VEN-3041] Add Yearn markets to the Core Pool
  • Loading branch information
web3rover authored Feb 9, 2025
2 parents c501e23 + b6d581d commit 288eac7
Show file tree
Hide file tree
Showing 18 changed files with 2,563 additions and 5 deletions.
Binary file added audits/123_erc4626Oracle_certik_20250206.pdf
Binary file not shown.
9 changes: 6 additions & 3 deletions contracts/oracles/ERC4626Oracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,30 @@ 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 {
uint256 public immutable ONE_CORRELATED_TOKEN;

/// @notice Constructor for the implementation contract.
/// @custom:oz-upgrades-unsafe-allow constructor
constructor(
address correlatedToken,
address underlyingToken,
address resilientOracle
) CorrelatedTokenOracle(correlatedToken, underlyingToken, resilientOracle) {}
) CorrelatedTokenOracle(correlatedToken, underlyingToken, resilientOracle) {
ONE_CORRELATED_TOKEN = 10 ** IERC4626(correlatedToken).decimals();
}

/**
* @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);
return IERC4626(CORRELATED_TOKEN).convertToAssets(ONE_CORRELATED_TOKEN);
}
}
49 changes: 49 additions & 0 deletions deploy/19-deploy-yearn-oracles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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 function ({ getNamedAccounts, deployments, network }: HardhatRuntimeEnvironment) {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();
const { WETH, USDC, USDT, USDS, yvUSDC_1, yvUSDT_1, yvUSDS_1, yvWETH_1 } = ADDRESSES[network.name];

const resilientOracle = await ethers.getContract("ResilientOracle");
await deploy("yvUSDC-1_ERC4626Oracle", {
contract: "ERC4626Oracle",
from: deployer,
log: true,
deterministicDeployment: false,
args: [yvUSDC_1, USDC, resilientOracle.address],
});

await deploy("yvUSDT-1_ERC4626Oracle", {
contract: "ERC4626Oracle",
from: deployer,
log: true,
deterministicDeployment: false,
args: [yvUSDT_1, USDT, resilientOracle.address],
});

await deploy("yvUSDS-1_ERC4626Oracle", {
contract: "ERC4626Oracle",
from: deployer,
log: true,
deterministicDeployment: false,
args: [yvUSDS_1, USDS, resilientOracle.address],
});

await deploy("yvWETH-1_ERC4626Oracle", {
contract: "ERC4626Oracle",
from: deployer,
log: true,
deterministicDeployment: false,
args: [yvWETH_1, WETH, resilientOracle.address],
});
};

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

export default func;
Loading

0 comments on commit 288eac7

Please sign in to comment.