> ## Documentation Index
> Fetch the complete documentation index at: https://docs.leokit.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# NEAR Earnings

> Affiliate fees collected by leodex.near from the NEAR Intents ecosystem

## Endpoint

```
GET /leokit/explorer/near-earnings
```

No authentication required. Cached for 10 minutes.

## Overview

`leodex.near` is the LeoFinance fee-collection account for NEAR Intents. Incoming fungible-token (FT) transfers from `intents.near` to `leodex.near` represent affiliate fee payments. This endpoint aggregates all such transfers from NearBlocks (paginated until exhausted) and groups them by token contract.

USD value is computed for stablecoin contracts (USDT, USDC). Other tokens have `usd_value: 0` since their on-chain price is not resolved here.

## Response

```json theme={null}
{
  "data": {
    "generated_at": "2026-04-28T12:00:00.000Z",
    "total_usd": 18230.55,
    "tokens": [
      {
        "token": "USDT",
        "contract": "usdt.tether-token.near",
        "amount": 12480.55,
        "decimals": 6,
        "usd_value": 12480.55,
        "tx_count": 482,
        "latest_tx": "abc123...",
        "latest_date": "2026-04-28T11:32:11.000Z"
      },
      {
        "token": "USDC",
        "contract": "17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1",
        "amount": 5750.00,
        "decimals": 6,
        "usd_value": 5750.00,
        "tx_count": 215,
        "latest_tx": "def456...",
        "latest_date": "2026-04-28T11:30:01.000Z"
      }
    ],
    "total_incoming_txs": 697
  }
}
```

## Field Reference

| Field                | Description                                             |
| -------------------- | ------------------------------------------------------- |
| `generated_at`       | When this snapshot was built (ISO-8601)                 |
| `total_usd`          | Sum of `usd_value` across all token entries             |
| `total_incoming_txs` | Count of qualifying FT transfers (across all tokens)    |
| `tokens[]`           | Per-token aggregation, sorted by `usd_value` descending |

#### `tokens[i]`

| Field         | Description                                              |
| ------------- | -------------------------------------------------------- |
| `token`       | Token symbol from NearBlocks metadata                    |
| `contract`    | NEAR account ID of the token contract                    |
| `amount`      | Total received in human-readable units                   |
| `decimals`    | Token decimals                                           |
| `usd_value`   | USD value (only computed for stablecoins; `0` otherwise) |
| `tx_count`    | Transfer count for this token                            |
| `latest_tx`   | Most recent transaction hash                             |
| `latest_date` | Timestamp of `latest_tx` (ISO-8601)                      |

## Caching

`X-Cache: HIT|MISS`. TTL 10 minutes.

## Errors

| Status | Description            |
| ------ | ---------------------- |
| `500`  | NearBlocks API failure |

## Notes

* The cache key is shared with `/leokit/explorer/stats` (`near_ecosystem_fees_usd`) and `/leokit/explorer/analytics` (`summary.near_ecosystem_fees_usd`).
* Pagination uses NearBlocks' `page` parameter; the loop stops when a page returns fewer than 100 results.
* Only `cause === "TRANSFER"` events from `involved_account_id === "intents.near"` are counted as fee transfers.


## OpenAPI

````yaml /api-reference/openapi.json GET /explorer/near-earnings
openapi: 3.0.3
info:
  title: Leokit API
  version: 1.0.0
  description: API reference for Leokit
servers:
  - url: https://api.leokit.dev
    description: Production
security:
  - ApiKeyAuth: []
paths:
  /explorer/near-earnings:
    get:
      summary: NEAR-ecosystem affiliate earnings
      responses:
        '200':
          description: Aggregated FT transfers from intents.near to leodex.near.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExplorerNearEarningsResponse'
      security:
        - {}
components:
  schemas:
    ExplorerNearEarningsResponse:
      type: object
      required:
        - data
      properties:
        data:
          type: object
          properties:
            generated_at:
              type: string
              format: date-time
            total_usd:
              type: number
            tokens:
              type: array
              items:
                type: object
                properties:
                  token:
                    type: string
                  contract:
                    type: string
                  amount:
                    type: number
                  decimals:
                    type: integer
                  usd_value:
                    type: number
                  tx_count:
                    type: integer
                  latest_tx:
                    type: string
                  latest_date:
                    type: string
                    format: date-time
            total_incoming_txs:
              type: integer
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Api-Key
      description: 'Demo API-Key (Sandbox): 7037d2b3-9c76-4f62-b730-c544f7570fa4'

````