Skip to content

fix: use SafeERC20 for all token transfers#71

Merged
RonTuretzky merged 2 commits intodevfrom
70-replace-all-ierc20-transfer-with-safeerc20-safetransfer
Apr 6, 2026
Merged

fix: use SafeERC20 for all token transfers#71
RonTuretzky merged 2 commits intodevfrom
70-replace-all-ierc20-transfer-with-safeerc20-safetransfer

Conversation

@rubydusa
Copy link
Copy Markdown
Contributor

Summary

  • Replace all raw IERC20.transfer / IERC20.transferFrom calls with SafeERC20.safeTransfer / SafeERC20.safeTransferFrom
  • Remove the now-unused custom TransferFailed error
  • Update tests to expect SafeERC20FailedOperation instead of TransferFailed

Why

Raw IERC20.transfer/transferFrom rely on the token returning a bool. Tokens like USDT don't return a value, which would cause the call to revert even on success. OZ's SafeERC20 wrapper handles non-standard return values correctly, making the contract safe to use with any ERC20 token.

Test plan

  • forge test — all 97 tests pass

🤖 Generated with Claude Code

@rubydusa rubydusa linked an issue Mar 31, 2026 that may be closed by this pull request
@rubydusa rubydusa force-pushed the 70-replace-all-ierc20-transfer-with-safeerc20-safetransfer branch from 5e1a2ca to 2d22c28 Compare April 2, 2026 20:00
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rubydusa rubydusa requested a review from RonTuretzky April 2, 2026 20:07
@RonTuretzky RonTuretzky merged commit 79fe2d6 into dev Apr 6, 2026
5 checks passed
@rubydusa rubydusa deleted the 70-replace-all-ierc20-transfer-with-safeerc20-safetransfer branch April 6, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace all IERC20 transfer with SafeERC20 safeTransfer

2 participants