---
name: hyperdash-tax
description: Build a tax record of one or more Hyperliquid wallets with Hyperdash Data. Use when the user names wallets they say are theirs and asks for tax figures, cost basis, realized PnL, trading fees, funding, transfers or a yearly PnL report, or for CSVs to import into Awaken Tax. Covers spot, perps and HIP-3 perps. For one quick figure use the hyperdash-data skill instead.
license: Proprietary
compatibility: Needs network access to data.hyperdash.com, a Hyperdash Data workspace with an active plan, and an environment that can run code and write files.
metadata:
  version: "1.0"
  homepage: https://docs.hyperdash.com/data-api/skills
---

# Hyperdash Tax

A record of everything that happened in the user's Hyperliquid wallets over a period: trades, realized PnL, cost basis, fees, funding, transfers and vault results. It ends in a summary and CSVs that Awaken Tax can import.

**Read the Data skill first:** `https://docs.hyperdash.com/skills/data`. Its rules for connecting, time, coins, addresses, credits and errors all apply here. Three rules change: this job needs many calls, so run them in code and save every raw page to disk; plan every request inside the plan's history window (Step 2); and on MCP you may read the window from a `history_limit` error.

On MCP, tool names do not match the paths in this file. Search the tool list by keyword (for example "fills" or "ledger") and read the tool's description before you call it. A tax year is thousands of rows: if you can run code, use the REST API.

**This is not tax advice.** Report events and amounts. Never say what is taxable, which rate applies or what to file. The tags in the files are Awaken's import categories, not a tax opinion. Say this once in the summary and once in the files.

## Before you start

Ask for anything the user has not given, in one message:

- The wallets they say are theirs (full addresses).
- The period: a tax year or two dates.
- Their time zone. Cut the period at local midnight, or at the exact times the user gives, and say which zone you used.

Use FIFO for spot cost basis unless the user asks for HIFO, LIFO or average cost. Do not ask about it; state it in the summary.

## Step 1: The wallet group

1. Read `/v1/accounts/{address}/subaccounts` for each wallet. Sub-accounts belong to the wallet that created them: add them, and list them for the user to confirm.
2. The group is the named wallets plus their sub-accounts. Never add another wallet unless the user confirms it is theirs. Lowercase every address before you compare it.
3. A transfer between two wallets in the group is a self-transfer: it moves lots with their cost basis and acquisition dates, and it is neither income nor a disposal. A transfer with any wallet outside the group is a deposit or withdrawal.
4. List the outside wallets the group sent funds to or received them from (from the ledger in Step 3). Ask whether any are the user's. A transfer is evidence of a link, not proof of ownership.

## Step 2: The window

1. Find the plan's history depth. `GET /v1/me` returns `plan`: `lite` (Hobby) and `starter` reach 90 days back, `growth` 180, `scale` 365 and `pro` (Enterprise) all history. On MCP, or when `/v1/me` is not available, a request older than the window returns `403 history_limit`, and its `detail` says how far the plan reaches.
2. The window is rolling: it reaches back from the time of each request, not to the start of a calendar year. Start 10 minutes inside it, so later pages do not fall outside.
3. Data starts on these dates, on every plan: fills on 2025-03-22; staking history, and ledger rows other than USDC deposits, withdrawals and transfers, on 2025-09-27 10:00 UTC.
4. Covered start = the latest of the period start, the plan's floor and the dataset's start. Record every part of the period you cannot cover.
5. Spot cost basis needs the purchases. Pull fills, ledger and staking from the earliest date the plan reaches; pull funding and the check figure for the period only.
6. If the period starts before the plan's floor, name the lowest plan whose window reaches the period start (`https://docs.hyperdash.com/data-api/plans`). A tax year that has already ended usually needs Enterprise.

## Step 3: Pull the data

Per wallet in the group, in code. Step through the range in windows no longer than the per-call limit, each starting 1 ms after the last one ended. Follow `next_cursor` inside each window, sending the same `limit` with it (a cursor is tied to its query), and save every page. Always send `start_time` and `end_time`: the defaults are short. Send a `User-Agent` header that names your client: the default one of Python's `urllib` is blocked (`403` with `error code: 1010`).

| Data | Endpoint | Per call |
|---|---|---|
| Trades, fees, perp PnL | `/v1/accounts/{address}/fills` (raw fills, not `aggregate`) | 7 days |
| Funding | `/v1/accounts/{address}/funding` | 7 days |
| Deposits, withdrawals, transfers, vaults, borrow and lend, rewards, staking | `/v1/accounts/{address}/ledger` (no `include`) | 30 days |
| Delegations | `/v1/accounts/{address}/staking/history` | 365 days |
| Spot names | `/v1/spot/markets` (`coin` such as `@107` to `base` and `quote`) | One call |
| Check figure | `/v1/accounts/{address}/realized-pnl` with `interval=1h` | 90 days |

