Skip to content
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

WOETH deployment #1320

Merged
merged 2 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion contracts/contracts/token/WOETH.sol
Original file line number Diff line number Diff line change
@@ -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_);
}
}
1 change: 0 additions & 1 deletion contracts/deploy/051_oeth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
68 changes: 68 additions & 0 deletions contracts/deploy/052_woeth.js
Original file line number Diff line number Diff line change
@@ -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: [],
},
];
};