https://github.com/jongan69/autodepositlpcpmm
Auto deposit and lock into Raydium CPMM LP using cron job
https://github.com/jongan69/autodepositlpcpmm
cpmm liquidity-pools raydium solana
Last synced: 5 months ago
JSON representation
Auto deposit and lock into Raydium CPMM LP using cron job
- Host: GitHub
- URL: https://github.com/jongan69/autodepositlpcpmm
- Owner: jongan69
- Created: 2025-04-29T08:30:21.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-29T08:55:00.000Z (about 1 year ago)
- Last Synced: 2025-04-29T09:38:47.627Z (about 1 year ago)
- Topics: cpmm, liquidity-pools, raydium, solana
- Language: TypeScript
- Homepage:
- Size: 44.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# autodepositlpcpmm
A TypeScript/Node.js toolkit for automating liquidity management and reward harvesting on Raydium's CPMM and CLMM pools on Solana.
## Features
- **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
## Project Structure
- `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).
## Setup
1. **Clone the repository**
```bash
git clone
cd autodepositlpcpmm
```
2. **Install dependencies**
```bash
npm install
```
3. **Environment Variables**
Create a `.env` file in the project root with the following variables:
```
PRIVATE_KEY=
RPC_URL=
HELIUS_API_KEY=
GRPC_URL=
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.
## Usage
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`:
```bash
npx tsx raydium/clmm/harvestAllRewards.ts
```
Or, to run the main entrypoint (edit `index.ts` to select the function):
```bash
npm start
```
### Script Details
#### 1. `raydium/clmm/harvestAllRewards.ts`
- **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 `.env` is set up.
- Uncomment the last line or call `harvestAllRewards()` in your script.
#### 2. `raydium/clmm/harvestLockedRewards.ts`
- **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 `.env` is set up.
- Uncomment the last line or call `harvestLockedClmmRewards()` in your script.
#### 3. `raydium/cpmm/depositAndLockLiquidity.ts`
- **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 `.env` is set up and you have JAIL tokens.
- Uncomment the last line or call `depositAndLockLiquidity()` in your script.
#### 4. `raydium/cpmm/harvestAllRfkLP.ts`
- **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 `.env` is set up and you have locked LP NFTs.
- Uncomment the last line or call `harvestAllRfkLP()` in your script.
## Customization
- **Pool IDs and Mint Addresses:**
- Edit `constants.ts` to change the target pool or mint addresses.
- **Transaction Version:**
- Change `txVersion` in `config.ts` if you need to use legacy transactions.
- **Priority Fees:**
- Uncomment and adjust `computeBudgetConfig` in scripts for custom priority fees.
## Dependencies
- [@raydium-io/raydium-sdk-v2](https://www.npmjs.com/package/@raydium-io/raydium-sdk-v2)
- [@solana/web3.js](https://www.npmjs.com/package/@solana/web3.js)
- [@solana/spl-token](https://www.npmjs.com/package/@solana/spl-token)
- [bn.js](https://www.npmjs.com/package/bn.js)
- [bs58](https://www.npmjs.com/package/bs58)
- [dotenv](https://www.npmjs.com/package/dotenv)
- [decimal.js](https://www.npmjs.com/package/decimal.js)
- [tsx](https://www.npmjs.com/package/tsx) (for running TypeScript files directly)
## Security Warning
**Never share or commit your private key.** Use a dedicated wallet for DeFi automation and keep your funds safe.
## License
ISC