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..ad1d0a163b 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, 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: [], + }, + ]; +};