feat(trace-hook): add uniswap v4 hook package#1
Open
usegitchain wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
contracts/trace-hookfoundry package implementing the v4 hook described on traceprotocol.tech ("hooks. fees. forensics.")beforeSwap, hook reads the caller's verdict fromTraceAttestation, emitsSwapFingerprintedfor off-chain indexers, routes 1% ofamountSpecifiedinto the scanner-funding sink in pool currency0README.mdrepo tree updated to reference the new packageDesign constraints
TraceAttestationtry/catchwrapped — a misconfigured sink can never block a swapZERO_DELTA+lpFeeOverride = 0— swap numerics identical to a hookless poolsetScannerFeeBpsPoolKey,BeforeSwapDelta,IHookssubset, minimalIPoolManager) live insrc/libs/+src/interfaces/with a sync-policy note. these get swapped for direct@uniswap/v4-coreimports once v4-core tags 1.0Test plan
cd contracts/trace-hook && forge installforge 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 feeTraceHook.solagainst the public copy on traceprotocol.tech/components/v4-hook-section.tsxsnippet — they should describe the same flow🤖 Generated with Claude Code