Skip to content

[FEAT] Build Zero-Allocation ERC-20 Permit Processor in Yul #683

Description

@mijinummi

Labels: medium-difficulty, yul, tokens, gasguard
Difficulty: Medium
Module: contracts/tokens/


🧠 Concept

Construct an inline assembly ERC-20 permit caller that formats EIP-2612 permit calls directly in memory without using high-level abi.encodeWithSelector.

⚠️ Problem

Standard permit wrappers allocate dynamic memory for call data, generating excessive mstore operations and expanding memory bounds prior to signature submission.

📁 Implementation Scope

  • contracts/tokens/YulPermitHandler.sol
  • test/tokens/YulPermitHandler.test.ts

🛠️ Requirements

  1. Pack permit(address,address,uint256,uint256,uint8,bytes32,bytes32) selector and arguments directly into scratch memory using Yul.
  2. Execute low-level call to target token contract and evaluate success return status.

🎯 Acceptance Criteria

  • Executes ERC-20 permit approvals with lower gas than standard library helpers.
  • Handles failed permit calls gracefully using custom error returns.

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions