Update usePools.js

This commit is contained in:
Daniel
2022-11-05 11:39:02 +01:00
parent 1a203532c1
commit c7dd0cc666

View File

@@ -3,10 +3,15 @@ import { useEffect, useState } from "react";
import { useConfig } from "@usedapp/core"; import { useConfig } from "@usedapp/core";
import { ROUTER_ADDRESS } from "../config"; import { ROUTER_ADDRESS } from "../config";
import { getFactoryInfo, getRouterInfo } from "../utils";
export const loadPools = async (providerUrl) => { //fetch liquidity pool export const loadPools = async (providerUrl) => { //fetch liquidity pool
const provider = new Web3.providers.HttpProvider(providerUrl); const provider = new Web3.providers.HttpProvider(providerUrl);
const web3 = new Web3(provider);
const routerInfo = await getRouterInfo(ROUTER_ADDRESS, web3);
const factoryInfo = await getFactoryInfo(routerInfo.factory, web3);
return factoryInfo.pairsInfo;
} }
export const usePools = () => { export const usePools = () => {
const { readOnlyChainId, readOnlyUrls } = useConfig(); const { readOnlyChainId, readOnlyUrls } = useConfig();