-
Notifications
You must be signed in to change notification settings - Fork 103
Add support for Strategist to harvest rewards #2853
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ccd4cfa
Forward rewards to another address
shahthepro fa76e07
prettify
shahthepro aa73bb5
Make strategist harvest rewards
shahthepro ae8876e
Fix CI and remove pause functionality
shahthepro 692241e
Fix failing tests
shahthepro f7f8438
fix tests
shahthepro 79d1676
Rename modifier
shahthepro 4bb3bf4
Fix renamed modifier
shahthepro bca69e1
Fix unit tests
shahthepro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,46 @@ | ||
| // SPDX-License-Identifier: BUSL-1.1 | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
|
|
||
| /** | ||
| * @title MockClaimableStrategy | ||
| * @dev Mock strategy for testing ClaimStrategyRewardsSafeModule. | ||
| * Holds reward tokens and transfers them to msg.sender on collectRewardTokens(). | ||
| */ | ||
| contract MockClaimableStrategy { | ||
| address[] private _rewardTokenAddresses; | ||
| bool public shouldRevert; | ||
|
|
||
| function setRewardTokenAddresses(address[] memory tokens) external { | ||
| _rewardTokenAddresses = tokens; | ||
| } | ||
|
|
||
| function setShouldRevert(bool _shouldRevert) external { | ||
| shouldRevert = _shouldRevert; | ||
| } | ||
|
|
||
| function getRewardTokenAddresses() | ||
| external | ||
| view | ||
| returns (address[] memory) | ||
| { | ||
| return _rewardTokenAddresses; | ||
| } | ||
|
|
||
| /** | ||
| * @dev Transfers all held reward tokens to msg.sender (the Safe). | ||
| * Reverts if shouldRevert is set, causing the Safe module exec to return false. | ||
| */ | ||
| function collectRewardTokens() external { | ||
| require(!shouldRevert, "MockClaimableStrategy: forced revert"); | ||
| for (uint256 i = 0; i < _rewardTokenAddresses.length; i++) { | ||
| uint256 balance = IERC20(_rewardTokenAddresses[i]).balanceOf( | ||
| address(this) | ||
| ); | ||
| if (balance > 0) { | ||
| IERC20(_rewardTokenAddresses[i]).transfer(msg.sender, balance); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
129 changes: 129 additions & 0 deletions
129
contracts/deploy/mainnet/187_upgrade_curve_amo_morpho_harvester.js
This file contains hidden or 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,129 @@ | ||
| const addresses = require("../../utils/addresses"); | ||
| const { deploymentWithGovernanceProposal } = require("../../utils/deploy"); | ||
|
|
||
| module.exports = deploymentWithGovernanceProposal( | ||
| { | ||
| deployName: "187_upgrade_curve_amo_morpho_harvester", | ||
| forceDeploy: false, | ||
| reduceQueueTime: true, | ||
| deployerIsProposer: false, | ||
| proposalId: "", | ||
| }, | ||
| async ({ deployWithConfirmation }) => { | ||
| // ── Proxy handles ──────────────────────────────────────────────────────── | ||
| const cOUSDCurveAMOProxy = await ethers.getContract("OUSDCurveAMOProxy"); | ||
| const cOETHCurveAMOProxy = await ethers.getContract("OETHCurveAMOProxy"); | ||
| const cOUSDMorphoV2Proxy = await ethers.getContract( | ||
| "OUSDMorphoV2StrategyProxy" | ||
| ); | ||
|
|
||
| // Strategy contract handles (used to call governor functions via proxy) | ||
| const cOUSDCurveAMO = await ethers.getContractAt( | ||
| "CurveAMOStrategy", | ||
| cOUSDCurveAMOProxy.address | ||
| ); | ||
| const cOETHCurveAMO = await ethers.getContractAt( | ||
| "CurveAMOStrategy", | ||
| cOETHCurveAMOProxy.address | ||
| ); | ||
| const cOUSDMorphoV2 = await ethers.getContractAt( | ||
| "MorphoV2Strategy", | ||
| cOUSDMorphoV2Proxy.address | ||
| ); | ||
|
|
||
| // ── Deploy new implementations ──────────────────────────────────────────── | ||
| // Both AMOs use CurveAMOStrategy but with different constructor args, | ||
| // so they get distinct artifact names. | ||
|
|
||
| // 1. OUSD/USDC Curve AMO | ||
| const dOUSDCurveAMO = await deployWithConfirmation( | ||
| "OUSDCurveAMOStrategy", | ||
| [ | ||
| [ | ||
| addresses.mainnet.curve.OUSD_USDC.pool, // platformAddress (Curve pool = LP token) | ||
| addresses.mainnet.VaultProxy, // vaultAddress | ||
| ], | ||
| addresses.mainnet.OUSDProxy, // _otoken | ||
| addresses.mainnet.USDC, // _hardAsset | ||
| addresses.mainnet.curve.OUSD_USDC.gauge, // _gauge | ||
| addresses.mainnet.CRVMinter, // _minter | ||
| ], | ||
| "CurveAMOStrategy", // actual contract to compile | ||
| true | ||
| ); | ||
|
|
||
| // 2. OETH/WETH Curve AMO | ||
| const dOETHCurveAMO = await deployWithConfirmation( | ||
| "OETHCurveAMOStrategy", | ||
| [ | ||
| [ | ||
| addresses.mainnet.curve.OETH_WETH.pool, // platformAddress | ||
| addresses.mainnet.OETHVaultProxy, // vaultAddress | ||
| ], | ||
| addresses.mainnet.OETHProxy, // _otoken (OETH) | ||
| addresses.mainnet.WETH, // _hardAsset | ||
| addresses.mainnet.curve.OETH_WETH.gauge, // _gauge | ||
| addresses.mainnet.CRVMinter, // _minter | ||
| ], | ||
| "CurveAMOStrategy", | ||
| true | ||
| ); | ||
|
|
||
| // 3. OUSD Morpho V2 | ||
| const dOUSDMorphoV2 = await deployWithConfirmation( | ||
| "MorphoV2Strategy", | ||
| [ | ||
| [ | ||
| addresses.mainnet.MorphoOUSDv2Vault, // platformAddress | ||
| addresses.mainnet.VaultProxy, // vaultAddress | ||
| ], | ||
| addresses.mainnet.USDC, // _assetToken | ||
| ], | ||
| undefined, | ||
| true | ||
| ); | ||
|
|
||
| // ── Governance actions ──────────────────────────────────────────────────── | ||
| return { | ||
| name: "Upgrade Curve AMO and Morpho V2 strategy implementations and set CoW Harvester", | ||
| actions: [ | ||
| // 1. Upgrade OUSD Curve AMO | ||
| { | ||
| contract: cOUSDCurveAMOProxy, | ||
| signature: "upgradeTo(address)", | ||
| args: [dOUSDCurveAMO.address], | ||
| }, | ||
| // 2. Set Multichain Strategist on OUSD Curve AMO | ||
| { | ||
| contract: cOUSDCurveAMO, | ||
| signature: "setHarvesterAddress(address)", | ||
| args: [addresses.multichainStrategist], | ||
| }, | ||
| // 3. Upgrade OETH Curve AMO | ||
| { | ||
| contract: cOETHCurveAMOProxy, | ||
| signature: "upgradeTo(address)", | ||
| args: [dOETHCurveAMO.address], | ||
| }, | ||
| // 4. Set Multichain Strategist on OETH Curve AMO | ||
| { | ||
| contract: cOETHCurveAMO, | ||
| signature: "setHarvesterAddress(address)", | ||
| args: [addresses.multichainStrategist], | ||
sparrowDom marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| // 5. Upgrade OUSD Morpho V2 | ||
| { | ||
| contract: cOUSDMorphoV2Proxy, | ||
| signature: "upgradeTo(address)", | ||
| args: [dOUSDMorphoV2.address], | ||
| }, | ||
| // 6. Set CoW Harvester on OUSD Morpho V2 | ||
| { | ||
| contract: cOUSDMorphoV2, | ||
| signature: "setHarvesterAddress(address)", | ||
| args: [addresses.mainnet.CoWHarvester], | ||
sparrowDom marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| ], | ||
| }; | ||
| } | ||
| ); | ||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.