Building a DeFi Yield Farming Dashboard: Track APY, TVL, and Positions
Yield farming is one of the most complex DeFi areas. Building a dashboard that aggregates positions across protocols requires integrating with various smart contracts and subgraphs.
Data Architecture for Yield Farming
interface FarmingPosition {
protocol: string; pool: string
totalValueUsd: number; apr: number; apy: number; il: number
rewards: Array<{ token: string; amount: number; valueUsd: number }>
}
interface YieldSummary {
totalDeployed: number; totalValueUsd: number
weightedApr: number; dailyEarnings: number
}Fetching On-Chain Data via Subgraphs
import { gql, request } from 'graphql-request'
const UNISWAP_SUBGRAPH = 'https://api.thegraph.com/subgraphs/name/uniswap/v3'
const POSITIONS_QUERY = gql`
query Positions($owner: String!) {
positions(where: { owner: $owner }) {
id, liquidity, depositedToken0, depositedToken1
pool { token0 { symbol } token1 { symbol } }
}
}
`Impermanent Loss Calculator
function calculateIL(entryPrice0: number, entryPrice1: number, currentPrice0: number, currentPrice1: number): number {
const priceRatio = (currentPrice0 / currentPrice1) / (entryPrice0 / entryPrice1)
return (2 * Math.sqrt(priceRatio) / (1 + priceRatio) - 1) * 100
}The Bottom Line
The DeFi Dashboard from BreafIO provides portfolio tracking and APY comparisons. The DeFi Lending UI covers lending. The Crypto Portfolio Tracker gives a simpler view. The Analytics Dashboard offers charting, and the SaaS Starter Kit is great for yield farming SaaS.
Related Template
Try this production-ready starter kit to build your project faster.
Total Value Locked
$12.45B
+8.2%
24h Volume
$845M
+12.5%
Active Users
142.3K
+5.1%
Avg APY
14.8%
-0.3%
Portfolio Overview
Total Assets
$245,820
24h P&L
+$3,420
Top Protocols
DeFi Dashboard
Track your DeFi positions in real-time
Ready to Build?
Get started with our production-ready starter kits and ship your project faster.
Browse Starter Kits