-
Couldn't load subscription status.
- Fork 92
Upgrade AAVE strategy to AAVE v2 #601
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
Conversation
|
Will write deploy script once we have the new deploy library running and merged. Contract changes ready for review. |
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.
These changes LGTM.
Notes on AAVE Liquidity rewards:
1. Get rewards amount
2. Convert rewards into stkAAVE
3. Trigger cooldownstkAAVE cannot be turned into AAVE without a five day cool down. Sending more funds in restarts the cool down, as does claiming rewards. Additionally, two days after the cool down unlocks, it locks again automatically. To restart the cool down clock:
To find out your current cool down start time:
4. Convert to AAVEWhen the time is right: All togetherBecause moving funds or claiming rewards resets the cool down, the order matters a little bit
|
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.
LGTM
Testing out AAVE StakingstkAave = Contract.from_explorer("0x4da27a545c0c5b758a6ba100e3a049001de870f5")
aave = Contract.from_explorer("0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9")
incentivesController = Contract.from_explorer("0xd784927Ff2f95ba542BfC824c8a8a98F3495f6b5")
VAULT = "0xE75D77B1865Ae93c7eaa3040B038D7aA7BC02F70"
ADAI_V2 = '0x028171bca77440897b824ca71d1c56cac55b68a3'
ME = "0x4a49985b14bd0ce42c25efde5d8c379a48ab02f3"
FROM_ME = {'from': ME}
stkAave.cooldown(FROM_ME)
chain.sleep(stkAave.COOLDOWN_SECONDS()+100)
chain.mine()
cooldown = stkAave.stakersCooldowns(ME)
windowStart = cooldown + stkAave.COOLDOWN_SECONDS()
windowEnd = windowStart + stkAave.UNSTAKE_WINDOW()
currentTimestamp = chain.time()
currentTimestamp > windowStart and currentTimestamp < windowEnd
stkAaveBalance = stkAave.balanceOf(ME)
rewardLiquidationThreshold = 50
stkAaveBalance > rewardLiquidationThreshold
stkAave.redeem(ME, stkAaveBalance, FROM_ME)
stkAave.balanceOf(ME)
aaveBalance = aave.balanceOf(ME)
aave.transfer(VAULT, aaveBalance, FROM_ME)
pendingRewards = incentivesController.getRewardsBalance([ADAI_V2], ME)
incentivesController.claimRewards([ADAI_V2], pendingRewards, ME, FROM_ME) |
|
Now we have tests, next up is deploy scripts. |
before running the implementation initialization code.
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.
Reviewed the deploy script - minor comment inline otherwise lgtm.
I haven't reviewed the contract piece yet.
…llar into DanielVF/aaveV2
| _amount, | ||
| address(this) | ||
| ); | ||
| require(actual >= _amount, "Did not withdraw enough"); |
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.
Backward comparison? Wouldn't actual > _amount mean we withdrew more than expected?
Looking at the LendingPool source, actual is likely to only be reduced to the user's balance if the max int is provided as an argument for amount. Not that we should depend on this never changing since it's upgradable.
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.
I guess this was just a cheap sanity check. Do you think it would be better to do actual == amount?
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.
IMO, I think that would be more appropriate since actual should never be greater than _amount. I was also suggesting the revert message wasn't accurate.
|
@tomlinton, could you take a look at the contract side of this when you have a chance? |
|
Not sure if I previously suggested this, but any thoughts on maintaining the v1 strategy as is (in the codebase) and adding a new file for the v2 strategy stuff? Might be more pain than it is worth. |
|
I think the reason I suggested the v1 vs v2 thing is that when I review the changes here I've got the blinders on with regard to how the rest of the strategy works because the stuff we originally had doesn't show up in the diff, e.g. checkBalance. Fortunately it's all reasonably simple. |
Yeah, maybe we talked in Discord. I'd rather keep the codebase simple, and we can all ways get the old strategy back from git in the unlikely event that we need it. |
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.
👍
RequirementsThis PR moves from AAVE v1 to AAVE v2, and adds support for the AAVE v2 rewards. Sheesh StkAAVE is a pain. Deployment ConsiderationsAAVE v2 rewards collection requires that the collectRewardToken() method on the strategy be called by the vault on the correct times to hit the unstaking window. We may need a keeper contract to do this. Internal StateNo internal state is modified during operation. Contract storage slots are configuration. All dynamic state is looked up from external sources. 💡 If we were using a more recent solidity version, we could AttackAAVE very difficult to misuse. Funds are only ever transferred out to the vault, or to the address specified by the vault. Balances are a simple 1-1 mapping of aToken balances. Logic💡 We aren't handling collecting the small amounts of StkAAVE interest that could be generated from the week worth of StkAAVE we'll build up between converting it to AAVE. If AAVE reintroduces rewards mining, we can upgrade to support it. Tests
FlavorCould reorder methods for more standardization. Will do later though, if we do. Overflow
Black magic
Authentication
Cryptographic codeNo crypto code used. Gas problems
External calls
Ethereum
|
Upgrade AAVE strategy to use AAVE v2.
Discussion for upgrade
We should plan on rolling this out as a new strategy address, just to guarantee a clean slate and that all addresses/state are correct. We'll remove the old strategy, then add this strategy.
Progress:
Contract change checklist: