generated from PaulRBerg/hardhat-template
-
Notifications
You must be signed in to change notification settings - Fork 15
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 #186 from VenusProtocol/feat/pendle-oracle
- Loading branch information
Showing
12 changed files
with
2,225 additions
and
11 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
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); | ||
} | ||
} |
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,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"; |
Oops, something went wrong.