Questions tagged [uniswapv2]
The uniswapv2 tag has no usage guidance.
92 questions
0
votes
0
answers
58
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/...
0
votes
1
answer
123
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.
...
0
votes
2
answers
154
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 &...
0
votes
1
answer
152
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....
0
votes
1
answer
202
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 ...
0
votes
1
answer
645
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 ...
1
vote
1
answer
111
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 ...
0
votes
0
answers
99
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). ...
1
vote
2
answers
405
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 ...
1
vote
1
answer
458
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 ...
1
vote
3
answers
245
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 ...
1
vote
1
answer
447
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');
...
1
vote
1
answer
35
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 {
...
2
votes
1
answer
512
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 ?
2
votes
1
answer
190
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, ...
1
vote
2
answers
5k
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 ...
1
vote
1
answer
28
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/...
2
votes
1
answer
236
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 ...
0
votes
1
answer
582
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
...
0
votes
2
answers
436
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/...
0
votes
1
answer
144
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 ...
0
votes
1
answer
161
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 ...
0
votes
3
answers
2k
views
What is the UniswapV2Factory address on the Sepolia network
Does anyone know what's the factory address of UniswapV2 in sepolia?
Thanks
0
votes
1
answer
899
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 ...
0
votes
1
answer
143
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 ...
1
vote
0
answers
506
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 =...
3
votes
1
answer
14k
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 ...
0
votes
1
answer
194
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), ...
0
votes
1
answer
84
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 ...
0
votes
1
answer
573
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 ...
1
vote
1
answer
172
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 ...
2
votes
0
answers
103
views
Can’t remove liquidity on uniswap [closed]
I’m having issue removing my lp from uniswap 0xbeF4fB0BE483c74667aB6Fb5f3C1fCdc7b4eC073
Please help check the contract out
1
vote
1
answer
938
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,
...
1
vote
0
answers
43
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 ...
0
votes
2
answers
445
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 ...
2
votes
0
answers
175
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 ...
0
votes
1
answer
57
views
I want to fetch live Feed's From Dex's like Uniswap sushi and pancake
I'm working on a project where we need to get prices from 3 to 4 dex on the Ethereum chain and the Solana chain. What is the best way to get a live feed from Ethereum dex? I want to fetch the live ...
2
votes
1
answer
2k
views
What is the use case of deadline in Uniswap's Router02?
The UniswapV2 Router02 performs a deadline check for adding/removing liquidity and swaps.
modifier ensure(uint deadline) {
require(deadline >= block.timestamp, 'UniswapV2Router: EXPIRED');
...
1
vote
0
answers
183
views
How to store dynamic bytes in memory in solidity inline assembly?
this is my code to test transferring some tokens to the target address, which functions well.
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
import "./interface/IERC20.sol";
...
1
vote
0
answers
499
views
Uniswap V2 getAmountOut arbitrage calculation
I'm trying to learn more about arbitrage bots and it seems I'm stuck on profit calculation.
Lets say I have two different routers - Uniswap V2 and Sushiswap
To calculate possible arbitrage I use ...
2
votes
3
answers
2k
views
DEX Real-Time Data
I have a project that tries to retrieve real time data from UnisWap V2 and SushiSwap I have already figured out how to get real time data from Sushi using api but it's not the same for Uniswap API ...
1
vote
1
answer
471
views
Manipulating Uniswap V2's pair totalSupply via flash loan
Let's assume that I'm writing a UniswapV2 LP token price oracle. Would it be a bad idea to rely on the LP token totalSupply for my calculation? Would it be possible to manipulate its value through a ...