Skip to main content

Track — Uniswap Foundation: Build with Uniswap

Prize: $4k / $3k / $2k / $1k (4 places). Status: pools + hook done (#2).

Use in our stack​

Our own Uniswap v4 pools (BTC, ETH, HYPE, ZEC vs USDC, one shared hook) with a dynamic-fee hook.

  • Terminal spot tab = this pool. No spot matching engine to build.
  • Vault spot leg (buy ETH on enter, sell ETH on exit) = same pool.

Fees, simply​

  • Normal pool: every swap pays fee (e.g. 0.3%) → goes to LPs. Nobody can skip it.
  • Hook = small contract attached to our pool. Uniswap asks it "what fee?" before each swap.
  • Our rule: vault → 0%, everyone else → 0.3%.

Hook​

contract VaultFeeHook is BaseHook {
address public immutable vault;
uint24 public constant PUBLIC_FEE = 3000; // 0.30%

constructor(IPoolManager pm, address _vault) BaseHook(pm) { vault = _vault; }

function getHookPermissions() public pure override returns (Hooks.Permissions memory p) {
p.beforeSwap = true;
}

function _beforeSwap(address sender, PoolKey calldata, SwapParams calldata, bytes calldata)
internal view override returns (bytes4, BeforeSwapDelta, uint24)
{
uint24 fee = sender == vault ? 0 : PUBLIC_FEE;
return (this.beforeSwap.selector, BeforeSwapDeltaLibrary.ZERO_DELTA, fee | LPFeeLibrary.OVERRIDE_FEE_FLAG);
}
}
  • Pool init with fee = LPFeeLibrary.DYNAMIC_FEE_FLAG.
  • Hook address must encode beforeSwap flag bit → mine salt w/ HookMiner.
  • sender = caller of PoolManager. Vault must call PoolManager.unlock itself (implement unlockCallback), not via router → sender == vault. No signatures needed.
  • Signature variant (rebalancer sig in hookData) only if swaps must go through generic router. Skip.

Caveats​

  • 0 fee ≠ 0 cost: price impact still applies. Testnet: team seeds liquidity.
  • LPs earn nothing on vault swaps; public swappers still pay 0.3%.
  • v4 protocol fee = governance-controlled, off on testnet.

Build steps​

  1. Foundry: hook + pool init + seed liquidity script.
  2. Test: vault swap pays 0, other address pays 0.3%.
  3. Vault unlockCallback swap function.
  4. Terminal spot tab: price, swap box, balances.

Qualification checklist​