A TypeScript/Node.js toolkit for automating liquidity management and reward harvesting on Raydium's CPMM and CLMM pools on Solana.
- Deposit and lock liquidity into Raydium CPMM pools
- Harvest all rewards from CLMM and CPMM pools, including locked positions
- Automated batch operations for efficient DeFi workflows
raydium/clmm/harvestAllRewards.ts: Harvests all available CLMM rewards for non-zero positions.harvestLockedRewards.ts: Harvests rewards from all locked CLMM positions (NFT-based).
raydium/cpmm/depositAndLockLiquidity.ts: Deposits 1% of your JAIL token balance into a CPMM pool and locks the resulting LP tokens.harvestAllRfkLP.ts: Harvests all CPMM rewards for locked LP NFTs (Raydium Fee Key - RFK).
raydium/config.ts: SDK and connection setup, environment variable management, and helper functions for fetching locked NFTs.raydium/utils.ts: Utility for validating CPMM pool program IDs.constants.ts: Pool and mint addresses.index.ts: Example usage and entrypoint (uncomment desired function to run).
- Clone the repository
git clone <repo-url>
cd autodepositlpcpmm- Install dependencies
npm install- Environment Variables
Create a .env file in the project root with the following variables:
PRIVATE_KEY=<base58-encoded-solana-private-key>
RPC_URL=<your-solana-rpc-url>
HELIUS_API_KEY=<your-helius-api-key>
GRPC_URL=<optional-grpc-url>
GRPC_TOKEN=<optional-grpc-token>
PRIVATE_KEY: Your Solana wallet's private key (base58 encoded)RPC_URL: Solana RPC endpoint (mainnet recommended)HELIUS_API_KEY: For NFT lookups (used in locked position scripts)
Note: Never commit your .env file or private key to version control.
All scripts are TypeScript files. You can run them using npm start after uncommenting the desired function call in index.ts, or by running individual files with tsx:
npx tsx raydium/clmm/harvestAllRewards.tsOr, to run the main entrypoint (edit index.ts to select the function):
npm start- Purpose: Harvests all available CLMM rewards for your wallet's non-zero positions.
- How it works:
- Fetches all CLMM positions for the wallet.
- Filters out positions with zero liquidity.
- Fetches pool info for each position.
- Calls the Raydium SDK to harvest all rewards in batch.
- Usage:
- Ensure your
.envis set up. - Uncomment the last line or call
harvestAllRewards()in your script.
- Ensure your
- Purpose: Harvests rewards from all locked CLMM positions (NFT-based).
- How it works:
- Scans wallet for NFTs representing locked CLMM positions.
- For each, calls the Raydium SDK to harvest rewards.
- Handles errors gracefully and continues with remaining positions.
- Usage:
- Ensure your
.envis set up. - Uncomment the last line or call
harvestLockedClmmRewards()in your script.
- Ensure your
- Purpose: Deposits 1% of your JAIL token balance into a CPMM pool and locks the resulting LP tokens.
- How it works:
- Fetches pool info and your JAIL token balance.
- Calculates 1% of your balance and deposits it as liquidity.
- Locks the received LP tokens.
- Usage:
- Ensure your
.envis set up and you have JAIL tokens. - Uncomment the last line or call
depositAndLockLiquidity()in your script.
- Ensure your
- Purpose: Harvests all CPMM rewards for locked LP NFTs (Raydium Fee Key - RFK).
- How it works:
- Uses the Helius API to find all RFK NFTs in your wallet.
- For each, calls the Raydium SDK to harvest rewards.
- Handles errors gracefully and continues with remaining NFTs.
- Usage:
- Ensure your
.envis set up and you have locked LP NFTs. - Uncomment the last line or call
harvestAllRfkLP()in your script.
- Ensure your
- Pool IDs and Mint Addresses:
- Edit
constants.tsto change the target pool or mint addresses.
- Edit
- Transaction Version:
- Change
txVersioninconfig.tsif you need to use legacy transactions.
- Change
- Priority Fees:
- Uncomment and adjust
computeBudgetConfigin scripts for custom priority fees.
- Uncomment and adjust
- @raydium-io/raydium-sdk-v2
- @solana/web3.js
- @solana/spl-token
- bn.js
- bs58
- dotenv
- decimal.js
- tsx (for running TypeScript files directly)
Never share or commit your private key. Use a dedicated wallet for DeFi automation and keep your funds safe.
ISC