Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [uniswapv2]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
14 views

Is it possible to recover non-reserve tokens accidentally sent to a Uniswap V2 Pair contract?

I'm trying to understand the operation and potential pitfalls of interacting with UniswapV2Pair contracts. I'm aware that if excess token0 or token1 are sent to a Pair contract, it may be possible to ...
opsec's user avatar
  • 1
-1 votes
1 answer
15 views

I updated Solidity to version to 0.6.12. Now the code is broken, how to fix?

How can I fix my code, the chainid is 9999.I tried changing chainId := chainid to chainId := chainid() but it doesn't work. Here is the whole code: pragma solidity 0.6.12; import './interfaces/...
Mr. arikodus's user avatar
0 votes
0 answers
21 views

uniswap v3 Calculate entrance price of a liqidity pool

for example I have added a liquidity on a uniswap v3 pool with this data: pair: CAKE-ETH min price: 1,074.54 max price: 1,118.39 cake amount: 116.752 eth amount: 0.077786 tick spacing: 200 now how ...
Sa SO_PO's user avatar
0 votes
0 answers
17 views

Downscaling liquidity tax according to ETH reserves for fair distribution without presale

So I wanted to try and solve the problems that arise when releasing a token with very low liquidity. Presaling should absolutely be avoided since holders always dump at the start. Assume 50 to 100% of ...
Ashraile's user avatar
  • 125
0 votes
2 answers
15 views

reserve0/reserve1 price is different compared to boughtTokensAmount/requiredWeiAmount

I would start with a sample on exact UniswapV2 pair SHIB/WETH (SushiSwap). I use local hardhat node and there's no possibility of 3-rd party effect on LP. I have this toSwapTokensAmount = ...
dvcr's user avatar
  • 3
0 votes
1 answer
34 views

UniversalRouter execution reverteed BASE chain

I'm trying to use UniversalRouter to swap WETH to token, this is how i'm doing it: //from - WETH, to - test token const contract = new ethers.Contract( "...
Moltea_'s user avatar
0 votes
1 answer
23 views

transaction reverted when calling swapExactETHForToken on uniswapRouter02

currently, I'm trying to swap eth for an erc20 token and the transaction gets reverted every time, not quite sure what I'm missing, i pre-approved some allowance for the router02 to spend on my behalf,...
yahdielo's user avatar
0 votes
1 answer
18 views

Transaction execution reverted on swapExactTokensForETH

I hope somebody can help I am trying to sell a token via Uniswap V2 Router02 (Token CA: 0x4ed4E862860beD51a9570b96d89aF5E1B0Efefed) (This token is a legit one, there is no scam here), I have ...
duyanhhz's user avatar
1 vote
1 answer
87 views

Insufficient Liquidity after adding liquidity on Sepolia Uniswap V2

I created a token "TestMe" with 2 million tokens (18dec), minting the deployer address the whole stack. I used the "addLiquidityETH" function provided by uniswap router to add 500k ...
SolidityNewbie's user avatar
0 votes
1 answer
43 views

Insufficient Allowance ERC20 when adding liquidity to Uniswap V2 Pool

I am trying to create a contract with a Uniswap V2 Pair for my TestMe Token on Sepolia Testnet. Smart Contract: // SPDX-License-Identifier: MIT pragma solidity 0.8.24; import "lib/openzeppelin-...
SolidityNewbie's user avatar
0 votes
1 answer
140 views

Uniswap V2 Router, Factory on amoy Test Network

what is the address of uniswap router on amoy test network as currenty uniswap doesn't support amoy network.
sahil's user avatar
  • 5
0 votes
0 answers
17 views

I cant sell this token, me3 contract below, anyway to sell?

/** *Submitted for verification at BscScan.com on 2024-04-13 */ // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.19; abstract contract Context { function _msgSender() internal view ...
Mohamad Alazawi's user avatar
0 votes
1 answer
27 views

