I have a func to get eth price from uniswap pair USDC-WETH but could’t really test on Ropsten. The pair address is here https://ropsten.etherscan.io/address/0x7cae76c0517ddca4c10bf023b607b4db92114b41#readContract
However, getReserves() will give me (0,0,) for the pair ratio. How can I test a close to mainnet ratio for this pair? Thanks
Skyge
April 29, 2021, 3:57pm
2
Emmm, it seems like there is not any reserves in this pair contract, so maybe you can try to add some liquidity and then call this function
1 Like
I’m trying to add lidquidity to USDC-WETH pair on Ropsten through Truffle js script but couldn’t quite get it working with this error: Error: IUniswapV2Router02 has not been deployed to detected network (network/artifact mismatch)
module.exports = async function main(callback) {
try {
const IUniswapV2Pair = artifacts.require("IUniswapV2Pair");
const IUniswapV2Factory = artifacts.require("IUniswapV2Factory");
const IUniswapV2Router01 = artifacts.require("IUniswapV2Router01");
const IUniswapV2Router02 = artifacts.require("IUniswapV2Router02");
const uniswapV2Router = await IUniswapV2Router02.deployed('0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D');
uniswapV2Router.approve('0x7cae76c0517ddca4c10bf023b607b4db92114b41', 1000);
uniswapV2Router.addLiquidityETH(
'0x7cae76c0517ddca4c10bf023b607b4db92114b41',
3,
3, // slippage is unavoidable
1, // slippage is unavoidable
owner(),
block.timestamp
);
callback(0);
} catch (error) {
console.error(error);
callback(1);
}
Skyge
April 30, 2021, 3:41pm
4
Do you use truffle
to run script or web3.js
? I think for truffle
, it should be
const uniswapV2Router = await UniswapV2Router02.at('0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D');
And if you use web3.js
, it should be:
const uniswapV2Router = await new web3.eth.Contract(Contract_Interface, Contract_address)`
But there is a more easier to do this, you can add liquidity by the website of the Uniswap with the Ropsten network.
1 Like
Thank you. I’m using truffle to run the js script. Truffle documentation is quite lacking. How did you know it is UniswapV2Router02.at
?
How do I use uniswap front end website on ropsten test net? I only see mainnet.
Skyge
May 1, 2021, 10:46pm
6
Just change your network to the Ropsten.