Use Cases

Uniswap Hooks Just Got a Lot More Powerful

Space and Time Foundation

The Space and Time Foundation is an independent organization dedicated to the advancement and adoption of Space and Time.

Uniswap v4 hooks let developers attach custom logic to every swap, mint, and burn in a liquidity pool. They're one of the most significant expansions of AMM design space in DeFi history. But hooks have always had a hard ceiling. Their logic is limited to whatever data is available at the moment of execution: current pool state, block-level data, and whatever you pass in as parameters. Historical activity, cross-wallet behavior, and multi-pool aggregates are all out of reach, which means even the most sophisticated hook is working without context on anything that happened before the current transaction.

Space and Time now provides Uniswap hook templates that remove that constraint entirely.

About Uniswap hooks

Before v4, Uniswap pools were essentially static: fixed fee tiers, fixed curve logic, no ability to respond to conditions outside the swap itself. Hooks change that by letting developers register contracts that execute at specific points in the pool lifecycle, before or after a swap, before or after liquidity is added or removed. A hook can adjust fees, gate access, trigger external calls, or update state, all within the transaction, all onchain.

This gave DeFi developers something they hadn't had before: pools that can behave differently based on context. The problem is that "context" has always meant present-tense context: what's in the pool right now, what's in the block right now. A hook building dynamic fee logic has no way to know what a wallet's trading history looks like, or whether a given LP has a pattern of extracting value and leaving. The programmability was there, but data to make it meaningful wasn't.

What this unlocks for DeFi developers

Space and Time is a data blockchain that lets smart contracts query onchain data and receive a cryptographic proof alongside every result. That proof is generated by Proof of SQL, a ZK proving system that verifies SQL computations over real blockchain data. The short version: your hook can ask "how much has this wallet traded in the last 30 days?" and get back an answer it can trust, without relying on an API or any trusted third party.

Your hook sends a SQL query to Space and Time, SXT executes it against indexed blockchain data, and the result comes back with a cryptographic proof that the computation was correct. The hook uses that verified result as business logic during a swap, mint, or burn, with no offchain infrastructure required on your end.

What you can actually build

The design space opens up considerably once hooks can read verified history. A few examples:

Dynamic fees driven by real market conditions. Adjust swap fees based on provable volatility, recent price movement, and liquidity depth, so LPs earn more during turbulent markets rather than absorbing the loss silently.

MEV defense. Query data about sandwich attacks and toxic order flow patterns in recent blocks, and automatically increase fees to protect LPs from predatory behavior.

Loyalty pricing. Query historical swap volume or LP participation to give lower fees or rebates to long-term users and high-volume traders, proven against real activity rather than self-reported claims.

Progressive whale fees. Large swaps pay incrementally higher fees based on historical trade size and liquidity impact, reducing pool destabilization without requiring manual governance intervention.

LP reputation gating. Analyze historical LP behavior to restrict or penalize just-in-time liquidity that appears only for profitable blocks and withdraws immediately after.

Policy-gated pools. Verify allowlists or onchain attestations via SQL queries, so swaps and mints are only available to verified participants.

Provable affiliate revenue sharing. Attribute swaps to routers, apps, or referrers using verified data and automatically split protocol fees, without relying on anyone to self-report.

Three templates to start from

Rather than building the query plumbing from scratch, three ready-to-customize hook templates are available on the Space and Time app, each covering a different pattern for how discount eligibility gets computed, cached, and applied at swap time.

The Loyalty Discount template is the most straightforward: a user checks their eligibility, SXT proves their onchain history, the hook caches a discount tier, and fees are adjusted when they swap. It's the easiest to audit and works well for discounts that don't need to refresh on every transaction.

The One-Click Intent template collapses the eligibility check and the swap into a single transaction. SXT handles the query in the background, and the swap executes when the verified result comes back.

The Discount Voucher template lets users earn an NFT voucher based on proven activity and redeem it for discounted swaps, which is useful if you want the discount to be composable or transferable.

Each template comes as a complete Foundry project with Solidity, SQL examples, documentation, and a security checklist. The only thing you need to replace is the SQL query itself, everything else is wired up.

How to get started

Head to chain.spaceandtime.io and open the Query Workbench, an onchain SQL editor where you can write and test your query against live indexed blockchain data. Once your query is working, export the proof plan your hook contract needs to verify results, drop it into the template, and wire the hook into your pool's beforeSwap function. The documentation in each template package covers required replacements, access control patterns, and adversarial test scenarios to run before deploying.

The SQL is the only thing that's yours to define. Everything else is already built.

Try it now: https://chain.spaceandtime.io/use-case/uniswap-hooks

Space and Time Foundation

The Space and Time Foundation is an independent organization dedicated to the advancement and adoption of Space and Time.