Decentralized Exchange (DEX) built on the Stellar blockchain
A Next.js 15 application providing swap and liquidity pool functionality using the Soroswap SDK and Stellar Wallets Kit, with additional earning/farming capabilities through the @defindex/sdk integration and cross-chain bridging via Rozo.ai.
- π Token Swaps - Trade tokens with optimal routing and slippage protection
- π§ Liquidity Pools - Provide liquidity and earn fees from trading activity
- πΎ Earn/Farming - Stake tokens in DeFindex vaults for automated yield strategies
- π Cross-Chain Bridge (Alpha) - Transfer assets between different blockchains via Rozo.ai
- π Wallet Integration - Connect with Freighter, LOBSTR, and other Stellar wallets
- π Real-Time Pricing - Server-side cached prices with multi-layer optimization
- π¨ Dark Mode - Theme switching with next-themes
Before you begin, ensure you have the following installed:
- Node.js >= 22.0.0
- pnpm (required package manager)
# Install pnpm globally if you haven't already
npm install -g pnpmgit clone https://github.com/soroswap/v2-frontend.git
cd v2-frontendpnpm installCopy the example environment file and configure it:
cp .env.example .envEdit .env with your configuration:
# Network configuration (mainnet or testnet)
NEXT_PUBLIC_ENV="mainnet"
# Soroswap API credentials
SOROSWAP_API_URL="https://api.soroswap.finance"
SOROSWAP_API_KEY="your_soroswap_api_key_here"
# DeFindex API credentials (for Earn features)
DEFINDEX_API_URL="https://api.defindex.io"
DEFINDEX_API_KEY="your_defindex_api_key_here"
# Stellar Router contract address
STELLAR_ROUTER_ADDRESS="contract_address_here"pnpm devOpen http://localhost:3000 to see the application.
pnpm dev # Start development server
pnpm build # Build for production
pnpm start # Start production server
pnpm lint # Run ESLintThe project follows a feature-based architecture:
src/
βββ app/ # Next.js App Router pages and API routes
β βββ api/ # Server-side API endpoints
β β βββ tokens/ # Token list from SDK
β β βββ pools/ # Pool operations
β β βββ price/ # Token pricing (cached)
β β βββ quote/ # Swap quotes
β βββ pools/ # Pool management pages
β βββ earn/ # Farming/staking pages
β βββ bridge/ # Cross-chain bridge
βββ features/ # Feature modules
β βββ swap/ # Swap components and logic
β βββ pools/ # Pool components and hooks
β βββ earn/ # Farming/staking components
β βββ bridge/ # Bridge integration
β βββ navbar/ # Navigation components
βββ shared/ # Shared utilities and components
β βββ components/ # Reusable UI components
β βββ hooks/ # Shared React hooks
β βββ lib/ # Utilities and constants
βββ contexts/ # React contexts and Zustand stores
- Next.js 15.3.3 with App Router
- React 19
- TypeScript (strict mode)
- Tailwind CSS 4 (utility-first)
- next-themes for dark mode
- class-variance-authority for component variants
- Zustand for client-side global state
- SWR for data fetching and caching
- @tanstack/react-query (v5.90.5) for bridge feature
- @soroswap/sdk v0.3.7 - DEX functionality
- @defindex/sdk v0.1.1 - Farming/earn
- @rozoai/intent-common & @rozoai/intent-pay - Bridge
- @creit.tech/stellar-wallets-kit - Wallet connections
- @stellar/stellar-sdk v14.1.1 - Stellar interactions
- Zod for runtime validation
- SWR with optimized caching strategies
- @tanstack/react-table for data tables
- Lucide React for icons
- React Tooltip for tooltips
The application exposes several server-side API routes:
GET /api/tokens- Get token list (SDK β hardcoded fallback)GET /api/token/metadata- Fetch on-demand token metadata
GET /api/pools- Get available poolsPOST /api/pools/add-liquidity- Add liquidity transactionPOST /api/pools/remove-liquidity- Remove liquidity transactionGET /api/pools/user- Get user positions
GET /api/price- Get token prices (3-min server cache)GET /api/quote- Calculate swap routePOST /api/quote/build- Build swap transaction
GET /api/earn/vaultInfo- Vault informationPOST /api/earn/deposit- Deposit to vaultPOST /api/earn/withdraw- Withdraw from vault
This project follows strict code style guidelines:
- Prettier as primary formatter (not TypeScript built-in)
- ESLint with Next.js configuration
- Semantic HTML - Use proper HTML elements (not generic
<span>or<div>) - Tailwind Utilities - Prefer utility classes over custom CSS
- TypeScript Strict Mode - No
anytypes, proper interfaces
See CLAUDE.md for detailed development guidelines.
Tokens are fetched with priority system:
- Primary: Soroswap SDK
getAssetList() - Fallback: Hardcoded token list (33 tokens with IPFS icons)
- Cache: 12-hour SWR cache on client
Multi-layer caching for optimal performance:
- Server-side: 3-minute in-memory cache
- Client-side: 10-minute SWR deduplication
- Reduces API calls by 85-95%
Separated loading states:
- Pools data loads independently
- TVL calculated separately when prices available
- Improves perceived performance (~2.5s vs ~40s)
Switch between mainnet and testnet via NEXT_PUBLIC_ENV:
- Affects SDK initialization
- Changes contract addresses
- Updates API endpoints
We welcome contributions! Please follow these guidelines:
- Read CLAUDE.md for development guidelines
- Use
pnpmas the package manager - Run
pnpm lintbefore committing - Test on both mainnet and testnet when applicable
- Follow the established code style and architecture
Use conventional commits with emojis:
β¨ feat: Add new feature
π fix: Bug fix
β»οΈ refactor: Code refactoring
π docs: Documentation
π style: UI/styling changes
The easiest way to deploy is using Vercel:
Make sure to configure the environment variables in Vercel's dashboard.
# Build for production
pnpm build
# Start production server
pnpm startSee Next.js deployment documentation for more deployment options.
This project is part of the Soroswap ecosystem. See individual dependencies for their respective licenses.
Built with β€οΈ by the Soroswap team