Dedupe fills on `time`, `coin`, `tid` and `side` together: TWAP fills share a zero `hash`, dust conversions all have `tid` `0`, and a fill against the wallet's own order has two sides. Dedupe funding on `time` plus `coin`. Drop exact duplicate ledger rows: one transfer can appear twice in a wallet's ledger, and a transfer inside the group appears in both wallets' ledgers.

## Step 4: Compute

**Sort the fills.** A `coin` starting with `#` is a HIP-4 outcome market: out of scope, so leave it out and count it in the gaps. A `coin` starting with `@` (or `PURR/USDC`) is spot. A `coin` with a dex prefix, such as `xyz:TSLA`, is a HIP-3 perp. Other coins are core perps. Sort by `time`. For fills that share a millisecond, chain them by `start_position`, the position or balance before each fill: the next fill is the one whose `start_position` equals the balance after the last.

**Perps.** Realized PnL is the sum of Hyperliquid's own `closed_pnl` over every perp fill, TWAP fills included. A fill is an opening fill only when `dir` starts with `Open`; every other perp fill is a closing fill, including one that flips the position (`Long > Short`). PnL and fees settle in the fill's `fee_token` (USDC, or another quote token such as USDH on some HIP-3 dexes). `builder_fee` and `deployer_fee` are already inside `fee`; a negative `fee` is a rebate. `priority_gas` is a separate HYPE cost: list it as not covered. The wallet was liquidated only where `liquidated_user` is the wallet itself; on other fills it names the wallet on the other side.

**Spot.** Build lots per wallet and token from buys and incoming transfers, then match sells and outgoing transfers with the user's method (FIFO by default). Cost basis and proceeds are `px` times `sz` in the quote token, before fees. A buy's fee is charged in the token received, so the lot holds `sz` minus the fee; in the import file, write the full `sz` as received and the fee in the fee columns. USDC and other perp quote tokens (such as USDH) are cash at face value, not lots: perp PnL, fees and funding also move them. Spot PnL is before fees, like perps: report fees once, under trading fees. `dir` `Spot Dust Conversion` is a sale. A trade between two cash tokens (USDH for USDC) is a swap at face value. A token received from outside the group is a lot with unknown cost basis: put the ledger's `usdc_value` in `Received Fiat Amount` as the value on receipt, or leave it blank when the value is 0. Spot fills also carry a `closed_pnl`: it is Hyperliquid's own figure, not a lot method, so it will not match FIFO. Do not use it.

**Lot check.** Before every spot fill, the wallet's lots in that token must hold its `start_position`. Lending moves count: supplied tokens leave the balance and return on withdraw. A difference under 0.001 is rounding. A larger shortfall is an opening balance or a missed transfer: add it as a lot with unknown cost basis, dated at the fill that needed it, and flag it.

**Funding.** One event per row: positive `usdc` was received, negative was paid, in the market's settlement token: the `fee_token` on that market's fills.

**Ledger.** Read each row's `details` JSON. The sender is `details.user`; the receiver is `destination`. A `send` whose `user` and `destination` are the same wallet moves funds between its own balances: not an event. The ledger of a vault's own address lists every depositor's vault moves: they are not that wallet's events.

| `type` | Event |
|---|---|
| `deposit`, `withdraw` | Deposit or withdrawal. A `withdraw`'s `usdc` is after its `fee` |
| `send`, `spotTransfer`, `subAccountTransfer`, `internalTransfer` | Self-transfer or outside transfer, by Step 1. A `fee` in `details.feeToken` is a cost only when the sender is in the group |
| `accountClassTransfer` | Spot to perp move inside one wallet: not an event |
| `vaultDeposit` | Moves funds into a vault: not an event |
| `vaultWithdraw` | Result = `netWithdrawnUsd` minus `basis`. `commission` and `closingCost` are already inside it: show them, never subtract them again. Count it only when `details.user` is the wallet |
| `borrowLend` | `operation` is `supply`, `withdraw`, `borrow` or `repay`. `interestAmount` on `withdraw` is interest earned, on `repay` interest paid, in the row's `token`; a `withdraw` `amount` includes it. Supplied principal keeps its lots; flag `borrow` and `repay` principal for review |
| `rewardsClaim` | Reward received |
| `cStakingTransfer` | HYPE moving between spot and staking (`isDeposit` true or false): a move |
| `liquidation` | No amount: the liquidation fills carry the PnL |
| Any other type | Keep it and flag it for review |

A `user` or `destination` of `0x2222222222222222222222222222222222222222`, or another system address starting `0x20000000`, is a move between the wallet's HyperCore and HyperEVM balances. HyperEVM is not covered: flag these rows.

**Staking.** Delegations, undelegations and staking moves are never disposals. Staking rewards are credited per validator, not per wallet, so they are not in the data: never estimate them. When more HYPE leaves staking (`cStakingTransfer`) than went in, and every deposit is inside the covered window, the difference is rewards received on unknown dates: report it, flag it and add it as a lot with unknown cost basis, dated at the withdrawal's `cStakingTransfer`. If a deposit may predate the window, say the split is unknown, add the excess as a lot with unknown cost basis and flag it `review`. In `staking/history` a withdrawal is listed twice: count only `finalized` true.

