Hydrex
Senior Smart Contract Engineer
November 2025 – September 2026
Hydrex is a concentrated-liquidity DEX on Base. I joined in November 2025 as a senior smart contract engineer. I started on the contracts, then built the service that pays out the protocol's liquidity rewards, which replaced an outside provider, and I was its only engineer. My contract ran to September 2026. Since October I've stayed on part-time as a consulting engineer, making fixes and looking after the systems I built.
The reward service
Liquidity mining sounds simple until you try to make it exact. A campaign says: pay this budget, to whoever provides liquidity in this pool, over this window, in proportion to how much and for how long. Doing that honestly means measuring every position continuously, and settling on-chain cheaply enough that the gas does not eat the reward.
I designed and built the whole thing — a TypeScript and NestJS service that continuously snapshots every position in incentivised pools, converts those observations into time-weighted score-seconds, allocates against a fixed budget, publishes Merkle roots on-chain, and serves claim proofs through a public API. PostgreSQL with TimescaleDB underneath, Redis for caching. I also wrote the distributor contract it publishes to.
In its first six months, to August 2026, it distributed 25.1 million tokens to 1,669 liquidity providers, across 2,469 campaigns and 163 pools.
The constraint that shaped the design
Merkle roots here are cumulative and irreversible. Once a root is published, an allocation can only ever go up — you cannot claw back a number you have already committed to. Every other design decision follows from that.
So rather than recomputing totals and asserting afterwards that they never decreased, I built the allocator around incremental deltas, which makes the monotonic floor hold by construction. The pipeline snapshots first and aggregates second, which keeps every reward calculation replayable from raw observations — if a number is ever disputed, it can be rebuilt from what was actually observed on-chain rather than from a cached total.
Settlement is batched: one transaction per cycle carrying every campaign's root, at about 18k gas per root, so gas stays roughly flat as campaigns multiply. It has run since February 2026, through an elevenfold rise in concurrent campaigns.
Running it
I ran the service in production myself, so I built the parts around the reward logic too.
- The API. About 20 REST endpoints with rate limiting, serving single and bulk claim proofs to the web app. I cut the bulk-proof p90 from 6.1s to 1.5s, and raised the proof-cache hit rate from 77% to 96%.
- An integration for the Base team. An endpoint that returns ready-to-send calldata for creating a campaign, with validation, an integration guide and Swagger docs. They have since run test campaigns on it.
- Splitting web from worker. During a weekly flip, people reading proofs while aggregation ran took the API down, and the whole service had to be restarted. I split it into separate web and worker processes, so each side's memory and CPU needs are separate, and it cost less to host. It also keeps the signing key off the public API: it is mounted on the worker alone, and the operator account holds a single on-chain role with no admin rights.
- A race in Postgres. During a deploy, two aggregators wrote duplicate batches for four campaigns, and only one of each pair reached the chain. I cleaned up against on-chain state and added an advisory lock and a unique index to stop it recurring.
- Watching it. Twelve health checks, Discord alerting and memory circuit breakers.
Invariants, and the bugs they did not catch
Three weeks before it paid anyone, I listed 62 ways the system could fail and wrote seven financial invariants from them — budget conservation, the monotonic floor, duplicate-free trees, leaf encoding matched byte-for-byte to the on-chain verifier. Each has tests, and I ran audit scripts against production data before deploys.
Two defects still got through, and neither raised an error.
The first divided an incremental reward delta by a cumulative score-seconds denominator. Newly joined providers were underpaid by up to a third; providers who had left kept accruing. Every batch balanced. The budget held. Somebody's yield was simply quietly wrong.
The second was a cache key. The snapshot downsampler keyed its cache on the position, while the row it guarded was per-campaign. Wherever two campaigns ran on the same pool, the second silently wrote zero snapshots — and because processing order reshuffled each cycle, each campaign lost roughly half its data, nondeterministically. I found it by auditing the pipeline ahead of a change in campaign-creation permissions, and confirmed it was already affecting live pools.
I think about those two more than anything else I have shipped.
Contracts
Alongside the service I wrote contracts for the protocol: about 6,370 lines of production Solidity by August 2026.
I delivered the protocol's decentralisation workstream, moving privileged functions behind a timelock and tightening who can do what on-chain. Fifteen contracts, audited, with zero high-severity findings. I was the sole counterpart to our external auditors across four engagements: scoping, findings response, remediation.