-
Notifications
You must be signed in to change notification settings - Fork 83
Add deployment file for Bridged wOETH Strategy #2496
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
Open
shahthepro
wants to merge
4
commits into
master
Choose a base branch
from
shah/plume-woeth-strategy
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,83 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.0; | ||
|
||
import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol"; | ||
import { AbstractOracleRouter } from "./AbstractOracleRouter.sol"; | ||
import { StableMath } from "../utils/StableMath.sol"; | ||
import "../interfaces/chainlink/AggregatorV3Interface.sol"; | ||
|
||
// @notice Oracle Router (for OETH on Plume) that denominates all prices in ETH | ||
contract OETHPlumeOracleRouter is AbstractOracleRouter { | ||
using StableMath for uint256; | ||
using SafeCast for int256; | ||
|
||
address constant WETH = 0xca59cA09E5602fAe8B629DeE83FfA819741f14be; | ||
address constant WOETH = 0xD8724322f44E5c58D7A815F542036fb17DbbF839; | ||
// Ref: https://docs.eo.app/docs/eprice/feed-addresses/plume | ||
address constant WOETH_ORACLE_FEED = | ||
0x4915600Ed7d85De62011433eEf0BD5399f677e9b; | ||
|
||
constructor() {} | ||
|
||
/** | ||
* @notice Returns the total price in 18 digit units for a given asset. | ||
* This implementation does not (!) do range checks as the | ||
* parent OracleRouter does. | ||
* @param asset address of the asset | ||
* @return uint256 unit price for 1 asset unit, in 18 decimal fixed | ||
*/ | ||
function price(address asset) | ||
external | ||
view | ||
virtual | ||
override | ||
returns (uint256) | ||
{ | ||
(address _feed, uint256 maxStaleness) = feedMetadata(asset); | ||
if (_feed == FIXED_PRICE) { | ||
return 1e18; | ||
} | ||
require(_feed != address(0), "Asset not available"); | ||
|
||
// slither-disable-next-line unused-return | ||
(, int256 _iprice, , uint256 updatedAt, ) = AggregatorV3Interface(_feed) | ||
.latestRoundData(); | ||
|
||
require( | ||
updatedAt + maxStaleness >= block.timestamp, | ||
"Oracle price too old" | ||
); | ||
|
||
uint8 decimals = getDecimals(_feed); | ||
uint256 _price = _iprice.toUint256().scaleBy(18, decimals); | ||
return _price; | ||
} | ||
|
||
/** | ||
* @dev The price feed contract to use for a particular asset along with | ||
* maximum data staleness | ||
* @param asset address of the asset | ||
* @return feedAddress address of the price feed for the asset | ||
* @return maxStaleness maximum acceptable data staleness duration | ||
*/ | ||
function feedMetadata(address asset) | ||
internal | ||
view | ||
virtual | ||
override | ||
returns (address feedAddress, uint256 maxStaleness) | ||
{ | ||
if (asset == WETH) { | ||
// FIXED_PRICE: WETH/ETH | ||
feedAddress = FIXED_PRICE; | ||
maxStaleness = 0; | ||
} else if (asset == WOETH) { | ||
// Chainlink: https://data.chain.link/feeds/base/base/woeth-oeth-exchange-rate | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: this should be from plume chain, but not a big deal. |
||
// Bridged wOETH/OETH | ||
feedAddress = WOETH_ORACLE_FEED; | ||
maxStaleness = 1 days + STALENESS_BUFFER; | ||
} else { | ||
revert("Asset not available"); | ||
} | ||
} | ||
} |
This file contains hidden or 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,104 @@ | ||
const { deployOnPlume } = require("../../utils/deploy-l2"); | ||
const { | ||
deployWithConfirmation, | ||
withConfirmation, | ||
} = require("../../utils/deploy"); | ||
const addresses = require("../../utils/addresses"); | ||
|
||
module.exports = deployOnPlume( | ||
{ | ||
deployName: "003_woeth_strategy", | ||
}, | ||
async ({ ethers }) => { | ||
const { deployerAddr, timelockAddr } = await getNamedAccounts(); | ||
|
||
const sDeployer = await ethers.getSigner(deployerAddr); | ||
|
||
const cOETHpVaultProxy = await ethers.getContract("OETHPlumeVaultProxy"); | ||
const cOETHpProxy = await ethers.getContract("OETHPlumeProxy"); | ||
const cOETHpVault = await ethers.getContractAt( | ||
"IVault", | ||
cOETHpVaultProxy.address | ||
); | ||
|
||
// Deploy oracle router | ||
await deployWithConfirmation("OETHPlumeOracleRouter"); | ||
const cOracleRouter = await ethers.getContract("OETHPlumeOracleRouter"); | ||
|
||
// Cache decimals | ||
await withConfirmation( | ||
cOracleRouter.cacheDecimals(addresses.plume.BridgedWOETH) | ||
); | ||
|
||
// Deploy proxy | ||
await deployWithConfirmation("BridgedWOETHStrategyProxy"); | ||
const cStrategyProxy = await ethers.getContract( | ||
"BridgedWOETHStrategyProxy" | ||
); | ||
|
||
// Deploy implementation | ||
const dStrategyImpl = await deployWithConfirmation("BridgedWOETHStrategy", [ | ||
[addresses.zero, cOETHpVaultProxy.address], | ||
addresses.plume.WETH, | ||
addresses.plume.BridgedWOETH, | ||
cOETHpProxy.address, | ||
]); | ||
const cStrategy = await ethers.getContractAt( | ||
"BridgedWOETHStrategy", | ||
cStrategyProxy.address | ||
); | ||
|
||
// Init Strategy | ||
const initData = cStrategy.interface.encodeFunctionData( | ||
"initialize(uint128)", | ||
[ | ||
100, // 1% maxPriceDiffBps | ||
] | ||
); | ||
// prettier-ignore | ||
await withConfirmation( | ||
cStrategyProxy | ||
.connect(sDeployer)["initialize(address,address,bytes)"]( | ||
dStrategyImpl.address, | ||
timelockAddr, | ||
initData | ||
) | ||
); | ||
console.log("Initialized BridgedWOETHStrategyProxy"); | ||
|
||
return { | ||
actions: [ | ||
{ | ||
// 1. Update oracle router | ||
contract: cOETHpVault, | ||
signature: "setPriceProvider(address)", | ||
args: [cOracleRouter.address], | ||
}, | ||
{ | ||
// 2. Approve strategy | ||
contract: cOETHpVault, | ||
signature: "approveStrategy(address)", | ||
args: [cStrategyProxy.address], | ||
}, | ||
{ | ||
// 3. Add to mint whitelist | ||
contract: cOETHpVault, | ||
signature: "addStrategyToMintWhitelist(address)", | ||
args: [cStrategyProxy.address], | ||
}, | ||
{ | ||
// 4. Update oracle price | ||
contract: cStrategy, | ||
signature: "updateWOETHOraclePrice()", | ||
args: [], | ||
}, | ||
{ | ||
// 5. Set strategist as Harvester | ||
contract: cStrategy, | ||
signature: "setHarvesterAddress(address)", | ||
args: [addresses.plume.strategist], | ||
}, | ||
], | ||
}; | ||
} | ||
); |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a trustworthy feed? How high is our confidence in this one?