Skip to content

Instantly share code, notes, and snippets.

@harishkotra
Created April 2, 2026 01:55
Show Gist options
  • Select an option

  • Save harishkotra/9ed34cd6c892b910c163fe66137ccd22 to your computer and use it in GitHub Desktop.

Select an option

Save harishkotra/9ed34cd6c892b910c163fe66137ccd22 to your computer and use it in GitHub Desktop.
"Shadow-Signal" - an autonomous copy-trading bot powered entirely by the Nansen CLI
const { execSync } = require('child_process');
// CONFIGURATION
const CHAIN = 'solana';
const TRADE_AMOUNT = '100000'; // 0.1 USDC (Adjust as needed)
const MIN_SM_INFLOW = 100; // Lowered to $100 for testing/hackathon purposes
async function runCommand(cmd) {
try {
const output = execSync(cmd, { encoding: 'utf-8' });
const parsed = JSON.parse(output);
return parsed;
} catch (e) {
// If the command fails, the output might be raw text or error
return { success: false, error: e.message };
}
}
async function shadowTrade() {
console.log("Initializing Shadow Trader...");
// 1. Get SM Netflow - Using --fields and 24h timeframe to ensure data
console.log(`Checking ${CHAIN} Smart Money flows (24h window)...`);
const cmd = `nansen research sm netflow --chain ${CHAIN} --timeframe 24h --limit 5 --fields token_symbol,net_flow_usd --table`;
// We run it without --table for the JSON parsing in the script
const flowData = await runCommand(`nansen research sm netflow --chain ${CHAIN} --timeframe 24h --limit 5 --fields token_symbol,net_flow_usd`);
if (!flowData.success || !flowData.data || flowData.data.length === 0) {
console.log("No Smart Money movement found. Try a different chain or check later.");
return;
}
const topToken = flowData.data[0];
const inflow = parseFloat(topToken.net_flow_usd);
console.log(`📈 Signal: ${topToken.token_symbol} | SM Inflow: $${inflow.toFixed(2)}`);
if (inflow < MIN_SM_INFLOW) {
console.log(`Inflow $${inflow} is below threshold ($${MIN_SM_INFLOW}). Skipping.`);
return;
}
// 2. ONLY run the expensive Agent command if we actually have a signal
console.log(`[CREDIT WARNING] Analyzing ${topToken.token_symbol} with Nansen AI Agent...`);
const agentCheck = await runCommand(`nansen agent "Briefly: Is ${topToken.token_symbol} on ${CHAIN} a high-risk project?"`);
if (agentCheck.success && (agentCheck.data.toLowerCase().includes('risk') || agentCheck.data.toLowerCase().includes('scam'))) {
console.log("⚠AI Agent flagged this as high risk. Trade aborted.");
return;
}
// 3. Execution Quote
console.log(`Getting trade quote for ${topToken.token_symbol}...`);
const quote = await runCommand(`nansen trade quote --chain ${CHAIN} --from USDC --to ${topToken.token_symbol} --amount ${TRADE_AMOUNT}`);
if (quote.success) {
console.log(`Trade Quote Ready: ${quote.data.quoteId}`);
console.log(`👉 To finish, run: nansen trade execute --quote ${quote.data.quoteId}`);
} else {
console.log("Quote failed. (Check if you have enough balance/liquidity)");
}
}
shadowTrade();
@Cool20224U
Copy link
Copy Markdown

interesting bot, will check it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment