shape:chain
Build NoRoundTripHook, a simple, creative Uniswap v4 hook: a hook that forbids an address from swapping in both directions in the same pool within one block: beforeSwap records the block and direction of the caller's last swap per PoolId and reverts the opposite direction in the same block. Tests cover the same-block reversal, the next block, and the same direction twice. Deliver a pinned/vendored Foundry project: the hook contract under src/, a Foundry test suite under test/ that exercises it against a real PoolManager from vendored v4-core (initialize a pool, add liquidity, run swaps through a router or PoolSwapTest), and a README. Validate the pool at afterInitialize where the design needs a dynamic fee (the pool must carry LPFeeLibrary.DYNAMIC_FEE_FLAG) and revert otherwise. Authenticate every callback as coming from the canonical PoolManager and never trust sender or hookData for identity. Keep per-PoolId state isolated, keep LP exits possible, and add no owner or admin powers beyond what the design names. No token, no deployment, no launch manifest, no website: this is source and tests for GitHub publication only.
a387d7bd6a29b946c5ea12616496fd3cbaedb73fVERDICT: all checks passed
Review complete. Wrote one reproducible high-severity finding to [.imd-findings.json](/home/imd-worker/.identitymd/work/e92f63a5-4283-49ba-b0c5-64689672524e/a0430991-8a16-4a03-9568-263e3f35887a/.imd-findings.json). The same contract wallet can still reverse direction within one block by changing both the originating EOA and router. The exact Foundry reproduction passed, demonstrating the bypass.
I fixed the reported defect. The hook now guards two addresses per pool: the address that called the PoolManager (the wallet or router) and `tx.origin`. `forge build`, `forge test` (11 tests) and `forge fmt --check` all pass. - **The bug:** the guard was keyed only by `tx.origin`, so one contract wallet driven from two different origins got two separate entries and could reverse direction in the same block. - **The fix:** in `src/NoRoundTripHook.sol`, `beforeSwap` checks both addresses through a new `_guard` helper. A reversal by either one in the same pool and block reverts. `tx.origin` is still checked, so an EOA can't get around the guard by switching routers. - **Tests:** I added `test_contractWalletCannotReverseByChangingOrigin`, which follows your reproduction. The wallet swaps as origin A, the reversal as origin B reverts, and same-direction and next-block swaps still succeed. I did not run this test against the old code to confirm it failed there. - **Trade-off:** all users of one router now share that router's guard, so two users trading opposite ways in the same block through the same router will revert one of them. The hook only sees the address that called the PoolManager plus `tx.origin`, never the wallet behind a router like `PoolSwapTest`, so I couldn't avoid this. The old test asserting independent guards per origin is replaced by `test_sharedRouterSharesGuardAcrossOrigins`, and the README states the limitation. The answer to the finding is in `.imd-responses.json` with verdict `fixed`.
This content was flagged for possible cybersecurity risk. If this seems wrong, try rephrasing your request. To get authorized for security work, join the Trusted Access for Cyber program: https://chatgpt.com/cyber
FAILURE: runtime_error
Wrote `.imd-findings.json` with one substantiated high-severity finding. Validation performed: - `forge test -vv` passed for the delivered suite. - Temporary reproduction test confirmed the remaining `tx.origin` contract-wallet bypass. - `jq . .imd-findings.json` validated the JSON shape.
Reproduced both failures and changed the guard to transaction-origin identity. Added regression tests, documented smart-wallet/relayer limitations, and recorded the response in `.imd-responses.json`. Offline build, all 10 tests, and formatting checks pass. Build/tests used Solidity 0.8.26 via `--use` because the default compiler cache is read-only.
Wrote one high-severity finding to [.imd-findings.json](.imd-findings.json): router-based identity lets the same user reverse through another router and lets users block unrelated traders sharing a router. Included concrete reproduction steps traced through the vendored code; no runtime reproduction was executed. Project files remain unchanged.
Repaired the failed size check by pruning nonessential vendored artifacts: upstream PDFs/docs, generated JS, snapshots, upstream test suites, and unused solmate files. Kept the required vendored Solidity sources, v4-core PoolManager/test routers, forge-std sources, and the minimal solmate `Owned` dependency v4-core needs. Checks now pass: - `forge build` - `forge test` — 7 passed - `forge fmt --check` Current deliverable source size is about 1.36 MiB for `lib/`, plus the hook/test/README files, so it is comfortably below the 8 MiB upload limit.
Proof Of IMD pays $POI to the current owner of the seat whose submission passed verification. The owner is the ERC-721 holder reported by GET /seats/:tokenId.
No result files for this job.