@real-wagmi/v2-sdk
v1.0.1
Published
TypeScript SDK for the Equilibra Swap
Readme
@real-wagmi/v2-sdk
Chain registry for Wagmi deployments: chain ids, canonical tokens
(WETH9, stablecoins, well-known tokens) and native-currency helpers on top
of the @real-wagmi/sdk primitives. Downstream SDKs
(@real-wagmi/equilibra-sdk) and services key their per-chain
configuration off this package.
Install
$ yarn add @real-wagmi/v2-sdk @real-wagmi/sdkUsage
Chain ids
ChainId is the source of truth for the chains Wagmi deployments cover —
values are the EVM chain ids:
import { ChainId } from '@real-wagmi/v2-sdk';
ChainId.ROBINHOOD; // 4663Well-known tokens
Per-chain Token instances (from @real-wagmi/sdk) with the canonical
addresses and decimals:
import { robinhoodTokens } from '@real-wagmi/v2-sdk';
robinhoodTokens.weth; // Token(4663, 0x0Bd7...aD73, 18, 'WETH', 'Wrapped Ether')
robinhoodTokens.usdg; // Token(4663, 0x5fc5...d168, 6, 'USDG', 'Global Dollar')
robinhoodTokens.anon; // Token(4663, 0x79bb...e07c, 18, 'Anon', 'HeyAnon')Canonical WETH9 and stablecoins
import { ChainId, STABLE_COINS, WETH9 } from '@real-wagmi/v2-sdk';
// The `wrapped` target of the chain's native currency:
WETH9[ChainId.ROBINHOOD].address;
// Pricing anchors for derived-price walks and stable-pair heuristics:
STABLE_COINS[ChainId.ROBINHOOD].map((token) => token.symbol); // ["USDG"]Native currency
import { ChainId, nativeOnChain } from '@real-wagmi/v2-sdk';
import { CurrencyAmount } from '@real-wagmi/sdk';
const eth = nativeOnChain(ChainId.ROBINHOOD); // cached per chain
eth.isNative; // true
eth.wrapped.address; // the Robinhood WETH9 address
// Works everywhere a Currency is expected, e.g. route endpoints:
const amount = CurrencyAmount.fromRawAmount(eth, 10n ** 18n); // 1 ETHEther.onChain(chainId) is the underlying entity; its wrapped getter
resolves through the WETH9 map and throws 'WRAPPED' for chains without
a canonical WETH9 entry.
Adding a chain
- Add the id to
ChainId(src/constants/chains.ts). - Add the chain's tokens under
src/tokens/chains/and export them. - Register the canonical entries in
WETH9andSTABLE_COINS— both maps aresatisfies Record<ChainId, ...>, so the compiler enforces completeness for every declared chain.
