DeFolio

Track your cross-chain portfolio, PnL, and taxes in one unified dashboard

DeFolio

Created At

ETHOnline 2025

Winner of

Avail

Avail - Developer Feedback (Test our Docs)

Project Description

Unified PnL & Tax is a cross-chain portfolio and tax analytics dashboard that unifies your on-chain holdings, transaction history, and profit & loss (PnL) reports across multiple networks — all powered by Avail Nexus SDK, Envio, and Pyth Network. The platform helps users and accountants calculate real-time realized and unrealized PnL, track multi-chain balances, and generate tax reports in a single interface, without manually exporting CSVs from each chain or wallet. Core Features: Unified Portfolio View: Using the Avail Nexus SDK, the app aggregates balances and transaction history across EVM-compatible testnets (Ethereum Sepolia, Base Sepolia, Arbitrum Sepolia, Polygon Amoy, and Optimism Sepolia). Implements unifiedBalance() and Bridge & Execute features to fetch and act upon cross-chain data. Displays assets, value in USD (via Pyth oracle), and cross-chain holdings in one dashboard.

Real-Time PnL Tracking: The Pyth Network provides high-frequency, verifiable price feeds for tokens on multiple chains. Calculates realized PnL (profit from completed trades or swaps). Calculates unrealized PnL (current portfolio gains/losses). Displays daily/weekly trends via an interactive chart.

Historical Transaction Indexing Envio indexes all relevant events (transfers, swaps, bridges) across supported chains. Enables time-based filtering of all transactions. Links each transaction to its chain, gas cost, and counterparty. Ensures fast querying and caching through Envio’s data pipelines.

Tax Computation Module: Automatically classifies transactions as short-term or long-term gains based on holding duration. Generates a downloadable Tax Report (PDF/CSV) with total realized gains, unrealized gains, staking rewards, and deductions. Includes filters for country-specific formats (starting with India, US).

Bridge & Execute Integration: Uses Avail’s Bridge & Execute flow to perform a transaction across multiple chains from one unified interface (e.g., swap on Polygon, bridge to Arbitrum, update dashboard state in one click). Demonstrates composability of multi-chain state and execution.

How it's Made

Unified PnL & Tax is built as a modular full-stack dApp using Next.js (App Router), TypeScript, and TailwindCSS for the frontend, with API routes acting as the backend layer for data aggregation. We integrated three major partner technologies:

  1. Envio HyperSync (Data Indexing Layer) Envio HyperSync is the core data source for fetching multi-chain wallet transaction history. Implemented using the envio-hypersync TypeScript SDK. Fetches complete transaction history for any address across Ethereum, Polygon, Arbitrum, and Base. Data is normalized and stored in memory for fast PnL and tax calculations. The implementation handles pagination, retries, and network fallbacks — ensuring reliable transaction retrieval. This replaces the need for complex subgraphs or manual RPC calls.

  2. Pyth Network (Real-Time Price Feeds) For accurate USD valuations and PnL computation, we integrated Pyth HermesClient to fetch real-time token prices. Integrated directly via a lightweight TypeScript client. Prices cached for 5 seconds to optimize performance. Fallback logic implemented for unavailable assets. Used to value assets like ETH, MATIC, USDC, USDT, and WBTC. This ensured precise mark-to-market valuation for every transaction and live portfolio view.

  3. Avail Nexus SDK (Cross-Chain Layer) We integrated the Avail Nexus SDK to experiment with unified cross-chain balance fetching and Bridge & Execute intents. Implemented the Nexus SDK client (lib/integrations/nexus-unified.ts) and React hook (useAvailNexus.tsx). Created an abstraction to unify balances and enable potential cross-chain rebalancing. Though not active in the final UI, the implementation is ready for integrating cross-chain proof-of-ownership and transaction execution. This layer provides a future-ready architecture for cross-chain portfolio actions like automatic rebalancing and tax payments.

background image mobile

Join the mailing list

Get the latest news and updates