From e794548910e319f24ed47df0d6fa6e599a034f05 Mon Sep 17 00:00:00 2001 From: Domen Grabec Date: Thu, 13 Apr 2023 00:30:26 +0200 Subject: [PATCH 1/2] add WOETH deployment --- contracts/contracts/token/WOETH.sol | 46 ++++++++++++++++++++++++++++- contracts/deploy/051_oeth.js | 42 +++++++++++++++++++++++++- 2 files changed, 86 insertions(+), 2 deletions(-) diff --git a/contracts/contracts/token/WOETH.sol b/contracts/contracts/token/WOETH.sol index 4fe91a107c..a15aa6283e 100644 --- a/contracts/contracts/token/WOETH.sol +++ b/contracts/contracts/token/WOETH.sol @@ -1,11 +1,55 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; +import { ERC4626 } from "../../lib/openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol"; +import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; + +import { Governable } from "../governance/Governable.sol"; +import { Initializable } from "../utils/Initializable.sol"; +import { OETH } from "./OETH.sol"; + /** * @title OETH Token Contract * @author Origin Protocol Inc */ -contract WOETH { +contract WOETH is ERC4626, Governable, Initializable { + using SafeERC20 for IERC20; + + constructor( + ERC20 underlying_, + string memory name_, + string memory symbol_ + ) ERC20(name_, symbol_) ERC4626(underlying_) Governable() {} + + /** + * @notice Enable OETH rebasing for this contract + */ + function initialize() external onlyGovernor initializer { + OETH(address(asset())).rebaseOptIn(); + } + + function name() public view override returns (string memory) { + return "Wrapped OETH"; + } + + function symbol() public view override returns (string memory) { + return "WOETH"; + } + /** + * @notice Transfer token to governor. Intended for recovering tokens stuck in + * contract, i.e. mistaken sends. Cannot transfer OETH + * @param asset_ Address for the asset + * @param amount_ Amount of the asset to transfer + */ + function transferToken(address asset_, uint256 amount_) + external + onlyGovernor + { + require(asset_ != address(asset()), "Cannot collect OETH"); + IERC20(asset_).safeTransfer(governor(), amount_); + } } diff --git a/contracts/deploy/051_oeth.js b/contracts/deploy/051_oeth.js index a2e460a3a1..288d94d3c0 100644 --- a/contracts/deploy/051_oeth.js +++ b/contracts/deploy/051_oeth.js @@ -19,7 +19,6 @@ module.exports = deploymentWithGuardianGovernor( const { deployerAddr, governorAddr } = await getNamedAccounts(); const sDeployer = await ethers.provider.getSigner(deployerAddr); - // actions = actions.concat(actions2) let actions = await deployCore({ deployWithConfirmation, withConfirmation, @@ -36,6 +35,14 @@ module.exports = deploymentWithGuardianGovernor( }) ); + actions = actions.concat( + await deployWOETH({ + deployWithConfirmation, + withConfirmation, + ethers, + }) + ); + // Governance Actions // ---------------- return { @@ -214,6 +221,39 @@ const deployDripper = async ({ ); }; +const deployWOETH = async ({ + deployWithConfirmation, + withConfirmation, + ethers, +}) => { + const { deployerAddr } = await getNamedAccounts(); + const sDeployer = await ethers.provider.getSigner(deployerAddr); + + const cOETHProxy = await ethers.getContract("OETHProxy"); + const cWOETHProxy = await ethers.getContract("WOETHProxy"); + + const dWOETHImpl = await deployWithConfirmation("WOETH", [ + cOETHProxy.address, + "Wrapped OETH", + "WOETH", + ]); + + const cWOETH = await ethers.getContractAt("WOETH", cWOETHProxy.address); + + return [ + { + contract: cWOETHProxy, + signature: "upgradeTo(address)", + args: [dWOETHImpl.address], + }, + { + contract: cWOETH, + signature: "initialize()", + args: [], + }, + ]; +}; + /** * Deploy Frax ETH Strategy */ From 1c8e2613ccbd7911a674edcb3ec65327bc8189ed Mon Sep 17 00:00:00 2001 From: Domen Grabec Date: Thu, 13 Apr 2023 12:49:40 +0200 Subject: [PATCH 2/2] deploy separate files --- contracts/deploy/051_oeth.js | 41 --------------------- contracts/deploy/052_woeth.js | 68 +++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 41 deletions(-) create mode 100644 contracts/deploy/052_woeth.js diff --git a/contracts/deploy/051_oeth.js b/contracts/deploy/051_oeth.js index 288d94d3c0..ad1d0a163b 100644 --- a/contracts/deploy/051_oeth.js +++ b/contracts/deploy/051_oeth.js @@ -35,14 +35,6 @@ module.exports = deploymentWithGuardianGovernor( }) ); - actions = actions.concat( - await deployWOETH({ - deployWithConfirmation, - withConfirmation, - ethers, - }) - ); - // Governance Actions // ---------------- return { @@ -221,39 +213,6 @@ const deployDripper = async ({ ); }; -const deployWOETH = async ({ - deployWithConfirmation, - withConfirmation, - ethers, -}) => { - const { deployerAddr } = await getNamedAccounts(); - const sDeployer = await ethers.provider.getSigner(deployerAddr); - - const cOETHProxy = await ethers.getContract("OETHProxy"); - const cWOETHProxy = await ethers.getContract("WOETHProxy"); - - const dWOETHImpl = await deployWithConfirmation("WOETH", [ - cOETHProxy.address, - "Wrapped OETH", - "WOETH", - ]); - - const cWOETH = await ethers.getContractAt("WOETH", cWOETHProxy.address); - - return [ - { - contract: cWOETHProxy, - signature: "upgradeTo(address)", - args: [dWOETHImpl.address], - }, - { - contract: cWOETH, - signature: "initialize()", - args: [], - }, - ]; -}; - /** * Deploy Frax ETH Strategy */ diff --git a/contracts/deploy/052_woeth.js b/contracts/deploy/052_woeth.js new file mode 100644 index 0000000000..6c32c9bc8e --- /dev/null +++ b/contracts/deploy/052_woeth.js @@ -0,0 +1,68 @@ +const { deploymentWithGuardianGovernor } = require("../utils/deploy"); +const addresses = require("../utils/addresses"); +const hre = require("hardhat"); +const { BigNumber, utils } = require("ethers"); +const { + getAssetAddresses, + getOracleAddresses, + isMainnet, + isFork, + isMainnetOrFork, +} = require("../test/helpers.js"); + +// 5/8 multisig +const guardianAddr = addresses.mainnet.Guardian; + +module.exports = deploymentWithGuardianGovernor( + { deployName: "052_woeth" }, + async ({ deployWithConfirmation, ethers, getTxOpts, withConfirmation }) => { + const { deployerAddr, governorAddr } = await getNamedAccounts(); + const sDeployer = await ethers.provider.getSigner(deployerAddr); + + const actions = await deployWOETH({ + deployWithConfirmation, + withConfirmation, + ethers, + }); + + // Governance Actions + // ---------------- + return { + name: "Deploy OETH Vault, Token, Strategies, Harvester and the Dripper", + actions, + }; + } +); + +const deployWOETH = async ({ + deployWithConfirmation, + withConfirmation, + ethers, +}) => { + const { deployerAddr } = await getNamedAccounts(); + const sDeployer = await ethers.provider.getSigner(deployerAddr); + + const cOETHProxy = await ethers.getContract("OETHProxy"); + const cWOETHProxy = await ethers.getContract("WOETHProxy"); + + const dWOETHImpl = await deployWithConfirmation("WOETH", [ + cOETHProxy.address, + "Wrapped OETH", + "WOETH", + ]); + + const cWOETH = await ethers.getContractAt("WOETH", cWOETHProxy.address); + + return [ + { + contract: cWOETHProxy, + signature: "upgradeTo(address)", + args: [dWOETHImpl.address], + }, + { + contract: cWOETH, + signature: "initialize()", + args: [], + }, + ]; +};