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.
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.
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.
Enhanced Safety: Flash allowances inherently expire, reducing the risk of approvals being exploited post-transaction.
Reduced Need for Re-Approvals: Only an initial approval to the Permit2 contract is necessary, with all subsequent allowances handled temporarily.
Smart Wallet Compatibility: This feature naturally aligns with smart wallets and accounts, promoting better integration and usability for users employing such setups.
Backward Compatibility: The new system is designed to work alongside the existing Permit2 functionalities, allowing for a smooth transition for existing integrators.
Gas Savings with Transient Storage: By not permanently storing allowance data, significant gas costs associated with storage operations are avoided.
Reduced Overhead Compared to Signed Approvals: Unlike EIP-712 signed approvals, flash allowances do not incur the cost of signature verification.
Potential Reduction in MetaTransaction Usage: This could make traditional meta transactions less necessary, offering a more secure and gas-efficient alternative.
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.
This feature is proposed to streamline token transfers within the Ethereum ecosystem, making DeFi interactions more user-friendly, secure, and cost-effective.