Divvy Functions

analyzeToken

Get comprehensive analysis of any cryptocurrency token including real-time price data, market capitalization, liquidity metrics, and trading volume. This function provides essential fundamental analysis data to help make informed trading decisions.

The analysis includes holder distribution patterns, recent price movements, and key metrics that professional traders use to evaluate token potential. Perfect for due diligence before entering positions.

// Example usage
const tokenData = await analyzeToken({
  mintAddress: "So11111111111111111111111111111111111111112",
  includeHolders: true
});

// Returns comprehensive token metrics
console.log(tokenData.price.usd);        // Current USD price
console.log(tokenData.marketCap.usd);    // Market capitalization  
console.log(tokenData.liquidity.usd);    // Available liquidity
console.log(tokenData.holders.count);    // Total holder count

analyzeTokens

Analyze multiple tokens simultaneously or discover recently launched tokens with strong fundamentals. This function is ideal for portfolio diversification research and identifying emerging opportunities in the cryptocurrency market.

You can specify multiple token addresses for comparative analysis, or use discovery parameters to find new tokens based on criteria like minimum liquidity, holder count, and market cap thresholds.

// Analyze multiple specific tokens
const multiTokenData = await analyzeTokens({
  tokens: [
    "So11111111111111111111111111111111111111112", // SOL
    "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"  // USDC
  ],
  compareMetrics: true
});

// Discover new tokens
const newTokens = await analyzeTokens({
  discovery: true,
  minLiquidity: 100000,  // Minimum $100k liquidity
  maxAge: 24            // Created within 24 hours
});

getTokenHolders

Access detailed information about the top token holders including wallet addresses and their percentage of total supply. This data is crucial for understanding token distribution and identifying potential whale movements that could impact price.

Analyze holder concentration to assess risk levels and market manipulation potential. Well-distributed tokens typically indicate healthier long-term prospects and reduced volatility from large holder actions.

// Get top token holders
const holdersData = await getTokenHolders({
  mintAddress: "So11111111111111111111111111111111111111112",
  limit: 20  // Top 20 holders
});

// Analyze distribution
holdersData.holders.forEach((holder, index) => {
  console.log(`#${index + 1}: ${holder.address}`);
  console.log(`Holdings: ${holder.percentage.toFixed(2)}%`);
  console.log(`Balance: ${holder.balance} tokens`);
});

getUserWallet

Retrieve your current wallet address and SOL balance to get an overview of your primary wallet status. This function provides essential account information needed for trading operations and portfolio management.

Use this to verify your wallet connection, check available SOL for gas fees and trading, and ensure your wallet is properly configured for Divvy's trading functions.

// Get current wallet information
const walletInfo = await getUserWallet();

// Access wallet details
console.log("Address:", walletInfo.address);
console.log("SOL Balance:", walletInfo.solBalance);
console.log("USD Value:", walletInfo.usdValue);
console.log("Status:", walletInfo.status);

// Check if ready for trading
if (walletInfo.solBalance > 0.1) {
  console.log("Wallet ready for trading");
} else {
  console.log("Insufficient SOL for gas fees");
}

getTokenBalance

Check the balance of any specific token in your wallet with real-time USD valuation. Essential for portfolio tracking and determining available amounts for trading decisions and position management.

This function helps you understand your current holdings before making trades, calculate position sizes, and track portfolio composition across different tokens.

// Check specific token balance
const balance = await getTokenBalance({
  mintAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" // USDC
});

// Display balance information
console.log("Token Balance:", balance.amount);
console.log("USD Value:", balance.usdValue);
console.log("Percentage of Portfolio:", balance.portfolioPercentage);
console.log("Price per Token:", balance.pricePerToken);

// Check if sufficient for trading
const minTradeAmount = 100; // $100 minimum
if (balance.usdValue >= minTradeAmount) {
  console.log("Sufficient balance for trading");
}

buyToken

Execute token purchases using your SOL balance with automatic slippage protection and optimal routing. Specify purchase amounts in SOL or USD value for flexible trading options that suit your strategy.

The function handles complex routing through multiple DEXs to find the best prices, manages slippage automatically, and provides real-time execution feedback for professional trading experiences.

// Buy token with SOL amount
const buyOrder = await buyToken({
  mintAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
  solAmount: 1.5,           // Spend 1.5 SOL
  slippageTolerance: 1.0,   // 1% slippage tolerance
  priorityFee: "medium"     // Transaction priority
});

// Buy token with USD amount
const buyOrderUSD = await buyToken({
  mintAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
  usdAmount: 500,           // Spend $500 worth
  slippageTolerance: 0.5    // 0.5% slippage tolerance
});

console.log("Transaction ID:", buyOrder.txId);
console.log("Tokens Received:", buyOrder.tokensReceived);

