From 90b3c94fe1e4dc1032599d3abba688c28003b41a Mon Sep 17 00:00:00 2001 From: Nika Khachiashvili Date: Tue, 1 Oct 2024 15:53:18 -0400 Subject: [PATCH] fix [HAL-03] unsafe type casting --- src/adapters/MorphoRUSDAdapter.sol | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/adapters/MorphoRUSDAdapter.sol b/src/adapters/MorphoRUSDAdapter.sol index 7568a03..352a19f 100644 --- a/src/adapters/MorphoRUSDAdapter.sol +++ b/src/adapters/MorphoRUSDAdapter.sol @@ -6,6 +6,7 @@ import {AccessControl} from "openzeppelin-contracts/contracts/access/AccessContr import {IERC4626} from "openzeppelin-contracts/contracts/interfaces/IERC4626.sol"; import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; +import {SafeCast} from "openzeppelin-contracts/contracts/utils/math/SafeCast.sol"; import {Stablecoin} from "../Stablecoin.sol"; import {IOracle} from "src/interfaces/IOracle.sol"; @@ -192,13 +193,13 @@ contract MorphoRUSDAdapter is IAssetAdapter, AccessControl { { int256 latestAnswer = underlyingPriceOracle.latestAnswer(); - return latestAnswer > 0 ? uint256(latestAnswer) : 0; + return latestAnswer > 0 ? SafeCast.toUint256(latestAnswer) : 0; } function _fundPriceOracleLatestAnswer() private view returns (uint256) { int256 latestAnswer = fundPriceOracle.latestAnswer(); - return latestAnswer > 0 ? uint256(latestAnswer) : 0; + return latestAnswer > 0 ? SafeCast.toUint256(latestAnswer) : 0; } function recover(address _token) external onlyRole(MANAGER) {