@pawtom/mcp 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,259 @@
1
+ # Pawtom on Unichain Sepolia
2
+
3
+ Live deployments of `PawtomHook` against the canonical Uniswap v4 contracts. **v8** is the current design: a momentum charge on swaps that continue the last block's measured move, and a priority charge set as a rate per gwei of priority fee above a floor ([`MECHANISM.md`](../../MECHANISM.md)). v7 had the same momentum charge with a priority charge priced in ETH. v1 to v6 charged moves away from a reference re-measured every 60 s, which real flow showed charging uninformed flow more than informed flow; they stay deployed as the record.
4
+
5
+ | Version | Hook | Status |
6
+ |---|---|---|
7
+ | **v8** | [`0x62b688EacD74A2a8Ea2453FCc7DEFE692f5510c4`](https://unichain-sepolia.blockscout.com/address/0x62b688EacD74A2a8Ea2453FCc7DEFE692f5510c4) | **Current: measured momentum + a priority rate.** Runs the app's main USDC/WETH pool. See [v8](#v8-the-priority-rate). |
8
+ | v7 | [`0x0517AF831F3Afcca2A7C9E64FC2F5e5a279bD0c4`](https://unichain-sepolia.blockscout.com/address/0x0517AF831F3Afcca2A7C9E64FC2F5e5a279bD0c4) | Superseded: the priority charge was an amount of ETH, once per transaction. See [v7](#v7-measured-momentum). |
9
+ | v6 | [`0x4c252FC4735909D935e1BdD29C82ab3E130510c4`](https://unichain-sepolia.blockscout.com/address/0x4c252FC4735909D935e1BdD29C82ab3E130510c4) | Superseded. Gas-optimised 60 s-window design; ran the app's main pool and the [six-year replay](#v6-six-years-of-ethusdc-replayed-on-chain). |
10
+ | v5 | [`0x540567F4C0Fb08817e92bC13C9E412503fe450c4`](https://unichain-sepolia.blockscout.com/address/0x540567F4C0Fb08817e92bC13C9E412503fe450c4) | Superseded. Its first gas-optimised build held a charge whenever `donate` failed for any reason; v6 holds only when no liquidity is in range. |
11
+ | v4 | [`0x7387BEb979DB68E264DF712992fbd908bA0F90C4`](https://unichain-sepolia.blockscout.com/address/0x7387BEb979DB68E264DF712992fbd908bA0F90C4) | The PWT-13 volatility cap. It runs the native ETH/USDC pool. See [v4](#v4-pwt-13-and-a-native-eth-pool). |
12
+ | v3 | [`0x876d1D611c905ADE7Ce7DC3d2f65d72de71FD0c4`](https://unichain-sepolia.blockscout.com/address/0x876d1D611c905ADE7Ce7DC3d2f65d72de71FD0c4) | The platform's first WETH/USDC pools. See [v3](#v3-the-platform-deployment). |
13
+ | v2 | [`0x9cEDea13Ec37604259C2613a7ac0bd96901410C4`](https://unichain-sepolia.blockscout.com/address/0x9cEDea13Ec37604259C2613a7ac0bd96901410C4) | The PWT-11 fix proven live: no collapse without in-range liquidity. See [v2](#v2-the-pwt-11-fix-live). |
14
+ | v1 | [`0xBab51E49B798D166f7C1b4cdb69840D25b8450c4`](https://unichain-sepolia.blockscout.com/address/0xBab51E49B798D166f7C1b4cdb69840D25b8450c4) | Kept as-is: its pools and the 14 swaps below are the record of the first live test. |
15
+
16
+ ## v8: the priority rate
17
+
18
+ | | |
19
+ |---|---|
20
+ | Hook | [`0x62b688EacD74A2a8Ea2453FCc7DEFE692f5510c4`](https://unichain-sepolia.blockscout.com/address/0x62b688EacD74A2a8Ea2453FCc7DEFE692f5510c4), source verified (solc 0.8.30, 10,000 runs), deployed at block 68,828,406 |
21
+ | Defaults | `PawtomConfig.ethUsdc5bps()`: momentum as in v7 (cap 2 bps, w = 1.1σ, dead zone 0.111 × fee, 60 s); priority 10 bps of each swap per gwei above 0.1 gwei, capped at 0.1%, on every swap |
22
+ | Main pool | USDC/WETH, fee 450, **tick spacing 20**, id `0xa44025b9aae971eb76839a3f87af584d9d8b447ad23924bfbd95c6b4a6044862`, initialised at block 68,828,524 at the v7 pool's price (3,017.11 USDC per WETH), liquidity L = 5.2480e16 on ticks 188,680 to 203,680 (v7: 5.2538e16) |
23
+ | Not used | The key with tick spacing 10 was initialised first at a wrong price: the starting price went through 64-bit shell arithmetic and wrapped. It holds only a dust position (L = 147) at a meaningless price, and nothing reads it. A pool cannot be re-initialised, so the main pool uses tick spacing 20 and the same range width |
24
+
25
+ Four live checks, each read from its receipt and checked to the wei ([log](logs/v8/live_checks.txt)):
26
+
27
+ | Swap | Block | Hook events | Result |
28
+ |---|---:|---|---|
29
+ | A: 3,000 USDC in (price down), 1 wei tip | 68,838,879 | `Measured` 0 (the block of creation moved nothing) | No charge |
30
+ | B: 500 USDC in, continuing A's −20.8 bps move | 68,838,890 | `Measured` −20.794 bps; `Charged` momentum 33,054,818,824,126 wei of WETH | **⌈2 bps × output⌉** exactly, the cap |
31
+ | C: 0.1 WETH in, against B's −3.5 bps move | 68,838,899 | `Measured` −3.464 bps | No charge |
32
+ | D: 2,000 USDC in, against C's move, **0.7 gwei tip** | 68,838,911 | `Measured` +2.095 bps; `Charged` priority 396,397,629,106,812 wei of WETH | **⌈6 bps × output⌉** exactly (10 bps × 0.6 gwei); no momentum |
33
+
34
+ The Supabase indexer (`unichain-sepolia:pawtom-v8` stream) reads the same four swaps with the same charges, directions and tips. Gas over a plain swap, in the test suite: 12.2k uncharged, 28.9k charged, 44.9k for a block's first swap.
35
+
36
+ ## v7: measured momentum
37
+
38
+ | | |
39
+ |---|---|
40
+ | Hook | [`0x0517AF831F3Afcca2A7C9E64FC2F5e5a279bD0c4`](https://unichain-sepolia.blockscout.com/address/0x0517AF831F3Afcca2A7C9E64FC2F5e5a279bD0c4), source verified (solc 0.8.30, 10,000 runs), deployed at block 68,806,209 |
41
+ | Defaults | `PawtomConfig.ethUsdc5bps(1)`: momentum cap 2 bps, w = 1.1σ, dead zone 0.111 × fee, a measurement counts for 60 s; priority 300,000 × (bid − 0.1 gwei) wei, capped at 0.1%; WETH is currency1 |
42
+ | Main pool | USDC/WETH, fee 450, tick spacing 10, id `0x1c245d43249e7a1d93d93b423df6cc89b1d57427d5ac8d235a0e0b93e05fafb9`, initialised at block 68,806,262 at the v6 pool's price (3,006.30 USDC per WETH), liquidity L = 5.2538e16 on ticks 188,730 to 203,730 (v6: 5.2511e16) |
43
+
44
+ Four live checks, each read from its receipt ([log](logs/v7/live_checks.txt)):
45
+
46
+ | Swap | Block | Hook events | Result |
47
+ |---|---:|---|---|
48
+ | A: 3,000 USDC in (price down), 1 wei tip | 68,806,364 | `Measured` 0 (first block after creation) | No charge |
49
+ | B: 500 USDC in, continuing A's −20.8 bps move | 68,806,372 | `Measured` −20.809 bps; `Charged` momentum 3.317e13 WETH | **2.00 bps**, the cap |
50
+ | C: 0.1 WETH in, against B's −3.5 bps move | 68,806,380 | `Measured` −3.466 bps | No charge |
51
+ | D: 2,000 USDC in, against C's move, **2 gwei tip** | 68,806,455 | `Measured` +2.089 bps; `Charged` priority 5.7e14 WETH | **300,000 × (2 − 0.1) gwei = 0.00057 WETH** exactly; no momentum |
52
+
53
+ The Supabase indexer reads the same four swaps with the same charges, directions and tips (`unichain-sepolia:pawtom-v7` stream). Gas over a plain swap, on a fork of this deployment: 12.4k uncharged, 43.7k for a block's first swap (measure + charge).
54
+
55
+ ## v6: gas-optimised, every swap under 30k
56
+
57
+ v6 runs the same scenarios as v3 on the same tokens and the same liquidity: main pool L = 5.2511e16 and narrow pool L = 9.443e15, tick spacings 10 and 60, NFTs #8039 and #8040. The source is verified on Blockscout. All checks pass: [guards](logs/v6/guards.txt) 13/13, [dust](logs/v6/dust.txt) 8/8, [ramp](logs/v6/boundary.txt) 35/35, [round trip](logs/v6/roundtrip.txt) 6/6, [drain and rescue](logs/v6/drain_rescue.txt) 9/9.
58
+
59
+ There is no per-swap charge event any more. The harness reads each charge from the PoolManager's `Donate` sent by the hook, or from `ChargeHeld` when the charge is held, and derives avgK from the `Swap` event.
60
+
61
+ The same swaps on v3 and v6, by actual `gasUsed`:
62
+
63
+ | Swap | v3 | v6 | Change |
64
+ |---|---:|---:|---:|
65
+ | Dust, first swap of a window | 135,437 | 124,713 | −10,724 |
66
+ | Dust, later swaps (×3) | 115–126k | 113–121k | −2.3k to −5.1k |
67
+ | +4.0 bps, inside the dead zone (opens the window) | 142,856 | 131,820 | −11,036 |
68
+ | Charged legs of the ramp, +4 → +400 bps (×7) | 142.6–145.2k | 132.9–135.5k | **−9,688 each** |
69
+ | −395 bps back toward mu_c (not charged) | 125,743 | 120,610 | −5,133 |
70
+ | Round trip in one transaction | 167,903 | 155,082 | −12,821 |
71
+ | Drain to MIN_TICK (charge held) | 583,916 | 581,807 | −2,109 |
72
+ | Rescue back into range (no collapse with L = 0) | 561,907 | 556,381 | −5,526 |
73
+ | Collapse that donates held charges | 160,033 | 151,318 | −8,715 |
74
+ | **All 19 swaps** | **3,556,094** | **3,399,514** | **−156,580** |
75
+
76
+ The −9,688 on every charged leg matches the unit-test overhead, which went from 39.3k to 29.6k.
77
+
78
+ **Found while deploying v5.** v5 was the first optimised build. A v5 drain ran out of gas at its estimated gas limit, which showed that holding a charge on *any* `donate` failure was unsafe: an out-of-gas inside `donate` would silently turn a donation into a held charge. v6 holds a charge only on `Pool.NoLiquidityToReceiveFees` and reverts on every other failure (`test_donateFailureOtherThanNoLiquidityRevertsTheSwap`). The harness now also sends swaps with a fixed 3M gas limit, so a lagging RPC node's estimate cannot starve them.
79
+
80
+ ## v6: six years of ETH/USDC, replayed on chain
81
+
82
+ `script/04_ReplayHistory.s.sol` (in the git history up to commit e081aee; v7 has no 60 s window to replay a day into) created a fresh pool on hook v6 with its own test tokens, then swapped it to each of 2,190 daily ETH/USDC closes (Nov 2020 to Oct 2026), one swap a day, in chunks of 150 steps. That is 2,204 transactions: 14 to set up, 2,190 swaps, every receipt successful, from block 68,172,786 to 68,179,156.
83
+
84
+ | | Address |
85
+ |---|---|
86
+ | Hook (v6) | [`0x4c252FC4735909D935e1BdD29C82ab3E130510c4`](https://unichain-sepolia.blockscout.com/address/0x4c252FC4735909D935e1BdD29C82ab3E130510c4) |
87
+ | Replay token0 | [`0x28C589485057DA49A5f0100878A0cab87fC82BCB`](https://unichain-sepolia.blockscout.com/address/0x28C589485057DA49A5f0100878A0cab87fC82BCB) |
88
+ | Replay token1 | [`0xd1b07611C1aE1fB92d8F8aCB442A90755C03d935`](https://unichain-sepolia.blockscout.com/address/0xd1b07611C1aE1fB92d8F8aCB442A90755C03d935) |
89
+ | Swap router (PoolSwapTest) | [`0x5be87188791E537ade4C1e285A52A5a197e6AE16`](https://unichain-sepolia.blockscout.com/address/0x5be87188791E537ade4C1e285A52A5a197e6AE16) |
90
+
91
+ [`model/verify_replay.py`](../../model/verify_replay.py) reads the broadcast receipts, takes each PoolManager `Swap` as one day, derives its charge from the hook's same-transaction donation, and re-runs the model with the real block timestamps ([log](logs/replay_v6.txt)):
92
+
93
+ - **2,190 of 2,190 swaps match the model**, 0 differ.
94
+ - **Total charge on chain equals the model to 100.000000%** (1.123030e24 against 1.123030e24 wei of the output token).
95
+ - No swap shared a block with the one before, so every day opened its own collapse window.
96
+
97
+ The broadcast records are in [`broadcast/04_ReplayHistory.s.sol/1301`](../../broadcast/04_ReplayHistory.s.sol/1301). Forge's attempts that sent nothing are not kept.
98
+
99
+ ## v4: PWT-13 and a native-ETH pool
100
+
101
+ v4 is the hook with the PWT-13 cap: a window's move counts at most 4σ in the volatility update. It runs a native ETH/USDC pool, which is how Unichain's real ETH/USDC pools are set up (ETH as currency0, no WETH). The source is verified on Blockscout.
102
+
103
+ | | Address / id |
104
+ |---|---|
105
+ | PawtomHook v4 | [`0x7387BEb979DB68E264DF712992fbd908bA0F90C4`](https://unichain-sepolia.blockscout.com/address/0x7387BEb979DB68E264DF712992fbd908bA0F90C4) (deploy tx `0xb49610bd…`; pool tx `0x827c11ee…`) |
106
+ | native ETH/USDC pool, tick spacing 10 | `0xfc576885f9ff18d06276d360661b20363a452a740afa169456aab5315a40643b`, NFT #8036: 0.005 ETH + 15 USDC (v3's USDC), ticks [-203750, -188750] |
107
+
108
+ The pool is small because it holds real testnet ETH. The [native scenario](logs/v4/native.txt) passed 18 of 18 checks over 6 swaps:
109
+ - Small swaps both ways inside the dead zone: ETH in is sent as the transaction's value, and the quote equals settlement.
110
+ - Buying ETH 30 bps away from mu_c is charged in ETH (avgK 0.56), and the charge is donated in ETH in the same swap.
111
+ - Selling ETH through mu_c to −30 bps is charged in USDC, on the away part only (avgK 0.27).
112
+ - An exact-output purchase of ETH toward mu_c is not charged.
113
+ - At the end the hook holds 0 wei of ETH and no claims.
114
+
115
+ Native ETH emits no Transfer event, so the harness reads the wallet's ETH balance change and adds back the L2 gas and the L1 data fee.
116
+
117
+ ## v3: the platform deployment
118
+
119
+ All five contracts are verified on Blockscout. They show as "partial" matches because the build sets `bytecode_hash = "none"`, so there is no metadata hash to match; the code itself matches exactly. The hook was matched automatically as identical to v2.
120
+
121
+ | | Address / id |
122
+ |---|---|
123
+ | PawtomHook v3 | [`0x876d1D611c905ADE7Ce7DC3d2f65d72de71FD0c4`](https://unichain-sepolia.blockscout.com/address/0x876d1D611c905ADE7Ce7DC3d2f65d72de71FD0c4) (deploy tx `0x75c43d4b…`) |
124
+ | USDC: Pawtom USD Coin, **6 decimals**, token0 | [`0x577CC3ab9650832658029E3C9dd051A035f8eD23`](https://unichain-sepolia.blockscout.com/address/0x577CC3ab9650832658029E3C9dd051A035f8eD23). Anyone can claim 30,000 a day with `faucet()`. |
125
+ | WETH: Pawtom Wrapped Ether, 18 decimals, token1 | [`0x6e28800a4f656E30C03B3d26cF097C624a3932B1`](https://unichain-sepolia.blockscout.com/address/0x6e28800a4f656E30C03B3d26cF097C624a3932B1). Anyone can claim 10 a day with `faucet()`. |
126
+ | Owner (hook, both tokens) | `0x2A87506f791FBB0FcFbcCEaAB6BE6A2F26b06238` |
127
+ | main pool, tick spacing 10 | `0x94289ed3fc942064f23eb99e1bf35f14e7755ac25403691c03c4995e01e1bafc`, NFT #8033: 900,000 USDC + 300 WETH, ticks [188750, 203750] (about ±112%) |
128
+ | narrow pool, tick spacing 60 | `0x2f8f3465f358648782a96fd35d91f289c9e3fe790d1f35084d8ecef8df78bf62`, NFT #8034: 3,000 USDC + 1 WETH, ticks [196140, 196260] (about ±0.6%) |
129
+ | full-range pool, tick spacing 200 | `0x71f0d3442d38aeb294f084fd5fb8c71826a6e1954db1d692645f4b0494768dc1`, NFT #8035: 3,000 USDC + 1 WETH, ticks [-887200, 887200] |
130
+
131
+ All pools started at 3,000 USDC per WETH, at tick ~196,256 because of the 6-vs-18 decimal gap. The token contract is `script/testing/PawtomTestToken.sol`, deployed by `script/testing/02_DeployPawtomTokens.s.sol`. Scenarios are in `script/live/extreme.py`, and swap sizes are derived from live liquidity so that each swap moves the price by a chosen number of bps.
132
+
133
+ ### v3 results: 30 swap transactions, 120 checks, 0 failures ([logs](logs/v3))
134
+
135
+ | Scenario | What it shows | Checks |
136
+ |---|---|---|
137
+ | [Dust](logs/v3/dust.txt) | 1 raw unit in each direction, exact-in and exact-out: nothing reverts and there is no charge. An input of 1e-6 USDC buys 0 WETH, because v4 rounds the LP fee up to the whole unit (core behaviour, in LPs' favour). | 8/8 |
138
+ | [Dead-zone edge and ramp](logs/v3/boundary.txt) | Charge as a share of the output: 0 up to +4.0 bps; 0.0002 bps for +4.0 → +4.6, just past the 4.5 bps edge (avgK 5e-6); then 0.34, 5.2, 26.2 and 39.7 bps for successive legs; exactly 40.0 bps (the cap) from +50 to +400 bps; 0 on the way back. avgK rises monotonically. | 35/35 |
139
+ | [Round trip in one tx](logs/v3/roundtrip.txt) | 4,320 USDC → WETH → USDC through the same pool in a single transaction. The away leg pays avgK 0.60; the return leg pays nothing. The round trip costs 32.8 bps: 9 bps of LP fees plus a 23.9 bps charge. | 6/6 |
140
+ | [Cross-window splitting](logs/v3/split.txt) | +40 bps at once pays 0.00525 WETH (27.4 bps of output). The same move as five +8 bps steps, one per window, pays 0.000106 WETH in total, about 50× less, but it takes 5 minutes. This is the staleness tradeoff in numbers. | 32/32 |
141
+ | [Extreme range](logs/v3/extreme_range.txt) | Full-range pool. A 7.0e26 USDC swap pushes the price to tick −880,000. In the same window, a 7.0e14 WETH swap crosses the whole range to tick +879,999 (avgK 0.39: only the part moving away from mu_c counts). The next window returns it to 3,000. The hook math holds at u ≈ ±88 with amounts near 1e33 raw units; every charge is exact and liquidity stays in range throughout. | 14/14 |
142
+ | [Drain and rescue](logs/v3/drain_rescue.txt) | The narrow pool is drained to MIN_TICK; the 0.00398 WETH charge is held as claims. A further USDC-in swap reverts with `PriceLimitAlreadyExceeded`. The next window has no collapse while L = 0. The rescue swap is not charged, and the next swap collapses and donates the held claims. | 9/9 |
143
+ | [Idle drift](logs/v3/idle.txt) | With the window closed, the quote for a +30 bps move falls by 3.2–3.3 ppm per minute (−9.8 ppm after 3 minutes), as documented in PWT-12. | 1/1 |
144
+ | [Guards](logs/v3/guards.txt) (eth_call) | `PoolAlreadyInitialized`; `NotOwner`; `InvalidParams` for sigmaMin < 1e9 and for LP fee + cap = 100% (fee 996,000), while fee 995,999 initialises; dynamic fee rejected; `SwapAmountCannotBeZero`; slippage exact at quote / quote + 1 in the same block; `DeadlinePassed`; `NotPoolManager`; token `mint` from a non-owner. | 13/13 |
145
+ | [Faucet](logs/v3/faucet.txt) | 30,000 USDC and 10 WETH claimed; a second claim the same day reverts with `FaucetCooldown`. | 2/2 |
146
+
147
+ **What the extreme cases show beyond v1/v2:**
148
+ - **A restore after a backed extreme price still pays the cap.** With full-range liquidity, an extreme price is backed, so the window that closed there collapsed normally (PWT-11 rightly does not apply). The swap back to 3,000 then paid the full 0.4%. Whoever pushes a pool that far has already paid fees and charges on astronomically large amounts, and the restore's charge goes to the LPs, so this is not exploitable. But it is why the cap matters.
149
+ - **sigma clamps at its max after an extreme window** (21 bps/min) and decays with the EWMA weight of 0.005 per minute, a half-life of about 2.3 hours. Until then the packet is wider, so charges on that pool are lower.
150
+ - **Patient arbitrage pays about 50× less** by splitting a move across windows. That is the design's built-in limit on staleness: the price catches up within a few windows instead of the pool being bypassed. The window length and dead zone set the tradeoff.
151
+
152
+ ## v1 addresses (chain 1301)
153
+
154
+ | | Address |
155
+ |---|---|
156
+ | PawtomHook v1 | [`0xBab51E49B798D166f7C1b4cdb69840D25b8450c4`](https://unichain-sepolia.blockscout.com/address/0xBab51E49B798D166f7C1b4cdb69840D25b8450c4) |
157
+ | Hook owner (deployer) | `0x2A87506f791FBB0FcFbcCEaAB6BE6A2F26b06238` |
158
+ | token0: Poincare USD Coin (USDC, 18 dec) | `0x1b4034d6c443eff3d2e9051a08147ef9ed8ebc70` |
159
+ | token1: Poincare Wrapped Ether (WETH, 18 dec) | `0x26b5d554c8118f247d5fa8a469ff3a3d3084a449` |
160
+ | PoolManager / PositionManager / V4 router / V4Quoter | canonical: `0x00B036B5…62AC` / `0xf969Aee6…d664` / `0x9cD2b0a7…5Dba` / `0x56dcd40a…4472` |
161
+
162
+ | Pool | Pool id | Tick spacing | Position | Purpose |
163
+ |---|---|---|---|---|
164
+ | main | `0x9419aa312210de878f6d8b0ac54753df127f4d2e0ffb9c56107cce237eb8df71` | 10 | NFT #8029: 15,000 USDC + 5 WETH, ticks [-87560, -72560] (about ±112%) | normal swaps |
165
+ | edge | `0xe8a1dea2e9e73e332087aa3b1fae68b87852069bef6adf9a34d29a1d8af3011b` | 60 | NFT #8030: ~300 USDC + 0.1 WETH, ticks [-80100, -79980] (about ±0.6%) | running out of liquidity |
166
+
167
+ Both pools started at 3,000 USDC per WETH. Deployment transactions are in `broadcast/00_DeployHook.s.sol/1301/` and `broadcast/01_CreatePoolAndAddLiquidity.s.sol/1301/` (hook: `0x9e3f88e0…`, main pool: `0xb3e3c87d…`, edge pool: `0x9ea6c61c…`). All of it, including the swaps, cost under 0.00001 ETH of gas.
168
+
169
+ ## How the swaps were checked
170
+
171
+ `script/live/scenarios.py` sends each swap through the canonical router with `cast`, and `script/live/pawtom_live.py` decodes the receipt. Each swap is checked against the state of the block before it:
172
+
173
+ - **The quote matches settlement.** The V4Quoter, run on block N−1, gives the amount settled in block N to the wei.
174
+ - **The charge follows the formula.** The `CollapseCharge` amount equals `ceil(|unspecified| × cap × avgK)`, computed from the PoolManager's `Swap` delta.
175
+ - **The user receives the pool's output less the charge.** On an exact-in swap the user receives the pool's output minus the charge; on an exact-out swap the user pays the pool's input plus the charge. Both are read from the receipt's ERC-20 transfers.
176
+ - **The charge goes to LPs in the same swap.** The PoolManager emits a matching `Donate` in the same transaction whenever liquidity is in range.
177
+
178
+ Guard checks run as `eth_call`, so they cost no gas and change no state. Logs are in [`logs/`](logs).
179
+
180
+ ## v1 results: 14 swaps, 47 checks, 0 failures
181
+
182
+ ### Main pool: one collapse window ([log](logs/main_window.txt), [log](logs/main_collapse.txt))
183
+
184
+ Moves are measured against mu_c in USDC/WETH. The dead zone is z = 4.5 bps; w ≈ 7 bps.
185
+
186
+ | Swap | Move vs mu_c | Charge | avgK | Gas | Tx |
187
+ |---|---|---|---|---|---|
188
+ | 1 wei USDC in, first swap of the window | 0 → 0 bps | none; `Collapse` emitted | – | 133k | `0x965aabf3…` |
189
+ | 5 USDC in, inside the dead zone | 0 → +2.1 | none | – | 125k | `0x5fc5e0de…` |
190
+ | 70 USDC in, away past z | +2.1 → +31.3 | 0.0000578 WETH, donated | 0.621 | 160k | `0x976ac5fa…` |
191
+ | 0.016 WETH in, back toward mu_c | +31.3 → +11.2 | none | – | 124k | `0xd2c2b1e0…` |
192
+ | 0.03 WETH in, through mu_c and out past −z | +11.2 → −26.3 | 0.126 USDC, only on the part beyond −z | 0.351 | 143k | `0x6c9e170d…` |
193
+ | Exact-out 30 USDC, further away | −26.3 → −38.9 | 0.0000401 WETH, taken on the **input** side | 0.999 | 139k | `0xf66293ef…` |
194
+ | Exact-out 0.005 WETH, toward mu_c | −38.9 → −32.6 | none | – | 125k | `0xec71e614…` |
195
+ | *Next window:* 2 USDC in | 0 → +0.8 | none; `Collapse` sets mu_c = 2,990.24 and sigma 6.90 → 7.22 bps/min | – | 142k | `0x13a1f681…` |
196
+ | 8 USDC in, same window | +0.8 → +4.2 | none (no second collapse) | – | 125k | `0x81cc42a5…` |
197
+ | 30 USDC in, same window | +4.2 → +16.7 | 0.0000127 WETH, donated | 0.318 | 143k | `0xadbf2017…` |
198
+
199
+ ### Edge pool: draining the range ([log](logs/edge_drain.txt), [log](logs/edge_return.txt), [log](logs/edge_floor.txt))
200
+
201
+ | Swap | What happened | Gas | Tx |
202
+ |---|---|---|---|
203
+ | 2 USDC in | opened a window, no charge | 159k | `0x08822459…` |
204
+ | 2,000 USDC in | Took all the WETH in range. Only 108.97 USDC was filled (a partial fill; the router settles what filled). The price ran to MIN_TICK (−887272) with L = 0. The 0.000145 WETH charge (avgK 1.0) was **held as ERC-6909 claims** and recorded in `accrued`. | 488k | `0xfb4e4264…` |
205
+ | 0->1 at the floor (eth_call) | The PoolManager reverts with `PriceLimitAlreadyExceeded`: the price cannot fall further. | – | – |
206
+ | 0.001 WETH in, next window | `beforeSwap` collapsed at the floor price while L = 0, so the claims **stayed held** and sigma clamped to its max (21 bps/min). The swap then jumped back into range, away from the new mu_c. It paid a 0.012 USDC charge (avgK 1.0), donated at once. | 494k | `0xda4d1523…` |
207
+ | 0.01 USDC in, next window | The collapse found L > 0. It emitted `Donated(0, 0.000145 WETH)`, donated the held claims and burned them. `accrued` and the hook's claims are back to 0. | 159k | `0xecb3b055…` |
208
+
209
+ ### Guards ([log](logs/reverts.txt))
210
+
211
+ | Call | Result |
212
+ |---|---|
213
+ | `setPoolParams` on an initialised pool | `PoolAlreadyInitialized` |
214
+ | `setPoolParams` from a non-owner | `NotOwner` |
215
+ | `setPoolParams` with cap = 0, or with cap + fee ≥ 100% | `InvalidParams` |
216
+ | Initialise a dynamic-fee pool with the hook | `WrappedError(…, DynamicFeeNotSupported)` |
217
+ | Exact-in with `amountOutMin` = quote + 1 / = quote (same block) | reverts (`SlippageExceeded`) / succeeds: the charge counts against slippage |
218
+ | Exact-out with `amountInMax` = quote − 1 | `SlippageExceeded` |
219
+ | `beforeSwap` called directly by an EOA | `NotPoolManager` |
220
+
221
+ ## Observations
222
+
223
+ 1. **On an idle pool, quotes for charged swaps drift slowly.** When a window has long closed, the next swap's collapse folds all the idle time into sigma. Sigma decays toward its floor, w narrows and the charge grows. On the main pool, a 100 USDC quote fell by about 2e-6 of the output per minute (about 69 gwei of WETH). Quote and settlement agree exactly within a block and within an open window. Across blocks on an idle pool, an integrator needs a small slippage tolerance, which it should have anyway.
224
+ 2. **After a collapse at a degenerate price, the swap that restores the price pays close to the full cap.** This was fixed in v2 as PWT-11. On the drained pool, the window closed while the price sat at MIN_TICK, so mu_c reset there. The swap back to about 3,000 then moved "away" from mu_c and paid avgK ≈ 1, the full 40 bps cap. This is bounded by the cap and only happens once a pool has been drained to an extreme price. It is still worth knowing for thin or empty pools: whoever restores the price pays the cap, and the charge goes to the remaining in-range LPs.
225
+ 3. **Gas.** In-zone swaps cost about 124k. Charged swaps that donate cost about 140–160k. The first swap of a window costs 8–35k more for the collapse. Crossing the full tick range on the edge pool cost about 490k, almost all of it in the PoolManager.
226
+
227
+ ## v2: the PWT-11 fix, live
228
+
229
+ | | Address / id |
230
+ |---|---|
231
+ | PawtomHook v2 | [`0x9cEDea13Ec37604259C2613a7ac0bd96901410C4`](https://unichain-sepolia.blockscout.com/address/0x9cEDea13Ec37604259C2613a7ac0bd96901410C4) (deploy tx `0xe5d4bacd…`). Source verified on Blockscout. |
232
+ | main pool, tick spacing 10 | `0xf674e8e86384e436b5e8ac24134707e597452c38e822d8901a0226f4d781a912`, NFT #8031: 10,000 USDC + 3.33 WETH, ticks [-87560, -72560] |
233
+ | edge pool, tick spacing 60 | `0x41c903f6de73283a7a5895022070168b636616a50ca8a8489956941135b66d9c`, NFT #8032: ~300 USDC + 0.1 WETH, ticks [-80100, -79980] |
234
+
235
+ On v2, the same drain-and-rescue sequence ([drain](logs/v2/edge_drain.txt), [rescue](logs/v2/edge_return.txt)) gives:
236
+
237
+ | | v1 | v2 |
238
+ |---|---|---|
239
+ | First swap after the window, starting at MIN_TICK with L = 0 | Collapses there: mu_c is reset to an extreme price and sigma clamps to 21 bps/min | **No collapse**: mu_c stays at 3,000 and sigma at 6.98 bps/min |
240
+ | That swap: 0.001 WETH back into the range | Charged 0.012 USDC (avgK 1.0) and received 2.996 USDC | **Not charged**; received **3.008 USDC** (`0xb0f28834…`) |
241
+ | Held 0.000145 WETH claims | Donated at the next window's collapse | Donated by the very next swap, which starts with liquidity in range (`0xad06e5b1…`). sigma updates normally, to 7.31 bps/min. |
242
+
243
+ The main-pool window ([log](logs/v2/main_window.txt)) and the guards ([log](logs/v2/reverts.txt)) also pass on v2. In total, v2 ran 11 swaps with 37 of 37 checks passing. The main pool holds two-thirds of v1's liquidity, so the same amounts move the price about 1.5× further.
244
+
245
+ ## Reproduce
246
+
247
+ ```bash
248
+ export PATH=$HOME/.foundry/bin:$PATH DEPLOYER_PRIVATE_KEY=<key>
249
+ export HOOK=0x9cEDea13Ec37604259C2613a7ac0bd96901410C4 \
250
+ TOKEN0=0x1b4034d6c443eff3d2e9051a08147ef9ed8ebc70 TOKEN1=0x26b5d554c8118f247d5fa8a469ff3a3d3084a449
251
+ python3 script/live/scenarios.py reverts # no gas
252
+ python3 script/live/scenarios.py main_window # 7 swaps
253
+ python3 script/live/scenarios.py main_collapse # 3 swaps
254
+ TICK_SPACING=60 python3 script/live/scenarios.py edge_drain # the edge pool is back in range, so this repeats
255
+ TICK_SPACING=60 python3 script/live/scenarios.py edge_price_floor
256
+ TICK_SPACING=60 python3 script/live/scenarios.py edge_return
257
+ ```
258
+
259
+ The amounts are sized for the pools as deployed. On the main pool, 10 USDC moves the price about 4 bps.
@@ -0,0 +1,75 @@
1
+ # Integrating Pawtom
2
+
3
+ For routers, aggregators, indexers and LPs. Pawtom is a Uniswap v4 hook on ordinary concentrated liquidity: a Pawtom pool is a normal v4 pool with a static LP fee, plus a **momentum charge** on swaps that continue the last block's measured move (up to 2 bps) and a **priority charge** on transactions that bid a priority fee above 0.1 gwei: 10 bps of each swap per gwei above it, up to 0.1%. [`MECHANISM.md`](MECHANISM.md) has the exact formulas.
4
+
5
+ ## Addresses (Unichain Sepolia, chain 1301)
6
+
7
+ | | Address |
8
+ |---|---|
9
+ | PawtomHook v8 | [`0x62b688EacD74A2a8Ea2453FCc7DEFE692f5510c4`](https://unichain-sepolia.blockscout.com/address/0x62b688EacD74A2a8Ea2453FCc7DEFE692f5510c4) |
10
+ | Main USDC/WETH pool id | `0xa44025b9aae971eb76839a3f87af584d9d8b447ad23924bfbd95c6b4a6044862` |
11
+ | PoolManager (canonical) | `0x00B036B58a818B1BC34d502D3fE730Db729e62AC` |
12
+ | V4Quoter (canonical) | `0x56dcd40a3f2d466f48e7f48bdbe5cc9b92ae4472` |
13
+ | Test USDC (6 decimals) / WETH (18 decimals) | `0x577CC3ab9650832658029E3C9dd051A035f8eD23` / `0x6e28800a4f656E30C03B3d26cF097C624a3932B1` |
14
+
15
+ The pool key is `(currency0 = USDC, currency1 = WETH, fee = 450, tickSpacing = 20, hooks = PawtomHook)`. Older deployments, v1 to v7, are listed in [`deployments/unichain-sepolia`](deployments/unichain-sepolia/README.md).
16
+
17
+ ## Routers and aggregators
18
+
19
+ **Quoting.** Use the canonical `V4Quoter` (`quoteExactInputSingle` / `quoteExactOutputSingle`, or the multi-hop variants). It simulates the hook, so the quote includes the momentum charge, and it equals settlement to the wei in the same block (`test_quoteEqualsSettlement`). `momentumRates(key)` returns the rate a swap in each direction would pay in the current block (1e18 = 100% of the unspecified amount), for display.
20
+
21
+ **Priority fees.** The priority charge reads the transaction's `tx.gasprice − block.basefee` and nothing else the sender does not choose. **Simulate the quote at the gas price you will send** (`eth_call` with `gasPrice`, or `maxFeePerGas` and `maxPriorityFeePerGas`, and a `from`) and it includes the charge exactly (`test_priority_quoteAtTheSendersGasPriceEqualsSettlement`; checked against the live pool). A quote at gas price 0, the usual default, leaves it out. `priorityRateFor(key, tip)` returns the rate for any tip. Swaps sent at or below 0.1 gwei of priority fee never pay it (Unichain blocks are rarely full; routers bid about 0.005 gwei and the Pawtom app 0.001 gwei). A transaction relayed by an ERC-4337 bundler with a high tip can pay up to 0.1% (PWT-16); on four days of real ETH/USDC flow, one swap came through a bundler, below the floor.
22
+
23
+ **Slippage.** Allow a normal tolerance plus the 2 bps momentum cap: a swap that lands in a later block than its quote faces that block's measurement, which can add up to the cap or remove it. Never set `amountOutMin` to the quote exactly.
24
+
25
+ **Swap parameters.** There is no `hookData`, and none is read. Exact input and exact output both work, in either direction, and so does native ETH as currency0. Both charges are taken in the **unspecified** currency: an exact-input swap receives less output, and an exact-output swap pays more input.
26
+
27
+ **Gas.** On top of a plain v4 swap: 12.2k for an uncharged swap (most retail flow), 28.9k for a charged swap, and 44.9k for the first swap of a block in the pool, which measures (cold storage, `isolate = true`).
28
+
29
+ **Splitting.** Every swap in a block faces the same measurement, so splitting an order inside a block saves nothing; walking a move across consecutive blocks pays at every step.
30
+
31
+ ## Routing and discovery
32
+
33
+ Will Uniswap's router send flow to a Pawtom pool? **Not automatically.** Uniswap's routing picks up most hooked pools on its own, but not hooks that return a swap delta (`afterSwapReturnDelta`, which Pawtom uses to take its charges) or use dynamic fees. Those are added by hand after review.
34
+
35
+ | Path | What it gives | Status for Pawtom |
36
+ |---|---|---|
37
+ | [Uniswap hook routing allowlist](https://developers.uniswap.org/hook-allowlist) | Flow from the Uniswap interface and API, through Uniswap Labs' routing | Needs a submission and review; the checklist below is what it asks for. Only for chains Uniswap routes on, so a mainnet deployment, not Sepolia |
38
+ | [Uniswap hooklist](https://github.com/Uniswap/hooklist) | A public registry of hooks, which integrators and explorers read | Open an issue with the chain and hook address; the source must be verified on the explorer, which it is. Listing does not mean routing |
39
+ | A [UniswapX](https://developers.uniswap.org/docs/protocols/v4/concepts/hook-routing) filler for the pool | Interface flow now, before the allowlist: the filler fills UniswapX orders from the Pawtom pool | Can run today; [`examples/strategies`](examples/strategies) has quoting code a filler can start from |
40
+ | Aggregators (1inch, 0x, KyberSwap, Odos, Tycho-based solvers) | Their own routing | Each must simulate the hook: on-chain simulation through the V4Quoter works as is; off-chain simulators need Pawtom's rules, which [`MECHANISM.md`](MECHANISM.md) states exactly |
41
+
42
+ Until a pool is routed, its flow comes from the app, direct integrations and fillers.
43
+
44
+ ## Routing allowlist checklist
45
+
46
+ Hooks that return a swap delta need Uniswap's routing allowlist. What it asks for, and where Pawtom shows it:
47
+
48
+ | Requirement | Pawtom |
49
+ |---|---|
50
+ | Quote equals settlement | Yes, in the same block, when the quote is simulated at the sender's gas price; at gas price 0 for transactions bidding at or below the 0.1 gwei floor (`test_quoteEqualsSettlement`, `test_priority_quoteAtTheSendersGasPriceEqualsSettlement`, fork test, live logs) |
51
+ | No `hookData` needed | Yes: `hookData` is ignored |
52
+ | Not upgradeable; no admin over live pools | Yes: no proxy, no `delegatecall`. The owner can set a pool's parameters only **before** it is initialised (`test_setPoolParams_frozenAfterInitialise`) |
53
+ | No external dependencies | Yes: no oracle, keeper or off-chain service. The hook calls only the PoolManager |
54
+ | Deterministic, bounded behaviour | Yes: momentum ≤ 2 bps and priority ≤ 0.1% of the unspecified amount, both functions of public state and the sender's own gas price, and valid swaps never revert (`testFuzz_randomSequence`) |
55
+ | Source verified | Yes, on Blockscout |
56
+
57
+ ## Indexers
58
+
59
+ | Event | Emitter | Meaning |
60
+ |---|---|---|
61
+ | `Swap(id, sender, amount0, amount1, sqrtPriceX96, liquidity, tick, fee)` | PoolManager | The swap, **before** the charge. `sender` is the router or contract that called the PoolManager |
62
+ | `Measured(id, delta, sigmaPerSecond)` | hook | At a block's first swap, before it runs: the last active block's net log-price move (1e18) and σ per second (1e18). No event when the block is not a measurement (no liquidity in range) |
63
+ | `Charged(id, inCurrency0, momentum, priority)` | hook | **The swap's charge**, emitted right after its `Swap`, in the unspecified currency's raw units |
64
+ | `Donate(id, sender, amount0, amount1)` with `sender == hook` | PoolManager | The same charge, donated to in-range LPs in that swap, or held charges paid out at a measurement (see `Donated`) |
65
+ | `ChargeHeld(id, amount0, amount1)` | hook | A charge held because the swap left no liquidity in range |
66
+ | `Donated(id, amount0, amount1)` | hook | Held charges donated at a measurement; followed by a PoolManager `Donate` with the same amounts |
67
+ | `PoolParamsSet(id, params)` | hook | The owner set a pool's own parameters before initialisation |
68
+
69
+ **Charge per swap** = its `Charged` event: attribute each `Charged` to the latest `Swap` of the same pool in the same transaction. **Direction**: a swap continues the measured move ("with") when its price move has the same sign as the `delta` measured at its block's first swap; a block with no `Measured` event faces no measurement. [`supabase/functions/pawtom-indexer`](supabase/functions/pawtom-indexer/index.ts) implements this.
70
+
71
+ **Views.** `state(id)` returns `(blockNumber, blockTime, prevTime, uStart, delta, sigmaPerSecond)`. `params(id)` and `defaultParams()` return the parameters. `momentumRates(key)` returns `(upRate, downRate)` for a swap now, `priorityRateFor(key, tip)` the priority rate at a priority fee per gas, and `logPrice(sqrtPriceX96)` converts a price to u. Values are 1e18 fixed point except block numbers, seconds, pips and wei.
72
+
73
+ ## LPs
74
+
75
+ Positions are ordinary v4 positions minted through the PositionManager. Charges are donated to the liquidity in range at the swap, so they accrue as fees and are collected like fees. A position must be in range when a charged swap trades through it to earn its share: a JIT position added afterwards gets nothing (`test_jitAfterChargeCannotSnipeIt`).
@@ -0,0 +1,102 @@
1
+ # The Pawtom mechanism (v8: measured momentum and a priority rate)
2
+
3
+ This note states exactly what the hook computes and the properties that follow, each linked to the test that checks it. Notation follows [`src/PawtomHook.sol`](src/PawtomHook.sol) and [`src/libraries/PawtomMath.sol`](src/libraries/PawtomMath.sol); all quantities are 1e18 fixed point on chain. The design was chosen on real flow and validated out of sample ([Why this design](#5-why-this-design)); earlier designs are described in the git history and the [internal review](audit/2026-11-internal-review.md).
4
+
5
+ ## 1. Quantities
6
+
7
+ | Symbol | Meaning | In the hook |
8
+ |---|---|---|
9
+ | u | log-price, u = ln P = 2 ln(√P), P = token1 per token0 | `logPrice(sqrtPriceX96)` |
10
+ | u_b | log-price at the start of the current block | `State.uStart` |
11
+ | Δ | the measured move: the last active block's net log-price move | `State.delta` |
12
+ | t_Δ | start time of the block Δ was measured over | `State.prevTime` |
13
+ | g | how long a measurement counts, seconds | `gap` (60) |
14
+ | σ | per-second volatility, an EWMA of measured block moves | `sigma[id]` |
15
+ | f | the pool's static LP fee | `key.fee` |
16
+ | z = k_z · f | dead zone: smaller moves are not a measurement worth charging | `kZ` (0.111, so 0.5 bps at f = 4.5 bps) |
17
+ | w = k_w · σ | kernel width: the move that is "normal" in about a second | `kW` (1.1) |
18
+ | c | momentum cap, as a fraction of the swap's unspecified amount; 0 turns momentum off | `capPips` (2 bps) |
19
+ | φ, r_p, c_p | priority floor (wei per gas), priority rate per wei of tip above it, priority cap | `priorityFloor` (0.1 gwei), `priorityRate` (1e-12 per wei = 10 bps per gwei), `priorityCapPips` (0.1%) |
20
+
21
+ ## 2. Measurement: once per block
22
+
23
+ At the first swap of each block, before the swap runs, the hook takes the current price u. Prices move only through swaps, so u is where the last active block ended, and
24
+
25
+ ```
26
+ Δ = u − u_b # the last active block's net move
27
+ dt = now − (that block's start time) # at least 1 s, at most 7 days
28
+ sample = min(Δ² / dt, 16 σ²) # one block's move counts at most 4σ
29
+ keep = (1 − α)^dt
30
+ σ² ← clamp(keep · σ² + (1 − keep) · sample, σ_min², σ_max²)
31
+ u_b ← u, t_Δ ← that block's start time
32
+ ```
33
+
34
+ A block counts as a measurement only if it **started with liquidity in range and the pool still has liquidity** when the next block begins. Otherwise Δ = 0 and σ is not updated: without liquidity, a dust swap can move the price anywhere (to MIN/MAX_TICK after a drain), and that move is not information (PWT-11, PWT-19). Every swap in a block faces the same measurement.
35
+
36
+ ## 3. The momentum charge
37
+
38
+ A swap continues the measured move when it pushes the price the same way, `oneForZero` (price up) for Δ > 0 and `zeroForOne` (price down) for Δ < 0. It pays
39
+
40
+ ```
41
+ x = |Δ| − z
42
+ K(x) = 1 − exp(−x² / 2w²) for x > 0, 0 otherwise
43
+ momentum = ceil(c · K(x) · |unspecified amount|)
44
+ ```
45
+
46
+ provided the measurement is fresh: `now ≤ t_Δ + g`. A swap against the move, a swap after a block whose move stayed inside the dead zone, and every swap once the measurement is more than g seconds old pay only the LP fee. The unspecified amount is the output of an exact-input swap and the input of an exact-output swap.
47
+
48
+ K is 0 at the edge of the dead zone, about 0.39 one width beyond it, and exactly 1 beyond about 9.2 widths. The kernel reads as the evidence that the last block's move was a trend rather than noise of width w.
49
+
50
+ **Worked example** (ETH/USDC defaults, σ ≈ 0.9 bps/s, so w ≈ 1 bp): after a block moved the price +1.5 bps, a swap that keeps pushing it up has x = 1.0 bp, K ≈ 0.39, and pays 0.8 bps on top of the 4.5 bps LP fee. After a +20 bps block it pays the full 2 bps. A swap selling into either move pays 4.5 bps.
51
+
52
+ ## 4. The priority charge
53
+
54
+ Unichain's builder orders a block by priority fee, so a transaction that bids to be first reveals that being first is worth money to it. With b = tx.gasprice − block.basefee (0 if the gas price is at or below the base fee, as for L1 deposits):
55
+
56
+ ```
57
+ priority = ceil(min(r_p · max(0, b − φ), c_p) · |unspecified amount|)
58
+ ```
59
+
60
+ on **every** swap. It is a rate, so it needs no ETH side or price conversion and works on any pool, and it is proportional to the swap, so splitting a transaction's swaps changes nothing. A once-per-transaction rule would let a dust swap absorb the charge for the real one. The rate is compared with its cap before multiplying, so no tip can overflow it. Retail wallets and routers on Unichain bid around 0.005 gwei, well below φ; the Pawtom app bids 0.001 gwei.
61
+
62
+ The charge depends only on the gas price the sender chose, so a quote simulated at that gas price includes it exactly. `priorityRateFor(key, tip)` returns the rate for any tip.
63
+
64
+ Both charges are taken through `afterSwapReturnDelta` and donated to in-range LPs in the same swap, with one `Charged(id, inCurrency0, momentum, priority)` event. Only if the swap left no liquidity in range is the total held as ERC-6909 claims, and then donated at the next measurement with liquidity.
65
+
66
+ ## 5. Why this design
67
+
68
+ The design before v7 charged moves away from the price at the first swap of a 60 s window. Judged on real Unichain ETH/USDC swaps, each labelled by its profit against Binance's one-second price ([`model/flow_eval.py`](model/flow_eval.py)), it charged uninformed flow more per dollar than informed flow and priced out about a fifth of arbitrage. Of every oracle-free family tried, only charging the continuation of the last block's move had the right sign at every horizon. The priority signal finds 43% of informed profit in 1% of volume.
69
+
70
+ v8 was then tested out of sample against criteria committed before the data was fetched ([`model/PREREGISTRATION.md`](model/PREREGISTRATION.md)). Pooled over three unseen weeks of ETH/USDC ($28M):
71
+
72
+ | Unseen ETH/USDC weeks, 10 s markout | v6 | v7 | **v8** |
73
+ |---|---:|---:|---:|
74
+ | Informed ÷ uninformed, per dollar (90% interval) | 0.66 [0.60, 0.71] | 1.24 [1.19, 1.29] | **1.45 [1.36, 1.56]** |
75
+ | Informed profit recovered for LPs | 9.3% | 10.6% | **13.3%** |
76
+ | Arbitrage priced out (stale prices) | 21.9% | 8.5% | 9.2% |
77
+ | Charge on swaps under $1,000 | 5.96 bps | 0.97 bps | 0.97 bps |
78
+
79
+ It also passes on ETH/USDT0 and HYPE/USDC, where the priority rate works without an ETH side, and **fails on ETH/WBTC**: there, swaps tipping above 0.5 gwei are uninformed. So the priority rate is a per-pool parameter. When a plain pool competes for routed flow, the priority charge never cost LPs money in a replay of real orders, while the momentum charge's effect swung by week, so the momentum cap is per pool too ([`model/competition_sim.py`](model/competition_sim.py)). The ceiling is low: from inside a pool, informed and uninformed flow look alike (dollar-weighted AUC 0.57).
80
+
81
+ ## 6. Properties and the tests that check them
82
+
83
+ | # | Property | Why it holds | Checked by |
84
+ |---|---|---|---|
85
+ | 1 | **Bounded**: momentum ≤ c · \|unspecified\| and priority ≤ c_p · \|unspecified\| (each rounded up by at most 1 wei) | 0 ≤ K ≤ 1; the priority rate is capped before multiplying; `_validate` keeps c + c_p + f < 100% | `test_chargeBoundedByCap`, `test_priority_capped`, `test_priority_noOverflowAtTheLargestRate`, `testFuzz_randomSequence` |
86
+ | 2 | **Exact**: a continuing swap pays ceil(c · K · \|unspecified\|), and nothing else differs from a plain pool | the charge is the only delta the hook returns | `test_continuationIsCharged_exactly`, `test_exactOut_chargeIncreasesInput`, `testFuzz_randomSequence` |
87
+ | 3 | **Against the move is free**, and so is the first move after a quiet block | only the direction of Δ is charged | `test_swapAgainstTheMoveIsFree`, `test_firstMoveIsNotCharged`, `testFuzz_randomSequence` |
88
+ | 4 | **Dead zone and kernel**: no charge for \|Δ\| ≤ z, then rising with \|Δ\| to the cap | K is 0 at x ≤ 0, increasing, saturating | `test_kernelRampFromDeadZone`, `test_kernel_knownValues`, `testFuzz_kernel_boundedAndMonotone`, `testFuzz_kernel_decreasingInWidth` |
89
+ | 5 | **Split-invariant within a block**: one swap or many swaps in a block pay the same rate | every swap in a block faces one measurement | `test_sameBlockSwapsShareOneMeasurement_splitInvariant` |
90
+ | 6 | **Walking a move across blocks pays at every step** | each block's move is the next block's measurement | `test_walkingAMoveAcrossBlocksIsChargedEachStep` |
91
+ | 7 | **Never stale**: an idle pool goes back to the LP fee alone | a measurement counts for g seconds | `test_idlePoolGoesBackToTheBaseFee`, `test_momentumRatesViewMatchesSettlement` |
92
+ | 8 | **No measurement from an unbacked price** | a block counts only if it started and ended with liquidity in range | `test_rescueAfterDrainIsNotCharged`, `test_chargeHeldOnlyWhenNoInRangeLiquidity_thenDonated` |
93
+ | 9 | **σ bounded, and one block cannot spike it** | clamp to [σ_min, σ_max] and the 16σ² sample cap | `test_sigmaSpike_onePushIsBounded`, `testFuzz_sigmaStaysWithinBounds` |
94
+ | 10 | **Priority rate**: zero at or below the floor or the base fee; exactly min(r_p · (b − φ), c_p) of every swap, in either direction and on exact output; off at r_p = 0; momentum can be off while it applies | a rate on the unspecified amount, no conversion, no per-transaction state | `test_priority_belowFloorIsFree`, `test_priority_rateAboveFloor_exactInBothDirections`, `test_priority_exactOut_chargesTheInput`, `test_priority_gasPriceBelowBaseFeeIsNotABid`, `test_priority_everySwapOfTheTransactionPays`, `test_priority_offWhenTheRateIsZero`, `test_momentumOff_priorityOnlyPool`, `testFuzz_randomSequence` |
95
+ | 11 | **Charges reach LPs who bore the trade** | same-swap donation to in-range liquidity | `test_chargeDonatedToInRangeLPsImmediately`, `test_jitAfterChargeCannotSnipeIt`, `test_donateFailureOtherThanNoLiquidityRevertsTheSwap` |
96
+ | 12 | **Quote equals settlement** in the same block, at the gas price the quote is simulated at; `momentumRates()` and `priorityRateFor()` preview the rates | the charges depend only on state the quoter simulates and the gas price | `test_quoteEqualsSettlement`, `test_priority_quoteAtTheSendersGasPriceEqualsSettlement`, `test_momentumRatesViewMatchesSettlement`, `test_priorityRateFor_matchesSettlement`, `test_fork_continuationChargedQuotedAndAgainstFree` |
97
+ | 13 | **Matches the reference model** | `model/pawtom_model.py` (`PawtomV7` with `V8_DEFAULTS`) implements the same state machine and both charges in floating point | `test_parityWithPythonModel_v8` (output ≤ 1e-8, charges ≤ 1e-6) |
98
+ | 14 | **Never reverts** on valid swaps | the kernel never reverts; the priority rate cannot overflow; Δ is clamped to int64 | `testFuzz_randomSequence`, `test_priority_noOverflowAtTheLargestRate`, `testFuzz_kernel_boundedAndMonotone` |
99
+
100
+ ## 7. Numerical method
101
+
102
+ K uses solady's `expWad`. To stay exact and overflow-free for any input, `kernel` saturates at x ≥ 10w, then computes r = x/w (< 10, 1e18) and e = r²/2 (< 50e18), and returns 1 − e^(−e), exactly 1 once e ≥ 42. The priority rate is min(c_p, r_p · (b − φ)), taking the cap whenever b − φ ≥ c_p / r_p, so the product is never formed for a tip that would overflow it.