Skip to content
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

fix(transfer): allow zero transfers #329

Merged
merged 5 commits into from
Oct 31, 2023
Merged

Conversation

Rubilmax
Copy link
Collaborator

@Rubilmax Rubilmax linked an issue Oct 25, 2023 that may be closed by this pull request
@Rubilmax Rubilmax marked this pull request as ready for review October 25, 2023 14:38
Copy link
Contributor

@MerlinEgalite MerlinEgalite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a comments since it's a bit different from the standard that we use in other bundlers

Copy link
Contributor

@julien-devatom julien-devatom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that an erc20 can revert on 0 transfer. We have a specific usecase to transfer(0), for slippage undertaken amount (if we reach the slippage tolerance). So I would suggest to have an early return and to not call the safeTransfer is 0, or to add a skim function that is returning on 0 amount.

@Jean-Grimal
Copy link
Contributor

Maybe we should add a return before the call to the token contract if the amount is zero

@Rubilmax
Copy link
Collaborator Author

Rubilmax commented Oct 25, 2023

The problem is that an erc20 can revert on 0 transfer. We have a specific usecase to transfer(0), for slippage undertaken amount (if we reach the slippage tolerance). So I would suggest to have an early return and to not call the safeTransfer is 0, or to add a skim function that is returning on 0 amount.

image

if the token is strictly EIP-20 compliant it shouldn't, do you have counter-examples in mind?

EDIT: however, for efficiency reason, there's indeed no reason to call the ERC20

Copy link
Contributor

@julien-devatom julien-devatom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, we have to reference somewhere that the 0 amount is not calling the transfer (and thus not triggering a Transfer event). This is a specific behavior different from the one defined by the EIP20, where the end user can expect to have a Transfer event with a 0 amount

@Rubilmax Rubilmax changed the base branch from review-cantina to fix/issue-17 October 26, 2023 13:37
Base automatically changed from fix/issue-17 to review-cantina October 30, 2023 16:57
@MerlinEgalite MerlinEgalite requested review from StErMi and removed request for StErMi October 30, 2023 17:00
@Rubilmax Rubilmax merged commit 08e893c into review-cantina Oct 31, 2023
8 checks passed
@Rubilmax Rubilmax deleted the fix/zero-transfer branch October 31, 2023 09:53
@MerlinEgalite
Copy link
Contributor

why merging it?

Rubilmax added a commit that referenced this pull request Oct 31, 2023
This reverts commit 08e893c, reversing
changes made to 97bab2b.
Rubilmax added a commit that referenced this pull request Oct 31, 2023
MerlinEgalite added a commit that referenced this pull request Oct 31, 2023
Revert "Merge pull request #329 from morpho-labs/fix/zero-transfer"
Rubilmax added a commit that referenced this pull request Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transfer reverts on zero amount
4 participants