99

Swap Interface

Swap interface for crowdfunding tokens ::

Swap Interface preview image

HookFi Swap is a prototype token swap interface built around a custom liquidity pool model for crowdfunding-oriented token flows. The app connects a user wallet directly to an onchain DEX contract and quotes swap output dynamically from the live reserves held in the pool, rather than using a fixed exchange rate. In its current form, the frontend is built with Next.js and React, wallet connectivity is handled through thirdweb, and the contracts are deployed on Optimism Sepolia for low-cost testing and iteration.

Under the hood, the swap flow uses a dedicated DEX contract and an ERC-20 token contract. The interface reads the pool's native asset balance and token reserve, then calls the contract's pricing function to estimate output based on current liquidity on both sides of the pool. For token-to-native swaps, users first approve the token contract and then execute the swap against the DEX. For native-to-token swaps, the app sends value directly with the transaction. This keeps the core mechanics simple while still reflecting the core AMM idea that price is shaped by liquidity depth and reserve ratios.

The project also explores how a swap interface can support crowdfunding or goal-based liquidity flows, where pools are not only used for exchange, but can also represent coordinated participation in a campaign, launch, or funding target. That makes HookFi Swap more than a generic token exchanger: it points toward a model where liquidity, participation, and community funding can overlap in a single onchain product.

There is still plenty of room to evolve this into a more complete swap experience. A production version would need features like slippage controls, better quote previews, transaction simulation, analytics, routing across multiple pools, liquidity provisioning and withdrawal, fee visibility, and stronger error handling. The most interesting future direction would be to rebuild the core around Uniswap v4 hook-based pools, where hooks could add custom logic for crowdfunding milestones, dynamic fees, referral rewards, launch conditions, liquidity locks, or treasury rules directly at the pool level. That would turn HookFi Swap from a simple prototype into a more expressive DeFi product with programmable behavior at the liquidity layer.

Features

  • Wallet connectivity via thirdweb — connects directly to an onchain DEX contract
  • Dynamic swap quotes read live from pool reserves, not a fixed exchange rate
  • Token-to-native swaps — approve token contract then execute swap against the DEX
  • Native-to-token swaps — sends value directly with the transaction
  • Crowdfunding-oriented liquidity flows — pools represent coordinated participation in a campaign or funding target
  • Deployed on Optimism Sepolia for low-cost testing and iteration

Snapshot

Swap Interface snapshot