@calp-pro/dex-db

中文文档
3.1.1发布于 2026/08/23MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 2641

Database designed for handle relation pair/pool address to token0 & token1 addresses

原始使用文档
文档目录4 节
  1. Install
  2. Use
  3. API
  4. sort

calp.pro icon  DEX DB  Coverage

Database for decentralize exchangers.
Each pair & token address indexed to a number.
Then factory information can be presented as:

  • 0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc - have index N
  • 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 - have index X
  • 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 - have index Y
data_structure[N    ] = X
data_structure[N + 1] = Y

where N, X, Y are uint24.

Example:
[0, 4, 0, 1, 5, 3, ...]
where:

  • 0, 4
    • is first and second element at array at index 0, 1 (pair index 0)
    • 0 index of token0 of pair 0
    • 4 index of token1 of pair 0
  • 0, 1
    • is next pair of token at positions 2, 3 (pair index 1)
    • 0 index of token0 of pair 1 (same token can be at different pairs)
    • 1 index of token1 of pair 1
  • 5, 3
    • is next pair of tokens at positions 4, 5 (pair index 2)
    • 5 index of token0 of pair 2
    • 3 index of token1 of pair 2

Install

npm i --save @calp-pro/dex-db

Use

import dex_db from '@calp-pro/dex-db'

const db = dex_db(
    [
        ['0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc', '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'],
        ['0x12ede161c702d1494612d19f05992f43aa6a26fb', '0x06af07097c9eeb7fd685c692751d5c66db49c215', '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'],
        ['0xa478c2975ab1ea89e8196811f51a7b7ade33eb11', '0x6b175474e89094c44da98b954eedeac495271d0f', '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'],
        ['0x07f068ca326a469fc1d87d85d448990c8cba7df9', '0x408e41876cccdc0f92210600ef50372656052a38', '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'],
        ['0xae461ca67b15dc8dc81ce7615e0320da1a9ab8d5', '0x6b175474e89094c44da98b954eedeac495271d0f', '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'],
        ['0xce407cd7b95b39d3b4d53065e711e713dd5c5999', '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0xfa3e941d1f6b7b10ed84a0c211bfa8aee907965e']
    ]
)

const pairs = dex_db.find_pairs_with_token('0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'/*USDC*/)

//pairs[0] == '0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc'/*WETH/USDC*/)
//pairs[1] == '0x07f068ca326a469fc1d87d85d448990c8cba7df9'/*REN/USDC*/)
//pairs[2] == '0xae461ca67b15dc8dc81ce7615e0320da1a9ab8d5'/*DAI/USDC*/)

API

  • find_pairs_with_token
  • find_pairs_with_tokens
  • get_pair_tokens
  • index
  • index_save
  • save
  • load
  • sort

sort

Compression of deltas five only 10% which is not much for 10mb of tokens/pools addresses. Delivery to web 9mb or 10mb is same long waiting time which is user will wait. Loading should happen in background and each loaded chunk should be processed. Then very important is order of data which came first. Sorting of data helps to present fast most important data and less important left for later.

By default token sorting is done by amount of pairs token have. WETH is top paired token - should appear first at sorted result. By default pair sorting is done by total pairs token0/1 have.

版本与发布记录

@calp-pro/dex-db 共发布 21 个版本,首次发布于 2026/03/14;过去 12 个月发布了 21 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.1.1latest2026/08/232 个月前
3.1.02026/08/232 个月前
3.0.32026/05/195 个月前
3.0.22026/05/195 个月前
3.0.12026/04/057 个月前
3.0.02026/04/057 个月前

关于 @calp-pro/dex-db 的常见问题

@calp-pro/dex-db 是什么?

Database designed for handle relation pair/pool address to token0 & token1 addresses

如何安装 @calp-pro/dex-db?

在项目目录运行 npm install @calp-pro/dex-db,或使用 pnpm add / yarn add / bun add。

@calp-pro/dex-db 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@calp-pro/dex-db 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@calp-pro/dex-db 可以商用吗?

@calp-pro/dex-db 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@calp-pro/dex-db 的下载量有多少?

根据 npm 官方下载统计,@calp-pro/dex-db 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,641 次,日均约 88 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@calp-pro/dex-db 还在维护吗?

最新版本 3.1.1 发布于 2026/08/23(2 个月前);至今共发布 21 个版本,其中过去 12 个月发布了 21 个;首次发布于 2026/03/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。