Skip to content

feat(sdk): add Nano (XNO) amount primitives (XnoAmount, xno, formatXno) - #107

Closed
dhyabi2 wants to merge 1 commit into
agenticpay-dev:mainfrom
dhyabi2:feat/nano-amount-primitives
Closed

dhyabi2 wants to merge 1 commit into
agenticpay-dev:mainfrom
dhyabi2:feat/nano-amount-primitives

Conversation

@dhyabi2

@dhyabi2 dhyabi2 commented Sep 24, 2026

Copy link
Copy Markdown

Summary

Adds Nano (XNO) amount primitives to @agenticpay/sdk: an XnoAmount type with exact decimal-string construction (xno()), a formatter (formatXno), and the associated constants (XNO_DECIMALS = 30, NANO_NETWORK = "nano:mainnet").

This is a pure leaf addition mirroring the existing UsdcAmount / usdc() / formatUsdc() pattern in types.ts. It has no runtime dependencies and changes no existing behaviour.

Why Nano — This SDK's own cheapest product prices at $0.0005 per call. A 6-decimal token (USDC's base unit) rounds that amount to zero raw at the point of settlement. Nano (XNO) has 30 native decimals, so a $0.0005 charge is exactly representable (5e26 raw) and settles at its true value with no gas/no fee. These primitives are the amount layer a Nano settlement option would need.

Changes

  • Code in packages/sdk/src/types.ts — new types + functions appended after the existing USDC helpers
  • No new files, no imports changed

Already exported via export * from "./types.js" in packages/sdk/src/index.ts.

Test plan

Build + typecheck pass for all 9 monorepo packages (pnpm -r build && pnpm -r typecheck).

Exactness verified manually:

xno("0.0005").raw = 500000000000000000000000000n  (true)
formatXno(xno("0.0005")) = "0.0005"
formatXno(xno("1")) = "1"
0.0003 + 0.0007 = 0.0010  (true)
xno("1").raw == 10^30  (true)

Backwards compatibility

  • No breaking changes to public APIs

Security

  • No new secrets stored in repo, env, or logs
  • No new external network surfaces

Adds a self-contained XNO amount type alongside the existing USDC primitives
in packages/sdk/src/types.ts:

- XnoAmount - 30-decimal bigint interface (mirrors UsdcAmount)
- XNO_DECIMALS = 30 - Nano native raw precision
- xno(human) - decimal-string parser, exact down to a single raw
- formatXno(amount) - renders back to a trimmed human string
- NANO_NETWORK = "nano:mainnet" - CAIP-2 chain id for x402 accepts

Already exported via export * from "./types.js" in index.ts. No new
dependencies. All 9 monorepo packages build and typecheck clean.
@krystiangw

Copy link
Copy Markdown
Collaborator

Hi, thanks for the PR and for the clear write-up :)

One thing in the motivation is not right - usdc("0.0005") gives 500n base units, not zero. 6 decimals go down to $0.000001, so our cheapest price settles fine in USDC.

Also, AgenticPay settles on Solana with USDC only, and adding a new network is a product decision we are not making right now. Amount helpers without a facilitator and client flow behind them would be dead code in the SDK, so I will close this one.

If we decide to add another network later, I will open an issue first so we can discuss it there. Thanks again 👍

@krystiangw krystiangw closed this Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants