# DEX Funding Rate Aggregator (`yyber/dex-funding-aggregator`) Actor

Aggregate perpetual funding rates across Hyperliquid, Aster, Lighter, and Pacifica with Binance/Bybit as CEX reference. Spot DEX-vs-CEX funding spreads and cross-venue carry-trade signals. No API key required.

- **URL**: https://apify.com/yyber/dex-funding-aggregator.md
- **Developed by:** [YY](https://apify.com/yyber) (community)
- **Categories:** Agents, Integrations, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## DEX Funding Rate Aggregator

> **The first Actor on Apify Store dedicated to DEX perpetual funding rates.**  
> Aggregate live funding rates across Hyperliquid, Aster, Lighter, and Pacifica — with Binance and Bybit as CEX benchmarks — in a single call. No API key required.

---

### The Problem

DEX perpetual funding rates are scattered across 4+ different chains and APIs with no unified view. A trader trying to find carry-trade opportunities must manually check Hyperliquid (Ethereum L1), Aster (BNB Chain), Lighter (Ethereum ZK L2), and Pacifica (Solana) — all with different data formats and funding intervals.

Meanwhile, DEX funding rates routinely diverge from CEX (Binance/Bybit) by **10–20% APR** — a real, recurring arbitrage opportunity that goes undetected without cross-venue aggregation.

### The Solution

This Actor fetches, normalizes, and compares funding rates across **6 venues in one call**, surfacing:

- 🏆 **Best carry-trade pair**: which venue to long, which to short
- 📊 **Cross-venue spread**: total APR captured by holding both sides
- 📡 **DEX-vs-CEX spread**: how much DEX funding deviates from CEX baseline

**Live example output** (real data, June 20 2026):

| Symbol | Best Long | Best Short | Spread APR |
|--------|-----------|------------|------------|
| ETH | Pacifica (−9.6%) | Hyperliquid (+11.0%) | **20.5%** |
| SOL | Binance (−7.2%) | Hyperliquid (+11.0%) | **18.1%** |
| BTC | Pacifica (−7.3%) | Hyperliquid (+8.3%) | **15.6%** |

A 20% APR spread on ETH means: long ETH on Pacifica (receive 9.6% APR from shorts), short ETH on Hyperliquid (receive 11.0% APR from longs) = **20.6% annualized yield**, delta-neutral.

---

### What It Does

1. **Fetches** live funding rates from 6 venues in parallel
2. **Normalizes** all rates to APR% (accounts for different settlement intervals: 1h vs 8h)
3. **Computes** cross-venue spread, DEX-vs-CEX spread, best long/short venue per symbol
4. **Filters & sorts** by spread size or absolute funding magnitude
5. **Alerts** via Telegram when funding exceeds your threshold

---

### Platforms Covered

| Platform | Type | Chain | Funding Interval |
|----------|------|-------|-----------------|
| Hyperliquid | DEX | Own L1 | 1h |
| Aster | DEX | Multi-chain (BNB Chain + Aster Chain L1) | 8h |
| Lighter | DEX | Ethereum ZK L2 | 8h |
| Pacifica | DEX | Solana | 1h |
| Binance | CEX reference | — | 8h |
| Bybit | CEX reference | — | 8h |

*All endpoints are public. No API keys required.*

---

### Input

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `symbols` | string[] | `["BTC","ETH","SOL"]` | Symbols to track |
| `includeHyperliquid` | boolean | true | |
| `includeAster` | boolean | true | |
| `includeLighter` | boolean | true | |
| `includePacifica` | boolean | true | |
| `includeBinance` | boolean | true | CEX reference |
| `includeBybit` | boolean | true | CEX reference |
| `minAbsFundingApr` | number | 0 | Filter: skip if max \|APR\| below this |
| `minVenueSpreadApr` | number | 0 | Filter: skip if spread below this |
| `sortBy` | string | `spread_desc` | `spread_desc` / `abs_funding_desc` / `symbol_asc` |
| `alertAbsApr` | number | 0 | Telegram alert threshold (0 = disabled) |
| `telegramBotToken` | string (secret) | — | |
| `telegramChatId` | string | — | |

#### Example: Find all symbols with spread > 5% APR
```json
{
  "symbols": ["BTC", "ETH", "SOL"],
  "minVenueSpreadApr": 5,
  "sortBy": "spread_desc"
}
````

#### Example: Telegram alert when funding goes extreme

```json
{
  "symbols": ["BTC", "ETH", "SOL"],
  "alertAbsApr": 30,
  "telegramBotToken": "<token>",
  "telegramChatId": "<chat_id>"
}
```

***

### Output

Each record represents one symbol across all enabled venues:

```json
{
  "symbol": "ETH",
  "hyperliquid_funding_apr_pct": 10.95,
  "aster_funding_apr_pct": 0.0,
  "lighter_funding_apr_pct": -0.876,
  "pacifica_funding_apr_pct": -9.583,
  "binance_funding_apr_pct": 4.071,
  "bybit_funding_apr_pct": 9.161,
  "max_abs_funding_apr_pct": 10.95,
  "venue_spread_apr_pct": 20.533,
  "dex_cex_spread_apr_pct": 6.879,
  "best_long_venue": "pacifica",
  "best_short_venue": "hyperliquid",
  "exchanges_present": 6,
  "next_funding_time": "2026-06-20T16:00:00.000Z",
  "timestamp": "2026-06-20T11:36:24.650Z"
}
```

| Field | Description |
|-------|-------------|
| `*_funding_apr_pct` | Funding rate annualized to APR% |
| `venue_spread_apr_pct` | Max APR minus min APR — the carry-trade spread |
| `dex_cex_spread_apr_pct` | Max DEX APR minus min CEX APR — DEX premium |
| `best_long_venue` | Cheapest venue to hold long (or receive most as short) |
| `best_short_venue` | Best venue to hold short and collect funding |
| `exchanges_present` | Number of venues with data for this symbol (1–6) |

***

### Data Sources

| Venue | Endpoint |
|-------|----------|
| Hyperliquid | `POST https://api.hyperliquid.xyz/info` (`metaAndAssetCtxs`) |
| Aster | `GET https://fapi.asterdex.com/fapi/v1/premiumIndex` |
| Lighter | `GET https://mainnet.zklighter.elliot.ai/api/v1/funding-rates` |
| Pacifica | `GET https://api.pacifica.fi/api/v1/funding_rate/history` |
| Binance | via Lighter aggregated endpoint (avoids geo-restrictions) |
| Bybit | via Lighter aggregated endpoint (avoids geo-restrictions) |

***

### Why This Matters

**Carry trading** is one of the most consistent yield strategies in crypto — but it requires knowing where the rate imbalance is. CEX funding rates are well-covered. DEX rates are not.

This Actor fills that gap: one call, 6 venues, actionable spread signal.

Use cases:

- **Quant traders** — scan for entry signals, run on schedule via Apify
- **DeFi protocols** — monitor funding conditions across chains
- **Risk desks** — track DEX-vs-CEX divergence as a market stress indicator

Live Sample Run: https://console.apify.com/storage/datasets/YEeLI3ofDrd8KoV76

# Actor input Schema

## `symbols` (type: `array`):

Base symbols to track. Defaults to BTC, ETH, SOL.

## `includeHyperliquid` (type: `boolean`):

Include Hyperliquid DEX (Ethereum L1, 1h funding).

## `includeAster` (type: `boolean`):

Include Aster DEX (Multi-chain: BNB Chain + Aster Chain L1, 8h funding).

## `includeLighter` (type: `boolean`):

Include Lighter DEX (Ethereum ZK L2).

## `includePacifica` (type: `boolean`):

Include Pacifica DEX (Solana, 1h funding).

## `includeBinance` (type: `boolean`):

Include Binance USDT-M futures as CEX reference.

## `includeBybit` (type: `boolean`):

Include Bybit linear perps as CEX reference.

## `minAbsFundingApr` (type: `number`):

Only return symbols where max |funding APR| exceeds this value.

## `minVenueSpreadApr` (type: `number`):

Only return symbols where cross-venue spread exceeds this value.

## `sortBy` (type: `string`):

How to sort output records.

## `alertAbsApr` (type: `number`):

Send Telegram alert when any symbol's |funding APR| exceeds this. Set 0 to disable.

## `telegramBotToken` (type: `string`):

Telegram bot token for alerts.

## `telegramChatId` (type: `string`):

Telegram chat ID to receive alerts.

## Actor input object example

```json
{
  "symbols": [
    "BTC",
    "ETH",
    "SOL"
  ],
  "includeHyperliquid": true,
  "includeAster": true,
  "includeLighter": true,
  "includePacifica": true,
  "includeBinance": true,
  "includeBybit": true,
  "minAbsFundingApr": 0,
  "minVenueSpreadApr": 0,
  "sortBy": "spread_desc",
  "alertAbsApr": 0
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "symbols": [
        "BTC",
        "ETH",
        "SOL"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("yyber/dex-funding-aggregator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "symbols": [
        "BTC",
        "ETH",
        "SOL",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("yyber/dex-funding-aggregator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "symbols": [
    "BTC",
    "ETH",
    "SOL"
  ]
}' |
apify call yyber/dex-funding-aggregator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=yyber/dex-funding-aggregator",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "DEX Funding Rate Aggregator",
        "description": "Aggregate perpetual funding rates across Hyperliquid, Aster, Lighter, and Pacifica with Binance/Bybit as CEX reference. Spot DEX-vs-CEX funding spreads and cross-venue carry-trade signals. No API key required.",
        "version": "0.1",
        "x-build-id": "a5u3neUfQaFoXOmjc"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/yyber~dex-funding-aggregator/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-yyber-dex-funding-aggregator",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/yyber~dex-funding-aggregator/runs": {
            "post": {
                "operationId": "runs-sync-yyber-dex-funding-aggregator",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/yyber~dex-funding-aggregator/run-sync": {
            "post": {
                "operationId": "run-sync-yyber-dex-funding-aggregator",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "symbols": {
                        "title": "Symbols",
                        "type": "array",
                        "description": "Base symbols to track. Defaults to BTC, ETH, SOL.",
                        "default": [
                            "BTC",
                            "ETH",
                            "SOL"
                        ],
                        "items": {
                            "type": "string"
                        }
                    },
                    "includeHyperliquid": {
                        "title": "Include Hyperliquid",
                        "type": "boolean",
                        "description": "Include Hyperliquid DEX (Ethereum L1, 1h funding).",
                        "default": true
                    },
                    "includeAster": {
                        "title": "Include Aster",
                        "type": "boolean",
                        "description": "Include Aster DEX (Multi-chain: BNB Chain + Aster Chain L1, 8h funding).",
                        "default": true
                    },
                    "includeLighter": {
                        "title": "Include Lighter",
                        "type": "boolean",
                        "description": "Include Lighter DEX (Ethereum ZK L2).",
                        "default": true
                    },
                    "includePacifica": {
                        "title": "Include Pacifica",
                        "type": "boolean",
                        "description": "Include Pacifica DEX (Solana, 1h funding).",
                        "default": true
                    },
                    "includeBinance": {
                        "title": "Include Binance (CEX reference)",
                        "type": "boolean",
                        "description": "Include Binance USDT-M futures as CEX reference.",
                        "default": true
                    },
                    "includeBybit": {
                        "title": "Include Bybit (CEX reference)",
                        "type": "boolean",
                        "description": "Include Bybit linear perps as CEX reference.",
                        "default": true
                    },
                    "minAbsFundingApr": {
                        "title": "Min Absolute Funding APR (%)",
                        "minimum": 0,
                        "type": "number",
                        "description": "Only return symbols where max |funding APR| exceeds this value.",
                        "default": 0
                    },
                    "minVenueSpreadApr": {
                        "title": "Min Venue Spread APR (%)",
                        "minimum": 0,
                        "type": "number",
                        "description": "Only return symbols where cross-venue spread exceeds this value.",
                        "default": 0
                    },
                    "sortBy": {
                        "title": "Sort By",
                        "enum": [
                            "spread_desc",
                            "abs_funding_desc",
                            "symbol_asc"
                        ],
                        "type": "string",
                        "description": "How to sort output records.",
                        "default": "spread_desc"
                    },
                    "alertAbsApr": {
                        "title": "Telegram Alert Threshold APR (%)",
                        "minimum": 0,
                        "type": "number",
                        "description": "Send Telegram alert when any symbol's |funding APR| exceeds this. Set 0 to disable.",
                        "default": 0
                    },
                    "telegramBotToken": {
                        "title": "Telegram Bot Token",
                        "type": "string",
                        "description": "Telegram bot token for alerts."
                    },
                    "telegramChatId": {
                        "title": "Telegram Chat ID",
                        "type": "string",
                        "description": "Telegram chat ID to receive alerts."
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
