Skip to content

Repository files navigation

OrbitSwap

OrbitSwap Logo

Fast, seamless token swaps powered by Stellar

CI Stellar Testnet License TypeScript React Tests

🌐 Live Demo Β· πŸ“Έ Screenshots Β· ⛓️ Deployed Contract


Overview

OrbitSwap is a production-ready decentralized token swap application built on the Stellar network. Users can securely connect multiple Stellar wallets, browse supported assets, inspect Stellar DEX market information, interact with deployed Soroban smart contracts, execute token swaps, monitor transaction progress, and receive live blockchain updates through a responsive modern interface.


Features

  • πŸ” Multi-Wallet Support β€” Connect with Freighter, xBull, Albedo, Rabet, and LOBSTR via StellarWalletsKit
  • πŸ’± Token Swap Interface β€” Production-quality DEX experience with real-time quotes
  • πŸ“Š Market Information β€” Live price feeds from Stellar DEX order books
  • ⛓️ Soroban Smart Contract β€” Deployed contract for swap operations with read/write support
  • πŸ“‘ Real-Time Events β€” Live contract event streaming and blockchain synchronization
  • πŸ“ Transaction Tracking β€” Full lifecycle tracking: preparing β†’ pending β†’ confirmed
  • πŸ”” Notifications β€” Toast notifications for all wallet and transaction events
  • πŸ“± Responsive Design β€” Optimized for desktop, tablet, and mobile
  • β™Ώ Accessibility β€” Semantic HTML, keyboard navigation, ARIA labels, focus states
  • πŸ§ͺ Comprehensive Tests β€” 29 passing tests covering hooks, components, and services

Technology Stack

Layer Technologies
Frontend React 18, TypeScript, Vite, Tailwind CSS
Blockchain Stellar SDK, Soroban SDK
Wallets StellarWalletsKit (Freighter, xBull, Albedo, Rabet, LOBSTR)
Smart Contract Soroban (Rust), deployed on Stellar Testnet
State Zustand
Routing React Router v6
Testing Vitest, React Testing Library
Linting ESLint, Prettier
Build Vite

Architecture

orbitswap/
β”œβ”€β”€ contracts/
β”‚   └── orbitswap/
β”‚       β”œβ”€β”€ Cargo.toml              # Soroban contract manifest
β”‚       └── src/
β”‚           β”œβ”€β”€ lib.rs              # Smart contract implementation
β”‚           └── test.rs             # Contract unit tests
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ favicon.svg
β”‚   └── wallets/                    # Wallet icon SVGs
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ layout/                 # Navbar, Footer, Layout
β”‚   β”‚   β”œβ”€β”€ swap/                   # SwapCard, AssetSelector
β”‚   β”‚   β”œβ”€β”€ ui/                     # Button, Skeleton, StatusBadge, Toast
β”‚   β”‚   └── wallet/                 # WalletSelector, WalletPanel
β”‚   β”œβ”€β”€ constants/                  # App configuration
β”‚   β”œβ”€β”€ contracts/                  # Contract references
β”‚   β”œβ”€β”€ hooks/                      # Custom React hooks
β”‚   β”œβ”€β”€ pages/                      # HomePage, HistoryPage
β”‚   β”œβ”€β”€ providers/                  # WalletProvider, ContractProvider
β”‚   β”œβ”€β”€ services/                   # wallet.service, stellar.service, contract.service
β”‚   β”œβ”€β”€ store/                      # Zustand state management
β”‚   β”œβ”€β”€ styles/                     # Global CSS with Tailwind
β”‚   β”œβ”€β”€ test/                       # Test setup and test files
β”‚   └── types/                      # TypeScript type definitions
β”œβ”€β”€ .env.example                    # Environment variables template
β”œβ”€β”€ index.html
β”œβ”€β”€ package.json
β”œβ”€β”€ tailwind.config.js
β”œβ”€β”€ tsconfig.json
└── vite.config.ts

Installation

Prerequisites

  • Node.js >= 18
  • npm >= 9
  • A Stellar wallet browser extension (Freighter, xBull, Albedo, or Rabet)

Setup

# Clone the repository
git clone https://github.com/your-username/orbitswap.git
cd orbitswap

# Install dependencies
npm install

# Copy environment configuration
cp .env.example .env

Environment Variables

Variable Description Default
VITE_STELLAR_NETWORK Stellar network (TESTNET or PUBLIC) TESTNET
VITE_HORIZON_URL Horizon API endpoint https://horizon-testnet.stellar.org
VITE_SOROBAN_RPC_URL Soroban RPC endpoint https://soroban-testnet.stellar.org
VITE_CONTRACT_ID Deployed Soroban contract ID CDMFGNFKQOJ3IRFN7GYL2B6242TWQX3JXLUHUZB3CLK2HNUT7VLYMNVN
VITE_APP_NAME Application name OrbitSwap
VITE_APP_URL Application URL http://localhost:3000

Running Locally

npm run dev

Open http://localhost:3000 in your browser.

Building for Production

npm run build
npm run preview

Testing

# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage
npm run test:coverage

🌐 Live Demo

πŸ”— https://orbitswap-eta.vercel.app

Deployed on Vercel.


πŸ“Έ Screenshots

Wallet Options Available