Can someone explain the initialize function in UniswapV2 contract?

https://etherscan.io/address/0x1b5bea98cb56da56723db75f2c3b24f6119faf98#code function Initialize () external onlyOwner { require(!tradingOpen,"init already called"); ...
Lappazuronef187's user avatar
0 votes
1 answer
41 views

Large price discrepancy between swapExactTokensForTokens and official swap

I am testing performing swaps using solidity ^0.8.24 smart contracts with hardhat on Polygon and Quickswap exchange. But I am getting relatively large price discrepancies between my swap and one ...
SolTester's user avatar
1 vote
1 answer
80 views

Execution Reverted due to UniswapV2-Pair creation in constructor

I am new to Blockchain development, so bear with me. I successfully deployed my first contract, but if I try to add a Uniswap V2 Pair creation inside the constructor, I always get the error "...
SolidityNewbie's user avatar
0 votes
2 answers
65 views

UniSwapV2 Testnet Support

As you may be aware, the Goerli Testnet has been deprecated, and furthermore, UniSwapV2 is not supported on the Sepolia Testnet. What would be the recommended solution? Thank you in advance.
rebwar's user avatar
  • 3
0 votes
0 answers
14 views

Optimizing gas consumption for the Spit Swap smart contract

how to optimize gas consumption for Spit Swap? If I use the pool contract directly, can this significantly reduce gas consumption? SplitSwapV2.sol // SPDX-License-Identifier: GPL-3.0 pragma solidity &...
Brain King's user avatar
1 vote
0 answers
9 views

Misalignment between Uniswap V2 calculateSwapInput and calculateSwapOutput functions

I've written my own functions calculateSwapInput and calculateSwapOutput for liquidity pools, based off of the Uniswap v2 spec. My functions are below: // Calculates how much of one token we need to ...
713sean's user avatar
  • 111
0 votes
2 answers
48 views

uniswapRouter.getAmountsOut returns less value of token B than present in reverses when provide full amounts of token A

