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

USDC v3 #338

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

USDC v3 #338

wants to merge 1 commit into from

Conversation

alexkroeger
Copy link

@alexkroeger alexkroeger commented Jan 24, 2022

USDC v3 reduces gas costs for users by replacing blacklist checks on transfer, transferFrom, and approve with a freezeBalance admin function.

Please check out this post on mirror.xyz for more context about these proposed changes.

"ERC20: transfer amount exceeds allowance"
);
_transfer(from, to, value);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(value);
Copy link

@phil-ociraptor phil-ociraptor Jan 24, 2022

Choose a reason for hiding this comment

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

While you're at it, can save 5k more gas on swaps and contract interactions by using infinite approval gas optimization!!

Something like this:

Suggested change
allowed[from][msg.sender] = allowed[from][msg.sender].sub(value);
if (allowed[from][msg.sender] != uint(-1)) {
allowed[from][msg.sender] = allowed[from][msg.sender].sub(value);
}

Reference

Copy link
Author

Choose a reason for hiding this comment

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

in this moment I am euphoric

Copy link

Choose a reason for hiding this comment

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

@phil-ociraptor in your suggestion aren't you missing a ]?

L121 of your suggestion 👇

if (allowed[from][msg.sender] != uint(-1)) {

Choose a reason for hiding this comment

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

🦅 👀

great catch! updated

@eztierney
Copy link
Contributor

Thanks for the PR, this is really cool. We would really love to reduce gas fees. At this point though I'm not sure we can get rid of the blacklist functionality as-is. Such change will require a broader discussion including legal and regulatory compliance teams.

Packing it into the high bit as you suggested https://twitter.com/alex_kroeger/status/1485756038502510593?s=21 might be more appealing as it preserves the existing functionality and should provide similar gas savings.

@alexkroeger alexkroeger mentioned this pull request Jul 14, 2022
10 tasks
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.

4 participants