The SDK offers a lightweight bundle with first-class support for viem, full TypeScript typings, ESM/CJS compatibility, and support for quoting, trading, and managing NFT-based liquidity positions.
Quick Start & Installation
Install the SDK along with theviem Ethereum client for RPC interactions:
Imports & Initialization
Core Imports
Client Setup
Quoting a Swap
Get swap quotes and calldata for token exchanges:Response Parameters
Compute & Inspect Pools
Compute Pool Address
Calculate the deterministic address for a specific token pair and fee tier:Fetch Pool State
Retrieve current pool information:Pool State Response
Executing a Trade
Execute swaps using the router contract:Managing Liquidity Positions (NFT)
Minting a Position
Create new concentrated liquidity positions:Increase / Decrease Liquidity
Modify existing positions:Collecting Fees
Collect accumulated fees from your positions:Technical Reference
Exports from @shibaswap/v2-sdk
Core Functions
getSwap(params)– fetch quote + calldatacomputePoolAddress({ factoryAddress, tokenA, tokenB, fee })
Constants
ChainId– enum of supported networksFeeAmount– fee presets:LOW = 500,MEDIUM = 3000,HIGH = 10000
Liquidity Classes
NonfungiblePositionManager– NFT position managementPosition– concentrated liquidity position abstractionPool– pool state and calculations
Utilities
Percent– percentage calculationsCurrencyAmount– token amount handling
Fee Amount Constants
Supported Networks
Best Practices
1
Use proper error handling
Always wrap SDK calls in try-catch blocks and handle potential failures gracefully.
2
Implement slippage protection
Set appropriate slippage tolerance based on market conditions and token volatility.
3
Optimize gas usage
Batch operations when possible and use appropriate gas limits for complex transactions.
Position management operations typically require higher gas limits than simple swaps.
4
Monitor position health
Regularly check if your concentrated liquidity positions are still in range.
Out-of-range positions don’t earn fees and may suffer impermanent loss.
Integration Examples
React Hook Example
Position Management Hook
Related Resources
Providing Liquidity
Learn about liquidity provision mechanics.
Smart Contracts
Understand the core protocol contracts.
Multihop Swaps
Learn about complex swap routing.
Liquidity Rewards
Understand fee distribution and rewards.
Build powerful DEX integrations with full control over trading and liquidity using ShibaSwap V2 SDK. The SDK provides all the tools needed to create sophisticated DeFi applications with concentrated liquidity support.