Skip to content

Liquid Staking Delegation Flow Graph Visualization for Protocol Token Holders #62

Description

@JamesEjembi

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

  1. Create src/types/delegation.ts – define DelegationNode{id, type, label, metadata}, DelegationEdge{source, target, amount, type, timestamp} interfaces
  2. 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
  3. 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
  4. Create src/hooks/useDelegationFlow.ts – manages graph state, incremental updates on WS events, applies filters, handles drill-down selection
  5. 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
  6. 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)
  7. Mount in StakingDashboard.tsx as full-screen "Delegation Flow" tab

Metadata

Metadata

Assignees

Labels

Complexity: HardcoreExtremely difficult, high-complexity engineering taskGrantFox OSSIssue tracked in GrantFox OSSLayer: Core-EngineCore engine layerMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignType: Core-ArchitectureCore architecture design and structural concern

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions