-
Notifications
You must be signed in to change notification settings - Fork 84
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
Simple harvester for OETH #2333
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2333 +/- ##
==========================================
- Coverage 52.15% 51.84% -0.32%
==========================================
Files 80 81 +1
Lines 4101 4126 +25
Branches 1079 1084 +5
==========================================
Hits 2139 2139
- Misses 1959 1984 +25
Partials 3 3 ☔ View full report in Codecov by Sentry. |
Code review - Simple harvesterRequirementsWe want to be able to route some strategy reward token earnings directly to the strategist, for further allocation/distribution. This contract allows anyone to harvest, does not pay incentives, and routes all to the strategist. The strategist can control which contracts this can call, while governance controls which strategies allow this contract to call it. Easy ChecksAuthentication
Ethereum
Cryptographic codeno crypto Gas problems
Black magicno magic Overflow
Proxy
Events
Rounding and castsNo rounding DependenciesNo dependancies outside our code. External calls
Deploy
LogicLogic looks correct Internal StateNo internal state, config only AttackThis contract will move weekly/daily reward token yield. It will not touch user funds. If an attacker could change the strategist address, they would receive the yield. However, the strategist address can only be controlled by the governor. The governor can only be changed by the governor. If the attacker were able to whitelist a malicious strategy this would not allow taking yield, since yield only goes to the strategist, and all coins are emptied after each strategy harvest runs. This could be used as a “clever backdoor” for recovering random coins sent to this contract by accident. A strategy that fails to be harvested can just be not called on, so that it does not block other harvests. FlavorFlavor is good.
|
expect(await simpleOETHHarvester.governor()).to.be.equal( | ||
addresses.mainnet.Timelock | ||
); | ||
expect(await simpleOETHHarvester.strategist()).to.be.equal(deployerAddr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this line will change as well once strategist address gets updated
) | ||
).to.be.equal(false); | ||
await simpleOETHHarvester | ||
.connect(timelock) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should also have a test for the strategist
to set a supported strategy
RequirementsThis PR introduces a simplified Harvester which harvests the reward tokens from strategies and without having the ability to swap sends them to the strategist. The strategist has the permissions to pick a set of strategies to be harvested. The governor sets the strategist and approves the harvester on the strategy contract. Easy ChecksAuthentication
Ethereum
Cryptographic code
Gas problems
Black magic
Overflow
Proxy
Events
Medium ChecksRounding and castsno rounding Dependenciesno dependencies External calls
Tests
Deploydeploy looks ok ThinkingLogicLogic looks ok Deployment ConsiderationsAside from changing the strategist address deployment is ok Internal StateInternal state is just config AttackThis contract doesn't touch user funds, rather the strategy rewards. In worst case if the strategist is compromised then:
Flavorcode is simple |
@sparrowDom Which address should I use for the strategist at the deployment? |
if (balance > 0) { | ||
// Transfer to strategist | ||
IERC20(rewardTokens[i]).safeTransfer(strategistAddr, balance); | ||
emit Harvested(rewardTokens[i], balance); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Let's emit the strategy address here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes good idea, done in this commit: 0e8ab277
@clement-ux you can set it to the mainnet Strategist: https://github.com/OriginProtocol/origin-dollar/blob/master/contracts/hardhat.config.js#L47 |
@sparrowDom I don't think we need to worry about gas on the coin loop. The number of coins is not under control, and we can upgrade the strategy if for some reason we had the hundreds of reward tokens it would take to hit gas limits. |
|
||
expect(await simpleOETHHarvester.governor()).to.be.equal( | ||
addresses.mainnet.Timelock | ||
); | ||
|
||
console.log("strategistAddr: ", strategistAddr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can probably delete this one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, indeed 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DanielVF cool sounds good.
@clement-ux all the things from my full report have been addressed. I've updated the report. Great job on this one 💪
Simple Harvester
This PR aims to deploy a simple harvester for the OETH AMO to replace the current.
This new harvester is simpler, as it will only harvest reward and send it to the strategist.
Note: strategist and operator addresses are set to the deployer address but must be changed.
Code Change Checklist
To be completed before internal review begins:
Internal review:
Deploy checklist
Two reviewers complete the following checklist: