Skip to content

MidTermDev/Alchemy

Repository files navigation

Alchemy Banner

Alchemy Token Distributor

Automated Rewards System for $ALCH Holders

Hold $ALCH, Earn $GOLD - Fully automated reward distribution on Solana

Solana TypeScript License

🌐 Website β€’ πŸ“– Docs β€’ πŸ’¬ Community


πŸ“‹ Overview

The Alchemy Token Distributor is an automated system that rewards $ALCH token holders with $GOLD tokens. The system continuously:

  1. Collects trading fees from the ALCH/SOL liquidity pool
  2. Converts SOL to GOLD using Jupiter aggregator for best rates
  3. Distributes GOLD proportionally to all ALCH holders based on their holdings

All operations run automatically every few minutes, ensuring consistent rewards for holders.

🎯 Token Information

Token Contract Address Type
$ALCH (Snapshot Token) WXsX5HSoVquYRGuJXJrCSogT1M6nZiPRrfZhQsPcXAU Token-2022 Token
$GOLD (Reward Token) GoLDppdjB1vDTPSGxyMJFqdnj134yH6Prg9eqsGDiw6A Reward Token

✨ Features

  • ⚑ Fully Automated - Runs continuously with PM2 process management
  • πŸ’Ž Proportional Rewards - Distribution based on ALCH holdings percentage
  • πŸ”„ Optimal Swaps - Jupiter aggregator finds best SOLβ†’GOLD routes
  • πŸ›‘οΈ Pool Filtering - Automatically excludes AMM/DEX addresses
  • πŸ“Š Batch Processing - Efficient parallel transaction execution
  • πŸ” Secure - No private keys in code, environment-based configuration

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ and npm
  • Solana wallet keypairs (JSON format)
  • RPC endpoint (Helius, Alchemy, or other)

Installation

# Clone the repository
git clone <repository-url>
cd alchemy-token-distributor

# Install dependencies
npm install

# Configure environment
cp .env.example .env
# Edit .env with your settings

# Add your keypairs
# - keypair.json (for pool fee collection)
# - keypair_distro.json (for token distribution)

Configuration

Create a .env file:

RPC_ENDPOINT=https://your-rpc-endpoint.com
KEYPAIR_PATH=keypair.json
KEYPAIR_DISTRO_PATH=keypair_distro.json

Running Scripts

# Collect pool fees (run every 2 minutes)
npm run collect-fees

# Swap SOL to GOLD (run every 2 minutes)
npm run swap

# Distribute GOLD to ALCH holders (run every 5 minutes)
npm run distribute

πŸ€– Automated Execution with PM2

For continuous automated operation:

# Install PM2 globally
npm install -g pm2

# Start all processes
pm2 start ecosystem.config.js

# Monitor processes
pm2 monit

# View logs
pm2 logs

# Stop all processes
pm2 stop all

The ecosystem.config.js schedules:

  • Fee Collection: Every 2 minutes
  • SOLβ†’GOLD Swap: Every 2 minutes
  • GOLD Distribution: Every 5 minutes

πŸ“ Project Structure

alchemy-token-distributor/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ collect-fees.ts        # Collect pool trading fees
β”‚   β”œβ”€β”€ swap-sol-to-gold.ts    # Swap SOL to GOLD via Jupiter
β”‚   └── distribute-tokens.ts   # Distribute GOLD to ALCH holders
β”œβ”€β”€ ecosystem.config.js         # PM2 configuration
β”œβ”€β”€ .env.example               # Environment template
└── README.md

πŸ”§ How It Works

1️⃣ Fee Collection

// Collects trading fees from ALCH/SOL pool on Meteora
// Fees are claimed to the pool owner wallet
collectPoolFees()

2️⃣ Automatic Swapping

// Swaps accumulated SOL to GOLD tokens
// Keeps 1 SOL reserve for transaction fees
// Uses Jupiter for optimal routing
swapSOLToGold()

3️⃣ Reward Distribution

// Takes snapshot of all ALCH holders
// Filters out pools and AMM addresses
// Distributes GOLD proportionally to holdings
distributeToHolders()

πŸ“Š Distribution Logic

  1. Snapshot: System scans all ALCH token accounts on-chain
  2. Filter: Removes AMM pools, DEX programs, and blacklisted addresses
  3. Calculate: Determines each holder's percentage of total supply
  4. Distribute: Sends proportional GOLD rewards to all eligible holders

Example: If you hold 5% of circulating ALCH, you receive 5% of each GOLD distribution.

πŸ› οΈ Development

# Build TypeScript
npm run build

# Run individual scripts
npm run collect-fees
npm run swap
npm run distribute

# Run with ts-node (development)
npx ts-node src/collect-fees.ts
npx ts-node src/swap-sol-to-gold.ts
npx ts-node src/distribute-tokens.ts

πŸ” Security Best Practices

  • βœ… Never commit keypair files to version control
  • βœ… Use environment variables for sensitive data
  • βœ… Keep RPC endpoints private
  • βœ… Regularly rotate wallet keys
  • βœ… Monitor transaction logs for anomalies
  • βœ… Use dedicated wallets for automated operations

πŸ“ Environment Variables

Variable Description Required
RPC_ENDPOINT Solana RPC URL Yes
KEYPAIR_PATH Path to fee collector keypair Yes
KEYPAIR_DISTRO_PATH Path to distributor keypair Yes

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

⚠️ Disclaimer

This software is provided "as is" without warranty. Use at your own risk. Always test thoroughly on devnet before mainnet deployment.

πŸ”— Links


Built with ❀️ for the Alchemy community

Hold $ALCH β€’ Earn $GOLD β€’ Prosper Together

About

On-Chain Alchemy

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors