Skip to content

Proxy Fee Template V2: receiver validation, accrued fees, and versioned upgrades#5

Open
giantcoconut wants to merge 4 commits into
intuition-box:mainfrom
giantcoconut:mission-02-proxy-fee-template-v2
Open

Proxy Fee Template V2: receiver validation, accrued fees, and versioned upgrades#5
giantcoconut wants to merge 4 commits into
intuition-box:mainfrom
giantcoconut:mission-02-proxy-fee-template-v2

Conversation

@giantcoconut
Copy link
Copy Markdown

@giantcoconut giantcoconut commented May 2, 2026

Summary

Implements Mission 02 sub-bounties 2A, 2B, and 2C while preserving the existing Hardhat/TypeScript project structure.

Covered

2A: Receiver Validation

  • Enforces receiver == msg.sender in deposit, depositBatch, createAtoms, and createTriples.
  • Adds IntuitionFeeProxy_InvalidReceiver.
  • Tests mismatch reverts and matching-receiver success paths.

2C: Fee Accumulation + Withdraw

  • Removes immediate fee forwarding.
  • Tracks collected proxy fees explicitly with accruedFees.
  • Adds withdrawFees(uint256), withdrawAllFees(), getNonFeeBalance(), and sweepNonFeeBalance(address,uint256).
  • Fee withdrawals always go to the configured feeRecipient.
  • Direct/non-fee native TRUST/tTRUST is separated from accrued fees.

2B: Versioned Upgradeability

  • Adds ERC7936Proxy, an ERC-7936-style versioned proxy.
  • Supports version registration, default-version routing, explicit version execution, and version upgrades.
  • Keeps the active ERC-1967 implementation synchronized with the registered default version.
  • Refactors IntuitionFeeProxy to initializer-based storage for upgradeable deployments.
  • Adds ERC-1822 proxiableUUID() compatibility for implementation validation.
  • Uses namespaced proxy storage to avoid collisions with fee proxy state.

Migration Note

Existing V1 deployments were standalone contracts, not proxy deployments, so they cannot keep the same address when moving to V2.

The intended migration path is to deploy a V2 implementation, deploy a new ERC7936Proxy initialized with the existing V1 fee/admin configuration, and update app integrations to use the new proxy address. Once on the V2 proxy, future implementation changes can be registered as new versions and promoted to the default version.

Validation

npm.cmd test
node ./node_modules/typescript/bin/tsc --noEmit --pretty false

Result:

58 passing

Refs #2

@giantcoconut
Copy link
Copy Markdown
Author

Local test run screenshot for reference:

npm.cmd test completed with 58 passing.
Screenshot 2026-05-02 132646

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