@navalabs/uniswap-adapter
v0.9.0
Published
Nava Uniswap adapter — V3/V4 swap primitives, pool discovery, Permit2 helpers, plus MCP and CLI integrations for the Nava SDK.
Readme
@navalabs/uniswap-adapter
Nava Uniswap adapter — V3 / V4 swap primitives, pool discovery, balance reads, Permit2 helpers, plus MCP and CLI integrations for the Nava SDK.
pnpm add @navalabs/uniswap-adapterThis package is a complete install. It ships the nava binary and the
nava-mcp server, and depends on @navalabs/sdk for the runtime and the
six base verification operations — no second package to add.
Installing other adapters alongside it works the same way. They share one
nava and one nava-mcp, and every installed protocol is reachable from
whichever copy your package manager links.
Operations
Six, under the same names on both surfaces:
| Operation | Kind | CLI | MCP tool |
|---|---|---|---|
| get-balance | read | nava uniswap get-balance | uniswap.get-balance |
| get-quote | read | nava uniswap get-quote | uniswap.get-quote |
| find-all-pools | read | nava uniswap find-all-pools | uniswap.find-all-pools |
| execute-swap | build | nava uniswap execute-swap | uniswap.execute-swap |
| wrap-eth | build | nava uniswap wrap-eth | uniswap.wrap-eth |
| mint-test-tokens | build | nava uniswap mint-test-tokens | uniswap.mint-test-tokens |
Nothing here is a verified-write. Every operation either reads chain state
or returns calldata — including execute-swap, which does not broadcast.
Guardian verification and submission belong to the calling application, via
NavaClient.requestVerification.
wrap-eth prepares a standalone WETH deposit. Never insert it automatically for
an ETH swap request; obtain separate authorization and a separate verdict.
Currencies: symbol or contract address
--currency-in / --currency-out (MCP: currencyIn / currencyOut) accept
either a token symbol or a token contract address. Symbols resolve from
the static registry first, then from published Uniswap token lists. A verified
token address is accepted even when it is not listed. Decimals are always read
on-chain and must match any claimed list/registry value.
# UNISWAP_CHAIN_ID=137 — the USDC.e/WETH v3 pool on Polygon.
nava uniswap get-quote --protocol v3 --currency-in USDC.e --currency-out WETH --amount-in 1
nava uniswap get-quote --protocol v3 \
--currency-in 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 \
--currency-out 0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619 \
--amount-in 1A listed or configured symbol, or a contract address whose decimals can be
verified on-chain, can be quoted and swapped. Amounts are decimal strings in
whole token units ("1.5"), never base units.
There is no fallback: an unknown symbol, a stale or conflicting token list, a
token-list fetch failure during search, a decimals mismatch, or a factory/pool
identity mismatch is an error naming the token, never a guessed value. Recover
with find-all-pools. V3 pools for an unregistered pair are discovered with
--currency-a / --currency-b.
Always choose v3 or v4 explicitly; both use Universal Router calldata.
Every swap remains unsigned calldata for Guardian verification.
TypeScript
import { createPublicClient, http } from 'viem';
import { sepolia } from 'viem/chains';
import { createUniswapTools } from '@navalabs/uniswap-adapter';
const tools = createUniswapTools({
escrowAddress: '0x...',
chainId: 11155111,
publicClient: createPublicClient({ chain: sepolia, transport: http() }),
});
// `execute` is optional on the AI SDK tool type, hence the `?.`.
const quote = await tools.getQuote.execute?.(
{ protocol: 'v3', currencyIn: 'TKA', currencyOut: 'TKB', amountIn: '1.0' },
{ toolCallId: 'cli', messages: [] },
);| Import | Contents |
|---|---|
| @navalabs/uniswap-adapter | createUniswapTools, the pure utilities, and the pool/token registries. Start here. |
| /tools | createUniswapTools, UniswapToolsConfig, and the six individual create* factories. |
| /mcp | createProtocolRegistrarFactory, registerUniswapTools, and the advertised zod schemas — what nava-mcp imports. |
| /cli | uniswapCliModule plus the six parse* argv parsers — what the nava bin imports. |
| /adapter | Empty. Reserved for a future verified-execution surface; it exports nothing today. Do not import it. |
Pure utilities (prepareSwapCalldata, getQuotes, getBalance,
checkBothApprovalLevels, the registries) are re-exported from the root.
Environment
For the CLI and the MCP registrar:
UNISWAP_RPC_URL(orRPC_URL) — JSON-RPC endpoint for the active chain.UNISWAP_CHAIN_ID(orCHAIN_ID) — numeric chain id, e.g.11155111.UNISWAP_WALLET_ADDRESS(orWALLET_ADDRESS) — wallet / escrow address used to construct calldata.UNISWAP_TOKEN_LIST_URLS— optional comma-separated Uniswap token list URLs for symbol discovery. Unset useshttps://tokens.uniswap.org.NAVA_API_KEY— required to runnava-mcp.NAVA_BASE_URL— optional Nava API origin. Defaults tohttps://internal.navalabs.dev/api.
Full parameter reference
Every option, requirement, default, and worked example lives in the bundled Nava
skill that ships with @navalabs/sdk, at
node_modules/@navalabs/sdk/skills/nava/references/uniswap.md. There is no
per-command --help; that file is the parameter reference.
Upstream SDK compatibility
The adapter pins to current Uniswap SDK releases and loads Universal Router
planner values through their CommonJS export, because the upstream ESM builds
still contain extensionless internal imports that fail under strict Node ESM
resolution. @uniswap/v4-sdk sourcemap warnings are harmless — the upstream
package ships sourcemaps pointing at missing TypeScript sources.
