@exodus/fiat-balances

中文文档
13.8.0发布于 2026/11/09MITTypeScriptES Module近 30 天下载 1.1万

Track asset and portfolio fiat balances based on changes in crypto balances and the user's preferred fiat currency

原始使用文档
文档目录5 节
  1. Install
  2. Usage
  3. Play with it
  4. API Side
  5. UI Side

@exodus/fiat-balances

This Exodus SDK feature tracks fiat-denominated balances for all enabled wallet accounts, based on the application's locale and user's preferred currency. For crypto-denominated balances, check out @exodus/balances.

Install

pnpm add @exodus/fiat-balances

Usage

This feature is designed to be used together with @exodus/headless. See using the sdk.

Play with it

  1. Open the playground https://exodus-hydra.pages.dev/
  2. Run selectors.fiatBalances.byAsset(store.getState()) in the Dev Tools Console to get fiat balances by asset aggregated across enabled wallet accounts.
  3. Try out some other selectors from selectors.fiatBalances. See example usage in tests.
  4. Mock an address with a balance, tick the blockchain monitor and check your balance.
// mock your ethereum address with one that has a balance
await exodus.debug.addressProvider.mockAddress({
  assetName: 'ethereum',
  walletAccount: 'exodus_0',
  address: '0x1111111111111111111111111111111111111111',
})
// force tick the ethereum monitor, or wait a while
await exodus.txLogMonitors.update({ assetName: 'ethereum', refresh: true })
// check your ETH balance in the user's preferred currency
selectors.fiatBalances.byAsset(store.getState()).ethereum.toDefaultString({ unit: true }) // 123.45 USD
// change currency
await exodus.locale.setCurrency('EUR')
selectors.fiatBalances.byAsset(store.getState()).ethereum.toDefaultString({ unit: true }) // 6.78 EUR

API Side

See using the sdk for more details on how features plug into the SDK. Note that the balances feature currently doesn't provide a top level API and is meant to be used purely through selectors.

If you're building a feature that requires balances, add a dependency on the fiatBalancesAtom as below.

const myModuleDefinition = {
  id: 'myModule',
  type: 'module',
  factory: ({ fiatBalancesAtom }) => {
    const doSomethingSpecial = async () => {
      const { balances } = await fiatBalancesAtom.get()
      console.log(
        '>>> total wallet balance',
        balances.totals.balance.toDefaultString({ unit: true })
      )
    }

    return {
      doSomethingSpecial,
    }
  },
  dependencies: ['fiatBalancesAtom'],
}

UI Side

See using the sdk for more details on basic UI-side setup.

import { selectors } from '~/ui/flux'

const MyComponent = () => {
  const totalWalletBalance = useSelector(
    selectors.fiatBalances.optimisticTotalBalance(store.getState())
  ) // returns a NumberUnit

  // create a function to convert ethereum to the user's preferred currency
  const ethToFiat = useSelector(selectors.fiatBalances.createAssetConversion('ethereum'))
  const ethBalanceInFiat = ethToFiat(ethereum.currency.defaultUnit(1))
}

版本与发布记录

@exodus/fiat-balances 共发布 90 个版本,首次发布于 2022/08/10;过去 12 个月发布了 8 个版本。

版本发布日期距今
13.8.0latest2026/11/094 天前
13.7.52026/10/101 个月前
13.7.42026/05/195 个月前
13.7.32026/03/068 个月前
13.7.22026/02/268 个月前
13.7.12026/02/049 个月前

关于 @exodus/fiat-balances 的常见问题

@exodus/fiat-balances 是什么?

Track asset and portfolio fiat balances based on changes in crypto balances and the user's preferred fiat currency

如何安装 @exodus/fiat-balances?

在项目目录运行 npm install @exodus/fiat-balances,或使用 pnpm add / yarn add / bun add。

@exodus/fiat-balances 支持 TypeScript 吗?

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

@exodus/fiat-balances 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@exodus/fiat-balances 可以商用吗?

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

@exodus/fiat-balances 的下载量有多少?

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

@exodus/fiat-balances 还在维护吗?

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