Get Wallet Position History
Wallet APIs
Get Wallet Position History
Replay every swap for a (wallet, token) pair and split the trading history into position cycles, each with its own realized PnL. The last cycle is flagged isOpen=true when still active and carries unrealizedPnlUSD.
GET
Get Wallet Position History
What is a “cycle”?
Existing/wallet/position and /wallet/positions endpoints return the lifetime aggregate for a wallet+token pair (sum of all buys, sum of all sells, one blended avg price). That’s great for “what did I do overall”, but it hides the fact that most traders buy → fully sell → buy again → fully sell, and each of those is a distinct trade with its own PnL.
A cycle is exactly that: a contiguous run of trades that opens on the first buy after a flat (zero-balance) state and closes when the cumulative token balance falls back to ≈ 0. Formally, a cycle is considered closed when the remaining balance ≤ 0.1% of the max balance reached within the cycle, so residual dust from rounding doesn’t keep cycles open forever.
If the most recent cycle hasn’t closed yet, it’s returned with isOpen: true and a non-zero unrealizedPnlUSD computed from the wallet’s current remaining balance × the token’s live price.
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
wallet | string | Yes | Wallet address. |
asset | string | Yes | Token contract address. |
blockchain | string | Yes | Blockchain name or chain ID (e.g. solana, ethereum, evm:8453). |
Usage Example
Sample Response
Field semantics
| Field | Meaning |
|---|---|
isOpen | true if the last cycle has not yet returned to dust balance. |
entryDate / exitDate | First and last swap in the cycle. exitDate is null when isOpen: true. |
buys / sells | Buy and sell swap counts within this cycle only. |
volumeBuyToken / volumeSellToken | Cumulative token amounts bought / sold in the cycle. |
volumeBuyUSD / volumeSellUSD | Cumulative USD value paid / received. |
avgBuyPriceUSD / avgSellPriceUSD | Volume-weighted average buy / sell unit price within the cycle. |
realizedPnlUSD | (avgSellPriceUSD − avgBuyPriceUSD) × min(volumeSellToken, volumeBuyToken). For a cleanly closed cycle this equals volumeSellUSD − volumeBuyUSD. |
unrealizedPnlUSD | Open cycles only: remainingBalance × (currentPriceUSD − avgBuyPriceUSD). 0 for closed cycles. |
totalPnlUSD | realizedPnlUSD + unrealizedPnlUSD. |
remainingBalance | Tokens still held at the cycle’s end. 0 for closed cycles (within dust tolerance). |
currentPriceUSD | Live unit price used to compute unrealizedPnlUSD. null for closed cycles. |
feesUSD | Sum of gas + platform + mev fees paid across all swaps in the cycle. |
swapCount | Total number of swaps that touched this cycle. |
Orphaned sells that happen before any buy (for example, a token received via a raw transfer and later dumped) have no cost basis and are skipped — they cannot open a cycle.
SDK Usage
Related Endpoints
/wallet/position— lifetime aggregate for a wallet+token./wallet/positions-history— paginated closed cycles across all tokens held by a wallet.