# Wallet PnL Analyzer — On-Chain Profit & Loss by Address (`gochujang/wallet-pnl-analyzer`) Actor

On-demand wallet analysis: full ERC20 transfer history, per-token positions, current USD value via DexScreener, top 10 holdings. Supports Ethereum, Base, Arbitrum, Optimism, Polygon, BSC. PPE $0.05 per wallet analyzed. No subscription.

- **URL**: https://apify.com/gochujang/wallet-pnl-analyzer.md
- **Developed by:** [Hojun Lee](https://apify.com/gochujang) (community)
- **Categories:** Developer tools, Automation, Other
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Wallet PnL Analyzer

> On-demand wallet analysis: full ERC20 history, per-token positions, current USD value, top holdings. **Free Zerion / Debank alternative.** Pay $0.05 per analysis, no subscription.

---

### Why this exists

You want to analyze a wallet — your own, a competitor's, a whale's — and the options are:
- **Etherscan UI**: free, but no PnL, no current portfolio value
- **Zerion**: $15/mo, paywalls the API
- **Debank Pro**: gated, scrapes blocked
- **Nansen**: $150/mo, mostly aggregate data

This actor takes one wallet address, pulls every ERC20 transfer from Etherscan V2, builds a per-token ledger, prices open positions via DexScreener, and returns a clean PnL report — for **$0.05**.

---

### Supported chains

| Chain | Status |
|---|---|
| Ethereum | ✅ |
| Base | ✅ |
| Arbitrum | ✅ |
| Optimism | ✅ |
| Polygon | ✅ |
| BSC | ✅ |

---

### What you get

#### 1. Summary row
```json
{
  "_type": "summary",
  "wallet": "0xd8da...96045",
  "chain": "ethereum",
  "total_transfers": 1247,
  "unique_tokens": 38,
  "open_position_count": 12,
  "current_portfolio_value_usd": 4250120.50,
  "top_10_holdings": [
    {"symbol": "USDC", "qty": 2000000, "value_usd": 2000000},
    {"symbol": "WETH", "qty": 850, "value_usd": 2028500},
    ...
  ]
}
````

#### 2. One row per token

```json
{
  "_type": "token_position",
  "token_symbol": "WETH",
  "token_name": "Wrapped Ether",
  "token_address": "0xc02aaa39...",
  "buy_count": 23,
  "sell_count": 18,
  "transfers_in": 23,
  "transfers_out": 18,
  "total_buy_qty": 1200.5,
  "total_sell_qty": 350.0,
  "net_qty": 850.5,
  "current_price_usd": 2385.0,
  "current_value_usd": 2028442.5,
  "first_seen_ts": 1707000000,
  "last_seen_ts":  1717999999
}
```

***

### Quick start

#### Analyze Vitalik's main wallet on Ethereum

```json
{
  "walletAddress": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
  "chain": "ethereum"
}
```

#### Analyze a Base wallet, filter dust

```json
{
  "walletAddress": "0x...",
  "chain": "base",
  "minHoldingUsd": 100
}
```

#### Analyze multiple chains

Run the actor 6 times (one per chain) and merge results — each costs $0.05.

***

### Pricing

**Pay-Per-Event**: `$0.05 per wallet analyzed.`

Flat fee per run regardless of transfer count. Vs:

- Zerion API: $15/mo (subscription)
- Debank Pro: $40/mo
- Nansen: $150/mo

If you analyze fewer than 300 wallets/mo, this actor is cheaper than any subscription.

***

### How it works

1. **Etherscan V2 tokentx** — page through all ERC20 transfers (up to 10K) for the wallet
2. **Build buy/sell ledger** per token from incoming vs outgoing transfers
3. **DexScreener price lookup** for open positions (max-liquidity pair on the target chain)
4. **Aggregate** per-token totals + top-10 holdings + summary
5. **Push rows** with `_type: "summary"` or `_type: "token_position"` for easy filtering

***

### Limitations & honest disclosure

- **No native ETH/MATIC/BNB tracking** in this version — only ERC20s. Native PnL coming in v0.2.
- **No swap-level matching** — counts buys / sells based on transfer direction, not actual DEX swap matching. Tokens received via airdrop will count as a "buy" with cost-basis 0.
- **No realized PnL with cost basis** — net\_qty + current\_value gives you portfolio snapshot, not historical realized PnL. Cost-basis tracking with cross-token swap matching is v0.3.
- **Prices via DexScreener** — for highly illiquid or new tokens, may be stale or absent.

For more sophisticated PnL (cross-token matching, FIFO cost basis, capital gains tax reports), use CoinTracker or Koinly.

***

### Related actors (same author)

- [Smart Money Wallet Tracker](https://apify.com/gochujang/smart-money-tracker) — Find smart wallets, then analyze them here
- [DeFi Liquidation Risk Checker](https://apify.com/gochujang/defi-liquidation-risk-checker) — Check Aave/Compound positions on the same wallet
- [Hyperliquid Whale Tracker](https://apify.com/gochujang/hyperliquid-whale-tracker) — Perp side
- [Token Holder Tracker](https://apify.com/gochujang/token-holder-tracker)

***

### Feedback

A short review helps other crypto analysts find it: [Leave a review on Apify Store](https://apify.com/gochujang/wallet-pnl-analyzer#reviews)

# Actor input Schema

## `walletAddress` (type: `string`):

EVM wallet address (0x...).

## `chain` (type: `string`):

EVM chain to analyze.

## `priceCurrentHoldings` (type: `boolean`):

Fetch current USD price for each open position via DexScreener.

## `minHoldingUsd` (type: `integer`):

Skip positions worth less than this USD value. 0 = include all.

## `etherscanApiKey` (type: `string`):

Bring your own Etherscan V2 key for higher rate limits. Default works for low volume.

## `telegramBotToken` (type: `string`):

Telegram bot token for summary notification.

## `telegramChatId` (type: `string`):

Chat ID.

## Actor input object example

```json
{
  "walletAddress": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
  "chain": "ethereum",
  "priceCurrentHoldings": true,
  "minHoldingUsd": 0,
  "telegramChatId": ""
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

## `summary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "walletAddress": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
};

// Run the Actor and wait for it to finish
const run = await client.actor("gochujang/wallet-pnl-analyzer").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "walletAddress": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" }

# Run the Actor and wait for it to finish
run = client.actor("gochujang/wallet-pnl-analyzer").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "walletAddress": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
}' |
apify call gochujang/wallet-pnl-analyzer --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=gochujang/wallet-pnl-analyzer",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Wallet PnL Analyzer — On-Chain Profit & Loss by Address",
        "description": "On-demand wallet analysis: full ERC20 transfer history, per-token positions, current USD value via DexScreener, top 10 holdings. Supports Ethereum, Base, Arbitrum, Optimism, Polygon, BSC. PPE $0.05 per wallet analyzed. No subscription.",
        "version": "0.1",
        "x-build-id": "J3VW2EAqjvbY6d7Bj"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/gochujang~wallet-pnl-analyzer/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-gochujang-wallet-pnl-analyzer",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/gochujang~wallet-pnl-analyzer/runs": {
            "post": {
                "operationId": "runs-sync-gochujang-wallet-pnl-analyzer",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/gochujang~wallet-pnl-analyzer/run-sync": {
            "post": {
                "operationId": "run-sync-gochujang-wallet-pnl-analyzer",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "walletAddress"
                ],
                "properties": {
                    "walletAddress": {
                        "title": "Wallet address",
                        "pattern": "^0x[a-fA-F0-9]{40}$",
                        "type": "string",
                        "description": "EVM wallet address (0x...)."
                    },
                    "chain": {
                        "title": "Chain",
                        "enum": [
                            "ethereum",
                            "base",
                            "arbitrum",
                            "optimism",
                            "polygon",
                            "bsc"
                        ],
                        "type": "string",
                        "description": "EVM chain to analyze.",
                        "default": "ethereum"
                    },
                    "priceCurrentHoldings": {
                        "title": "Price open positions",
                        "type": "boolean",
                        "description": "Fetch current USD price for each open position via DexScreener.",
                        "default": true
                    },
                    "minHoldingUsd": {
                        "title": "Min holding (USD)",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Skip positions worth less than this USD value. 0 = include all.",
                        "default": 0
                    },
                    "etherscanApiKey": {
                        "title": "Etherscan API key (optional)",
                        "type": "string",
                        "description": "Bring your own Etherscan V2 key for higher rate limits. Default works for low volume."
                    },
                    "telegramBotToken": {
                        "title": "Telegram Bot Token",
                        "type": "string",
                        "description": "Telegram bot token for summary notification."
                    },
                    "telegramChatId": {
                        "title": "Telegram Chat ID",
                        "type": "string",
                        "description": "Chat ID.",
                        "default": ""
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
