TypeScript SDKs for building applications on ETCswap, the decentralized exchange on Ethereum Classic.
| Package | Version | Description |
|---|---|---|
| @etcswapv2/sdk-core | Core types, tokens, and utilities | |
| @etcswapv2/sdk | V2 AMM SDK (Pair, Route, Trade) | |
| @etcswapv3/sdk | V3 CLMM SDK (Pool, Position) | |
| @etcswapv3/router-sdk | Universal Router SDK |
Future: @etcswapv4/sdk - V4 Hooks-based AMM (see V4 Roadmap)
| Chain | Chain ID | Native Currency | RPC URL | Block Explorer |
|---|---|---|---|---|
| Ethereum Classic | 61 | ETC | https://etc.rivet.link | https://etc.blockscout.com |
| Mordor Testnet | 63 | METC | https://rpc.mordor.etccooperative.org | https://etc-mordor.blockscout.com |
# Using npm
npm install @etcswapv2/sdk-core @etcswapv2/sdk @etcswapv3/sdk @etcswapv3/router-sdk
# Using pnpm
pnpm add @etcswapv2/sdk-core @etcswapv2/sdk @etcswapv3/sdk @etcswapv3/router-sdk
# Using yarn
yarn add @etcswapv2/sdk-core @etcswapv2/sdk @etcswapv3/sdk @etcswapv3/router-sdk# V2 only
npm install @etcswapv2/sdk-core @etcswapv2/sdk
# V3 only
npm install @etcswapv2/sdk-core @etcswapv3/sdk
# Universal Router (V2 + V3)
npm install @etcswapv2/sdk-core @etcswapv2/sdk @etcswapv3/sdk @etcswapv3/router-sdkimport { ChainId, Token, WETC, ETC } from '@etcswapv2/sdk-core'
// Use built-in WETC token
const wetc = WETC[ChainId.CLASSIC]
// Create custom tokens
const USC = new Token(
ChainId.CLASSIC,
'0xDE093684c796204224BC081f937aa059D903c52a',
6,
'USC',
'Classic USD Stablecoin'
)
// Native ETC (for wrapping/unwrapping)
const etc = ETC.onChain(ChainId.CLASSIC)import { ChainId, Token, CurrencyAmount, TradeType, Percent } from '@etcswapv2/sdk-core'
import { Pair, Route, Trade } from '@etcswapv2/sdk'
// Define tokens
const WETC = new Token(ChainId.CLASSIC, '0x1953cab0E5bFa6D4a9BaD6E05fD46C1CC6527a5a', 18, 'WETC')
const USC = new Token(ChainId.CLASSIC, '0xDE093684c796204224BC081f937aa059D903c52a', 6, 'USC')
// Create pair from reserves (fetched from chain)
const pair = new Pair(
CurrencyAmount.fromRawAmount(WETC, reserveWETC),
CurrencyAmount.fromRawAmount(USC, reserveUSC)
)
// Create route and trade
const route = new Route([pair], WETC, USC)
const amountIn = CurrencyAmount.fromRawAmount(WETC, '1000000000000000000') // 1 WETC
const trade = new Trade(route, amountIn, TradeType.EXACT_INPUT)
console.log('Output:', trade.outputAmount.toSignificant(6), 'USC')
console.log('Price Impact:', trade.priceImpact.toSignificant(2), '%')
// Calculate minimum output with slippage
const slippage = new Percent(50, 10000) // 0.5%
const minOutput = trade.minimumAmountOut(slippage)import { ChainId, Token, CurrencyAmount } from '@etcswapv2/sdk-core'
import { Pool, Position, FeeAmount, nearestUsableTick } from '@etcswapv3/sdk'
// Create pool from chain data
const pool = new Pool(
tokenA,
tokenB,
FeeAmount.MEDIUM, // 0.3% fee
sqrtPriceX96, // Current sqrt price
liquidity, // Total liquidity
tick // Current tick
)
// Create position
const position = Position.fromAmounts({
pool,
tickLower: nearestUsableTick(pool.tickCurrent - 1000, pool.tickSpacing),
tickUpper: nearestUsableTick(pool.tickCurrent + 1000, pool.tickSpacing),
amount0: '1000000000000000000',
amount1: '1000000',
useFullPrecision: true,
})
console.log('Liquidity:', position.liquidity.toString())See deployed-contracts.md for the complete list.
| Contract | Address |
|---|---|
| WETC | 0x1953cab0E5bFa6D4a9BaD6E05fD46C1CC6527a5a |
| V2 Factory | 0x0307cd3D7DA98A29e6Ed0D2137be386Ec1e4Bc9C |
| V2 Router | 0x79Bf07555C34e68C4Ae93642d1007D7f908d60F5 |
| V3 Factory | 0x2624E907BcC04f93C8f29d7C7149a8700Ceb8cDC |
| V3 SwapRouter02 | 0xEd88EDD995b00956097bF90d39C9341BBde324d1 |
| Universal Router | 0x9b676E761040D60C6939dcf5f582c2A4B51025F1 |
| Permit2 | 0x000000000022D473030F116dDEE9F6B43aC78BA3 |
Important: ETCswap uses different INIT_CODE_HASH values than Uniswap:
| Type | Chain | Hash |
|---|---|---|
| V2 Pair | Classic | 0xb5e58237f3a44220ffc3dfb989e53735df8fcd9df82c94b13105be8380344e52 |
| V2 Pair | Mordor | 0x4d8a51f257ed377a6ac3f829cd4226c892edbbbcb87622bcc232807b885b1303 |
| V3 Pool | All | 0x7ea2da342810af3c5a9b47258f990aaac829fe1385a1398feb77d0126a85dbef |
# Clone the repository
git clone https://github.com/etcswap/sdks.git
cd sdks
# Install dependencies
pnpm install
# Build all packages
pnpm build
# Run tests
pnpm test
# Type check
pnpm typechecksdks/
├── .github/
│ ├── CLAUDE.md # AI assistant instructions (Claude Code)
│ └── copilot-instructions.md # AI assistant instructions (GitHub Copilot)
├── docs/
│ ├── PUBLISHING.md # npm publishing guide
│ └── V4_ROADMAP.md # V4 SDK roadmap
├── sdks/
│ ├── sdk-core/ # @etcswapv2/sdk-core
│ ├── v2-sdk/ # @etcswapv2/sdk
│ ├── v3-sdk/ # @etcswapv3/sdk
│ └── router-sdk/ # @etcswapv3/router-sdk
├── deployed-contracts.md # Contract addresses reference
├── CONTRIBUTING.md # Contribution guidelines
└── README.md
| Document | Description |
|---|---|
| Contributing Guide | How to contribute to this project |
| Publishing Guide | How to publish packages to npm |
| V4 Roadmap | Future V4 SDK development plans |
| Deployed Contracts | All contract addresses for Classic and Mordor |
| Claude Instructions | Instructions for Claude Code AI assistant |
| Copilot Instructions | Instructions for GitHub Copilot |
Core building blocks shared across all SDKs:
ChainId- Supported chain identifiers (CLASSIC=61, MORDOR=63)Token- ERC20 token representationCurrencyAmount- Amount with currency contextPercent- Percentage calculationsPrice- Price representationTradeType- EXACT_INPUT or EXACT_OUTPUTETC- Native currency helperWETC- Wrapped ETC token addresses
V2 AMM (constant product) entities:
Pair- Liquidity pair representationRoute- Path through pairsTrade- Swap trade with amounts and impactcomputePairAddress- Calculate pair address via CREATE2INIT_CODE_HASH_MAP- Chain-specific pair init code hashes
V3 CLMM (concentrated liquidity) entities:
Pool- V3 pool with tick dataPosition- Liquidity position in tick rangeRoute- Path through poolsTrade- V3 swap tradeFeeAmount- Fee tier enum (100, 500, 3000, 10000)computePoolAddress- Calculate pool address via CREATE2nearestUsableTick- Round tick to valid valueTickMath- Tick <-> sqrt price conversionsTICK_SPACINGS- Fee tier to tick spacing mapping
Universal Router support:
MixedRouteSDK- Mixed V2/V3 routesTrade- Universal trade representationProtocol- V2, V3, or MIXED identifier
This repository includes instructions for AI coding assistants:
- Claude Code: See .github/CLAUDE.md
- GitHub Copilot: See .github/copilot-instructions.md
Key points for AI assistants:
- Use JSBI ^3.x (not 4.x) for big integer math
- ETCswap INIT_CODE_HASH values differ from Uniswap
- Chain IDs: Classic=61, Mordor=63
- Follow existing code patterns in each SDK
- ETCswap V2: https://v2.etcswap.org
- ETCswap V3: https://v3.etcswap.org
- Analytics: https://v3-info.etcswap.org
- Ethereum Classic: https://ethereumclassic.org
MIT