A TypeScript implementation for executing swaps on Solana using the Photon Protocol with PumpFun integration.
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.
-
Example Transaction: View on Solscan
-
Screenshot of the transaction:
- 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
-
Program IDs:
- Photon Program:
BSfD6SHZigAfDWSjzD5Q41jw8LmKwtmjskPH9XW1mrRW
- PumpFun Program:
6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P
- Photon Program:
-
Fee Structure:
- Photon Fee Vault:
AVUCZyuT35YSuj4RH7fwiyPu82Djn2Hfg7y2ND2XcnZH
- PumpFun Fee Recipient:
62qc2CNXwrYqQScmEdiZFFAnJR262PxWEwNQtxfafNgV
- BloxRoute Fee: 0.06 SOL per transaction
- Photon Fee Vault:
- Node.js
- TypeScript
- Solana Web3.js
- SPL Token Library
- BloxRoute Solana Trader Client
SOLANA_PRIVATE_KEY=<your-private-key>
npm install
- Set up your environment variables in
.env
- Run the application:
npm dev
-
Initialization:
- Creates keypair from private key
- Establishes connection to Solana network
- Validates token accounts
-
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
- 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)
@solana/web3.js
@solana/spl-token
@bloxroute/solana-trader-client-ts
bs58
dotenv