Questions tagged [uniswapv2]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
11 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
2 votes
1 answer
18 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
26 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
  • 5
0 votes
1 answer
49 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
13 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
12 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
95 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
  • 125
1 vote
2 answers
39 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
516 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
35 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
40 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
10 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
37 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
  • 313
0 votes
1 answer
42 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
35 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
124 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
75 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
39 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
81 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
157 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
  • 45
1 vote
3 answers
95 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
  • 183
1 vote
1 answer
130 views

Use the swapExactETHForTokensSupportingFeeOnTransferTokens method of uniswap routerV2 to purchase uniswap V3pair tokens

const buyToken = async (account: any, tokenContract: any, gasLimit: any, gasPrice: any) => { let amountOutMin = 0; const amountIn = ethers.utils.parseUnits(useBuy.value.toString(), 'ether'); ...
lawrence Alan's user avatar
1 vote
1 answer
21 views

Can someone tell me you to pass an array argument to external function in assembly/yul?

So far I have tried this: function swapEthForToken( address router, uint256 minAmount, address _tokenIn, address _tokenOut ) public payable { assembly { ...
Mehul Singh Rathore's user avatar
2 votes
1 answer
230 views

How can I get all tokens listed on `Sushiswap`

How can I get all tokens listed on Sushiswap. For uniswap we can call factory.getTokenWithId(id) with the token id. But how can we do the same for Sushiswap ?
Saikat Karmakar's user avatar
1 vote
1 answer
48 views

"Error: Invalid Argument in getAmountsOut Function Call."

// Get Provider const providers = new ethers.providers.JsonRpcProvider("https://"); // Get Velodrome V1 Router const routerABI = [ "function getAmountsOut(uint amountIn, ...
Mochi Vani's user avatar
1 vote
2 answers
751 views

How a price of a token is being calculated on uniswap & other dexes?

I have just started learning about Uniswap. I have a question, How a price of a token is calculated? I know the x*y = k which defines the price of 2 assets from a pool but how the value of a single ...
Saikat Karmakar's user avatar
1 vote
1 answer
21 views

error Dai/insufficient-allowance even when sufficient amount has been approved

I am testing smart contract interaction with Gains.trade on hardhat mainnet fork. However i always got this error Error: VM Exception while processing transaction: reverted with reason string 'Dai/...
Haziq Raz's user avatar
2 votes
1 answer
108 views

Finding IUniswapV2Callee in UniswapV2 clones for flashloans

In similar fashion to this question specific to PancakeSwap For many UniswapV2 clones, I want to find the part of the code which is replicating IUniswapV2Callee interface, so that I can use it in a ...
miskin's user avatar
  • 21
0 votes
1 answer
151 views

Abi encode / decode mystery additional 32 byte field Uniswap v2

When I encode my abi data in web3js or web3.py for a uni v2 trade I get the following: 0x 00000000000000000000000000000000000000000000000000000000000000a0 ...
Nat's user avatar
  • 279
0 votes
2 answers
293 views

Contract Address for Swap Router for Goerli ARB

Does anyone know an address or sanple address for Swap Router in Goerli Arbitrum Testnet Network? Like this sample in mumbai https://mumbai.polygonscan.com/address/...
Lloyd Ramos's user avatar
0 votes
0 answers
55 views

ETH Sent to Uniswap V2 router after creating LP

Please help. I tried creating an LP on Uniswap V2 on Arbitrum. It turns out only v3 is available on arb one. On uniswap page, I chose v2 pool on Eth network, then on top right, I changed it to Arb one....
ven's user avatar
  • 1
0 votes
0 answers
81 views

Transfer Delay enabled. Only one purchase per block allowed

I am using uniswap v2 router in with the following code: function mintNFT(address recipient) public payable returns (uint256) { require(msg.value >= mintCost, "Insufficient ...
Jesse Jacob's user avatar
0 votes
1 answer
37 views

How to estimate input amount for sushiswap?

For estimation of input amount of tokens while calling quoteExactOutputSingle I use following for uni v2 const pair = await Fetcher.fetchPairData(tokenFrom, tokenTo, provider); const route = new ...
Serhii Nikitin's user avatar
0 votes
1 answer
86 views

Combining getAmountsIn() and swapTokensForExactTokens() in UniswapV2Router: Can I Achieve Accurate Token Swap Without Slippage?

Can I perform the following functions using UniswapV2Router at once? Theoretically, as far as I know, if I call both getAmountsIn() and swapTokensForExactTokens() within a single function, both logics ...
Harriger's user avatar
0 votes
0 answers
77 views

Uniswap V2 flashswap how to work with it?

Problem: I need to make an arbitrage between two uniswap v2 like exchanges. I have researched many open-sourced repositories and read documentation, but still don't understand the next: How to ...
Paul Bolhar's user avatar
0 votes
3 answers
465 views

What is the UniswapV2Factory address on the Sepolia network

Does anyone know what's the factory address of UniswapV2 in sepolia? Thanks
Harsh Gupta's user avatar
0 votes
1 answer
278 views

Why am I getting different quotes, at the same time, between uniswap website and the router v2 contract?

If I run the queries at the same time, I would expect very approximate results, if not the exact same, but that's not what I get between the Uniswap's website and the Router V2 contract as you can see ...
Pedro D.'s user avatar
0 votes
1 answer
71 views

Is there any significant advantage that UniswapV3 has over UniswapV2 in a Flashloan(or Flashswap) scenario?

I have been following the flash loan market for a while and I want to eventually experiment on it but i am having a hard time choosing between UniswapV2 and uniswapV3 for making my swaps. Is there any ...
Shigaba Shigaba's user avatar
0 votes
0 answers
14 views

Unable to do swap via swapExactTokensForETHSupportingFeeOnTransferTokens

What seems to be the issue in this code I am unable to swap tried everything: function transferFrom(address sender, address recipient, uint256 amount) public { require(sender != address(0), ...
Hammas Ali's user avatar
1 vote
0 answers
239 views

Uniswap: get token price for USDC in solidity

I try to create a function in Solidity which returns the amount of a ERC20 token for a set amount of USDC. For that I go through the following steps: Get the address of the pair. address pairAddress =...
rajohs's user avatar
  • 179
2 votes
1 answer
4k views

Uniswap V2 Router, Factory on Sepolia Test Network

Is it possible to use a Uniswap V2 router in Sepolia? what is the contract address of a router? What I got is only for the Goerli test network, and it is already an obsolete network, and you have to ...
querylab's user avatar
0 votes
1 answer
92 views

Transaction fails on Etherscan but succeeds on Tenderly, why is that?

So I have made a Uniswap V2 Fork and deployed it successfully, added liquidity etc everything successfully, all on Goerli. But when I am working on my frontend for my main Swap Component(in ReactJS), ...
CheeseMcBurger's user avatar
0 votes
1 answer
35 views

How to know the exact AMM implementation for a liquidity pool?

Is every liquidity pool which uses Uniswap V2 using the exact same AMM implementation? i.e. for 2 different liquidity pools, if I know the amount of liquidity (ratio of tokenA and tokenB) in the pool ...
Sergio Gliesh's user avatar
0 votes
1 answer
338 views

Uniswap router v2 pairing

I'm writing a token contract, and I'm wondering how pairing works precisely. I want to pair my token A with custom token B. I will add liquidity with x amount of token A and y amount of token B to ...
JohnDoeMighty's user avatar
1 vote
1 answer
93 views

How is Uniswap's way of calling the balanceOf function of an ERC20 gas optimized?

What is the redundant extcodesize check and returndatasize check that is mentioned here? /// @dev This function is gas optimized to avoid a redundant extcodesize check in addition to the ...
Maanas O T's user avatar
2 votes
0 answers
70 views

Can’t remove liquidity on uniswap [closed]

I’m having issue removing my lp from uniswap 0xbeF4fB0BE483c74667aB6Fb5f3C1fCdc7b4eC073 Please help check the contract out
dwanloaded tv's user avatar
1 vote
1 answer
745 views

Swapping token function in Uniswap V2 failed

I am trying to swap multiple tokens to Weth but this transaction gets failed with an error Fail with error TransferHelper: TRANSFER_FROM_FAILED function swapToWeth( address[] calldata tokens, ...
CHITRANSHU VARSHNEY's user avatar
1 vote
0 answers
33 views

My createTokenPair function isnt working when I call it from my frontend please help

Hello, I`ve forked Uniswap V2 perfectly fine on the backend and now I want to connect it to my frontend. I have built a basic webpage and I am now doing the frontend. When calling the createPair ...
CheeseMcBurger's user avatar
0 votes
2 answers
196 views

Is profitable direct arbitrage impossible with getAmountsOut?

I’ve run the math on a uniswap v2 arbitrage trade that looks more or less like this: 1) Buy X amount of token1 with Y amount of token0 on Uniswap 2) Sell equivalent amount of token1 in exchange for ...
Trent Kennelly's user avatar
1 vote
0 answers
66 views

Support FACTORY_ADDRESS and INIT_CODE_HASH in different forks of UniswapV2

I'm trying to parse transactions of different UniswapV2 like DEXes and have problems adding new forks of UniswapV2 to my project, such as SushiSwap, etc. I'm using @uniswap/v2-sdk for transactions of ...
Vlad's user avatar
  • 11