Skip to content

feat(trace-hook): add uniswap v4 hook package#1

Open
usegitchain wants to merge 1 commit into
mainfrom
feat/v4-hook
Open

feat(trace-hook): add uniswap v4 hook package#1
usegitchain wants to merge 1 commit into
mainfrom
feat/v4-hook

Conversation

@usegitchain
Copy link
Copy Markdown
Owner

Summary

  • new contracts/trace-hook foundry package implementing the v4 hook described on traceprotocol.tech ("hooks. fees. forensics.")
  • on every beforeSwap, hook reads the caller's verdict from TraceAttestation, emits SwapFingerprinted for off-chain indexers, routes 1% of amountSpecified into the scanner-funding sink in pool currency0
  • root README.md repo tree updated to reference the new package

Design constraints

  • hook never writes to the attestation registry — writes are only by the off-chain attester key on TraceAttestation
  • scanner-funding call is try/catch wrapped — a misconfigured sink can never block a swap
  • returns ZERO_DELTA + lpFeeOverride = 0 — swap numerics identical to a hookless pool
  • fee bps hard-capped at 100 (1%) in both the constant and the constructor / setScannerFeeBps
  • v4 type mirrors (PoolKey, BeforeSwapDelta, IHooks subset, minimal IPoolManager) live in src/libs/ + src/interfaces/ with a sync-policy note. these get swapped for direct @uniswap/v4-core imports once v4-core tags 1.0

Test plan

  • cd contracts/trace-hook && forge install
  • forge test -vv — mock registry + mock funding sink cover: scanner gets exactly 1% of amountSpecified, only PoolManager can invoke, mismatched PoolKey reverts, fee bps cap at 100 enforced, owner can lower fee
  • static review of TraceHook.sol against the public copy on traceprotocol.tech /components/v4-hook-section.tsx snippet — they should describe the same flow
  • sanity check that root README tree still parses cleanly

🤖 Generated with Claude Code

new contracts/trace-hook foundry package implementing the v4 hook that
fingerprints the swap caller against TraceAttestation and routes a basis-
point share of the pool fee into the scanner funding sink.

- src/TraceHook.sol: beforeSwap fingerprint + scanner fee routing (cap 1%),
  afterSwap stub reserved for price-impact signal capture
- src/Errors.sol: custom errors for misconfig / unauthorised callers
- src/interfaces/: minimal v4 IHooks + IPoolManager surface, ITraceAttestation
  read view, IScannerFunding sink
- src/libs/: PoolKey + BeforeSwapDelta type mirrors with v4-core sync note
- test/TraceHook.t.sol: forge tests with mock registry + mock funding sink
- README.md (package): layout, deploy command, v4-core sync policy

design constraints:
- hook never writes to the attestation registry
- scanner-funding call is try/catch wrapped: a misconfigured sink cannot
  block a swap
- ZERO_DELTA + lpFeeOverride 0: swap numerics identical to a hookless pool
- fee bps hard capped at 100 (1%)

root README updated to reference the new package.
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