diff --git a/contracts/adapters/balancer/BalancerV2VaultAdapter.sol b/contracts/adapters/balancer/BalancerV2VaultAdapter.sol index e29e91ca..754004cf 100644 --- a/contracts/adapters/balancer/BalancerV2VaultAdapter.sol +++ b/contracts/adapters/balancer/BalancerV2VaultAdapter.sol @@ -496,11 +496,8 @@ contract BalancerV2VaultAdapter is AbstractAdapter, IBalancerV2VaultAdapter { /// @dev Internal function that changes approval for a batch of assets in the vault (overloading) function _approveAssets(IAsset[] memory assets, uint256[] memory filter, uint256 amount) internal { uint256 len = assets.length; - - unchecked { - for (uint256 i = 0; i < len; ++i) { - if (filter[i] > 1) _approveToken(address(assets[i]), amount); - } + for (uint256 i = 0; i < len; ++i) { + if (filter[i] > 1) _approveToken(address(assets[i]), amount); } } diff --git a/contracts/adapters/camelot/CamelotV3Adapter.sol b/contracts/adapters/camelot/CamelotV3Adapter.sol index dbf2678e..d05f8fb5 100644 --- a/contracts/adapters/camelot/CamelotV3Adapter.sol +++ b/contracts/adapters/camelot/CamelotV3Adapter.sol @@ -280,26 +280,24 @@ contract CamelotV3Adapter is AbstractAdapter, ICamelotV3Adapter { /// @param pools Array of `CamelotV3PoolStatus` objects function setPoolStatusBatch(CamelotV3PoolStatus[] calldata pools) external override configuratorOnly { uint256 len = pools.length; - unchecked { - for (uint256 i; i < len; ++i) { - (address token0, address token1) = _sortTokens(pools[i].token0, pools[i].token1); - - bytes32 poolHash = keccak256(abi.encode(token0, token1)); - if (pools[i].allowed) { - /// For each added pool, we verify that the pool tokens are valid collaterals, - /// as otherwise operations with unsupported tokens would be possible, leading - /// to possibility of control flow capture - _getMaskOrRevert(token0); - _getMaskOrRevert(token1); - - _supportedPoolHashes.add(poolHash); - _hashToPool[poolHash] = CamelotV3Pool({token0: token0, token1: token1}); - } else { - _supportedPoolHashes.remove(poolHash); - delete _hashToPool[poolHash]; - } - emit SetPoolStatus(token0, token1, pools[i].allowed); // U: [CAMV3-9] + for (uint256 i; i < len; ++i) { + (address token0, address token1) = _sortTokens(pools[i].token0, pools[i].token1); + + bytes32 poolHash = keccak256(abi.encode(token0, token1)); + if (pools[i].allowed) { + /// For each added pool, we verify that the pool tokens are valid collaterals, + /// as otherwise operations with unsupported tokens would be possible, leading + /// to possibility of control flow capture + _getMaskOrRevert(token0); + _getMaskOrRevert(token1); + + _supportedPoolHashes.add(poolHash); + _hashToPool[poolHash] = CamelotV3Pool({token0: token0, token1: token1}); + } else { + _supportedPoolHashes.remove(poolHash); + delete _hashToPool[poolHash]; } + emit SetPoolStatus(token0, token1, pools[i].allowed); // U: [CAMV3-9] } } diff --git a/contracts/adapters/convex/ConvexV1_Booster.sol b/contracts/adapters/convex/ConvexV1_Booster.sol index 65af0114..97b81695 100644 --- a/contracts/adapters/convex/ConvexV1_Booster.sol +++ b/contracts/adapters/convex/ConvexV1_Booster.sol @@ -180,28 +180,26 @@ contract ConvexV1BoosterAdapter is AbstractAdapter, IConvexV1BoosterAdapter { address[] memory allowedAdapters = cc.allowedAdapters(); uint256 len = allowedAdapters.length; - unchecked { - for (uint256 i = 0; i < len; ++i) { - address adapter = allowedAdapters[i]; - address poolTargetContract = IAdapter(adapter).targetContract(); - - if ( - IAdapter(adapter).contractType() == "AD_CONVEX_V1_BASE_REWARD_POOL" - && IBaseRewardPool(poolTargetContract).operator() == targetContract - ) { - uint256 pid = IBaseRewardPool(poolTargetContract).pid(); - address phantomToken = IConvexV1BaseRewardPoolAdapter(adapter).stakedPhantomToken(); - - /// No sanity checks on pool-related tokens (Curve token, Convex token, phantom token) being collateral - /// need to be performed, as they were already done while deploying the pool adapter itself - - pidToPhantomToken[pid] = phantomToken; - pidToCurveToken[pid] = IConvexV1BaseRewardPoolAdapter(adapter).curveLPtoken(); - pidToConvexToken[pid] = IConvexV1BaseRewardPoolAdapter(adapter).stakingToken(); - - _supportedPids.add(pid); - emit AddSupportedPid(pid); - } + for (uint256 i = 0; i < len; ++i) { + address adapter = allowedAdapters[i]; + address poolTargetContract = IAdapter(adapter).targetContract(); + + if ( + IAdapter(adapter).contractType() == "AD_CONVEX_V1_BASE_REWARD_POOL" + && IBaseRewardPool(poolTargetContract).operator() == targetContract + ) { + uint256 pid = IBaseRewardPool(poolTargetContract).pid(); + address phantomToken = IConvexV1BaseRewardPoolAdapter(adapter).stakedPhantomToken(); + + /// No sanity checks on pool-related tokens (Curve token, Convex token, phantom token) being collateral + /// need to be performed, as they were already done while deploying the pool adapter itself + + pidToPhantomToken[pid] = phantomToken; + pidToCurveToken[pid] = IConvexV1BaseRewardPoolAdapter(adapter).curveLPtoken(); + pidToConvexToken[pid] = IConvexV1BaseRewardPoolAdapter(adapter).stakingToken(); + + _supportedPids.add(pid); + emit AddSupportedPid(pid); } } } diff --git a/contracts/adapters/curve/CurveV1_Base.sol b/contracts/adapters/curve/CurveV1_Base.sol index 36c11331..0b47aee7 100644 --- a/contracts/adapters/curve/CurveV1_Base.sol +++ b/contracts/adapters/curve/CurveV1_Base.sol @@ -65,12 +65,10 @@ abstract contract CurveV1AdapterBase is AbstractAdapter, ICurveV1Adapter { use256 = _use256(); address[4] memory tokens; - unchecked { - for (uint256 i; i < nCoins; ++i) { - tokens[i] = _getCoin(_curvePool, i); // U:[CRVB-1] - if (tokens[i] == address(0)) revert IncorrectParameterException(); // U:[CRVB-1] - _getMaskOrRevert(tokens[i]); // U:[CRVB-1] - } + for (uint256 i; i < nCoins; ++i) { + tokens[i] = _getCoin(_curvePool, i); // U:[CRVB-1] + if (tokens[i] == address(0)) revert IncorrectParameterException(); // U:[CRVB-1] + _getMaskOrRevert(tokens[i]); // U:[CRVB-1] } token0 = tokens[0]; diff --git a/contracts/adapters/uniswap/UniswapV2.sol b/contracts/adapters/uniswap/UniswapV2.sol index c9aa3280..5f8450d9 100644 --- a/contracts/adapters/uniswap/UniswapV2.sol +++ b/contracts/adapters/uniswap/UniswapV2.sol @@ -181,25 +181,23 @@ contract UniswapV2Adapter is AbstractAdapter, IUniswapV2Adapter { configuratorOnly // U:[UNI2-6] { uint256 len = pairs.length; - unchecked { - for (uint256 i; i < len; ++i) { - (address token0, address token1) = _sortTokens(pairs[i].token0, pairs[i].token1); - bytes32 pairHash = keccak256(abi.encode(token0, token1)); - if (pairs[i].allowed) { - /// For each added pool, we verify that the pool tokens are valid collaterals, - /// as otherwise operations with unsupported tokens would be possible, leading - /// to possibility of control flow capture - _getMaskOrRevert(token0); - _getMaskOrRevert(token1); - - _supportedPairHashes.add(pairHash); - _hashToPair[pairHash] = UniswapV2Pair({token0: token0, token1: token1}); - } else { - _supportedPairHashes.remove(pairHash); - delete _hashToPair[pairHash]; - } - emit SetPairStatus(token0, token1, pairs[i].allowed); // U:[UNI2-6] + for (uint256 i; i < len; ++i) { + (address token0, address token1) = _sortTokens(pairs[i].token0, pairs[i].token1); + bytes32 pairHash = keccak256(abi.encode(token0, token1)); + if (pairs[i].allowed) { + /// For each added pool, we verify that the pool tokens are valid collaterals, + /// as otherwise operations with unsupported tokens would be possible, leading + /// to possibility of control flow capture + _getMaskOrRevert(token0); + _getMaskOrRevert(token1); + + _supportedPairHashes.add(pairHash); + _hashToPair[pairHash] = UniswapV2Pair({token0: token0, token1: token1}); + } else { + _supportedPairHashes.remove(pairHash); + delete _hashToPair[pairHash]; } + emit SetPairStatus(token0, token1, pairs[i].allowed); // U:[UNI2-6] } } diff --git a/contracts/adapters/uniswap/UniswapV3.sol b/contracts/adapters/uniswap/UniswapV3.sol index ed89a29c..2aace47e 100644 --- a/contracts/adapters/uniswap/UniswapV3.sol +++ b/contracts/adapters/uniswap/UniswapV3.sol @@ -241,25 +241,23 @@ contract UniswapV3Adapter is AbstractAdapter, IUniswapV3Adapter { configuratorOnly // U:[UNI3-9] { uint256 len = pools.length; - unchecked { - for (uint256 i; i < len; ++i) { - (address token0, address token1) = _sortTokens(pools[i].token0, pools[i].token1); - bytes32 poolHash = keccak256(abi.encode(token0, token1, pools[i].fee)); - if (pools[i].allowed) { - /// For each added pool, we verify that the pool tokens are valid collaterals, - /// as otherwise operations with unsupported tokens would be possible, leading - /// to possibility of control flow capture - _getMaskOrRevert(token0); - _getMaskOrRevert(token1); - - _supportedPoolHashes.add(poolHash); - _hashToPool[poolHash] = UniswapV3Pool({token0: token0, token1: token1, fee: pools[i].fee}); - } else { - _supportedPoolHashes.remove(poolHash); - delete _hashToPool[poolHash]; - } - emit SetPoolStatus(token0, token1, pools[i].fee, pools[i].allowed); // U:[UNI3-9] + for (uint256 i; i < len; ++i) { + (address token0, address token1) = _sortTokens(pools[i].token0, pools[i].token1); + bytes32 poolHash = keccak256(abi.encode(token0, token1, pools[i].fee)); + if (pools[i].allowed) { + /// For each added pool, we verify that the pool tokens are valid collaterals, + /// as otherwise operations with unsupported tokens would be possible, leading + /// to possibility of control flow capture + _getMaskOrRevert(token0); + _getMaskOrRevert(token1); + + _supportedPoolHashes.add(poolHash); + _hashToPool[poolHash] = UniswapV3Pool({token0: token0, token1: token1, fee: pools[i].fee}); + } else { + _supportedPoolHashes.remove(poolHash); + delete _hashToPool[poolHash]; } + emit SetPoolStatus(token0, token1, pools[i].fee, pools[i].allowed); // U:[UNI3-9] } } diff --git a/contracts/adapters/velodrome/VelodromeV2RouterAdapter.sol b/contracts/adapters/velodrome/VelodromeV2RouterAdapter.sol index b8baf11b..2e70f7d1 100644 --- a/contracts/adapters/velodrome/VelodromeV2RouterAdapter.sol +++ b/contracts/adapters/velodrome/VelodromeV2RouterAdapter.sol @@ -151,30 +151,28 @@ contract VelodromeV2RouterAdapter is AbstractAdapter, IVelodromeV2RouterAdapter /// @param pools Array of `VelodromeV2PoolStatus` objects function setPoolStatusBatch(VelodromeV2PoolStatus[] calldata pools) external override configuratorOnly { uint256 len = pools.length; - unchecked { - for (uint256 i; i < len; ++i) { - (address token0, address token1) = _sortTokens(pools[i].token0, pools[i].token1); - bytes32 poolHash = keccak256(abi.encode(token0, token1, pools[i].stable, pools[i].factory)); - if (pools[i].allowed) { - /// For each added pool, we verify that the pool tokens are valid collaterals, - /// as otherwise operations with unsupported tokens would be possible, leading - /// to possibility of control flow capture - _getMaskOrRevert(token0); - _getMaskOrRevert(token1); - - _supportedPoolHashes.add(poolHash); - _hashToPool[poolHash] = VelodromeV2Pool({ - token0: token0, - token1: token1, - stable: pools[i].stable, - factory: pools[i].factory - }); - } else { - _supportedPoolHashes.remove(poolHash); - delete _hashToPool[poolHash]; - } - emit SetPoolStatus(token0, token1, pools[i].stable, pools[i].factory, pools[i].allowed); // U: [VELO2-05] + for (uint256 i; i < len; ++i) { + (address token0, address token1) = _sortTokens(pools[i].token0, pools[i].token1); + bytes32 poolHash = keccak256(abi.encode(token0, token1, pools[i].stable, pools[i].factory)); + if (pools[i].allowed) { + /// For each added pool, we verify that the pool tokens are valid collaterals, + /// as otherwise operations with unsupported tokens would be possible, leading + /// to possibility of control flow capture + _getMaskOrRevert(token0); + _getMaskOrRevert(token1); + + _supportedPoolHashes.add(poolHash); + _hashToPool[poolHash] = VelodromeV2Pool({ + token0: token0, + token1: token1, + stable: pools[i].stable, + factory: pools[i].factory + }); + } else { + _supportedPoolHashes.remove(poolHash); + delete _hashToPool[poolHash]; } + emit SetPoolStatus(token0, token1, pools[i].stable, pools[i].factory, pools[i].allowed); // U: [VELO2-05] } } diff --git a/contracts/adapters/zircuit/ZircuitPoolAdapter.sol b/contracts/adapters/zircuit/ZircuitPoolAdapter.sol index fe392467..4261b639 100644 --- a/contracts/adapters/zircuit/ZircuitPoolAdapter.sol +++ b/contracts/adapters/zircuit/ZircuitPoolAdapter.sol @@ -147,23 +147,20 @@ contract ZircuitPoolAdapter is AbstractAdapter, IZircuitPoolAdapter { ICreditManagerV3 cm = ICreditManagerV3(creditManager); uint256 len = cm.collateralTokensCount(); - - unchecked { - for (uint256 i = 0; i < len; ++i) { - address token = cm.getTokenByMask(1 << i); - try IPhantomToken(token)._gearboxPhantomTokenType() returns (PhantomTokenType ptType) { - if (ptType == PhantomTokenType.ZIRCUIT_PHANTOM_TOKEN) { - address depositedToken = ZircuitPhantomToken(token).underlying(); - - _getMaskOrRevert(token); - _getMaskOrRevert(depositedToken); - - tokenToPhantomToken[depositedToken] = token; - _supportedUnderlyings.add(depositedToken); - emit AddSupportedUnderlying(depositedToken, token); - } - } catch {} - } + for (uint256 i = 0; i < len; ++i) { + address token = cm.getTokenByMask(1 << i); + try IPhantomToken(token)._gearboxPhantomTokenType() returns (PhantomTokenType ptType) { + if (ptType == PhantomTokenType.ZIRCUIT_PHANTOM_TOKEN) { + address depositedToken = ZircuitPhantomToken(token).underlying(); + + _getMaskOrRevert(token); + _getMaskOrRevert(depositedToken); + + tokenToPhantomToken[depositedToken] = token; + _supportedUnderlyings.add(depositedToken); + emit AddSupportedUnderlying(depositedToken, token); + } + } catch {} } } }