Skip to content

RozoAI/soroswap-v2-frontend

Β 
Β 

Repository files navigation

Soroswap Frontend

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.

Next.js React TypeScript Node

✨ Features

  • πŸ”„ 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

πŸ“‹ Prerequisites

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 pnpm

πŸš€ Getting Started

1. Clone the Repository

git clone https://github.com/soroswap/v2-frontend.git
cd v2-frontend

2. Install Dependencies

pnpm install

3. Configure Environment Variables

Copy the example environment file and configure it:

cp .env.example .env

Edit .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"

4. Run Development Server

pnpm dev

Open http://localhost:3000 to see the application.

πŸ“œ Available Commands

pnpm dev          # Start development server
pnpm build        # Build for production
pnpm start        # Start production server
pnpm lint         # Run ESLint

πŸ—οΈ Project Architecture

The 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

πŸ› οΈ Tech Stack

Core Framework

  • Next.js 15.3.3 with App Router
  • React 19
  • TypeScript (strict mode)

Styling

  • Tailwind CSS 4 (utility-first)
  • next-themes for dark mode
  • class-variance-authority for component variants

State Management

  • Zustand for client-side global state
  • SWR for data fetching and caching
  • @tanstack/react-query (v5.90.5) for bridge feature

Blockchain & DEX

  • @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

Data & Validation

  • Zod for runtime validation
  • SWR with optimized caching strategies

UI Components

  • @tanstack/react-table for data tables
  • Lucide React for icons
  • React Tooltip for tooltips

🌐 API Routes

The application exposes several server-side API routes:

Token Operations

  • GET /api/tokens - Get token list (SDK β†’ hardcoded fallback)
  • GET /api/token/metadata - Fetch on-demand token metadata

Pool Operations

  • GET /api/pools - Get available pools
  • POST /api/pools/add-liquidity - Add liquidity transaction
  • POST /api/pools/remove-liquidity - Remove liquidity transaction
  • GET /api/pools/user - Get user positions

Price & Quotes

  • GET /api/price - Get token prices (3-min server cache)
  • GET /api/quote - Calculate swap route
  • POST /api/quote/build - Build swap transaction

Earn/Farming

  • GET /api/earn/vaultInfo - Vault information
  • POST /api/earn/deposit - Deposit to vault
  • POST /api/earn/withdraw - Withdraw from vault

🎨 Code Style Guidelines

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 any types, proper interfaces

See CLAUDE.md for detailed development guidelines.

πŸ—‚οΈ Key Concepts

Token List Management

Tokens are fetched with priority system:

  1. Primary: Soroswap SDK getAssetList()
  2. Fallback: Hardcoded token list (33 tokens with IPFS icons)
  3. Cache: 12-hour SWR cache on client

Price Caching

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%

Pool Data Loading

Separated loading states:

  • Pools data loads independently
  • TVL calculated separately when prices available
  • Improves perceived performance (~2.5s vs ~40s)

Network Configuration

Switch between mainnet and testnet via NEXT_PUBLIC_ENV:

  • Affects SDK initialization
  • Changes contract addresses
  • Updates API endpoints

🀝 Contributing

We welcome contributions! Please follow these guidelines:

  1. Read CLAUDE.md for development guidelines
  2. Use pnpm as the package manager
  3. Run pnpm lint before committing
  4. Test on both mainnet and testnet when applicable
  5. Follow the established code style and architecture

Git Commit Convention

Use conventional commits with emojis:

✨ feat: Add new feature
πŸ› fix: Bug fix
♻️ refactor: Code refactoring
πŸ“ docs: Documentation
πŸ’„ style: UI/styling changes

πŸ“š Learn More

Project Resources

Framework Documentation

🚒 Deployment

Vercel (Recommended)

The easiest way to deploy is using Vercel:

Deploy with Vercel

Make sure to configure the environment variables in Vercel's dashboard.

Manual Deployment

# Build for production
pnpm build

# Start production server
pnpm start

See Next.js deployment documentation for more deployment options.

πŸ“„ License

This project is part of the Soroswap ecosystem. See individual dependencies for their respective licenses.


Built with ❀️ by the Soroswap team

About

Rozo <> Soroswap

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 99.1%
  • Other 0.9%