A decentralized investment platform that automates DeFi strategies using Uniswap V3 liquidity positions and 1inch token swaps.
Piggy Pot UI is a Next.js-based web application that enables users to:
- Embedded Wallet: Privy generates embedded wallets for seamless DeFi interactions
- Automated Investment: Split investments between risky and conservative DeFi strategies
- Token Swapping: Use 1inch API for optimal token swaps
- Liquidity Provision: Create Uniswap V3 positions for yield generation
- AI-Powered Pool Recommendations: Backend provides intelligent pool suggestions
- Frontend: Next.js 15, React 19, TypeScript
- UI: Chakra UI, React Icons
- Blockchain: Ethers.js v5, Viem, Wagmi
- Authentication: Privy (Web3 Auth)
- DeFi Integration: Uniswap V3 SDK, 1inch API
- State Management: React Query (TanStack Query)
- Backend: Piggy Pot Backend - AI-powered pool recommendations
- Embedded Wallets: Privy generates embedded wallets for each user
- Top-up Flow: Users can top up their embedded wallet balance
- Balance Tracking: Real-time wallet balance monitoring
- Seamless UX: No external wallet connection required
- Backend Integration: Connected to Piggy Pot Backend
- Daily Metrics: AI analyzes Uniswap data and 1inch metrics daily
- Intelligent Suggestions: Recommends optimal pools based on risk profile
- Real-time Updates: Pool recommendations update based on market conditions
- Wallet Top-up: User tops up their embedded wallet balance
- Investment Amount: User sets total investment amount
- Strategy Allocation: Split between risky and conservative strategies
- Pool Recommendations: Backend provides AI-powered pool suggestions
- make an investment: under the hood:
- Token Swapping: Convert USDC to target tokens via 1inch
- Liquidity Provision: Create Uniswap V3 positions
- Position Management: Track and manage liquidity positions
Risky Strategy
- Definition: Pools containing at least one volatile token (e.g., WETH, WBTC)
- Characteristics: Higher volatility, potential for higher returns
- Examples: WETH/USDC, WBTC/USDC, WETH/USDT pairs
Conservative Strategy
- Definition: Pools containing only stablecoins (e.g., USDC, USDT, DAI)
- Characteristics: Lower volatility, consistent yield generation
- Examples: USDC/USDT, USDC/DAI, USDT/DAI pairs
- Bun: This project requires Bun runtime (not Node.js)
- Base network RPC access
# Clone the repository
git clone <repository-url>
cd piggy-pot-ui
# Install dependencies (using Bun)
bun install
# Set up environment variables
cp .env.example .env.local# Privy Configuration
NEXT_PUBLIC_PRIVY_APP_ID=your_privy_app_id
NEXT_PUBLIC_PRIVY_CLIENT_ID=your_privy_client_id
# 1inch API
NEXT_PUBLIC_ONE_INCH_API_KEY=your_1inch_api_key
# Backend API
NEXT_PUBLIC_API_URL=your_backend_url# Start development server
bun run dev
# Build for production
bun run build
# Start production server
bun run startsrc/
βββ app/ # Next.js App Router
β βββ api/ # API routes (1inch proxy, backend communication)
β βββ dashboard/ # Dashboard page (investment overview, balance display)
β βββ invest/ # Investment workflow (stepper, amount, strategy)
β βββ settings/ # Settings page (token revoke, transfers)
βββ components/ # React components
β βββ layouts/ # Layout components (investment workflow, dashboard)
β βββ providers/ # Context providers (Privy, Chakra, React Query)
β βββ ui/ # UI components (buttons, forms, modals)
βββ hooks/ # Custom React hooks
β βββ useBalance.ts # Wallet balance tracking
β βββ useSwap.ts # 1inch token swapping
β βββ use1inchApprove.ts # 1inch token approvals
β βββ useUniswapApprove.ts # Uniswap token approvals
β βββ usePoolsRecommendations.ts # Backend pool recommendations
βββ libs/ # External library integrations
β βββ 1inch/ # 1inch API integration (swaps, prices, balances)
β β βββ callApi.ts # Generic API caller with proxy
β β βββ getTokenPrices.ts # Real-time token price fetching
β β βββ executeSwaps.ts # Token swap execution
β βββ uniswap/ # Uniswap V3 integration
β βββ pool.ts # Pool information and configuration
β βββ position.ts # Position creation and minting
β βββ createToken.ts # Token object creation
βββ types/ # TypeScript type definitions
β βββ 1inch/ # 1inch API response types
β βββ backend/ # Backend API response types
β βββ uniswap/ # Uniswap SDK types
β βββ user.ts # User and wallet types
βββ config/ # Configuration files
β βββ constants.ts # Contract addresses, network config
β βββ oneInch.ts # 1inch API configuration
β βββ index.ts # App configuration
βββ utils/ # Utility functions
β βββ abis.ts # Contract ABIs (ERC20, Uniswap)
β βββ converter.ts # Token amount conversions
β βββ issuesProcessing.ts # Error handling utilities
βββ mocks/ # Mock data for development
βββ recommendations.ts # Mock pool recommendations
- Step-by-step process: Top-up β Amount β Strategy β Execution
- Real-time validation: Balance checks and allowance verification
- Progress tracking: Visual progress indicators
- Error handling: Comprehensive error management
- Daily Analysis: Backend processes Uniswap data and 1inch metrics daily
- Risk Classification: Automatically categorizes pools as risky or conservative
- Intelligent Matching: Suggests pools based on user's risk allocation
- Market Adaptation: Recommendations adapt to changing market conditions
- Automatic approvals: Handle token allowances
- Price fetching: Real-time token prices via 1inch
- Gas optimization: Efficient transaction batching
- Uniswap V3 positions: Create concentrated liquidity positions
- Range optimization: Automatic tick range calculation
- Slippage protection: Configurable slippage tolerance
- Create components in
src/components/ - Add types in
src/types/ - Create hooks in
src/hooks/ - Update pages in
src/app/
# Run linting
bun run lint
# Type checking
bunx tsc --noEmitSee 1INCH_API.md for detailed 1inch API integration documentation.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.
For support, please open an issue in the GitHub repository or contact the development team.
Built with β€οΈ for the DeFi community