-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Cherrypick harvester changes * Store dripper locally
- Loading branch information
1 parent
3873d86
commit 83b8790
Showing
9 changed files
with
339 additions
and
95 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,40 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.0; | ||
|
||
import { OETHHarvesterSimple, IERC20, IStrategy, SafeERC20 } from "./OETHHarvesterSimple.sol"; | ||
|
||
contract SuperOETHHarvester is OETHHarvesterSimple { | ||
using SafeERC20 for IERC20; | ||
|
||
constructor(address _wrappedNativeToken) | ||
OETHHarvesterSimple(_wrappedNativeToken) | ||
{} | ||
|
||
/// @inheritdoc OETHHarvesterSimple | ||
function _harvestAndTransfer(address _strategy) internal virtual override { | ||
// Ensure strategy is supported | ||
require(supportedStrategies[_strategy], "Strategy not supported"); | ||
|
||
address receiver = strategistAddr; | ||
require(receiver != address(0), "Invalid receiver"); | ||
|
||
// Harvest rewards | ||
IStrategy(_strategy).collectRewardTokens(); | ||
|
||
// Cache reward tokens | ||
address[] memory rewardTokens = IStrategy(_strategy) | ||
.getRewardTokenAddresses(); | ||
|
||
uint256 len = rewardTokens.length; | ||
for (uint256 i = 0; i < len; i++) { | ||
// Cache balance | ||
address token = rewardTokens[i]; | ||
uint256 balance = IERC20(token).balanceOf(address(this)); | ||
if (balance > 0) { | ||
// Transfer everything to the strategist | ||
IERC20(token).safeTransfer(receiver, balance); | ||
emit Harvested(_strategy, token, balance, receiver); | ||
} | ||
} | ||
} | ||
} |
This file contains 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,67 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.0; | ||
|
||
import { InitializeGovernedUpgradeabilityProxy } from "./InitializeGovernedUpgradeabilityProxy.sol"; | ||
|
||
/** | ||
* @notice BridgedBaseWOETHProxy delegates calls to BridgedWOETH implementation | ||
*/ | ||
contract BridgedBaseWOETHProxy is InitializeGovernedUpgradeabilityProxy { | ||
|
||
} | ||
|
||
/** | ||
* @notice OETHBaseVaultProxy delegates calls to OETHBaseVault implementation | ||
*/ | ||
contract OETHBaseVaultProxy is InitializeGovernedUpgradeabilityProxy { | ||
|
||
} | ||
|
||
/** | ||
* @notice OETHBaseProxy delegates calls to OETH implementation | ||
*/ | ||
contract OETHBaseProxy is InitializeGovernedUpgradeabilityProxy { | ||
|
||
} | ||
|
||
/** | ||
* @notice WOETHBaseProxy delegates calls to WOETH implementation | ||
*/ | ||
contract WOETHBaseProxy is InitializeGovernedUpgradeabilityProxy { | ||
|
||
} | ||
|
||
/** | ||
* @notice OETHBaseDripperProxy delegates calls to a FixedRateDripper implementation | ||
*/ | ||
contract OETHBaseDripperProxy is InitializeGovernedUpgradeabilityProxy { | ||
|
||
} | ||
|
||
/** | ||
* @notice AerodromeAMOStrategyProxy delegates calls to AerodromeAMOStrategy implementation | ||
*/ | ||
contract AerodromeAMOStrategyProxy is InitializeGovernedUpgradeabilityProxy { | ||
|
||
} | ||
|
||
/** | ||
* @notice BridgedWOETHStrategyProxy delegates calls to BridgedWOETHStrategy implementation | ||
*/ | ||
contract BridgedWOETHStrategyProxy is InitializeGovernedUpgradeabilityProxy { | ||
|
||
} | ||
|
||
/** | ||
* @notice OETHBaseHarvesterProxy delegates calls to a SuperOETHHarvester implementation | ||
*/ | ||
contract OETHBaseHarvesterProxy is InitializeGovernedUpgradeabilityProxy { | ||
|
||
} | ||
|
||
/** | ||
* @notice OETHBaseCurveAMOProxy delegates calls to a OETHBaseCurveAMO implementation | ||
*/ | ||
contract OETHBaseCurveAMOProxy is InitializeGovernedUpgradeabilityProxy { | ||
|
||
} |
This file contains 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
This file contains 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
This file contains 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,73 @@ | ||
const addresses = require("../../utils/addresses"); | ||
const { deployWithConfirmation } = require("../../utils/deploy"); | ||
const { deployOnBase } = require("../../utils/deploy-l2"); | ||
|
||
module.exports = deployOnBase( | ||
{ | ||
deployName: "026_harvester_v2", | ||
}, | ||
async ({ ethers }) => { | ||
const cHarvesterProxy = await ethers.getContract("OETHBaseHarvesterProxy"); | ||
const cAMOStrategyProxy = await ethers.getContract( | ||
"AerodromeAMOStrategyProxy" | ||
); | ||
const cCurveAMOStrategyProxy = await ethers.getContract( | ||
"OETHBaseCurveAMOProxy" | ||
); | ||
const cCurveAMOStrategy = await ethers.getContractAt( | ||
"BaseCurveAMOStrategy", | ||
cCurveAMOStrategyProxy.address | ||
); | ||
|
||
const dHarvester = await deployWithConfirmation("SuperOETHHarvester", [ | ||
addresses.base.WETH, | ||
]); | ||
console.log("SuperOETHHarvester deployed at", dHarvester.address); | ||
|
||
const cHarvester = await ethers.getContractAt( | ||
"SuperOETHHarvester", | ||
cHarvesterProxy.address | ||
); | ||
|
||
const cDripperProxy = await ethers.getContract("OETHBaseDripperProxy"); | ||
|
||
return { | ||
actions: [ | ||
{ | ||
// Upgrade the harvester | ||
contract: cHarvesterProxy, | ||
signature: "upgradeTo(address)", | ||
args: [dHarvester.address], | ||
}, | ||
{ | ||
// Upgrade the harvester | ||
contract: cHarvester, | ||
signature: "initialize(address,address,address)", | ||
args: [ | ||
addresses.base.timelock, | ||
addresses.multichainStrategist, | ||
cDripperProxy.address, | ||
], | ||
}, | ||
{ | ||
// Mark Aerodome AMO strategy as supported | ||
contract: cHarvester, | ||
signature: "setSupportedStrategy(address,bool)", | ||
args: [cAMOStrategyProxy.address, true], | ||
}, | ||
{ | ||
// Mark Curve AMO strategy as supported | ||
contract: cHarvester, | ||
signature: "setSupportedStrategy(address,bool)", | ||
args: [cCurveAMOStrategyProxy.address, true], | ||
}, | ||
{ | ||
// Set the harvester address on the Curve AMO strategy | ||
contract: cCurveAMOStrategy, | ||
signature: "setHarvesterAddress(address)", | ||
args: [cHarvesterProxy.address], | ||
}, | ||
], | ||
}; | ||
} | ||
); |
This file contains 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,57 @@ | ||
const addresses = require("../../utils/addresses.js"); | ||
const { deployOnSonic } = require("../../utils/deploy-l2.js"); | ||
const { | ||
deployWithConfirmation, | ||
withConfirmation, | ||
} = require("../../utils/deploy.js"); | ||
|
||
module.exports = deployOnSonic( | ||
{ | ||
deployName: "009_harvester", | ||
}, | ||
async ({ ethers }) => { | ||
const { deployerAddr, strategistAddr } = await getNamedAccounts(); | ||
|
||
const sDeployer = await ethers.provider.getSigner(deployerAddr); | ||
await deployWithConfirmation("OSonicHarvesterProxy"); | ||
|
||
await deployWithConfirmation("OETHHarvesterSimple", [addresses.sonic.wS]); | ||
const dHarvester = await ethers.getContract("OETHHarvesterSimple"); | ||
|
||
const cHarvesterProxy = await ethers.getContract("OSonicHarvesterProxy"); | ||
const cHarvester = await ethers.getContractAt( | ||
"OETHHarvesterSimple", | ||
cHarvesterProxy.address | ||
); | ||
|
||
const cDripperProxy = await ethers.getContract("OSonicDripperProxy"); | ||
|
||
// const cStakingStrategyProxy = await ethers.getContract("SonicStakingStrategyProxy"); | ||
|
||
const initSonicStakingStrategy = cHarvester.interface.encodeFunctionData( | ||
"initialize(address,address,address)", | ||
[addresses.sonic.timelock, strategistAddr, cDripperProxy.address] | ||
); | ||
|
||
// prettier-ignore | ||
await withConfirmation( | ||
cHarvesterProxy | ||
.connect(sDeployer)["initialize(address,address,bytes)"]( | ||
dHarvester.address, | ||
addresses.sonic.timelock, | ||
initSonicStakingStrategy | ||
) | ||
); | ||
|
||
return { | ||
actions: [ | ||
// TODO: Enable for Curve AMO after it has been deployed | ||
// { | ||
// contract: cHarvesterProxy, | ||
// signature: "setSupportedStrategy(address,bool)", | ||
// args: [cStakingStrategyProxy.address, true], | ||
// }, | ||
], | ||
}; | ||
} | ||
); |
Oops, something went wrong.