> For the complete documentation index, see [llms.txt](https://hydromancer.xyz/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hydromancer.xyz/docs/rest-api/fees/referral.md). Agents can also search and read this documentation through its [MCP server](https://hydromancer.xyz/docs/~gitbook/mcp).

# referral

A Hyperliquid user's referrer, volume, and unclaimed, claimed and builder rewards per token.

Returns a user's referral and builder reward state: who referred them, their volume, and their unclaimed, claimed and builder rewards, in total for USDC and per collateral token.

The request and field names match Hyperliquid's `referral` info type, with two differences:

{% hint style="warning" %}
The amounts are based on snapshots taken roughly every 12 minutes. You can use `snapshotTime` to show users how recent the data is.
{% endhint %}

{% hint style="info" %}
`referrerState` and `rewardHistory` are not returned at this time.
{% endhint %}

## POST Request

<table><thead><tr><th width="180">Field</th><th width="105">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td>string</td><td>Must be <code>"referral"</code></td></tr><tr><td><code>user</code></td><td>string</td><td>Ethereum address: <code>0x</code> followed by 40 hex digits, in either case</td></tr></tbody></table>

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X POST https://api.hydromancer.xyz/info \
  -H "Authorization: Bearer $HYDROMANCER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"type": "referral", "user": "0x1234567890abcdef1234567890abcdef12345678"}'
```

{% endtab %}

{% tab title="Python" %}

```python
import os
import requests

response = requests.post(
    "https://api.hydromancer.xyz/info",
    headers={"Authorization": f"Bearer {os.environ['HYDROMANCER_API_KEY']}"},
    json={"type": "referral", "user": "0x1234567890abcdef1234567890abcdef12345678"},
)
response.raise_for_status()
state = response.json()
print(state["unclaimedRewards"], state["snapshotTime"])
```

{% endtab %}
{% endtabs %}

## Response

<table><thead><tr><th width="200">Field</th><th width="130">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>referredBy</code></td><td>object | null</td><td>The user's referrer as <code>{"referrer": address, "code": string}</code>, or <code>null</code> if the user was not referred</td></tr><tr><td><code>cumVlm</code></td><td>string</td><td>USDC volume</td></tr><tr><td><code>unclaimedRewards</code></td><td>string</td><td>USDC rewards not yet claimed</td></tr><tr><td><code>claimedRewards</code></td><td>string</td><td>USDC rewards already claimed</td></tr><tr><td><code>builderRewards</code></td><td>string</td><td>USDC builder fees collected</td></tr><tr><td><code>tokenToState</code></td><td>array</td><td>The same four amounts per collateral token, as <code>[tokenId, amounts]</code> pairs ordered by token id</td></tr><tr><td><code>snapshotTime</code></td><td>integer</td><td>Block time of the snapshot these values come from, in Unix milliseconds</td></tr></tbody></table>

```json
{
  "referredBy": {
    "referrer": "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",
    "code": "EXAMPLE"
  },
  "cumVlm": "152340.75",
  "unclaimedRewards": "12.5031",
  "claimedRewards": "48.2",
  "builderRewards": "60.7031",
  "tokenToState": [
    [0, {"cumVlm": "152340.75", "unclaimedRewards": "12.5031", "claimedRewards": "48.2", "builderRewards": "60.7031"}],
    [360, {"cumVlm": "8120.4", "unclaimedRewards": "1.75", "claimedRewards": "0.0", "builderRewards": "1.75"}]
  ],
  "snapshotTime": 1794689881053
}
```

### Tokens

The four top-level amounts are the **USDC** values only, as on Hyperliquid. Rewards and volume in other collateral tokens appear only in `tokenToState`, so sum across its rows if you need every token. Token ids are Hyperliquid spot token indexes:

| Token id | Token |
| -------- | ----- |
| `0`      | USDC  |
| `235`    | USDe  |
| `268`    | USDT0 |
| `360`    | USDH  |

A token appears once the user has state in it; new collateral tokens show up with their own id.

### Notes

* Amounts are decimal strings with trailing zeros removed and at least one decimal place (`"0.0"`, `"48.2"`).
* A user with no referral state gets `referredBy: null`, `"0.0"` amounts and an empty `tokenToState`.
* A user who can no longer be referred has `referredBy` set to the zero address with code `"N/A"`.
* A referrer without a code has `code: ""`.
* `code` is free text chosen by the referrer. Escape it before putting it in HTML, a shell command or a query.
* `cumVlm` is exact to the cent. Hyperliquid's own response can show floating-point noise in this field (for example `"1976518.1899999999"` where we return `"1976518.19"`).

## Rate limits and cost

2 points per request, the default weight (see [rate limits](https://hydromancer.xyz/docs/rest-api/rate-limits-and-user-limits.md)), and 0.1 tokens per request (see [pricing](https://hydromancer.xyz/docs/pricing.md)).

## Errors

Errors use the structured format (`error`, `code`, `correlationId`) without needing the `X-HM-Error-Format` header.

| Status | `code`            | When                                                                                |
| ------ | ----------------- | ----------------------------------------------------------------------------------- |
| `400`  | `invalid_request` | `user` is missing or is not a valid address                                         |
| `503`  | `unavailable`     | No snapshot is loaded yet. Retry in a few minutes; a `503` never means zero rewards |
