Skip to main content

Documentation

Use @ring-protocol/v2-sdk for TypeScript and JavaScript integrations with Ring Swap.

Structured reference
TOC available

Ring Swap SDK

Use @ring-protocol/v2-sdk for TypeScript and JavaScript integrations with Ring Swap.

yarn add @ring-protocol/v2-sdk @ring-protocol/sdk-core

Package map

PackageRoleUse directly?
@ring-protocol/v2-sdkFewToken-aware pairs, routes, trades, and address helpersYes. This is the default Ring Swap SDK
@ring-protocol/sdk-coreShared token, amount, price, and percentage typesYes, when constructing SDK inputs
@ring-protocol/uniswap-v2-sdkLower-level v2-compatible primitivesOnly when you specifically need the base compatibility layer

All three packages are maintained in the Ring SDK monorepo.

Published network support

This table describes @ring-protocol/[email protected]. A chain appearing in @ring-protocol/sdk-core does not mean the FewToken-aware v2 package supports that chain.

NetworkChain IDPublished v2 SDK status
Ethereum Mainnet1Configured. Verify FewFactory, factory, and init code against the deployment page and onchain before use
BNB Smart Chain56Configured. Verify the derived FewToken and pair onchain before use
HyperEVM999Configured. Verify the derived FewToken and pair onchain before use
MegaETH Mainnet4326Unsupported in the published package. Do not use v1.0.0 FewToken or pair-address helpers for MegaETH

MegaETH support becomes available only after a package with the reviewed Ring Swap Factory, FewFactory, and init-code configuration is published and this table names that version. Until then, read addresses from the deployment page and resolve them directly onchain.

Start by task

TaskGuide
Install the SDK and create tokensQuick Start
Read pair dataFetching Data
Calculate pricesPricing
Construct a tradeTrading
Derive a pair addressGetting Pair Addresses

FewToken rule

Ring Swap pools and paths use FewToken addresses. Derive wrappers through SDK configuration only on a supported network, then verify the result onchain against the published FewFactory. Do not identify a wrapper only from its symbol, name, token-list entry, or the existence of a pool.

The v1.0.0 isFewToken() helper checks display metadata and must not be used as an authorization or asset-identity check. Confirm FewFactory.getWrappedToken(underlying) === candidate onchain. For pair identity, confirm Ring Swap Factory.getPair(tokenA, tokenB) rather than accepting a locally derived address alone.

Use Contract Deployments as the maintained factory and router directory, then verify the selected deployment onchain. If you need a hosted quote service, use the Routing API and apply its response-validation checklist.