Welcome to Volex Finanace, a decentralized token swapping platform built on Solana using Next.js. The platform integrates with Jupiter Aggregator for token swaps and zk-compression to compress and decompress tokens during transactions by optimizing on-chain interactions. This platform is built for users who want to perform atomic swaps with efficiency, privacy, and scalability on Solana's mainnet.
- Features
- Tech Stack
- Getting Started
- Environment Variables
- Key Components
- How to Run
- How to Use
- Swap Flow
- Contributing
- License
- Token Swapping: Swap SPL tokens and Solana tokens using the Jupiter Aggregator API.
- zk-Compression: Compress and decompress tokens to optimize on-chain storage using Light Protocol's stateless zk-compression.
- User-friendly Interface: Intuitive UI to interact with the wallet and monitor token balances.
- Wallet Integration: Connect your Solana wallet using
@solana/wallet-adapter-react
for a seamless decentralized experience. - Atomic Transactions: Compress, swap, and decompress tokens in a single atomic transaction.
- Framework: Next.js
- Blockchain: Solana
- API Integration: Jupiter Aggregator
- zk-compression: Light Protocol
- Wallet Adapter:
@solana/wallet-adapter-react
- Languages: TypeScript
- Styling: Tailwind CSS
To run this project locally, follow the steps below:
- Node.js: v16.x or higher
- npm or yarn: Latest version
- Solana Wallet: A connected Solana wallet (e.g., Phantom, Sollet)
- RPC Endpoints: You need RPC API keys for both the mainnet and devnet.
-
Clone the repository:
git clone https://github.com/codewithmide/Velox-Finance cd volex
-
Install dependencies:
npm install
Or with yarn:
yarn install
-
Configure environment variables:
Create a
.env
file in the root directory with the following content:NEXT_PUBLIC_MAINNET_API_BASE_URL=https://example-mainnet-api.com/your-key NEXT_PUBLIC_DEVNET_API_BASE_URL=https://example-devnet-api.com/your-key
Replace the placeholder values with your actual API keys for Solana RPC endpoints.
-
Start the development server:
npm run dev
Or with yarn:
yarn dev
The application should now be running at
http://localhost:3000
.
This project relies on two key environment variables for Solana RPC connections:
- NEXT_PUBLIC_MAINNET_API_BASE_URL: The RPC endpoint for Solana mainnet. Used for production deployments and live token swaps.
- NEXT_PUBLIC_DEVNET_API_BASE_URL: The RPC endpoint for Solana devnet. Used for testing and development purposes.
These values must be set in the .env
file. If you're using public RPC endpoints, ensure they are reliable and include your API key for better rate-limiting control.
NEXT_PUBLIC_MAINNET_API_BASE_URL=<your-mainnet-rpc-url>
NEXT_PUBLIC_DEVNET_API_BASE_URL=<your-devnet-rpc-url>
- Located in
app/components/Swap.tsx
. - This component handles:
- Token selection from dropdowns for the "From" and "To" tokens.
- Fetching token balances from the connected Solana wallet.
- Slippage settings for swap transactions.
- Token compression and decompression using zk-compression.
- Swapping tokens using Jupiter Aggregator.
- Located in
app/components/molecules/Modal.tsx
. - A reusable modal component used for displaying UI elements like slippage settings.
- Solana Wallet Adapter (
@solana/wallet-adapter-react
) is used to manage wallet connections, balances, and transactions. The application supports wallets like Phantom and Sollet.
To run the app with the mainnet environment:
-
Make sure your
.env
file has theNEXT_PUBLIC_MAINNET_API_BASE_URL
set correctly. -
Then, run the following command to build and start the production version:
npm run build && npm start
For development and testing purposes, you can switch to the devnet environment by setting NEXT_PUBLIC_DEVNET_API_BASE_URL
in your .env
file and running the development server:
npm run dev
- Connect your wallet: Open the app and connect your Solana wallet (e.g., Phantom).
- Select tokens: Choose the tokens you wish to swap from the dropdown menu.
- Input amount: Enter the amount of tokens to swap.
- Adjust slippage: If needed, open the slippage modal to adjust the slippage tolerance for the swap.
- Perform swap: Click the Swap button to compress, swap, and decompress the tokens atomically.
Before the swap happens, the platform uses zk-compression to compress the tokens, optimizing transaction size and privacy. This is handled using the CompressedTokenProgram
from Light Protocol.
Once the token is compressed, the swap is executed using the Jupiter Aggregator API, which ensures the best route and lowest fees for the swap.
After the swap, the token is decompressed back to its original form. This entire process happens atomically, ensuring no interruptions in the user experience.