feat: add new contract to support merkl reward claiming#112
feat: add new contract to support merkl reward claiming#112
Conversation
1c758c8 to
c4178fe
Compare
f707b9d to
6069218
Compare
- inherits from ATokenVault - updates storage struct to store merkl distributor contract (consumes the first of 50 gap slots) - expose functions to set/get distributor (onlyOwner) - expose function to claim rewards from merkl distributor (onlyOwner) - add test that forks Ethereum mainnet to claim rewards
6069218 to
34ae3cb
Compare
- make comments more concise - clarify in comment that native asset can not be rescued - move custom interface into a /dependencies dir - order read/write functions on ATokenVaultMerklRewardsClaim contract and interface
- an operator will be set on the reward distributor contract - an operator can claim rewards on behalf of a user (rewards are still sent to the user i.e. the ATokenVault)
422ca9b to
896fd68
Compare
a2065b4 to
7d5c2f0
Compare
2783fa4 to
558c9ef
Compare
…ward reward tokens to
| * @param destination Address of the destination receiving the reward token | ||
| * @param amount Amount of the reward token transferred to the destination | ||
| */ | ||
| event MerklRewardsTokenForwarded(address indexed token, address indexed destination, uint256 indexed amount); |
There was a problem hiding this comment.
We could do smt similar to RewardsClaimed, and emit the destination, tokens array and amounts array.
There was a problem hiding this comment.
I have no strong preference, but I wanted to avoid emitting the event if the rewardTokensToForward array is empty. If you have a strong preference please lmk. Maybe we return early if rewardTokensToForward is empty then iterate through the tokens then emit an event at the event.
Imagine it would look like this:
event MerklRewardsTokenForwarded(address indexed destination, address[] tokens, uint256[] amounts);
We can also pass in an array of destinations to claimMerklRewards(...) if you think the flexibility would be valuable - then the single token/amount/destination event makes more sense.
…ing of aToken - The change is intended to protect against an attack which leverages a malicious distributor contract which enters into the ATokenVault via depositATokens(uint256 assets, address receiver) then forwards the aToken after the IMerklDistributor::claim call executes, effectively allowing an actor to obtain vault shares for free
Motivation
Currently there is exists no way for an ATokenVault supplying to Aave to claim Merkl rewards. This change adds a contract that inherits from the upgradeable
ATokenVaultand adds functionality to claim Merkl rewards from a distributor address. If existing ATokenVault instances want to upgrade to support these functions then it can be done as this change consumes one of the gap slots reserved for upgrades to hold the Merkl distributor address.Changes