Skip to content

Commit aea558b

Browse files
committed
[CurvePB] Add duplicate check and use calldata for pool lists
Refactor _addPoolBoosterAddress to accept a single address and revert with "Pool already added" if it already exists, preventing double processing and double bridge fees. Switch addPoolBoosterAddress parameter to calldata for gas efficiency, consistent with removePoolBoosterAddress.
1 parent 94262a8 commit aea558b

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

contracts/contracts/automation/CurvePoolBoosterBribesModule.sol

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ contract CurvePoolBoosterBribesModule is AbstractSafeModule {
5353
uint256 _bridgeFee
5454
) AbstractSafeModule(_safeContract) {
5555
_grantRole(OPERATOR_ROLE, _operator);
56-
_addPoolBoosterAddress(_pools);
56+
for (uint256 i = 0; i < _pools.length; i++) {
57+
_addPoolBoosterAddress(_pools[i]);
58+
}
5759
_setBridgeFee(_bridgeFee);
5860
}
5961

@@ -63,11 +65,13 @@ contract CurvePoolBoosterBribesModule is AbstractSafeModule {
6365

6466
/// @notice Add new CurvePoolBooster addresses to the managed list
6567
/// @param _pools Addresses to add
66-
function addPoolBoosterAddress(address[] memory _pools)
68+
function addPoolBoosterAddress(address[] calldata _pools)
6769
external
6870
onlyOperator
6971
{
70-
_addPoolBoosterAddress(_pools);
72+
for (uint256 i = 0; i < _pools.length; i++) {
73+
_addPoolBoosterAddress(_pools[i]);
74+
}
7175
}
7276

7377
/// @notice Remove CurvePoolBooster addresses from the managed list
@@ -137,13 +141,15 @@ contract CurvePoolBoosterBribesModule is AbstractSafeModule {
137141
/// --- Internal Functions
138142
////////////////////////////////////////////////////
139143

140-
/// @notice Internal logic to add pool booster addresses
141-
/// @param _pools Addresses to append to the pools array
142-
function _addPoolBoosterAddress(address[] memory _pools) internal {
143-
for (uint256 i = 0; i < _pools.length; i++) {
144-
pools.push(_pools[i]);
145-
emit PoolBoosterAddressAdded(_pools[i]);
144+
/// @notice Internal logic to add a single pool booster address
145+
/// @dev Reverts if the address is already in the pools array
146+
/// @param _pool Address to append to the pools array
147+
function _addPoolBoosterAddress(address _pool) internal {
148+
for (uint256 j = 0; j < pools.length; j++) {
149+
require(pools[j] != _pool, "Pool already added");
146150
}
151+
pools.push(_pool);
152+
emit PoolBoosterAddressAdded(_pool);
147153
}
148154

149155
/// @notice Internal logic to remove a pool booster address

0 commit comments

Comments
 (0)