OrbitSwap Wallet Selector showing Freighter, xBull, Albedo, Rabet, and LOBSTR

Wallet selector modal showing all 5 supported Stellar wallets: Freighter, xBull, Albedo, Rabet, and LOBSTR


Wallet Setup

OrbitSwap supports 5 Stellar wallets through StellarWalletsKit:

Wallet Installation
Freighter freighter.app
xBull xbull.app
Albedo albedo.link
Rabet rabet.io
LOBSTR lobstr.co

Connecting a Wallet

  1. Click the "Connect Wallet" button in the navigation bar
  2. Select your preferred wallet from the list
  3. Approve the connection request in your wallet extension
  4. Your wallet address and balance will appear in the Wallet Panel

Wallet Features

  • Multi-wallet switching β€” Switch between wallets without refreshing
  • Auto-reconnect β€” Persists wallet connection across page reloads
  • Address display β€” Shows short address with copy-to-clipboard
  • Balance tracking β€” Real-time balance updates every 15 seconds
  • Network badge β€” Displays current Stellar network

Smart Contract

Contract Overview

The OrbitSwap Soroban smart contract manages:

  • Asset registry β€” Maintains a list of supported swap assets
  • Swap estimation β€” Calculates estimated output and fees
  • Swap execution β€” Validates and executes token swaps with slippage protection
  • Admin controls β€” Pause/unpause functionality for emergency stops
  • Events β€” Emits SwapExecuted events for real-time tracking

Contract Structure

contracts/orbitswap/
β”œβ”€β”€ Cargo.toml
└── src/
    β”œβ”€β”€ lib.rs       # Contract + client implementation
    └── test.rs      # Contract tests (init, swap, pause)

Deployed Contract

  • Network: Stellar Testnet
  • Contract ID: CDMFGNFKQOJ3IRFN7GYL2B6242TWQX3JXLUHUZB3CLK2HNUT7VLYMNVN
  • Soroban RPC: https://soroban-testnet.stellar.org
  • Deployer: GDQY77NYQ2A4RYCQ4PKD2BFC532ECYEKPFHPS24POUHG7L4KLDB74567

Verified Contract Call

  • Transaction Hash (init): 8f582b3bd3a59c4ed777e7f74f3c6b01ee859129d7658bd3999cfc9928a4ef73
  • Stellar Expert: View on Explorer
  • Network: Testnet
  • Function Called: init(admin: orbitswap-deployer)

This is a Soroban contract invocation (init function), fully verifiable on Stellar Explorer.

Deploying the Contract

# Install Rust and Soroban CLI
cargo install --locked soroban-cli

# Build the contract
cd contracts/orbitswap
cargo build --target wasm32-unknown-unknown --release

# Deploy to testnet (requires funded Stellar account)
soroban contract deploy \
  --wasm target/wasm32-unknown-unknown/release/orbitswap.wasm \
  --source <YOUR_SECRET_KEY> \
  --network testnet

Contract Interaction

The frontend interacts with the contract via ContractService:

Read Operations:

  • get_assets() β€” Fetch supported assets
  • get_swap_estimate() β€” Get swap quote from contract
  • get_balance() β€” Check contract balance for an asset

Write Operations:

  • swap() β€” Execute a token swap with slippage protection
  • add_asset() β€” Admin: add a new supported asset
  • pause() / unpause() β€” Admin: emergency pause controls

Real-Time Sync

Contract events are streamed via polling (every 5 seconds) using the Soroban RPC getEvents endpoint. Events are stored in the Zustand store and displayed in the Notifications panel.


Transaction Lifecycle

Every transaction goes through a defined lifecycle:

Preparing β†’ Awaiting Wallet Approval β†’ Signing β†’ Submitting β†’ Pending β†’ Confirmed
                                                                       β†˜ Failed
                                                                       β†˜ Rejected
                                                                       β†˜ Timeout

Status badges are displayed with color-coded indicators:

  • 🟑 Pending states β€” amber/yellow pulsing dot
  • 🟒 Confirmed β€” green dot
  • πŸ”΄ Failed/Rejected β€” red dot
  • βšͺ Timeout β€” gray dot

Swap Flow

  1. Connect Wallet β€” Select and connect a Stellar wallet
  2. Select Assets β€” Choose input and output tokens from the asset selector
  3. Enter Amount β€” Input the swap amount (or click MAX)
  4. Review Quote β€” View exchange rate, network fee, and estimated output
  5. Confirm Swap β€” Review the preview modal and confirm
  6. Track Transaction β€” Monitor status with in-app tracking and Explorer links

Error Handling

The application explicitly handles these error scenarios:

Error Display Recovery
Wallet not installed Installation guide + link Install wallet, retry
Wallet rejected request User cancelled message Dismiss, retry
Insufficient balance Current vs required balance Add funds, retry
Unsupported network Network mismatch warning Switch network
Timeout Transaction timeout notice Retry transaction
Contract failure Friendly error message Dismiss, retry

Stellar Explorer Links

All transactions include direct links to Stellar Expert for on-chain verification.


License

MIT Β© 2026 OrbitSwap


Acknowledgments

Built for the Rise In Stellar Builder Challenge – Level 2 (Yellow Belt).

Built with:

About

OrbitSwap is a production-ready decentralized token swap application built on the Stellar network.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages