https://github.com/cashblaze127/photon-swap
Photon Swap using Typescript, Pumpfun Swap using Photon Contract, Photon Swap, Swap for Photon Trading. Swap Photon, Photon Swap
https://github.com/cashblaze127/photon-swap
blockchain defi dex photon pumpfun solana swap web3
Last synced: about 1 year ago
JSON representation
Photon Swap using Typescript, Pumpfun Swap using Photon Contract, Photon Swap, Swap for Photon Trading. Swap Photon, Photon Swap
- Host: GitHub
- URL: https://github.com/cashblaze127/photon-swap
- Owner: cashblaze127
- Created: 2025-03-25T08:50:49.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-25T11:18:55.000Z (about 1 year ago)
- Last Synced: 2025-03-25T12:27:19.653Z (about 1 year ago)
- Topics: blockchain, defi, dex, photon, pumpfun, solana, swap, web3
- Language: TypeScript
- Homepage:
- Size: 68.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Photon Swap
A TypeScript implementation for executing swaps on Solana using the Photon Protocol with PumpFun integration.
## Overview
Photon Swap is a decentralized exchange (DEX) integration that facilitates token swaps on the Solana blockchain. It specifically implements PumpFun swaps with built-in fee management through the Photon protocol.
## Have a project in mind? Ping me if you need help!
[](mailto:cashblaze129@gmail.com)
[](https://t.me/cashblaze127)
[](https://discordapp.com/users/965772784653443215)
[](https://www.linkedin.com/in/legend-keyvel-alston)
[](https://github.com/cashblaze127)
- Example Transaction: [View on Solscan](https://solscan.io/tx/4D1KSAd9B4TzPwF5UQBEhciffDchxxSsiFpJa5HYyYEdzequ3U4c3kSjkYdPJKpr4kzhBfxARu4wFLgtF3Detx5W)
- Screenshot of the transaction:
- 
## Features
- **Photon Protocol Integration**: Implements swap functionality using the Photon Program (`BSfD6SHZigAfDWSjzD5Q41jw8LmKwtmjskPH9XW1mrRW`)
- **PumpFun Support**: Direct integration with PumpFun protocol for token swaps
- **Automatic Token Account Creation**: Creates Associated Token Accounts (ATAs) if they don't exist
- **Fee Management**:
- Handles Photon protocol fees
- Includes BloxRoute integration for transaction routing
- Implements priority fees for better transaction success rates
- **Transaction Optimization**:
- Compute budget management
- Priority fee settings
- Transaction simulation before submission
## Technical Details
### Key Components
- **Program IDs**:
- Photon Program: `BSfD6SHZigAfDWSjzD5Q41jw8LmKwtmjskPH9XW1mrRW`
- PumpFun Program: `6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P`
- **Fee Structure**:
- Photon Fee Vault: `AVUCZyuT35YSuj4RH7fwiyPu82Djn2Hfg7y2ND2XcnZH`
- PumpFun Fee Recipient: `62qc2CNXwrYqQScmEdiZFFAnJR262PxWEwNQtxfafNgV`
- BloxRoute Fee: 0.06 SOL per transaction
### Prerequisites
- Node.js
- TypeScript
- Solana Web3.js
- SPL Token Library
- BloxRoute Solana Trader Client
### Environment Variables
```env
SOLANA_PRIVATE_KEY=
```
## Installation
```bash
npm install
```
## Usage
1. Set up your environment variables in `.env`
2. Run the application:
```bash
npm dev
```
## Transaction Flow
1. **Initialization**:
- Creates keypair from private key
- Establishes connection to Solana network
- Validates token accounts
2. **Swap Execution**:
- Sets compute budget and priority fees
- Creates Associated Token Account if needed
- Constructs swap instruction with Photon protocol
- Handles fee transfers
- Simulates transaction
- Submits and confirms transaction
## Security Considerations
- Private keys should be securely stored in environment variables
- Transaction simulation is performed before submission
- Compute budget is properly configured to prevent transaction failures
- Slippage protection is implemented (default: 1000 basis points)
## Dependencies
- `@solana/web3.js`
- `@solana/spl-token`
- `@bloxroute/solana-trader-client-ts`
- `bs58`
- `dotenv`