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

feat: add flash allowance functionality #262

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gabririgo
Copy link

Flash Allowances for Permit2

Overview

This pull request introduces the concept of Flash Allowances to Uniswap's Permit2, utilizing Ethereum's new transient storage opcodes (tload and tstore). Flash Allowances provide a mechanism for setting token approvals that are valid only for the duration of the transaction in which they are used. This approach aims to enhance both user experience and gas efficiency while maintaining or improving security.

Key Features

Implementation Details

  • Transient Storage: The PR uses tload and tstore to set and retrieve temporary allowances. Upon transaction completion, this storage is automatically reset, eliminating the need for explicit approval revocation.

  • Security Considerations: Although the automatic reset feature reduces potential risks, integrators are encouraged to explicitly reset approvals when no longer needed to guard against potential misuse scenarios, like transactions being manipulated through phishing attacks.

Advantages

User Experience

  1. Simplified Approval Process: Users no longer need to separately approve Permit2 (once per expiration period) and then sign the transaction. The approval and transaction are combined into a single step.
  2. Enhanced Safety: Flash allowances inherently expire, reducing the risk of approvals being exploited post-transaction.
  3. Reduced Need for Re-Approvals: Only an initial approval to the Permit2 contract is necessary, with all subsequent allowances handled temporarily.
  4. Smart Wallet Compatibility: This feature naturally aligns with smart wallets and accounts, promoting better integration and usability for users employing such setups.
  5. Backward Compatibility: The new system is designed to work alongside the existing Permit2 functionalities, allowing for a smooth transition for existing integrators.

Gas Efficiency

  1. Gas Savings with Transient Storage: By not permanently storing allowance data, significant gas costs associated with storage operations are avoided.
  2. Reduced Overhead Compared to Signed Approvals: Unlike EIP-712 signed approvals, flash allowances do not incur the cost of signature verification.
  3. Potential Reduction in MetaTransaction Usage: This could make traditional meta transactions less necessary, offering a more secure and gas-efficient alternative.

Potential Future Implications

  • EIP-3074 Compatibility: With the advent of account abstraction, this feature could seamlessly integrate with master contracts, setting flash approvals as part of the transaction flow where needed.

Integration Guidelines

  • For Developers: Integrators should understand that while this PR provides flash allowances, they might still want to reset transient allowances post-transaction for clarity or security purposes. Documentation will be updated to include best practices for integrating with flash allowances. As this process does not involve modifications of state, if is also very efficient in terms of extra gas savings.
  • Backward Compatibility: Current Permit2 users can continue with existing features, and upgrade to utilize flash allowances at their convenience.

Conclusion

This feature is proposed to streamline token transfers within the Ethereum ecosystem, making DeFi interactions more user-friendly, secure, and cost-effective. Feedback and discussion on this PR are welcomed to ensure it meets the community's needs and security standards.

⚠️ Tests have not been integrated yet, this is a POC for understanding if there is enough support.

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.

1 participant