I have the next code to get familiar with uniswap mechanics: create pair contract get reserves invoke getAmountsOut and provide all UNI token reserves const pairAddress = await _V2Factory.getPair(...
dvcr's user avatar
  • 3
0 votes
2 answers
406 views

Does Uniswap allow testing swap on testnets?

I am testing my smart contract on goerli testnet. Everything is working. After I complete adding an LP when I want to test whether it is able to swap, the system keep showing "Insufficient ...
yaoyao's user avatar
  • 1
1 vote
1 answer
28 views

Swapping continuouly failing. only one become success with swapExactTokenForTokens

I have this function.I want to perform swap 3 times with the interval of 30 second using swapExactTokenForTokens.But only only one transaction get success.Others failing. Here is my Code. const ...
Ruwini Shashikala's user avatar
1 vote
1 answer
110 views

I am getting reason: 'invalid BigNumber value', Error. What is the reason?

wallet = ethers.Wallet.fromMnemonic(mnemonic) // console.log(wallet.address) const signer = wallet.connect(provider); // console.log(signer) const routerInstance = new ethers.Contract(routerAddress, ...
Ruwini Shashikala's user avatar
1 vote
0 answers
21 views

How can Retrieving Pending Transaction Reserves (reserve0 and reserve1) in Uniswap V2?

How can I retrieve the reserve0 and reserve1 values from Uniswap V2, not from already mined blocks, but specifically from transactions that are still pending?
PandaKungFuu's user avatar
0 votes
0 answers
27 views

Unable to Add Liquidity using uni swap V2 front end clone

I’m having error from the Uniswapv2 clone that I cloned following the below website instructions: https://www.covalenthq.com/docs/unified-api/guides/how-to-clone-uniswapv2-frontend/ The problem I’m ...
bature's user avatar
  • 1
1 vote
1 answer
43 views

Liquidity pool question (probably very dumb)

My company launched an ERC20 with a Uniswap LP a few years back (2020). They never did anything much with it, and now they want to pull the LP and be done with it. The problem is that nobody in the ...
user130599's user avatar
0 votes
1 answer
589 views

Uniswap V2 optimal arbitrage amount

Tried out whole week to find an answer somewhere for this question, but, nothing to see, unfortunately, Let suppose there are 2 USDT/WETH pairs, one on Uniswap and another one on any Uniswap v2 fork ( ...
Mar St's user avatar
  • 1
1 vote
0 answers
235 views

How can I run the Uniswap Dapp locally for sepolia testnet

I am trying to play around with the Uniswap contracts, by creating pools then swapping etc. The problem I'm facing is that Uniswap V2 doesn't support the sepolia network, V3 does. So when I interact ...
Zartaj Afser's user avatar
  • 4,296
0 votes
1 answer
147 views

Trouble making UniV2 swap on Sepolia with web3py

I'm using the below code to try and make a swap on Sepolia. I've got ETH in my wallet and have found a token that has had liquidity added. Depending what I set the minOutput to I get 'Fail with error '...
stooks's user avatar
  • 11
1 vote
1 answer
71 views

Python Web3 sign transaction without calling "build_transaction"

I need to sign two different transactions: token_contract = web3.eth.contract(address=web3.to_checksum_address(TOKEN_ADDRESS), abi=json.loads(erc20_abi)) approve_trx = token_contract.functions.approve(...
Francesco Stucci's user avatar
0 votes
1 answer
23 views

Vulnerable when using swapExactETHForTokens

I thought that setting block.timestamp to a deadline prevents MEV sandwich attacks.But my question is does it do the work well? address destinationAddress, uint256 minAmountOut ) ...
jacobs david's user avatar
1 vote
2 answers
152 views

What happens when we directly send tokens to Uniswap pair?

This is about Uni V2 pools. So usually we call the function addLiquidity to add liquidity, but the function decides how many tokens should be added depending on the reserves. What if we directly send ...
Solidity Nerd's user avatar
0 votes
0 answers
186 views

Does anyone know what uniswapRouterAddress and uniswap abi is on Sepolia network?

I am working on react native project, using v6 of ethers.js and infuria as my node. I initiate the contract like this: const uniswapRouterAddress = '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45'; ...
Scott's user avatar
  • 15
0 votes
1 answer
193 views

getAmountIn equivalent of uniswapV3 or how to calculate it?

I was exploring uniswap V3 router, quoter and factory contracts, but it doesn't have getAmountIn function to calculate the minimum amount I must input to get the desired amount. On some thread, I ...
Biruk Damte's user avatar
2 votes
0 answers
26 views

Uniswap/PancakeSwap automatically manage tokens with different amount of decimals (swap)?

I'm getting number results that do not make sense for me, when executing swap functions with USDT (in Uniswap V2 and PancakeSwap V2), and I noticed that USDT Token has only 6 decimals, instead of 18 (...
Alexander Herranz's user avatar
0 votes
1 answer
31 views

what will happen when two people execute removeLiquidity in uniswap v2?

According to the code of uniswap-v2/v2-periphery/contracts/UniswapV2Router02.sol in function removeLiquidity(): // **** REMOVE LIQUIDITY **** function removeLiquidity( address tokenA, ...
sy liu's user avatar
  • 1
1 vote
0 answers
142 views

cannot use array as type ptr as argument

I am using Go-Ethereum and I have the following error: abi: cannot use array as type ptr as argument But it does not make any since I don't pass an array. The arguments to routerABI.Pack function ...
pigfox's user avatar
  • 71
1 vote
2 answers
167 views

How to know base token from the pool

here is quick question. From uniswap pool, which one is base token? token0 or token1?
Biruk Damte's user avatar
4 votes
2 answers
3k views

Getting Uniswap v2 latest price and interpreting values using Python

When interacting with functions price0CumulativeLast and price1CumulativeLast of any smart contract on Uniswap V2 I keep getting incomprehensive values. I am not able to figure out how to extract the ...
Aniss Itaoui's user avatar
0 votes
0 answers
51 views

Can you tell me, why addLiquidityETH is not working?

Can you tell me, why addLiquidityETH is not working? I'm trying to call her through etherscan. // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/...
user125862's user avatar
0 votes
1 answer
81 views

UniswapV2 addLiquidityETH revert ds-math-sub-underflow

I tried this code for many contracts, and sending ETH and approving were done well, but on the addliquidityETH section, I get an error: reverted with 'ds-math-sub-underflow'. I can't understand why. ...
upme24's user avatar
  • 1
0 votes
0 answers
37 views

Minimal proxy contract, can make pair but can’t add liquidity

I have a cloneFactory which produces ERC20 compliant clones based on a master template. I’m able to deploy my clones and even create pairs for the clones. But when I want to add liquidity (...
Cloudronaut's user avatar
0 votes
2 answers
100 views

Questioning about the _safeTransfer in the swap function of the UniswapV2 pair contract

I have a question about the _safeTransfer function in the swap function down below. if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens if (amount1Out &...
DHC's user avatar
  • 367
0 votes
1 answer
93 views

While deploying contract i got Warning: Contract code size exceeds 24576 bytes

I'm trying to deploy UniswapV2Router02 but i got error Contract code size exceeds 24576 bytes. How do I proceed with optimization? Now i'm using remix and current compiler is 0.6.6 pragma solidity =0....
Hunter Joe's user avatar
0 votes
1 answer
149 views

ERC20 token with a uniswapV2 router address initialized in the constructor. I also have method to change the router address. but confused

I'm working on ERC20 token with a uniswapV2 router address initialized in the constructor. I also have method to change the router address. but I'm confused because when i create the new Pair with a ...
Hamza Shafeeq's user avatar
0 votes
1 answer
400 views

pancakeswap v2 flash loan arbitrage real output amount is not as expected

when i monitor a profitable trade. The difference in profit calculated by my own method and the result of getAmoutsOut is not significant. Before sending the transaction, I would use the getAmoutsOut ...
DOGGODCoder's user avatar
1 vote
1 answer
88 views

How will liquidity be affected if I call ERC20 transfer() directly on a pair in Uniswap V2?

If I transfer() one of the paired X or Y tokens, or a completely unrelated Z token, to the address of an X/Y pair contract developed on UniswapV2, won't the liquidity of the pool change? (It seems ...
Harriger's user avatar
0 votes
0 answers
90 views

Require WETH liquidity on uniswap v2 pair to be min 1 ETH to trade

I want to launch a token with a significant part of the supply being airdropped (no vesting). I'd like to implement a requirement so that airdropped holders won't sell into initial liquidity (1 ETH). ...
soliditynoob's user avatar
1 vote
2 answers
256 views

UniswapV2's equivalent of getPair and other functions

i see uniswapv3 quoter or factory or router contracts doesn't have getPair, getReserve and other similar ABI functions like UniswapV2. does UniswapV3 have Equivalent for this functions? or did they ...
Biruk Damte's user avatar
1 vote
1 answer
333 views

Uniswap V2 Transfer Tax Math

The normal question to get the amount of token received when doing a Uniswap V2 swap is amount_out = 0.997 * amount_in * reserves_out / (reserves_in + 0.997 * amount_in) I want to adjust this equation ...
galpo's user avatar
  • 145
1 vote
3 answers
170 views

Help me make sense of this seeminlgly simple Uniswap V2 transaction, please

https://etherscan.io/tx/0x006a041ade99b4715e6578ac968932f47fa9f1be1a676ad66678260ca0fbb6d1 This appears like a vanilla UniswapV2Router02 swap, sending the well-known method ...
blitter's user avatar
  • 193