## Step 5: The files

Write the files for Awaken Tax, which takes two CSV formats: one for spot and transfers, one for perps. Header rows must match exactly, in this order, with no extra columns. `Date` is UTC, `MM/DD/YYYY HH:MM:SS`. Amounts are plain numbers with at most 8 decimals and no thousands separators. Leave a hash blank when it is all zeros.

**`awaken-<period>.csv`** holds every spot fill, every transfer of a token other than USDC and every opening lot from the earliest date pulled, so Awaken can rebuild cost basis, and the other events below for the period only. Rows before the period never count in the period's figures.

`Date`, `Received Quantity`, `Received Currency`, `Received Fiat Amount`, `Sent Quantity`, `Sent Currency`, `Sent Fiat Amount`, `Fee Amount`, `Fee Currency`, `Transaction Hash`, `Notes`, `Tag`

| Event | Row | `Tag` |
|---|---|---|
| Spot trade, dust conversion | Received the full `sz` or the quote amount, sent the other; fee in the fee columns | `swap` |
| Deposit, withdrawal, outside transfer | One side only; `Sent Quantity` excludes the fee | Blank |
| Opening lot | Received; `Received Fiat Amount` blank | Blank |
| Vault withdrawal result | Received the gain, or sent the loss, in USDC | Blank, with `Notes` "vault result" |
| Lending interest | Received when earned, sent when paid | Blank, with `Notes` "lending interest" |
| Reward | Received | `rewards_income` |
| Staking excess | Received HYPE | `claim_rewards` |

The fiat columns hold the USD value: stablecoins at face value, spot trades at the fill's quote value, blank when unknown.

**`awaken-perps-<period>.csv`** holds every perp fill and funding row in the period.

`Date`, `Asset`, `Amount`, `Fee`, `P&L`, `Payment Token`, `ID`, `Notes`, `Tag`, `Transaction Hash`

| Event | Row | `Tag` |
|---|---|---|
| Opening fill | `Asset` the coin, `Amount` the `sz` (negative on a sell), `Fee` the `fee`, `P&L` 0, `Payment Token` the `fee_token` | `open_position` |
| Closing fill | The same, with `P&L` the `closed_pnl` | `close_position`, or `liquidation` when the wallet itself was liquidated |
| Funding | `Asset` and `Payment Token` the settlement token, `Amount` the size of the payment, `Fee` 0, `P&L` the signed `usdc`, the market in `Notes` | `funding_payment` |

`ID` is `tid` and `side` joined by a dash. A rebate is a negative `Fee`.

Treat the group as one wallet in the import: self-transfers stay out of both files and go in the summary. Vault deposits, principal of borrow and lend, staking and class moves are not rows: count them in the summary.

**`tax-<period>-detail.csv`** is the audit file, one row per event in either Awaken file: `Date`, `Wallet` (full address), `Event`, `Market`, `Amount`, `Currency`, `Cost Basis USD`, `Proceeds USD`, `Realized PnL USD`, `In Period` (`yes` or `no`), `Method` (`FIFO`, `HIFO`, `LIFO` or `AVERAGE` on spot rows, `HL_CLOSED_PNL` on perp rows) and `Flag` (`basis_unknown`, `liquidation`, `hyperevm`, `staking_reward` or `review`).

Write `README.txt` next to the CSVs: the not-tax-advice line, the method, the covered window, the full gap list with dates, a note that lots are matched per wallet so Awaken's pooled figures can differ, and a note that rows with a blank `Tag` land in Awaken's review queue to label. Write money as `100 USD`. Import files cannot carry these notes.

## Step 6: Check before you answer

- Perp `closed_pnl` minus perp fees plus funding equals `/v1/accounts/{address}/realized-pnl` over the same window, per wallet, within a few cents, with every quote token at face value. Call it with `interval=1h` and `start_time` at the covered start, in pieces of up to 90 days: each series starts at 0, so its last point is that piece's total. It counts one side of a fill against the wallet's own order, and before 2025-09-27 10:00 UTC it books funding when a trade closes: explain either difference. That endpoint needs the `analytics:read` scope; skip the check without it and say so.
- Every spot lot check passed or is flagged.
- The Awaken files' row counts equal the events you computed, and the detail file matches them.

## The answer

1. **Scope:** the wallets as full linked addresses, the period and time zone, the window the data covers, and the spot method.
2. **Table:** one row per wallet and a group total: realized perp PnL, realized spot PnL, trading fees, net funding, vault results, interest, rewards, deposits and withdrawals.
3. **Self-transfers and staking moves:** count and totals, outside the figures.
4. **Not covered:** each item, or "none": dates before the plan's window or the dataset start, spot lots with unknown cost basis, staking rewards, priority gas, HIP-4 outcome fills (with the count), HyperEVM activity, rows flagged for review.
5. **Files written**, and the not-tax-advice line.
6. **Next steps:** two or three, such as filling in unknown cost basis, confirming flagged wallets, or the plan that reaches the period start.
