| name | wallet-analytics |
| description | Analyze Polymarket wallet performance, positions, and trading activity. Use this skill when the user wants to analyze a trader's performance, get wallet positions, calculate PnL, or identify smart money wallets. Triggers include phrases like "analyze wallet", "trading performance", "wallet PnL", "positions", "smart money", or "trader analysis". |
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";
const wallet = await fetchWalletInfo(apiKey, {
proxy: "0x...",
with_metrics: true
});
const positions = await fetchAllPositions(apiKey, wallet.proxy);
const pnl = await fetchWalletPnL(apiKey, wallet.proxy, {
granularity: "day"
});
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...",
with_metrics: true,
start_time: 1700000000,
end_time: 1700000000
});
fetchPositions()
Fetch wallet positions with pagination.
const result = await fetchPositions(apiKey, walletAddress, {
limit: 100
});
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",
start_time: 1700000000,
end_time: 1700000000
});
calculateTradingPerformance()
Calculate comprehensive trading metrics.
const performance = calculateTradingPerformance(pnlPeriods);
calculateSharpeRatio()
Calculate risk-adjusted returns.
const sharpe = calculateSharpeRatio(returns, riskFreeRate);
getPositionSummary()
Summarize positions by status and side.
const summary = getPositionSummary(positions);
analyzeSmartMoneyIndicators()
Analyze smart money characteristics.
const indicators = analyzeSmartMoneyIndicators(parsedWallet, performance);
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.