Titan
DeFi super app combining token swapping, liquid staking, overcollateralized lending, and on-chain governance with native Uniswap V4 integration.
## What is Titan?

Titan is a full-stack DeFi protocol built on Ethereum Sepolia, featuring native Uniswap V4 integration for token swaps and concentrated liquidity. The protocol implements its own token ecosystem with TITAN as the base asset, sTITAN as a liquid staking derivative, and tUSD as an overcollateralized stablecoin.
The Uniswap V4 integration runs through custom SwapRouter and LiquidityRouter contracts that interact directly with V4's singleton PoolManager architecture. This enables gas-efficient swaps and concentrated liquidity positions without relying on third-party routers or aggregators.
Staking in Titan works through a share-based liquid staking model. When you stake TITAN, you receive sTITAN shares. As protocol rewards flow into the StakedTitan contract, the TITAN-per-share exchange rate increases automatically. Your sTITAN balance stays the same, but it becomes redeemable for more TITAN over time. No manual compounding, no claiming - the math handles everything.
The lending system lets you deposit TITAN as collateral and mint tUSD, the protocol's native stablecoin. The Vault contract enforces a 150% minimum collateral ratio and liquidates positions that fall below 110%. Liquidators receive a 10% bonus on seized collateral. This creates a MakerDAO-style CDP system where users can leverage their TITAN holdings without selling.
Governance runs entirely on-chain through the Governor contract. sTITAN holders can create proposals and vote with their staked balance. The system uses ERC20Votes snapshots - your voting power is recorded at the moment a proposal is created, preventing flash loan attacks where someone borrows tokens just to swing a vote.
The protocol runs on 9 interconnected smart contracts: TitanToken, StakedTitan, Earn, Vault, TitanUSD, Governor, SwapRouter, LiquidityRouter, and Faucet. Each handles a specific DeFi primitive while remaining fully composable with the others.
## Core Features
### Swap

Trade tokens through Uniswap V4 pools via the SwapRouter contract. The router constructs pool keys, calculates optimal amounts, and enforces slippage protection.
```mermaid
flowchart LR
User[User] --> |Token A| SR[SwapRouter]
SR --> |Build PoolKey| PM[PoolManager]
PM --> |Execute| Pool[Uniswap V4 Pool]
Pool --> |Token B| User
```
The swap flow: user approves Token A, calls `swap()` with parameters (tokenIn, tokenOut, amount, minOut), SwapRouter builds the PoolKey and interacts with Uniswap V4's PoolManager, tokens are exchanged atomically.
### Liquidity

Provide concentrated liquidity to Uniswap V4 pools and earn trading fees. The LiquidityRouter manages position creation, tick range selection, and liquidity math.
```mermaid
flowchart LR
User[User] --> |Token A + B| LR[LiquidityRouter]
LR --> |Mint Position| PM[PositionManager]
PM --> |NFT| User
Pool[Pool Fees] --> |Collect| User
```
Users select a price range (tickLower, tickUpper), deposit both tokens, and receive an NFT representing their position. Fees accumulate automatically and can be collected anytime.
### Earn

Stake TITAN and earn additional TITAN rewards. The Earn contract uses a per-token reward accumulator that tracks rewards across all stakers proportionally.
```mermaid
flowchart LR
User[User] --> |TITAN| Earn[Earn Contract]
Earn --> |Track| Stake[(Staked Balance)]
Time[Block Time] --> |Accumulate| RPS[Reward Per Token]
RPS --> |Calculate| Earned[User Rewards]
Earned --> |Claim| User
```
Reward calculation uses accumulated rewards per token: `earned = stakedBalance * (rewardPerToken - userPaid) + pending`. Stake, unstake, or claim anytime with no lockups.
### Stake (sTITAN)

