Skip to content

Commit ba801e1

Browse files
committed
enh: address PR comments
- 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
1 parent 34ae3cb commit ba801e1

File tree

4 files changed

+44
-38
lines changed

4 files changed

+44
-38
lines changed

src/ATokenVaultMerklRewardClaimer.sol

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,12 @@ import {IERC20} from "@openzeppelin/interfaces/IERC20.sol";
88

99
import {ATokenVault} from "./ATokenVault.sol";
1010
import {IATokenVaultMerklRewardClaimer} from "./interfaces/IATokenVaultMerklRewardClaimer.sol";
11-
12-
interface IMerklDistributor {
13-
function claim(
14-
address[] calldata users,
15-
address[] calldata tokens,
16-
uint256[] calldata amounts,
17-
bytes32[][] calldata proofs
18-
) external;
19-
}
11+
import {IMerklDistributor} from "./dependencies/merkl/DistributorInterface.sol";
2012

2113
/**
2214
* @title ATokenVaultMerklRewardClaimer
2315
* @author Aave Protocol
24-
* @notice A contract that allows the owner to claim Merkl rewards for the ATokenVault
16+
* @notice ATokenVault, with Merkl reward claiming capability
2517
*/
2618
contract ATokenVaultMerklRewardClaimer is ATokenVault, IATokenVaultMerklRewardClaimer {
2719
/**
@@ -34,19 +26,6 @@ contract ATokenVaultMerklRewardClaimer is ATokenVault, IATokenVaultMerklRewardCl
3426
ATokenVault(underlying, referralCode, poolAddressesProvider)
3527
{}
3628

37-
/// @inheritdoc IATokenVaultMerklRewardClaimer
38-
function getMerklDistributor() external view override returns (address) {
39-
return _s.merklDistributor;
40-
}
41-
42-
/// @inheritdoc IATokenVaultMerklRewardClaimer
43-
function setMerklDistributor(address merklDistributor) external override onlyOwner {
44-
require(merklDistributor != address(0), "ZERO_ADDRESS_NOT_VALID");
45-
address currentMerklDistributor = _s.merklDistributor;
46-
_s.merklDistributor = merklDistributor;
47-
emit MerklDistributorUpdated(currentMerklDistributor, merklDistributor);
48-
}
49-
5029
/// @inheritdoc IATokenVaultMerklRewardClaimer
5130
function claimMerklRewards(address[] calldata rewardTokens, uint256[] calldata amounts, bytes32[][] calldata proofs)
5231
public
@@ -63,7 +42,7 @@ contract ATokenVaultMerklRewardClaimer is ATokenVault, IATokenVaultMerklRewardCl
6342

6443
// The claim function does not return a list of tokens and amounts actually received.
6544
// It is possible for rewards to be in aTokens, the underlying asset or some other token.
66-
// If necessary the owner can use IATokenVault.emergencyRescue(...) to rescue the non-aToken rewards.
45+
// If necessary the owner can use IATokenVault.emergencyRescue(...) to rescue the non-aToken rewards and non-native rewards.
6746
IMerklDistributor(_s.merklDistributor).claim(users, rewardTokens, amounts, proofs);
6847
// Do not attempt to accrue yield as it can be delegated to subsequent calls to this contract.
6948
// We do not need to accrue before claiming because new shares are not granted anywhere (rewards are socialized across all current share holders).
@@ -72,4 +51,17 @@ contract ATokenVaultMerklRewardClaimer is ATokenVault, IATokenVaultMerklRewardCl
7251

7352
emit MerklRewardsClaimed(rewardTokens, amounts);
7453
}
54+
55+
/// @inheritdoc IATokenVaultMerklRewardClaimer
56+
function setMerklDistributor(address merklDistributor) external override onlyOwner {
57+
require(merklDistributor != address(0), "ZERO_ADDRESS_NOT_VALID");
58+
address currentMerklDistributor = _s.merklDistributor;
59+
_s.merklDistributor = merklDistributor;
60+
emit MerklDistributorUpdated(currentMerklDistributor, merklDistributor);
61+
}
62+
63+
/// @inheritdoc IATokenVaultMerklRewardClaimer
64+
function getMerklDistributor() external view override returns (address) {
65+
return _s.merklDistributor;
66+
}
7567
}

src/ATokenVaultStorage.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ abstract contract ATokenVaultStorage {
2020
uint40 __deprecated_gap;
2121
// as a fraction of 1e18
2222
uint64 fee;
23-
// Merkl distributor contract address called to claim Merkl rewards
23+
// Merkl distributor contract
2424
address merklDistributor;
2525
// Reserved storage space to allow for layout changes in the future
2626
uint256[49] __gap;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
// Based on implementation from https://github.com/AngleProtocol/merkl-contracts/blob/b7bd0e65a3f366e4041bc83494cbd981f8852b16/contracts/Distributor.sol#L202
3+
// All Rights Reserved © AaveCo
4+
5+
pragma solidity ^0.8.10;
6+
7+
interface IMerklDistributor {
8+
function claim(
9+
address[] calldata users,
10+
address[] calldata tokens,
11+
uint256[] calldata amounts,
12+
bytes32[][] calldata proofs
13+
) external;
14+
}

src/interfaces/IATokenVaultMerklRewardClaimer.sol

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,6 @@ interface IATokenVaultMerklRewardClaimer {
2626
*/
2727
event MerklDistributorUpdated(address indexed oldMerklDistributor, address indexed newMerklDistributor);
2828

29-
/**
30-
* @notice Getter for the contract address called to claim Merkl rewards
31-
* @return Address of the Merkl distributor contract
32-
*/
33-
function getMerklDistributor() external view returns (address);
34-
35-
/**
36-
* @notice Sets the Merkl distributor address for the vault uses to claim Merkl rewards.
37-
* @dev Only callable by the owner
38-
* @param merklDistributor Address of the new Merkl distributor contract
39-
*/
40-
function setMerklDistributor(address merklDistributor) external;
41-
4229
/**
4330
* @notice Claims Merkl rewards earned by deposits from this contract through the Merkl distributor contract
4431
* @dev Only callable by the owner
@@ -51,4 +38,17 @@ interface IATokenVaultMerklRewardClaimer {
5138
*/
5239
function claimMerklRewards(address[] calldata rewardTokens, uint256[] calldata amounts, bytes32[][] calldata proofs)
5340
external;
41+
42+
/**
43+
* @notice Sets the Merkl distributor address for the vault uses to claim Merkl rewards.
44+
* @dev Only callable by the owner
45+
* @param merklDistributor Address of the new Merkl distributor contract
46+
*/
47+
function setMerklDistributor(address merklDistributor) external;
48+
49+
/**
50+
* @notice Getter for the contract address called to claim Merkl rewards
51+
* @return Address of the Merkl distributor contract
52+
*/
53+
function getMerklDistributor() external view returns (address);
5454
}

0 commit comments

Comments
 (0)