Skip to content

feat: optimize rehype and add separate integrator fee handling - #548

Merged
Zodomo merged 2 commits into
mainfrom
zodomo/rehype-integrator
Aug 26, 2026
Merged

feat: optimize rehype and add separate integrator fee handling#548
Zodomo merged 2 commits into
mainfrom
zodomo/rehype-integrator

Conversation

@Zodomo

@Zodomo Zodomo commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Description

Implemented unique fee handling within rehype for integrators, such that an integrator can apply their own fee processing config separately from the remaining beneficiaries. In order to help minimize gas impact, the FeeDistributionInfo struct was internally optimized to reduce excess state reads, while preserving externally facing ABI.

Motivation

Integrators have requested the ability to apply their own fee routing configurations separately from the creator and remaining beneficiaries (such as taking all fees in WETH). These changes enable them to do so, while restoring flexibility with respect to receiving automatic payments instead of enforcing a claimable-only flow.

Changes

  • Added per-pool IntegratorInitConfig support to RehypeDopplerHookInitializer, including:
    • Integrator address.
    • Immutable share of gross Rehype fees.
    • Independent asset-to-numeraire and numeraire-to-asset conversion ratios.
    • Optional automatic payout.
  • Updated fee accounting so every gross Rehype fee is separated into:
    • Airlock owner fees.
    • Integrator fees.
    • Residual fees processed through the existing beneficiary and LP distribution configuration.
  • Added independent integrator fee processing:
    • Integrator conversion inputs are aggregated with compatible Rehype fee-distribution swaps.
    • Swap inputs and outputs are attributed proportionally, including partial-fill handling.
    • Unconverted or failed amounts are retained as claimable fees in their source currency.
  • Added integrator administration and settlement functions:
    • Update conversion ratios.
    • Enable or disable automatic payout.
    • Rotate the integrator address and associated claim rights.
    • Claim accrued fees to a chosen destination.
  • Added resilient automatic payouts:
    • Native and ERC-20 payments are attempted independently for each currency.
    • Failed payments become claimable instead of reverting the originating user swap.
    • ERC-20 handling supports standard, no-return, and malformed-return behaviors.
  • Preserved the Bundler dev-buy exemption by excluding integrator and other non-protocol fees from the exempt first swap.
  • Optimized Rehype fee-distribution storage:
    • Packed the eight FeeDistributionInfo weights from eight storage slots into two.
    • Packed the integrator fee share into the existing fee-schedule slot.
    • Preserved the existing external getFeeDistributionInfo ABI.
    • Applied the fee-distribution packing optimization to both the Rehype initializer and migrator.
  • Added events and validation for integrator initialization, configuration changes, rotation, claims, fee-share bounds, conversion-ratio bounds, and accounting overflow.
  • Updated deployment configuration and incremented versions
  • Updated Rehype initializer and migrator documentation to describe the new accounting, routing, payout, and configuration semantics.
  • Expanded unit, integration, fuzz, and invariant coverage for:
    • Gross-fee conservation and rounding.
    • Both token orientations, swap directions, and exact-input/output modes.
    • Successful, failed, and partial conversions.
    • Pending and claimable fee transitions.
    • Configuration changes and integrator rotation.
    • Manual claims and automatic payout failures.
    • Native and adversarial ERC-20 transfer behavior.
    • Bundler compatibility, solvency, and state-packing compatibility.

@Zodomo
Zodomo requested a review from clemlak August 21, 2026 19:42
@Zodomo Zodomo self-assigned this Aug 21, 2026
Comment thread src/dopplerHooks/RehypeDopplerHookInitializer.sol Outdated
Comment thread src/dopplerHooks/RehypeDopplerHookInitializer.sol Outdated
@github-actions

Copy link
Copy Markdown

Gas Benchmark Summary

Status: 6 regression(s), 0 improvement(s), 27 below-threshold change(s).
Net significant delta: +5,460 gas.
Largest regression: migrate with Multicurve, Doppler Hook Initializer, Doppler Hook Migrator, Governance Factory +910 gas (+0.09%).

Changed Facets

Facet Regressions Improvements Net Delta
Balance limit Disabled 6 0 +5,460
Migration costs 6 0 +5,460
Proceeds split Disabled 6 0 +5,460

Top Regressions

Metric Facets Base Head Delta Delta %
migrate Multicurve, Doppler Hook Initializer, Doppler Hook Migrator, Governance Factory 1,056,511 1,057,421 +910 +0.09%
migrate Multicurve, Doppler Hook Initializer, Doppler Hook Migrator, Launchpad Governance Factory 1,056,511 1,057,421 +910 +0.09%
migrate Multicurve, Doppler Hook Initializer, Doppler Hook Migrator, No-op Governance Factory 1,056,458 1,057,368 +910 +0.09%
migrate Multicurve, Doppler Hook Initializer, Uniswap V2 Migrator Split, Governance Factory 698,366 699,276 +910 +0.13%
migrate Multicurve, Doppler Hook Initializer, Uniswap V2 Migrator Split, Launchpad Governance Factory 698,366 699,276 +910 +0.13%

1 more significant change(s) hidden below.

All significant changes by section

Migration costs

Metric Facets Base Head Delta Delta %
migrate Multicurve, Doppler Hook Initializer, Doppler Hook Migrator, Governance Factory 1,056,511 1,057,421 +910 +0.09%
migrate Multicurve, Doppler Hook Initializer, Doppler Hook Migrator, Launchpad Governance Factory 1,056,511 1,057,421 +910 +0.09%
migrate Multicurve, Doppler Hook Initializer, Doppler Hook Migrator, No-op Governance Factory 1,056,458 1,057,368 +910 +0.09%
migrate Multicurve, Doppler Hook Initializer, Uniswap V2 Migrator Split, Governance Factory 698,366 699,276 +910 +0.13%
migrate Multicurve, Doppler Hook Initializer, Uniswap V2 Migrator Split, Launchpad Governance Factory 698,366 699,276 +910 +0.13%
migrate Multicurve, Doppler Hook Initializer, Uniswap V2 Migrator Split, No-op Governance Factory 681,266 682,176 +910 +0.13%

@Zodomo
Zodomo merged commit 5754c7e into main Aug 26, 2026
3 checks passed
@Zodomo
Zodomo deleted the zodomo/rehype-integrator branch August 26, 2026 15:37
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.

2 participants