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

optimization: support burn onbehalf of other #14

Merged
merged 3 commits into from
Apr 12, 2024
Merged

Conversation

chefburger
Copy link
Collaborator

Two major changes here per discussion:

  1. new burn(address from, Currency currency, uint256 amount): ppl can burn others vaultToken to finish payment as long as they have corresponding allowance
  2. Updates mint signature from function mint(Currency currency, address to, uint256 amount) to function mint(address to, Currency currency, uint256 amount) so as to aligns with burn function

if (allowed != type(uint256).max) allowance[from][msg.sender][currency] = allowed - amount;
}

_burn(from, currency, amount);
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems that directly using the codes in the _burn function, will save some gas?

// _burn(from, currency, amount);
balanceOf[from][currency] -= amount;
emit Transfer(msg.sender, from, address(0), currency, amount);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It seems not a big deal in this case probabaly a extra jump ? I feel like _burn gives better readability

CleanShot 2024-04-09 at 16 51 32@2x

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok, lgtm

ChefSnoopy
ChefSnoopy previously approved these changes Apr 9, 2024
ChefMist
ChefMist previously approved these changes Apr 11, 2024
Copy link
Collaborator

@ChefMist ChefMist left a comment

Choose a reason for hiding this comment

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

created pancakeswap/pancake-v4-periphery#11 to track since a follow-up update on v4-periphery is required

@chefburger chefburger dismissed stale reviews from ChefMist and ChefSnoopy via e685560 April 12, 2024 03:19
@chefburger chefburger merged commit a3cf6ea into main Apr 12, 2024
2 checks passed
@chefburger chefburger deleted the feat/vault-burn-from branch April 12, 2024 03:27
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.

3 participants