Skip to content

Commit

Permalink
tradeFactory: safeApprove()-->forceApprove()
Browse files Browse the repository at this point in the history
  • Loading branch information
mil0xeth committed Apr 3, 2024
1 parent abdec36 commit db1b56d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/swappers/TradeFactorySwapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
Expand Down

0 comments on commit db1b56d

Please sign in to comment.