22pragma solidity ^ 0.8.12 ;
33
44import {Initializable} from "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol " ;
5+ import {IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol " ;
6+ import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol " ;
57import {ISignatureUtils} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtils.sol " ;
68import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol " ;
79import {IRewardsCoordinator} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol " ;
@@ -18,6 +20,7 @@ import {BitmapUtils} from "./libraries/BitmapUtils.sol";
1820 * @author Layr Labs, Inc.
1921 */
2022abstract contract ServiceManagerBase is ServiceManagerBaseStorage {
23+ using SafeERC20 for IERC20 ;
2124 using BitmapUtils for * ;
2225
2326 /// @notice when applied to a function, only allows the RegistryCoordinator to call it
@@ -97,18 +100,14 @@ abstract contract ServiceManagerBase is ServiceManagerBaseStorage {
97100 for (uint256 i = 0 ; i < rewardsSubmissions.length ; ++ i) {
98101 // transfer token to ServiceManager and approve RewardsCoordinator to transfer again
99102 // in createAVSRewardsSubmission() call
100- rewardsSubmissions[i].token.transferFrom (
103+ rewardsSubmissions[i].token.safeTransferFrom (
101104 msg .sender ,
102105 address (this ),
103106 rewardsSubmissions[i].amount
104107 );
105- uint256 allowance = rewardsSubmissions[i].token.allowance (
106- address (this ),
107- address (_rewardsCoordinator)
108- );
109- rewardsSubmissions[i].token.approve (
108+ rewardsSubmissions[i].token.safeIncreaseAllowance (
110109 address (_rewardsCoordinator),
111- rewardsSubmissions[i].amount + allowance
110+ rewardsSubmissions[i].amount
112111 );
113112 }
114113
@@ -152,18 +151,15 @@ abstract contract ServiceManagerBase is ServiceManagerBaseStorage {
152151 }
153152
154153 // Transfer token to ServiceManager and approve RewardsCoordinator to transfer again
155- // in createAVSPerformanceRewardsSubmission () call
156- operatorDirectedRewardsSubmissions[i].token.transferFrom (
154+ // in createOperatorDirectedAVSRewardsSubmission () call
155+ operatorDirectedRewardsSubmissions[i].token.safeTransferFrom (
157156 msg .sender ,
158157 address (this ),
159158 totalAmount
160159 );
161- uint256 allowance = operatorDirectedRewardsSubmissions[i]
162- .token
163- .allowance (address (this ), address (_rewardsCoordinator));
164- operatorDirectedRewardsSubmissions[i].token.approve (
160+ operatorDirectedRewardsSubmissions[i].token.safeIncreaseAllowance (
165161 address (_rewardsCoordinator),
166- totalAmount + allowance
162+ totalAmount
167163 );
168164 }
169165
0 commit comments