From 326da13924c38f5a7e0f9bbe422d8fe18fd61162 Mon Sep 17 00:00:00 2001 From: mil0xeth <96582887+mil0xeth@users.noreply.github.com> Date: Fri, 5 Apr 2024 03:29:14 +0200 Subject: [PATCH] tradeFactory: safeApprove()-->forceApprove() (#43) --- src/swappers/TradeFactorySwapper.sol | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/swappers/TradeFactorySwapper.sol b/src/swappers/TradeFactorySwapper.sol index cbd454f..b756310 100644 --- a/src/swappers/TradeFactorySwapper.sol +++ b/src/swappers/TradeFactorySwapper.sol @@ -57,8 +57,7 @@ abstract contract TradeFactorySwapper { function _addToken(address _tokenFrom, address _tokenTo) internal { address _tf = tradeFactory(); if (_tf != address(0)) { - ERC20(_tokenFrom).safeApprove(_tf, type(uint256).max); - + ERC20(_tokenFrom).forceApprove(_tf, type(uint256).max); ITradeFactory(_tf).enable(_tokenFrom, _tokenTo); } @@ -82,7 +81,7 @@ abstract contract TradeFactorySwapper { } if (_tf != address(0)) { - ERC20(_tokenFrom).safeApprove(_tf, 0); + ERC20(_tokenFrom).forceApprove(_tf, 0); ITradeFactory(_tf).disable(_tokenFrom, _tokenTo); } @@ -126,7 +125,7 @@ abstract contract TradeFactorySwapper { for (uint256 i; i < _rewardTokensLocal.length; ++i) { address token = _rewardTokensLocal[i]; - ERC20(token).safeApprove(tradeFactory_, type(uint256).max); + ERC20(token).forceApprove(tradeFactory_, type(uint256).max); ITradeFactory(tradeFactory_).enable(token, _tokenTo); } @@ -141,7 +140,7 @@ abstract contract TradeFactorySwapper { address _tf = tradeFactory(); address[] memory rewardTokensLocal = rewardTokens(); for (uint256 i; i < rewardTokensLocal.length; ++i) { - ERC20(rewardTokensLocal[i]).safeApprove(_tf, 0); + ERC20(rewardTokensLocal[i]).forceApprove(_tf, 0); } _tradeFactory = address(0);