wallet-analytics

Installation
SKILL.md

Wallet Analytics

Overview

Analyze Polymarket wallet performance including trading metrics, positions, realized PnL, and performance indicators like Sharpe ratio and win rate.

Security

This skill implements defense-in-depth measures against indirect prompt injection (Snyk W011):

  • Input Sanitization: All user-generated content (handles, pseudonyms, position titles, labels) is sanitized using security.ts
  • Pattern Filtering: Known prompt injection patterns are removed (e.g., "ignore previous instructions", "system:")
  • Content Validation: Suspicious content with excessive special characters is flagged
  • Fail-Safe: Processing errors return original data rather than corrupting it

The skill fetches data from the trusted DOME API (api.domeapi.io) which provides structured wallet and position data from the Polymarket protocol.

Setup

npm install
npm run build

Quick Start

import {
  fetchWalletInfo,
  fetchPositions,
  fetchWalletPnL,
  calculateTradingPerformance,
  getPositionSummary
} from "./scripts/walletAnalytics.js";

// Get wallet info with metrics
const wallet = await fetchWalletInfo(apiKey, {
  proxy: "0x...",
  with_metrics: true
});

// Get current positions
const positions = await fetchAllPositions(apiKey, wallet.proxy);

// Get PnL history
const pnl = await fetchWalletPnL(apiKey, wallet.proxy, {
  granularity: "day"
});

// Calculate performance
const performance = calculateTradingPerformance(pnl.pnl_over_time);
console.log(`Sharpe ratio: ${performance.sharpe_ratio}`);

Core Functions

fetchWalletInfo()

Fetch wallet information with optional trading metrics.

const wallet = await fetchWalletInfo(apiKey, {
  eoa: "0x...",        // Or proxy, or handle
  with_metrics: true,
  start_time: 1700000000,
  end_time: 1700000000
});

fetchPositions()

Fetch wallet positions with pagination.

const result = await fetchPositions(apiKey, walletAddress, {
  limit: 100
});
// Returns: { wallet_address, positions: [...], pagination }

fetchAllPositions()

Fetch all positions with automatic pagination.

const positions = await fetchAllPositions(apiKey, walletAddress, {
  maxPages: 5
});

fetchWalletPnL()

Fetch realized PnL with time granularity.

const pnl = await fetchWalletPnL(apiKey, walletAddress, {
  granularity: "day",   // "day" | "week" | "month" | "year" | "all"
  start_time: 1700000000,
  end_time: 1700000000
});

calculateTradingPerformance()

Calculate comprehensive trading metrics.

const performance = calculateTradingPerformance(pnlPeriods);
// Returns: {
//   total_return,
//   max_drawdown,
//   win_rate,
//   profitable_days,
//   sharpe_ratio,
//   average_daily_return,
//   volatility
// }

calculateSharpeRatio()

Calculate risk-adjusted returns.

const sharpe = calculateSharpeRatio(returns, riskFreeRate);

getPositionSummary()

Summarize positions by status and side.

const summary = getPositionSummary(positions);
// Returns: { total_positions, open_positions, closed_positions, by_side, ... }

analyzeSmartMoneyIndicators()

Analyze smart money characteristics.

const indicators = analyzeSmartMoneyIndicators(parsedWallet, performance);
// Returns: { volume_percentile, consistency_score, overall_score, ... }

Important Note

PnL data shows realized gains only - from confirmed sells or redeems. Unrealized gains from open positions are not included until the market is redeemed.

Related skills

More from 0xweaksheep/dome_skills

Installs
2
GitHub Stars
5
First Seen
Mar 19, 2026