Skip to content
This repository was archived by the owner on Apr 25, 2024. It is now read-only.
This repository was archived by the owner on Apr 25, 2024. It is now read-only.

Fails to return reserve outputs from getReserves() #115

@Samboy76

Description

@Samboy76

Hello,

I have an issue in that I cannot get passed executing code line await pairContract.functions.getReserves(); shown in below code snippet. There is no error caught in trycatch so what am I doing wrong here? Any suggestions please?

const getPair = async (other) => {
	const pairAddress = Pair.getAddress(other, WETH[other.chainId], provider,);
	console.log("pairAddress ", pairAddress);

	const pairContract = new ethers.Contract(
		pairAddress,
		UniswapV2Pair.abi,
		provider,
	);

	console.log("pairContract ", pairContract.address);
	try {
		const reserves = await pairContract.functions.getReserves();
		console.log("reserves ", reserves);
	} catch (error) {
		console.log("error text ", error);
	}
	
	const [reserve0, reserve1] = reserves;
  
	const tokens = [other, WETH[other.chainId]];
	const [token0, token1] = tokens[0].sortsBefore(tokens[1]) ? tokens : [tokens[1], tokens[0]];
  
	const pair = new Pair(new TokenAmount(token0, reserve0), new TokenAmount(token1, reserve1));
	return pair;
};

Truffle v5.5.31 (core: 5.5.31)
Ganache v7.4.3
Solidity - >=0.5.0 <0.9.0 (solc-js)
Node v16.17.0
Web3.js v1.7.4

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions