ghost-dao-interface/src/hooks/uniswapv2/UniswapV2Factory.js
Uncle Fatso d4446f6fb1
version 0.0.22
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
2025-04-28 14:03:56 +03:00

22 lines
707 B
JavaScript

import { useReadContract } from "wagmi";
import { abi as UniswapV2Factory } from "../../abi/UniswapV2Factory.json";
import { UNISWAP_V2_FACTORY } from "../../constants/addresses";
export const useUniswapV2Pair = (chainId, factoryAddress, token0, token1) => {
const t0 = token0 > token1 ? token0 : token1;
const t1 = token0 > token1 ? token1 : token0;
const { data, refetch } = useReadContract({
abi: UniswapV2Factory,
address: factoryAddress,
functionName: "getPair",
args: [token0, token1],
scopeKey: `getPair-${t0}-${t1}-${chainId}`,
chainId: chainId,
});
const pairAddress = data ? data : "";
return { pairAddress, refetch };
}