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

Deploy a Fixed Rate Dripper for OETH. #2350

Closed
wants to merge 8 commits into from
Closed
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
12 changes: 12 additions & 0 deletions contracts/contracts/harvest/Dripper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,16 @@ contract Dripper is Governable {
// Send funds
IERC20(token).safeTransfer(vault, amountToSend);
}

/// @dev Transfer out all ERC20 held by the contract. Governor only.
/// @param _asset ERC20 token address
function transferAllToken(address _asset, address _receiver)
external
onlyGovernor
{
IERC20(_asset).safeTransfer(
_receiver,
IERC20(_asset).balanceOf(address(this))
);
}
}
14 changes: 14 additions & 0 deletions contracts/contracts/harvest/OETHFixedRateDripper.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { FixedRateDripper } from "./FixedRateDripper.sol";

/**
* @title OETH FixedRateDripper Contract
* @author Origin Protocol Inc
*/
contract OETHFixedRateDripper is FixedRateDripper {
constructor(address _vault, address _token)
FixedRateDripper(_vault, _token)
{}
}
7 changes: 7 additions & 0 deletions contracts/contracts/proxies/Proxies.sol
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,10 @@ contract MorphoGauntletPrimeUSDTStrategyProxy is
{

}

/**
* @notice OETHFixedRateDripperProxy delegates calls to a OETHFixedRateDripper implementation
*/
contract OETHFixedRateDripperProxy is InitializeGovernedUpgradeabilityProxy {

}
99 changes: 99 additions & 0 deletions contracts/deploy/mainnet/117_oeth_fixed_rate_dripper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
const addresses = require("../../utils/addresses");
const { deploymentWithGovernanceProposal } = require("../../utils/deploy");

module.exports = deploymentWithGovernanceProposal(
{
deployName: "117_oeth_fixed_rate_dripper",
forceDeploy: false,
//forceSkip: true,
reduceQueueTime: true,
deployerIsProposer: false,
proposalId: "",
},
async ({ deployWithConfirmation, withConfirmation }) => {
const cOETHVaultProxy = await ethers.getContractAt(
"VaultAdmin",
addresses.mainnet.OETHVaultProxy
);

// Deployer Actions
// ----------------
const { deployerAddr } = await getNamedAccounts();
const sDeployer = await ethers.provider.getSigner(deployerAddr);

// 1. Deploy new implementation of OETH Dripper (with transferAllToken function)
// 2. Deploy new OETH fixed rate dripper (proxy + implementation)
// 3. Upgrade Dripper to the new version (with transferAll token function)
// 4. Transfer all funds from old dripper to new dripper
// 5. Set new dripper on the vault

// --- 1 ---
// 1.a. Get the current OETH Dripper Proxy
const cOETHDripperProxy = await ethers.getContract("OETHDripperProxy");

// 1.b. Deploy the new OETH Dripper implementation (with transferAllToken function)
const dOETHDripper = await deployWithConfirmation(
"OETHDripper",
[addresses.mainnet.OETHVaultProxy, addresses.mainnet.WETH],
undefined,
true // due to changing name from `perBlock` to `perSecond`
);

const cOETHDripper = await ethers.getContractAt(
"OETHDripper",
cOETHDripperProxy.address
);

// --- 2 ---
// 2.a Deploy the Fixed Rate Dripper Proxy
const dOETHFixedRateDripperProxy = await deployWithConfirmation(
"OETHFixedRateDripperProxy"
);

const cOETHFixedRateDripperProxy = await ethers.getContract(
"OETHFixedRateDripperProxy"
);

// 2.b. Deploy the OETH Fixed Rate Dripper implementation
const dOETHFixedRateDripper = await deployWithConfirmation(
"OETHFixedRateDripper",
[addresses.mainnet.OETHVaultProxy, addresses.mainnet.WETH]
);

// 2.c. Initialize the Fixed Rate Dripper Proxy
const initFunction = "initialize(address,address,bytes)";
await withConfirmation(
cOETHFixedRateDripperProxy.connect(sDeployer)[initFunction](
dOETHFixedRateDripper.address,
addresses.mainnet.Timelock, // governor
"0x" // no init data
)
);
// --- 3 & 4 & 5 ---
// Governance Actions
// ----------------
return {
name: "",
actions: [
// 3. Upgrade the Dripper to the new version
{
contract: cOETHDripperProxy,
signature: "upgradeTo(address)",
args: [dOETHDripper.address],
},
// 4. Transfer all funds from the old dripper to the new dripper
{
contract: cOETHDripper,
signature: "transferAllToken(address,address)",
args: [addresses.mainnet.WETH, cOETHFixedRateDripperProxy.address],
},
// 5. Set new dripper address on the vault
{
contract: cOETHVaultProxy,
signature: "setDripper(address)",
args: [dOETHFixedRateDripperProxy.address],
},
],
};
}
);
Loading