Routing a Swap
This section explains how to use Storyhunt's router to compute optimal routes and execute swaps.
Introduction
Get required Trading Pools
const tokenPoolResult = await executeGraphQuery<GraphPoolResponse>(
POOLWTOKEN_QUERY,
{
token0: currencyIn.address.toLowerCase(),
token1: currencyOut.address.toLowerCase(),
});
const poolObj = new Pool(
tokenA,
tokenB,
parseInt(pool.feeTier),
JSBI.BigInt(pool.sqrtPrice),
JSBI.BigInt(pool.liquidity),
parseInt(pool.tick),
tickDataProvider
);