Problem Statement / Feature Objective
Liquid staking protocols allow token holders to delegate stake to validator operators in exchange for LSTs (Liquid Staking Tokens). Operators managing delegated stake need a flow graph visualization showing delegation sources, amounts, delegation share per validator, and reward distribution flows. Build a DAG (Directed Acyclic Graph) visualization that renders delegation relationships as nodes (protocols, validators, holders) and edges (delegation amounts) with proportional edge widths, interactive filtering, and real-time flow updates.
Technical Invariants & Bounds
- Graph nodes: 3 types – Delegator (token holder), Protocol (liquid staking contract), Validator (node operator)
- Edge direction: Delegator → Protocol (deposit), Protocol → Validator (delegate), Validator → Protocol (rewards), Protocol → Delegator (distributions)
- Edge width proportional to amount (log scale: width = 2 + 8 × log10(amount_eth)), min 2px, max 50px
- Maximum graph size: 10,000 nodes and 50,000 edges (typical for mid-size protocol); using WebGL for rendering via
@antv/graphin or custom Three.js
- Layout constraint: Sugiyama layered layout (delegators top layer, protocols middle, validators bottom) with cross-edge minimization
- Real-time updates: WebSocket events for new delegations, unstaking, and reward distributions update graph incrementally without full re-render
- Filtering: by protocol (dropdown), by minimum delegation amount (slider), by time range (date picker), by validator status (active/exiting/slashed)
- Drill-down: click node → show detail panel with historical delegation breakdown, current APR, and delegator count
Codebase Navigation Guide
src/components/canvas/DelegationFlowGraph.tsx – main graph component
src/hooks/useDelegationFlow.ts – hook for delegation data
src/utils/delegationGraphLayout.ts – Sugiyama layout implementation
src/services/liquidStakingService.ts – API service for liquid staking data
src/components/validators/DelegationDetailPanel.tsx – drill-down panel
src/pages/staking/StakingDashboard.tsx – integration point
Implementation Blueprint
- Create
src/types/delegation.ts – define DelegationNode{id, type, label, metadata}, DelegationEdge{source, target, amount, type, timestamp} interfaces
- Build
src/services/liquidStakingService.ts – fetches delegation graph data from protocol API endpoints (GET /delegations, GET /protocols, GET /validators/stake); subscribes to WS for real-time updates
- Implement
src/utils/delegationGraphLayout.ts – Sugiyama layered layout algorithm:
- Layer assignment: delegators (0), protocols (1), validators (2)
- Within-layer ordering: barycenter heuristic for cross-edge minimization
- Node positioning: evenly spaced within each layer, with padding proportional to node label length
- Create
src/hooks/useDelegationFlow.ts – manages graph state, incremental updates on WS events, applies filters, handles drill-down selection
- Build
src/components/canvas/DelegationFlowGraph.tsx using a WebGL-based renderer (Three.js):
- Nodes: colored circles (blue=delegator, purple=protocol, green=validator), sized by connected stake
- Edges: semi-transparent bezier curves, width proportional to delegation amount
- Edge animation: particle flow along edges for reward distribution direction
- Interactivity: drag nodes (elastic constraint to layer), hover tooltip, click drill-down
- Filter controls overlaid: protocol dropdown, amount slider, time range, status filter
- Create
src/components/validators/DelegationDetailPanel.tsx – slide-out panel showing:
- Node info (name, type, total delegated/received)
- Historical delegation chart (area chart over time)
- Top edges (largest delegations in/out)
- Key metrics (APR, delegator count, avg delegation size)
- Mount in
StakingDashboard.tsx as full-screen "Delegation Flow" tab
Problem Statement / Feature Objective
Liquid staking protocols allow token holders to delegate stake to validator operators in exchange for LSTs (Liquid Staking Tokens). Operators managing delegated stake need a flow graph visualization showing delegation sources, amounts, delegation share per validator, and reward distribution flows. Build a DAG (Directed Acyclic Graph) visualization that renders delegation relationships as nodes (protocols, validators, holders) and edges (delegation amounts) with proportional edge widths, interactive filtering, and real-time flow updates.
Technical Invariants & Bounds
@antv/graphinor custom Three.jsCodebase Navigation Guide
src/components/canvas/DelegationFlowGraph.tsx– main graph componentsrc/hooks/useDelegationFlow.ts– hook for delegation datasrc/utils/delegationGraphLayout.ts– Sugiyama layout implementationsrc/services/liquidStakingService.ts– API service for liquid staking datasrc/components/validators/DelegationDetailPanel.tsx– drill-down panelsrc/pages/staking/StakingDashboard.tsx– integration pointImplementation Blueprint
src/types/delegation.ts– defineDelegationNode{id, type, label, metadata},DelegationEdge{source, target, amount, type, timestamp}interfacessrc/services/liquidStakingService.ts– fetches delegation graph data from protocol API endpoints (GET /delegations,GET /protocols,GET /validators/stake); subscribes to WS for real-time updatessrc/utils/delegationGraphLayout.ts– Sugiyama layered layout algorithm:src/hooks/useDelegationFlow.ts– manages graph state, incremental updates on WS events, applies filters, handles drill-down selectionsrc/components/canvas/DelegationFlowGraph.tsxusing a WebGL-based renderer (Three.js):src/components/validators/DelegationDetailPanel.tsx– slide-out panel showing:StakingDashboard.tsxas full-screen "Delegation Flow" tab