PnL calculator

Endpoints for calculating performance metrics like PnL and monitoring API usage patterns.

Calculate PnL (POST /api/analytics/pnl)

Calculates the Profit and Loss (PnL) for a specific SPL token within a Solana wallet over a defined period, analyzing transaction history.

Request Endpoint: POST /api/analytics/pnl

Request Body: application/json

{
  "walletAddress": "user_wallet_address",
  "tokenAddress": "token_mint_address",
  "accountIndex": 0, // Usually 0, for specific account derivation paths
  "startDate": "2023-01-01T00:00:00.000Z", // ISO 8601 format
  "endDate": "2023-12-31T23:59:59.999Z"   // ISO 8601 format
}

Success Response (200 OK): Returns detailed PnL data.

{
  "success": true,
  "pnl": { /* Object containing realized/unrealized PnL, costs, proceeds, etc. */ },
  "details": { /* Supporting summary data */ }
}

Common Errors:

  • 500 Internal Server Error: Calculation failure (e.g., cannot fetch or parse transaction history, RPC errors).

Last updated