Skip to content

Commit ddca6ca

Browse files
feat: Disallow duplicated recipients
1 parent 657db34 commit ddca6ca

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/ATokenVaultRevenueSplitterOwner.sol

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ contract ATokenVaultRevenueSplitterOwner is Ownable {
7070
* @dev Constructor.
7171
* @param vault The address of the aToken Vault to own, whose revenue is split.
7272
* @param owner The address owning this contract, the effective owner of the vault.
73-
* @param recipients The recipients to set for the revenue split. It is the caller's responsibility to avoid
74-
* duplicates in the recipients array. The recipients configuration cannot be modified afterwards.
73+
* @param recipients The recipients to set for the revenue split. Duplicates are not allowed. The recipients
74+
* configuration cannot be modified afterwards.
7575
*/
7676
constructor(address vault, address owner, Recipient[] memory recipients) {
7777
VAULT = IATokenVault(vault);
@@ -196,7 +196,7 @@ contract ATokenVaultRevenueSplitterOwner is Ownable {
196196
}
197197

198198
/**
199-
* @dev Does not check for duplicates in the recipients array. Sum of shares must represent 100.00% in basis points.
199+
* @dev Sum of shares must represent 100.00% in basis points.
200200
*/
201201
function _setRecipients(Recipient[] memory recipients) internal {
202202
uint256 accumulatedShareInBps = 0;
@@ -206,6 +206,9 @@ contract ATokenVaultRevenueSplitterOwner is Ownable {
206206
accumulatedShareInBps += recipients[i].shareInBps;
207207
_recipients.push(recipients[i]);
208208
emit RecipientSet(recipients[i].addr, recipients[i].shareInBps);
209+
for (uint256 j = 0; j < i; j++) {
210+
require(recipients[i].addr != recipients[j].addr, "DUPLICATED_RECIPIENT");
211+
}
209212
}
210213
require(accumulatedShareInBps == TOTAL_SHARE_IN_BPS, "WRONG_BPS_SUM");
211214
}

0 commit comments

Comments
 (0)