sellToken

Sell a specified percentage of your token holdings with intelligent market timing analysis. Supports partial sales and complete position exits while providing real-time profit/loss calculations.

The function automatically calculates the optimal selling strategy based on current market conditions, liquidity availability, and your specified parameters for professional portfolio management.

// Sell percentage of holdings
const sellOrder = await sellToken({
  mintAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
  percentage: 50,           // Sell 50% of holdings
  slippageTolerance: 1.0,   // 1% slippage tolerance
  priorityFee: "high"       // High priority for faster execution
});

// Sell specific amount
const sellOrderAmount = await sellToken({
  mintAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
  tokenAmount: 1000,        // Sell exactly 1000 tokens
  slippageTolerance: 0.5
});

console.log("SOL Received:", sellOrder.solReceived);
console.log("Profit/Loss:", sellOrder.profitLoss);

startCopyTrading

Begin copying another wallet's trading activity with customizable parameters including investment limits, token filters, and risk management rules. Learn from successful traders while automating your execution.

Set up sophisticated copy trading strategies with position sizing, stop-loss rules, and token whitelisting to match your risk tolerance and investment goals while following proven traders.

// Start copy trading session
const copySession = await startCopyTrading({
  targetWallet: "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
  maxInvestmentPerTrade: 0.5,    // Max 0.5 SOL per trade
  totalMaxInvestment: 5.0,       // Max 5 SOL total exposure
  stopLossPercentage: 10,        // 10% stop loss
  takeProfitPercentage: 50,      // 50% take profit
  tokenWhitelist: [              // Only copy these tokens
    "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "So11111111111111111111111111111111111111112"
  ]
});

console.log("Copy Trading Session ID:", copySession.sessionId);
console.log("Status:", copySession.status);

stopCopyTrading

Safely terminate copy trading sessions while choosing how to handle your current positions. You can maintain copied positions independently or liquidate them according to your preferences.

This function provides flexibility in exit strategies, allowing you to stop copying while keeping profitable positions or completely exit all copied trades based on your investment strategy.

// Stop copy trading session
const stopResult = await stopCopyTrading({
  sessionId: "ct_12345abc",
  action: "maintain_positions"  // Keep current positions
});

// Stop and liquidate all positions
const liquidateResult = await stopCopyTrading({
  sessionId: "ct_12345abc",
  action: "liquidate_all",      // Sell all copied positions
  urgency: "normal"             // Normal liquidation speed
});

// Partial exit - keep profitable positions
const partialExit = await stopCopyTrading({
  sessionId: "ct_12345abc",
  action: "liquidate_losses",   // Only sell losing positions
  profitThreshold: 5           // Keep positions with >5% profit
});

console.log("Session stopped:", stopResult.success);

getCopyTradingSessions

View all your active copy trading sessions with detailed performance metrics, target wallets, and current profit/loss status. Essential for monitoring and managing multiple copy trading strategies.

Track the performance of each copied wallet, see which strategies are working best, and make informed decisions about continuing or modifying your copy trading approach.

// Get all copy trading sessions
const sessions = await getCopyTradingSessions({
  includeInactive: false  // Only active sessions
});

// Display session performance
sessions.forEach(session => {
  console.log("Session ID:", session.sessionId);
  console.log("Target Wallet:", session.targetWallet);
  console.log("Total P&L:", session.totalProfitLoss);
  console.log("Win Rate:", session.winRate);
  console.log("Active Positions:", session.activePositions);
  console.log("Total Invested:", session.totalInvested);
  console.log("ROI:", session.roi);
});

// Get detailed session
const detailedSession = await getCopyTradingSessions({
  sessionId: "ct_12345abc",
  includePositions: true
});

getCopyTradingTransactions

Access complete transaction history for your copy trading activities including entry and exit prices, timing analysis, and detailed performance metrics for each copied trade across all sessions.

Analyze your copy trading performance with comprehensive transaction data, identify the most successful copied strategies, and optimize your future copy trading decisions based on historical results.

// Get copy trading transaction history
const transactions = await getCopyTradingTransactions({
  sessionId: "ct_12345abc",
  limit: 50,
  includeOpen: true  // Include open positions
});

// Analyze transaction performance
transactions.forEach(tx => {
  console.log("Token:", tx.tokenSymbol);
  console.log("Type:", tx.type);        // "buy" or "sell"
  console.log("Entry Price:", tx.entryPrice);
  console.log("Exit Price:", tx.exitPrice);
  console.log("Profit/Loss:", tx.profitLoss);
  console.log("Hold Duration:", tx.holdDuration);
  console.log("Copy Delay:", tx.copyDelay);  // Delay from original trade
});

// Get performance summary
const summary = await getCopyTradingTransactions({
  summary: true,
  dateRange: "30d"
});