pzza.works

Titan: Building a DeFi Super App

Berke (pzzaworks)Berke (pzzaworks)

March 9th, 2026

Titan is a DeFi protocol on Ethereum Sepolia that puts token swapping, concentrated liquidity, liquid staking, overcollateralized lending and on-chain governance into a single platform. Trading runs on Uniswap V4, and the protocol has its own token ecosystem built from three pieces: TITAN, sTITAN and tUSD.

The Token Ecosystem

TITAN - The Base Token

TITAN is the native ERC-20 token, and everything else in the protocol hangs off it. It launches with an initial supply of 100 million tokens under a maximum cap of 1 billion. It implements ERC20Votes, so holders can delegate their voting power and take part in governance. It also supports ERC20Permit for gasless approvals and ERC20Burnable for deflationary mechanics when they are needed.

You can do three things with it. You can stake it to earn rewards, lock it as collateral to borrow tUSD, or convert it to sTITAN for governance participation and auto-compounding yield.

sTITAN - Liquid Staking Token

sTITAN is staked TITAN, and it works on shares rather than balances. When you deposit TITAN into the StakedTitan contract, you receive sTITAN shares at the current exchange rate. The interesting part comes after that. As protocol rewards flow into the contract, the total TITAN it holds grows while the total sTITAN supply stays the same, so each sTITAN becomes redeemable for more TITAN over time.

Say you stake 1000 TITAN when the exchange rate is 1:1. You get 1000 sTITAN. Once rewards accumulate and the rate reaches 1:1.1, those same 1000 sTITAN are worth 1100 TITAN. There is nothing to claim and nothing to compound by hand; the math does it.

The contract carries two guards. A virtual offset of 1e8 prevents first-depositor attacks, where an attacker manipulates the initial exchange rate, and a minimum deposit of 0.001 TITAN keeps dust positions out. sTITAN also inherits ERC20Votes with automatic self-delegation, which makes it the governance token for the protocol.

tUSD - Protocol Stablecoin

tUSD is Titan's stablecoin, minted against TITAN collateral through the Vault contract. Only authorized minters, in practice mainly the Vault, can create new tUSD, which keeps the supply tied to real collateral. Otherwise it is a standard ERC-20 with 18 decimals.

Staking and Rewards

The Earn Contract

The Earn contract is the plain way to stake TITAN and earn more TITAN. Where sTITAN uses shares, Earn uses a per-token reward accumulator, the pattern you will recognize from Synthetix.

The contract tracks a global "reward per token" value that rises over time according to the configured reward rate. Each user keeps a snapshot of that value from their last interaction. Whenever you stake, unstake or claim, the contract computes what you earned as your staked balance multiplied by the difference between the current reward-per-token and your last snapshot.

That keeps distribution proportional: hold 10% of the staked supply and you earn 10% of the rewards. There are no lockups, so you can stake, unstake or claim at any time.

The Lending System

Vault - Collateralized Debt Positions

The Vault implements a CDP (Collateralized Debt Position) system in the style of MakerDAO. You deposit TITAN as collateral and borrow tUSD against it, and three numbers govern the whole thing.

The Minimum Collateral Ratio (MCR) is 150%. To borrow, your collateral has to be worth at least 150% of your debt, so borrowing 1000 tUSD takes at least 1500 tUSD worth of TITAN. The liquidation threshold is 110%. If your ratio drops below that, the position becomes liquidatable, which leaves a 40% buffer between the minimum ratio and liquidation. The liquidation bonus is 10%. A liquidator who repays someone's debt receives the collateral plus a 10% bonus, which gives people a reason to liquidate quickly and keeps the protocol solvent.

Each position is just two values: collateral (TITAN deposited) and debt (tUSD borrowed). On a borrow, the Vault checks that the new debt still respects the MCR. On a liquidation, it confirms the position is underwater, burns the debt from the liquidator, and transfers the collateral plus the bonus.

Governance

On-Chain Voting with Snapshots

The Governor contract lets sTITAN holders propose and vote on protocol changes. It runs on five configurable parameters:

  • Proposal Threshold - minimum sTITAN required to create a proposal
  • Voting Delay - blocks between proposal creation and the start of voting
  • Voting Period - how long voting lasts, in blocks
  • Timelock Delay - waiting period before execution
  • Quorum Percentage - participation required for the vote to count

