V3 SDK
The v3-sdk is a TypeScript library for interacting with StoryHunt V3, offering utilities for swaps, position management, and more.
npm install @storyhunt/v3-sdkimport { Pool, Trade, SwapRouter } from '@storyhunt/v3-sdk';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 } );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, });