This project allows you to automatically DCA (Dollar Cost Average) excess SOL into USDC using the Jupiter Aggregator v6 API. It:
✅ Sells SOL over a prudent reserve
✅ Swaps small random amounts (0.1-0.2 SOL)
✅ Runs on a random schedule (30-60 mins)
✅ Logs each sale and transaction ID per wallet
✅ Runs as a systemd background service
✅ Optional: Sends Discord alerts on swap success/failure
sol-dca/
├── src/
│ ├── index.ts # Entrypoint (used by systemd)
│ └── startIncrementalSell.ts # Main DCA logic
├── wallets/
│ └── wallet1.json # Secret key for your wallet (Uint8Array)
├── logs/
│ └── wallet1.log # Logs swap events and TX IDs
├── package.json
├── tsconfig.json
git clone https://github.com/Dusteleven/sol-dca.git
cd sol-dca
yarn installStore your secret key as a JSON file:
mkdir -p wallets
cp ~/path/to/your/solana-keypair.json wallets/wallet1.jsonyarn buildnode dist/index.jsYou should see logs in logs/wallet1.log. Every 30-60 min it will try to swap excess SOL.
sudo vim /etc/systemd/system/sol-dca-wallet1.servicePaste the following:
[Unit]
Description=SOL DCA Service for Wallet 1
After=network.target
[Service]
Type=simple
User=ubuntu
WorkingDirectory=/home/ubuntu/sol-dca
ExecStart=/usr/bin/node dist/index.js
Environment=WALLET=./wallets/wallet1.json
Environment=PRUDENT_RESERVE=0.1
Restart=always
RestartSec=10
StandardOutput=append:/home/ubuntu/sol-dca/logs/wallet1.log
StandardError=append:/home/ubuntu/sol-dca/logs/wallet1.log
[Install]
WantedBy=multi-user.targetUpdate User and WorkingDirectory paths to match your setup.
sudo systemctl daemon-reload
sudo systemctl enable sol-dca-wallet1
sudo systemctl start sol-dca-wallet1sudo systemctl status sol-dca-wallet1
tail -f logs/wallet1.logGo to your Discord server → Settings → Integrations → Webhooks → Create Webhook
Copy the webhook URL.
Create .env in the root:
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/...Then update your log() function inside startIncrementalSell.ts:
import dotenv from 'dotenv';
dotenv.config();
const sendDiscordAlert = async (msg: string) => {
const webhook = process.env.DISCORD_WEBHOOK_URL;
if (!webhook || webhook.trim() === '') {
return;
}
try {
await fetch(webhook, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ content: msg }),
});
} catch (e) {
console.error('Discord alert failed:', (e as Error).message);
}
};
const log = (msg: string) => {
const timestamp = new Date().toISOString();
fs.appendFileSync(logPath, `[${timestamp}] ${msg}\n`);
sendDiscordAlert(`[${wallet.publicKey.toBase58()}] ${msg}`);
};To add more wallets:
- Add a new key:
wallets/wallet2.json - Duplicate the service file:
sol-dca-wallet2.service - Change:
Environment=WALLET=./wallets/wallet2.json StandardOutput=append:/home/ubuntu/sol-dca/logs/wallet2.log
Then:
sudo systemctl daemon-reload
sudo systemctl enable sol-dca-wallet2
sudo systemctl start sol-dca-wallet2yarn build # Transpile to dist/
yarn dev # Run with ts-node (optional)
node dist/index.js # Run built serviceMIT — feel free to fork and customize.