diff --git a/nest/src/ComponentToken.sol b/nest/src/ComponentToken.sol index 66e54d6..2f3dcf1 100644 --- a/nest/src/ComponentToken.sol +++ b/nest/src/ComponentToken.sol @@ -10,6 +10,8 @@ import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/ import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol"; import { IERC4626 } from "@openzeppelin/contracts/interfaces/IERC4626.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; + +import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { ERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; @@ -252,9 +254,7 @@ abstract contract ComponentToken is revert Unimplemented(); } - if (!IERC20(asset()).transferFrom(owner, address(this), assets)) { - revert InsufficientBalance(IERC20(asset()), owner, assets); - } + SafeERC20.safeTransferFrom(IERC20(asset()), owner, address(this), assets); $.pendingDepositRequest[controller] += assets; emit DepositRequest(controller, owner, REQUEST_ID, owner, assets); @@ -309,9 +309,7 @@ abstract contract ComponentToken is $.claimableDepositRequest[controller] -= assets; $.sharesDepositRequest[controller] -= shares; } else { - if (!IERC20(asset()).transferFrom(controller, address(this), assets)) { - revert InsufficientBalance(IERC20(asset()), controller, assets); - } + SafeERC20.safeTransferFrom(IERC20(asset()), controller, address(this), assets); shares = convertToShares(assets); } @@ -429,9 +427,7 @@ abstract contract ComponentToken is assets = convertToAssets(shares); } - if (!IERC20(asset()).transfer(receiver, assets)) { - revert InsufficientBalance(IERC20(asset()), address(this), assets); - } + SafeERC20.safeTransfer(IERC20(asset()), receiver, assets); emit Withdraw(controller, receiver, controller, assets, shares); }