Skip to content

Commit 558c9ef

Browse files
committed
refactor(ATokenVaultMerklRewardClaimer): address feedback
1 parent 7d5c2f0 commit 558c9ef

5 files changed

Lines changed: 237 additions & 190 deletions

File tree

src/ATokenVaultMerklRewardClaimer.sol

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,13 @@ contract ATokenVaultMerklRewardClaimer is ATokenVault, IATokenVaultMerklRewardCl
3333
onlyOwner
3434
{
3535
require(_s.merklDistributor != address(0), "MERKL_DISTRIBUTOR_NOT_SET");
36+
require(rewardTokens.length == amounts.length && rewardTokens.length == proofs.length, "ARRAY_LENGTH_MISMATCH");
3637

3738
address[] memory users = new address[](rewardTokens.length);
3839
for (uint256 i = 0; i < rewardTokens.length; i++) {
39-
// users represent depositors into Aave which is this contract
4040
users[i] = address(this);
4141
}
42-
43-
// The claim function does not return a list of tokens and amounts actually received.
44-
// It is possible for rewards to be in aTokens, the underlying asset or some other token.
45-
// If necessary the owner can use IATokenVault.emergencyRescue(...) to rescue the non-aToken rewards and non-native rewards.
4642
IMerklDistributor(_s.merklDistributor).claim(users, rewardTokens, amounts, proofs);
47-
// Do not attempt to accrue yield as it can be delegated to subsequent calls to this contract.
48-
// We do not need to accrue before claiming because new shares are not granted anywhere (rewards are socialized across all current share holders).
49-
// We do not need to accrue after claiming because any subsequent call will trigger an accrual before state updates
50-
// and preview functions read the balance of aTokens on the vault at runtime.
51-
5243
emit MerklRewardsClaimed(_s.merklDistributor, rewardTokens, amounts);
5344
}
5445

@@ -60,14 +51,6 @@ contract ATokenVaultMerklRewardClaimer is ATokenVault, IATokenVaultMerklRewardCl
6051
emit MerklDistributorUpdated(currentMerklDistributor, merklDistributor);
6152
}
6253

63-
/// @inheritdoc IATokenVaultMerklRewardClaimer
64-
function toggleOperator(address operator) external override onlyOwner {
65-
require(_s.merklDistributor != address(0), "MERKL_DISTRIBUTOR_NOT_SET");
66-
require(operator != address(0), "ZERO_ADDRESS_NOT_VALID");
67-
IMerklDistributor(_s.merklDistributor).toggleOperator(address(this), operator);
68-
emit MerklRewardsOperatorToggled(_s.merklDistributor, operator);
69-
}
70-
7154
/// @inheritdoc IATokenVaultMerklRewardClaimer
7255
function getMerklDistributor() external view override returns (address) {
7356
return _s.merklDistributor;
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
// SPDX-License-Identifier: UNLICENSED
1+
// SPDX-License-Identifier: BUSL-1.1
22
// Based on implementation from https://github.com/AngleProtocol/merkl-contracts/blob/b7bd0e65a3f366e4041bc83494cbd981f8852b16/contracts/Distributor.sol#L202
3-
// All Rights Reserved © AaveCo
4-
53
pragma solidity ^0.8.10;
64

75
interface IMerklDistributor {
@@ -11,6 +9,4 @@ interface IMerklDistributor {
119
uint256[] calldata amounts,
1210
bytes32[][] calldata proofs
1311
) external;
14-
15-
function toggleOperator(address user, address operator) external;
1612
}

src/interfaces/IATokenVaultMerklRewardClaimer.sol

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ interface IATokenVaultMerklRewardClaimer {
2020
*/
2121
event MerklRewardsClaimed(address indexed distributor, address[] tokens, uint256[] amounts);
2222

23-
/**
24-
* @dev Emitted when the operator status for the vault is toggled
25-
* @param distributor Address of the Merkl distributor contract
26-
* @param operator Address of the operator to toggle
27-
*/
28-
event MerklRewardsOperatorToggled(address indexed distributor, address indexed operator);
29-
3023
/**
3124
* @dev Emitted when the Merkl distributor address is updated
3225
* @param oldMerklDistributor The old address of the Merkl distributor contract
@@ -35,7 +28,7 @@ interface IATokenVaultMerklRewardClaimer {
3528
event MerklDistributorUpdated(address indexed oldMerklDistributor, address indexed newMerklDistributor);
3629

3730
/**
38-
* @notice Claims Merkl rewards earned by deposits from this contract through the Merkl distributor contract
31+
* @notice Claims Merkl protocol rewards accrued from vault deposits.
3932
* @dev Only callable by the owner
4033
* @dev Merkl distributor address must be set
4134
* @dev The IMerklDistributor.claim(...) function does not return a list of tokens and amounts the users actually receive
@@ -55,15 +48,8 @@ interface IATokenVaultMerklRewardClaimer {
5548
function setMerklDistributor(address merklDistributor) external;
5649

5750
/**
58-
* @notice Toggles the operator status for the vault
59-
* @dev Only callable by the owner
60-
* @param operator Address of the operator to toggle
61-
*/
62-
function toggleOperator(address operator) external;
63-
64-
/**
65-
* @notice Getter for the contract address called to claim Merkl rewards
66-
* @return Address of the Merkl distributor contract
51+
* @notice Returns the address of the Merkl distributor contract.
52+
* @return The address of the Merkl distributor contract
6753
*/
6854
function getMerklDistributor() external view returns (address);
6955
}

0 commit comments

Comments
 (0)