-
Notifications
You must be signed in to change notification settings - Fork 62
[PT1-115] Added safe send for UniERC20 #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds safe send functionality for UniERC20 operations to ensure Ether transfers succeed even when recipients have failing receive/fallback functions. The implementation uses a new SafeSendLib that leverages assembly code with selfdestruct to force Ether delivery.
- Added SafeSendLib library with assembly-based safe send mechanism
- Implemented uniSafeTransfer and uniSafeTransferFrom functions in UniERC20
- Added corresponding test coverage and mock contract interfaces
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| contracts/libraries/SafeSendLib.sol | New library implementing safe Ether transfer using selfdestruct |
| contracts/libraries/UniERC20.sol | Added safe transfer functions that use SafeSendLib for ETH transfers |
| contracts/tests/mocks/UniERC20Helper.sol | Added mock interfaces and implementations for testing safe transfers |
| test/contracts/UniERC20.test.ts | Added test cases for safe transfer functionality |
| docgen/index.ts | Duplicate export statement added |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #199 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 17 18 +1
Lines 346 364 +18
Branches 65 74 +9
=========================================
+ Hits 346 364 +18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| if (amount > 0) { | ||
| if (isETH(token)) { | ||
| if (address(this).balance < amount) revert InsufficientBalance(); | ||
| to.safeSend(amount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about check address(this).code.length == 0 that code is executing inside the constructor?
| if (msg.value > amount) { | ||
| // Return remainder if exist | ||
| unchecked { | ||
| from.safeSend(msg.value - amount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method sends ETH from msg.sender to somewhere vie eip7702? It's not obvious where the funds will go despite that the description is they have to go to the to
No description provided.