Liquid staking with auto-compounding. Stake TITAN, receive sTITAN shares. The exchange rate increases as rewards accrue to the contract.
```mermaid
flowchart LR
User[User] --> |TITAN| ST[StakedTitan]
ST --> |Calculate Shares| Shares[sTITAN]
Shares --> User
Rewards[Protocol Rewards] --> |Increase| Rate[Exchange Rate]
User --> |sTITAN| ST
ST --> |Rate * Shares| TITAN2[More TITAN]
TITAN2 --> User
```
The contract uses a virtual offset (1e8) to prevent first-depositor attacks and enforces a minimum deposit of 0.001 TITAN. Exchange rate calculation includes pending rewards based on the configured rewardRate.
sTITAN also grants governance voting power through ERC20Votes with automatic self-delegation on deposit.
### Borrow

Deposit TITAN as collateral, mint tUSD stablecoin. The Vault enforces collateralization ratios and handles liquidations.
```mermaid
flowchart LR
User[User] --> |TITAN| Vault[Vault]
Vault --> |Check Ratio >= 150%| Mint[Mint tUSD]
Mint --> |tUSD| User
Price[Price Drop] --> |Ratio < 110%| Liq[Liquidation]
Liq --> |Seize + 10% Bonus| Liquidator[Liquidator]
```
| Parameter | Value |
|-----------|-------|
| Minimum Collateral Ratio | 150% |
| Liquidation Threshold | 110% |
| Liquidation Bonus | 10% |
| Collateral Asset | TITAN |
| Borrowed Asset | tUSD |
Users must maintain 150% collateral. Below 110%, anyone can liquidate - repaying the debt and seizing the collateral plus a 10% bonus.
### Governance

sTITAN holders create proposals and vote on protocol changes. Snapshot-based voting prevents flash loan attacks.
```mermaid
flowchart LR
User[sTITAN Holder] --> |Create| Prop[Proposal]
Prop --> |Snapshot Block| Votes[Record Voting Power]
Voters[sTITAN Holders] --> |For/Against/Abstain| Prop
Prop --> |Quorum + Majority| Queue[Timelock Queue]
Queue --> |After Delay| Execute[Execute]
```
Voting power is snapshotted at proposal creation via `getPastVotes()`. The Governor supports configurable voting delay, voting period, quorum percentage, and timelock delay. Proposals pass through a timelock before execution.
## Token Economics
### TITAN Token
| Property | Value |
|----------|-------|
| Initial Supply | 100,000,000 TITAN |
| Maximum Supply | 1,000,000,000 TITAN |
| Token Standard | ERC-20 + ERC20Votes |
| Governance | Vote delegation enabled |
TITAN serves as the ecosystem's utility token. Stake it to earn rewards, use it as collateral to borrow tUSD, or convert it to sTITAN for governance participation.
### sTITAN Token
The liquid staking derivative of TITAN. Exchange rate starts at 1:1 and increases as staking rewards accumulate. Your sTITAN balance stays constant while its TITAN value grows.
### tUSD Stablecoin
Minted against TITAN collateral through the Vault. Designed to maintain a 1:1 peg with USD through overcollateralization and liquidation mechanics.
## Smart Contracts
Titan deploys 9 core contracts on Ethereum Sepolia:
| Contract | Purpose |
|----------|--------|
| TitanToken | ERC-20 + ERC20Votes with 100M initial, 1B max supply |
| StakedTitan | Liquid staking with auto-compounding via rewardRate |
| Earn | TITAN staking with per-token reward accumulator |
| Vault | CDP lending with 150% MCR, 110% liquidation, 10% bonus |
| TitanUSD | Stablecoin minted by authorized minters (Vault) |
| Governor | Snapshot voting with configurable timelock |
| SwapRouter | Uniswap V4 swap via PoolManager unlock callback |
| LiquidityRouter | V4 concentrated liquidity position management |
| Faucet | Testnet token distribution with configurable cooldown |
## Security
All contracts implement battle-tested security patterns:
- **ReentrancyGuard** on all state-changing functions
- **Ownable** for administrative access control
- **Solidity 0.8+** built-in overflow protection
- **ERC20Permit** for gasless approvals
- **Snapshot voting** to prevent flash loan governance attacks
The 40% gap between minimum collateral ratio (150%) and liquidation threshold (110%) provides users time to add collateral before liquidation.
## More Slices From This Pzza
Dive deeper into the ideas and technology behind this project:
- [Titan: Building a DeFi Super App](/oven/titan-building-defi-super-app) - Complete technical walkthrough of the protocol