Captain Happy Hook

Captain Happy Hook

A Uniswap v4 hook to make fairly distributed swaps: no frontrunning, minimise prize impact

The problem Captain Happy Hook solves

Attacks e.g. Frontrunning, sandwich...
Price Impact e.g. for small trades after large ones
Reverted tx e.g. for price spikes

Challenges we ran into

  • The contract's data structure: we iterated through 3 different approaches. In the end we found an intermediate solution between nested struct and just int[] & address[]... Finally we used a struct, but a simpler one.
  • Foundry testing: we struggled initialising our contract from the test and processing data from our contract's functions and state variables, making it slower to write assertions. Once we got our setup working, we could work on multiple tests.
  • Chainlink Automation: figuring out how to set up checkUpkeep and getting the tests to pass took us especially long. We had to debug small errors such as uint & int conversions,

Tracks Applied (3)

Hook Features

Our project is a Uniswap v4 pool with a beforeSwap hook integrated. We want to mitigate some well-known risks and inconv...Read More

Uniswap

Solarpunk Solutions Award

Captain Happy Hook tries to make defi safer for the average Joe, especially for users who move small amounts of tokens. ...Read More

Best New Subgraph

We use a subgraph to index all the events emitted by our hook smart contract. Using this information in a meaningful way...Read More

The Graph

Cheer Project

Cheering for a project means supporting a project you like with as little as 0.0025 ETH. Right now, you can Cheer using ETH on Arbitrum, Optimism and Base.

Discussion