PortfoliOne
One-click DeFi portfolio rebalancing with optimal swap rates
Problem Statement
PortfoliOne is an intelligent crypto portfolio rebalancing platform built on Base mainnet that enables users to achieve optimal asset allocation with a single click. The project solves the complex problem of maintaining target portfolio allocations in the volatile crypto market by automating the entire rebalancing process through 1inch swap integration and swap optimization.The platform fetches real-time portfolio data from users' wallets, allows them to set custom target allocations for their holdings, and then calculates the minimal number of swaps needed to achieve those targets. Using a greedy optimization algorithm, PortfoliOne determines the most efficient swap routes and executes them atomically through Alchemy Account Kit's UserOperation batching, ensuring either all swaps succeed or none do.Key features include:Real-time portfolio tracking with USD valuations via 1inch API integrationIntuitive input interface for setting target allocationsIntelligent swap optimization that minimizes transaction costs and slippageAtomic transaction execution through Account Abstraction (EIP-4337)Gas-sponsored transactions for seamless user experienceBeautiful progress tracking with step-by-step rebalancing feedbackIntegration with BaseScan for transaction transparencyThe project addresses a real pain point in DeFi where users manually rebalance portfolios through multiple transactions, often losing money to MEV, slippage, and gas fees. PortfoliOne automates this entirely while providing institutional-grade execution through smart account infrastructure.
Solution
PortfoliOne is built as a modern full-stack Web3 application using cutting-edge technologies and innovative architectural patterns:Frontend Architecture:Next.js 14 with App Router for server-side rendering and optimal performanceTypeScript for type safety and developer experienceTailwind CSS for responsive, beautiful UI designReact Portals for proper modal rendering and UX consistencyCustom React hooks for state management and wallet integrationSmart Account Integration:Alchemy Account Kit (v4.35.1) for EIP-4337 Account Abstraction implementationSmart contract wallets enable gas sponsorship and transaction batchingUserOperation batching allows atomic execution of multiple swapsEliminates the need for users to hold ETH for gas feesDeFi Integration:1inch Aggregation Protocol for optimal swap routing and executionReal-time portfolio data fetching with token metadata and pricingBase mainnet integration for fast, low-cost transactionsCustom proxy API calls to avoid CORS issues and API key exposureAlgorithmic Innovation:The core innovation is our greedy swap optimization algorithm that:Calculates deltas between current and target allocationsSeparates tokens into surplus (sell) and deficit (buy) categoriesOptimally pairs swaps to minimize the total number of transactionsConverts USD amounts to precise wei values for blockchain executionNotable Technical Achievements:Implemented React Portal pattern for proper modal overlay effects across the entire appCreated atomic transaction batching where either all swaps execute or none doDesigned a beautiful stepper UI with real-time progress tracking and BaseScan integrationPartner Technology Benefits:Alchemy Account Kit enabled gasless transactions and improved UX through smart accounts1inch Protocol provided optimal swap routing with minimal slippageBase L2 offered fast, cheap transactions perfect for frequent rebalancingParticularly Hacky/Notable Elements:Custom hash extraction logic to handle Account Kit's UserOperation response format variationsIntelligent threshold-based rebalancing (minimum $0.01) to support portfolios of all sizesPortal-based modal rendering to achieve proper app-wide background blur effectsSophisticated error suppression for expected Account Kit initialization warningsReal-time portfolio value calculation and display in the header navbarThe entire application is designed with production-grade patterns, comprehensive error handling, and a focus on user experience that rivals traditional fintech applications.
Hackathon
ETHGlobal Unite
2025
Prizes
- 🏆
Build a full Application using 1inch APIs2nd place
1inch
Contributors
- officialcmg
29 contributions