The important part is snapshot-based voting. When a proposal is created, the contract records the current block number, and every vote is weighted by the voter's power at that snapshot through getPastVotes(). That shuts down flash loan attacks, where someone borrows tokens, votes and returns them in a single transaction: tokens borrowed after the snapshot carry no weight.

Voters cast For, Against or Abstain. A proposal that passes goes through a timelock queue before it executes, which gives users time to react to the change.

Uniswap V4 Integration

SwapRouter - Token Trading

Titan's SwapRouter is built on Uniswap V4's singleton PoolManager. In V3 every pool is its own contract; V4 consolidates all pools into one contract, which cuts gas costs significantly.

A swap goes through the router in a fixed order. It first builds a PoolKey that identifies the trading pair, with tokens sorted by address so the lower address becomes currency0. From that ordering it works out the swap direction, zeroForOne, based on which token you are selling. It then calls the PoolManager's swap function with the amount and slippage parameters, reads the returned BalanceDelta to find the actual output, and checks that output against your minimum amount.

All of this sits inside V4's unlock callback pattern. The router starts the swap by calling unlock(), which triggers a callback where the swap logic actually runs. That is what makes atomic multi-step operations possible.

LiquidityRouter - Concentrated Liquidity

The LiquidityRouter manages concentrated liquidity positions on Uniswap V4. In a traditional AMM, liquidity is spread across every possible price. Concentrated liquidity lets a provider put capital inside a specific price range instead.

To add liquidity you pick the token pair and fee tier, a tick range where tickLower and tickUpper set the price bounds, and the amounts of each token you want to put in. The router passes this to V4's PositionManager, which mints a position NFT representing the LP's stake. The position earns trading fees while the current price sits inside its range, and you can later remove the liquidity or collect the fees it has accumulated.

Positions are tracked in a nested mapping: user address -> pool ID -> tick lower -> tick upper -> liquidity amount. That lets one user hold several positions across different ranges.

Frontend Architecture

The web app is built with Next.js 16, TypeScript and TailwindCSS 4. On the Web3 side it uses wagmi 3.5 for React hooks, viem 2.46 for Ethereum interactions, and Reown AppKit (formerly WalletConnect Web3Modal) for wallet connections.

Hook-Based Contract Interactions

Each protocol feature gets a dedicated React hook that owns all of its contract interactions. The sTITAN hook, for example, reads the balance and exchange rate through useReadContract, exposes stake and unstake through useWriteContract, tracks loading states for pending transactions, and refetches automatically after state changes.

That keeps blockchain logic out of the UI components, which makes the codebase easier to maintain and test. A component calls the hook's functions and renders whatever state comes back.

Wallet Connection

Reown AppKit handles wallet connections for MetaMask, WalletConnect and other providers. The configuration pins Sepolia as the network and applies custom theming to match Titan's design. Its adapter pattern makes it easy to switch wallet providers while keeping the same API.

Testnet Infrastructure

Faucet Contract

For the testnet deployment, Titan ships a faucet that hands TITAN to new users. The drip amount per claim and the cooldown between claims are both configurable, the faucet can be paused for maintenance, and only the owner can update its parameters.

It records each address's last claim timestamp and refuses another claim until the cooldown has passed. First-time claimers can always claim immediately.

Security Design

The contracts stack several layers of protection, and most of them have already come up above.

Every state-changing function uses OpenZeppelin's ReentrancyGuard modifier, so a callback cannot re-enter and manipulate state. Administrative functions such as minting, pausing and parameter updates are restricted to the owner through the Ownable pattern. Solidity 0.8+ reverts on overflow and underflow on its own, which removes a vulnerability class that used to be common.

The economic and governance guards come from the design itself. The 40% gap between the MCR (150%) and the liquidation threshold (110%) gives users real time to add collateral during a price drop. Recording voting power at proposal creation blocks flash loan governance attacks. And the 1e8 virtual offset in sTITAN stops first-depositor manipulation of the exchange rate.

Conclusion

Titan is an exercise in building a cohesive DeFi protocol out of proven primitives: Uniswap V4 for trading, share-based liquid staking for yield, CDP-style lending for leverage, and snapshot voting for governance. The 9 smart contracts work together while each stays individually composable, and the frontend hides the complexity behind custom hooks. Users get one interface for swapping, providing liquidity, staking, borrowing and voting, without needing to understand the contract architecture underneath.

Keep reading