V3 SDK
The v3-sdk is a TypeScript library for interacting with StoryHunt V3, offering utilities for swaps, position management, and more.
Installation
npm install @storyhunt/v3-sdk
Key Features
Generate optimized swap routes.
Compute liquidity position fees.
Encode calldata for on-chain execution.
Example Usage
Import and Configure:
import { Pool, Trade, SwapRouter } from '@storyhunt/v3-sdk';
Create Pool:
const pool = new Pool( tokenA, tokenB, parseInt(pool.feeTier), JSBI.BigInt(pool.sqrtPrice), JSBI.BigInt(pool.liquidity), parseInt(pool.tick), tickDataProvider ); const trade = await Trade.bestTradeExactIn( allPools, CurrencyAmount.fromRawAmount( currencyIn, JSBI.BigInt(amount.toString()) ), currencyOut, { maxHops: 3, maxNumResults: 1 } );
Encode calldata:
const { calldata, value } = SwapRouter.swapCallParameters(trade, { slippageTolerance: new Percent(JSBI.BigInt(50), JSBI.BigInt(10000)), // 0.5% deadline: JSBI.BigInt(Math.floor(Date.now() / 1000) + 60 * 20), // 20 minutes from now recipient: address, });