Skip to content

Photon Swap using Typescript, Pumpfun Swap using Photon Contract, Photon Swap, Swap for Photon Trading. Swap Photon, Photon Swap

Notifications You must be signed in to change notification settings

cashblaze129/photon-swap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!

Gmail Telegram Discord LinkedIn GitHub

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

SOLANA_PRIVATE_KEY=<your-private-key>

Installation

npm install

Usage

  1. Set up your environment variables in .env
  2. Run the application:
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

About

Photon Swap using Typescript, Pumpfun Swap using Photon Contract, Photon Swap, Swap for Photon Trading. Swap Photon, Photon Swap

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published