@arca-network/sdk

中文文档
2.15.0发布于 2026/11/01SEE LICENSE IN LICENSETypeScriptCommonJS近 30 天下载 1713

TypeScript SDK for the Arca platform

原始使用文档
文档目录8 节
  1. Build
  2. Dev (watch mode)
  3. Clean
  4. Requirements
  5. WebSocket support
  6. Equity & P&L Charts
  7. Operation wait recovery
  8. Wallet execution candidate (2026-09-30)

@arca-network/sdk (TypeScript)

TypeScript SDK for the Arca platform.

Build

From repo root:

pnpm run sdk:build

Or directly:

cd sdk/typescript
pnpm run build

Dev (watch mode)

pnpm run sdk:dev

Clean

pnpm run sdk:clean

Requirements

  • Node.js 20+

WebSocket support

The SDK uses WebSocket for real-time operation tracking. Node.js 22+ provides a native global WebSocket; on Node.js 20–21, the SDK automatically falls back to the bundled ws package. No additional setup is needed.

Equity & P&L Charts

Use the chart APIs below. The server is the single source of truth for every point including the open bucket; the SDK never synthesizes a "now" point and never invalidates the cache on a 5%-deviation heuristic. Each point carries an explicit status flag ('sealed' | 'open' | 'carried' | 'incomplete') the renderer is required to honor.

  • getEquityHistory({ path, from, to, points?, kind?, objectId? }) — fetches /objects/aggregate/history using target/kind and normalizes the current response to the stable SDK shape.
  • getPnlHistory({ path, from, to, points?, anchor?, kind?, objectId? }) — fetches /objects/pnl/history using target/kind; P&L is derived inline by the server from the same snapshot rows. Use anchor: 'equity' to receive flow-adjusted valueUsd, where deposits/transfers shift the baseline instead of drawing timeline jumps.
  • watchEquityChart({ path, from, to, points?, kind?, objectId?, exchange? }) — combines getEquityHistory with live aggregation updates and refetches history after gaps.
  • watchPnlChart({ path, from, to, points?, anchor?, kind?, objectId?, exchange? }) — same stream pattern for P&L charts.

Resolution selection is shared with the backend (pickResolution from '@arca-network/sdk'); pick a points budget — the server picks the rung. When the chosen rung's retention has been exceeded for the requested window, the response carries resolutionRequested to indicate which rung was promoted to.

Exported types: EquityChartStream, PnlChartStream, EquityHistoryResponse, PnlHistoryResponse, EquityPoint, PnlPoint, EquityChartUpdate, PnlChartUpdate, Resolution.

const chart = await arca.watchEquityChart({
  path: '/users/alice/',
  from: oneDayAgoIso,
  to: nowIso,
  points: 500,
});
chart.onUpdate(({ response }) => {
  for (const p of response.points) {
    // p.status: 'sealed' | 'open' | 'carried' | 'incomplete'
    // p.equityUsd: string
  }
});

Operation wait recovery

waitForOperation listens before acquiring its subscription. Startup and actual stream gaps, reauthentication, or sparse operation notifications request a fresh, correlated acknowledgement before reading the operation. A failed acknowledgement or read gets at most three attempts per recovery; a healthy pending operation stays on the stream without periodic reads. A terminal push can complete during acknowledgement or snapshot recovery. Timeout stops the wait and preserves the original operation identity; it never submits a replacement operation.

Terminal operations in the initial or buffered subscription snapshot resolve the wait before any HTTP read, including typed failed/expired results. Socket rotation requests fresh operation evidence on the replacement connection; its pong only establishes transport readiness. Stale snapshot request IDs and unrelated operation IDs cannot settle the wait. Verified snapshot operations are shared with all live waiters, including results buffered while another caller refreshes the same root watch; each waiter still accepts only its original operation ID.

Wallet execution candidate (2026-09-30)

Wallet action proposals, verified provider wallets and deposit links express intent and owner consent to Arca. Arca owns execution, source reservations, gas/nonce management and settlement; a builder does not run a sweep worker. The additive wallet accounting envelope includes canonical source, Cash, trading and in-transit money at one committed position. Preserve null amounts and completeness/freshness; custody-only totals retains its earlier meaning.

Go exposes StreamFundingV9WalletsWithTransport; TypeScript exposes streamFundingV9Wallets. Both use bounded buffering and await the consumer before acknowledging a position. Heartbeats indicate connection health only. Reconnect from the last durably applied position, retaining prior coherent money as stale across incomplete/error frames. Wallet mutations are single-send; resolve uncertain outcomes using the original operation/request identity. Deposit links accept optional maxCashMicro and maxDepositMicro product caps; admission preserves partial deposits and leaves the remainder at source. This source has not yet been published; no deployed-wallet parity is implied.

版本与发布记录

@arca-network/sdk 共发布 48 个版本,首次发布于 2026/06/06;过去 12 个月发布了 48 个版本。

版本发布日期距今
2.15.0latest2026/11/018 天前
2.14.02026/10/3110 天前
2.13.02026/10/2911 天前
2.12.12026/10/2912 天前
2.12.02026/10/2812 天前
2.11.02026/10/1822 天前

关于 @arca-network/sdk 的常见问题

@arca-network/sdk 是什么?

TypeScript SDK for the Arca platform

如何安装 @arca-network/sdk?

在项目目录运行 npm install @arca-network/sdk,或使用 pnpm add / yarn add / bun add。

@arca-network/sdk 支持 TypeScript 吗?

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

@arca-network/sdk 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@arca-network/sdk 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@arca-network/sdk 可以商用吗?

@arca-network/sdk 使用 SEE LICENSE IN LICENSE 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@arca-network/sdk 的下载量有多少?

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

@arca-network/sdk 还在维护吗?

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