Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d984968
feat: add V4 fee adapter with policy-based waterfall and automated ho…
ccashwell Apr 6, 2026
001026f
feat: replace opaque familyId self-report with composable flag bitfie…
ccashwell Apr 17, 2026
7dccfb3
refactor(v4): replace baseline curve with global pips multiplier
ccashwell May 5, 2026
a2588c6
refactor(v4): unify classified-path multiplier units to pips
ccashwell May 5, 2026
4554152
docs: document V4 adapter design in README
ccashwell May 5, 2026
c64860a
refactor(v4): replace single multiplier with piecewise-linear fee buc…
ccashwell May 5, 2026
1b335c4
chore(fmt): lint fixes
ccashwell May 8, 2026
c1bb3fa
fix(v4): fall back on rounded classified fees
ccashwell May 18, 2026
b3496fe
fix(v4): disambiguate zero fee events
ccashwell May 18, 2026
005c925
fix(v4): bound hook self-report returndata
ccashwell May 18, 2026
50e65c4
chore(v4): apply fee adapter cleanups
ccashwell May 18, 2026
a669077
chore(v4): refresh fee adapter gas snapshots
ccashwell May 18, 2026
f17594c
chore(qa): correct license strings, remove unused import
ccashwell May 19, 2026
c75ba73
chore(qa): no unwrapping, reuse constants
ccashwell May 19, 2026
5eda399
feat(v4): validate flag rule ordering
ccashwell May 20, 2026
8138b86
feat(v4): replace pair fees with per-family pairClassFees
ccashwell May 27, 2026
f99c3cd
feat(v4): add batch hook family and pair class fee setters
ccashwell May 27, 2026
a10860c
feat(v4): unify fee resolution with native-math family sentinel
ccashwell May 28, 2026
d84002e
chore: rename oz audit for merge conflict
ccashwell May 28, 2026
955576b
chore: fmt
ccashwell May 28, 2026
9596feb
chore(docs): update readme, snapshots
ccashwell May 28, 2026
52b3a68
chore(docs): add v4 policy governance guide
ccashwell May 28, 2026
0617abb
fix(v4): reject setFamilyDefault on native-math family id
ccashwell May 28, 2026
ae55fd9
refactor(v4): remove HookFeeFlags library in favor of documented conv…
ccashwell Jun 5, 2026
83bd154
docs(v4): document safe policy deployment ordering
ccashwell Jun 5, 2026
31aa2a0
fix(v4): guard native-math fee branch against dynamic-fee keys
ccashwell Jun 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 45 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Uniswap Fee Collection

_A unified system for collecting and converting fees from arbitrary revenue sources on arbitrary chains._
*A unified system for collecting and converting fees from arbitrary revenue sources on arbitrary chains.*

## Table of Contents

Expand Down Expand Up @@ -110,10 +110,46 @@ Fee Sources are adapter contracts that channel fees from various protocols into
- Permissionless protocol fee collection
- Configurable fee rates per fee tier

**Uniswap V4 (TBD)**
**Uniswap V4**

- V4FeeAdapter as ProtocolFeeAdapter
- Not included as part of the initial fee enablement
- `V4FeeAdapter` registered with the PoolManager as `protocolFeeController`; permissionless `triggerFeeUpdate` and `collect` calls push resolved fees to the PoolManager and route accrued revenue to the TokenJar
- Fee resolution is split between a thin, long-lived adapter and a replaceable `V4FeePolicy`, so governance can iterate on fee strategy without re-handing PoolManager privileges
- Piecewise-linear protocol fee schedule for vanilla/static pools; family-based fees for classified hooks and dynamic-fee pools (see [V4 Fee Resolution](#v4-fee-resolution) and the [governance operator guide](docs/V4FeePolicy-governance-guide.md))

#### V4 Fee Resolution

**Operator guide:** [docs/V4FeePolicy-governance-guide.md](docs/V4FeePolicy-governance-guide.md) — use cases, recipes, and footguns.

The adapter checks for a per-pool override first, then delegates to the policy:

```
adapter.poolOverrides[poolId] ──► return (sentinel-decoded)
└──► policy.computeFee(key)
├── resolve family (_resolveFamily)
│ hookFamilyId[hook] → else static pool → 255 (native math)
│ else protocolFeeFlags + flagRules → else 0 (unclassified)
└── apply fee for family
0 (unclassified) → defaultFee
pairClassFees[pair][family] (if set)
255 (native math) → fee buckets from key.fee
1–255 (classified) → familyDefaults[family] → defaultFee
```

**Native math (family 255):** pools with no `*_RETURNS_DELTA` hook bits and static LP fee (`key.fee != 0x800000`). Fee = `pairClassFees[pair][255]` if set, else piecewise-linear **fee buckets** (`alpha + beta × (lpFee - floor) / 1_000_000`, max 16 buckets).

**Classified (families 1–255 via governance):** custom-accounting hooks, dynamic-fee pools, or any hook with `setHookFamily`. Waterfall: `pairClassFees` → `familyDefaults` → `defaultFee`. `key.fee` is not used for bucket math on these pools.

**Unclassified (family 0):** `defaultFee` only (no buckets, no family defaults).

Constants: `NATIVE_MATH_FAMILY_ID = 255`, `UNCLASSIFIED_FAMILY_ID = 0`. After policy or override changes, call `triggerFeeUpdate` so the PoolManager picks up new fees.

Permissioned roles:

- **owner** — swaps the policy, sets the fee-setter
- **feeSetter** — configures pool overrides, pair class fees, hook families, flag rules, family defaults, the fee buckets, and `defaultFee`

### 3. Releasers

Expand Down Expand Up @@ -403,8 +439,10 @@ src/
│ ├── Nonce.sol // Utility contract to safely sequence multiple pending transactions
│ └── ResourceManager.sol. // Utility contract for defining the `RESOURCE` token and its amount requirements
├── feeAdapters
│ ├── V3FeeAdapter.sol // Logic for Uniswap v3 fee-setting and collection
│ └── V4FeeAdapter.sol // Work-in-progress logic for Uniswap v4 fee-setting and collection
│ ├── V3FeeAdapter.sol // Logic for Uniswap v3 fee-setting and collection
│ ├── V3OpenFeeAdapter.sol // Permissionless v3 adapter for non-mainnet chains
│ ├── V4FeeAdapter.sol // V4 protocolFeeController: pool overrides + policy delegation
│ └── V4FeePolicy.sol // V4 fee resolution: LP-fee multiplier + family-based classification
├── interfaces/ // interfaces
├── libraries
│ ├── ArrayLib.sol // Utility library
Expand All @@ -422,6 +460,7 @@ test
├── ProtocolFees.fork.t.sol // Fork tests against Ethereum Mainnet, using Deployer.sol
├── V3FeeAdapter.t.sol
├── V4FeeAdapter.t.sol
├── V4FeeAdapter.fork.t.sol // V4 integration tests against a real PoolManager
├── interfaces/ // interfaces for integrations
├── mocks/ // mocks and examples
└── utils
Expand Down Expand Up @@ -456,7 +495,6 @@ Advanced mechanism design for optimizing fee collection efficiency through aucti

### Additional Protocol Support

- Uniswap v4
- UniswapX fee integration
- Interface fee collection
- Third-party protocol adapters
Expand Down
File renamed without changes.
Loading
Loading