Skip to main content
8 votes

Uniswap V2 Router, Factory on Sepolia Test Network

No, you cannot use it because if we want to test our smart contract by deploying on Goerli then we use uniswap V2 Router address 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D but as we know Goerli faucet ...
Afaq Ahsan's user avatar
8 votes
Accepted

Getting Uniswap v2 latest price and interpreting values using Python

Dev advocate at Chainstack here. You can get prices directly from the Uniswap V2 pair contract, like you are attempting now, by analyzing the reserves of each token in the pair. The key to obtaining ...
Dave Dev Advocate Chainstack's user avatar
3 votes

Uniswap V2 optimal arbitrage amount

Short answer Plug these numbers in to calculate r, where r = optimal amount in x_a = reserve out of AMM A y_a = reserve in of AMM A x_b = reserve in of AMM B y_b = reserve out of AMM B f = fee (0.03%)...
tsknakamura's user avatar
3 votes

How can I get all tokens listed on `Sushiswap`

The SushiSwap subgraph provides a GraphQL API that you can query to get information about tokens, pairs, and other relevant data. You can find the SushiSwap subgraph URL on their official ...
Canard Coca's user avatar
3 votes
Accepted

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

The price of anything is calculated against something else. Nothing has value by itself. Remember the first time man traded a cow for a chicken. One gives a cow value in chickens. So the next time ...
Magno C's user avatar
  • 370
3 votes

DEX Real-Time Data

You can use smart contract logs of emitted events to retrieve a stream of real-time logs emitted by the Uniswap smart contract. You have two options: Use the eth_newFilter method combined with ...
Dave Dev Advocate Chainstack's user avatar
3 votes

What is the UniswapV2Factory address on the Sepolia network

Uniswap does not support sepolia for v2, so you won't be able to interact with it via uniswap frontend. if you want to use Sepolia then you need to deploy uniswap on the Sepolia network and then use ...
Zartaj Afser's user avatar
  • 5,320
2 votes

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

The price is based on the balance of tokens in the pools reserves. For "price" you can usually just divide one reserve by the other (v2 pools and many others). To give a quote (real price ...
Maka's user avatar
  • 1,383
2 votes
Accepted

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

Ok so I think I figured it out, studying the token's source code, this is a common scheme to "cash out" taxes/fees charged on every token trade or transfer. What are taxes/fees? Taxes/fees ...
blitter's user avatar
  • 193
2 votes

Getting Uniswap v2 latest price and interpreting values using Python

Here is an example how to get the last price on Uniswap v2 compatible DEXes using web3-ethereum-defi Python package. The PairDetails class will do an automatic conversion of prices to human-readable, ...
Mikko Ohtamaa's user avatar
2 votes
Accepted

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

If you send X or Y, yes the pool will be changed: Some one can call skim() to get the excess token amounts that don't align with reserve0 and reserve1 Some one can call sync() or perform a swap to ...
minhhn2910's user avatar
  • 1,840
2 votes

What happens when we directly send tokens to Uniswap pair?

Uniswap V2 is using the reserve amounts for calculation, not token balances. When you send the tokens directly to the pool's address, uniswap actually does not know you are doing this, because you are ...
0xsam's user avatar
  • 101
2 votes
Accepted

How to know base token from the pool

Price in Uniswap pools is tracked in terms of token1/token0, so token1 is the numeraire token if that's what you're asking.
kfx's user avatar
  • 1,750
2 votes

Trouble making UniV2 swap on Sepolia with web3py

Because you use function swapETHForExactTokens, thus, you have to define "value" when build_transaction to send ETH with transaction. That why in the transaction hash you can see 0 at value ...
tqdpham96's user avatar
  • 628
2 votes

Swapping continuouly failing. only one become success with swapExactTokenForTokens

"Error: nonce has already been used". You need to update the nonce between each transaction. Grab the nonce on the first occasion, and then increment the number when building the transaction ...
Maka's user avatar
  • 1,383
2 votes
Accepted

Execution Reverted due to UniswapV2-Pair creation in constructor

The UniswapV2Router02 address you're using is not available for the Sepolia testnet. Instead, the corresponding address for the Sepolia testnet is 0xC532a74256D3Db42D0Bf7a0400fEFDbad7694008. ...
SYED ASAD KAZMI's user avatar
1 vote

What happens when we directly send tokens to Uniswap pair?

Transferring tokens directly won't effect the price until you call either the sync or mint functions. That will update the reserves which will update the price. That's ultimately how the token swaps ...
CathalMF's user avatar
  • 283
1 vote

How to know base token from the pool

There is no on-chain way to determine which token is a base token or which is a quote token if token0 and token1 are mapped to normal trading pairs. The trading pair base-quote token order is a human-...
Mikko Ohtamaa's user avatar
1 vote

"Error: Invalid Argument in getAmountsOut Function Call."

In your routerABI it seems that the type of routes is incorrect, it should be address. const routerABI = [ "function getAmountsOut(uint amountIn, address[] memory routes) public view returns (...
Soham Zemse's user avatar
  • 2,136
1 vote
Accepted

UniswapV2's equivalent of getPair and other functions

Uniswap V3 factory has getPool function which takes two token addresses and the pool's fee (100, 500, 3000 or 10000) and returns address of the pool. Knowing the pool address you can get balances of ...
Vas Treck's user avatar
  • 422
1 vote

Uniswap V2 Transfer Tax Math

Actually the formula in my question is correct. What I didn't realize is that a lot of contracts implement logic in transfer() whereby if the number of tokens (of itself) that the contract itself owns ...
galpo's user avatar
  • 155
1 vote

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

I can name a function jklh, then in that function I can put a call to make a swap on one pool, and then a call to make a swap on the other. If I am a good bot designer I am likely not wasting gas on ...
Maka's user avatar
  • 1,383
1 vote

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

Answering your Question 2 Yes you are right the transaction happens twice i have also checked the transaction on Tenderly which debugs the transaction an d swap function has been triggered twice.
Jaskaran Singh's user avatar
1 vote

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

You have to encode it following the solidity ABI specification https://docs.soliditylang.org/en/v0.8.21/abi-spec.html. path is array of variable length, you have to encode an offset within the ...
Ismael's user avatar
  • 30.3k
1 vote

DEX Real-Time Data

So I figured that the best way to get real-time data from uniswap v2 is to use WebSocket and subscribe to uniswap contract and read new data everytime new block is mined this is free and fast way of ...
Said's user avatar
  • 31
1 vote

Finding IUniswapV2Callee in UniswapV2 clones for flashloans

Trident is not v2. Trident pools use the Bentobox contract to store liquidity. You can flashloan from Bentobox easily. Here is an old example: You call flashloan, Bento transfers you the token(s), ...
Maka's user avatar
  • 1,383
1 vote
Accepted

Abi encode / decode mystery additional 32 byte field Uniswap v2

"that guy" indicates where the data start, and it is hex 0x20 so data starts at byte 32. (it seems this appears only whenever there is any dynamic value) word 1 is 0xa0, which is the offset ...
ceseshi's user avatar
  • 765
1 vote
Accepted

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

You can set slippage to zero by using the exact amount out at time of you calling. But there is a good chance that on any active pool, a transaction mined before theirs will push price out of range. ...
Maka's user avatar
  • 1,383
1 vote
Accepted

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

Goerli has been super unsteady un unreliable lately. Its gas prices have been through the roof. Basically Goerli shouldn't be used anymore for testing dapps. Sepolia is the meant network for dapp ...
Lauri Peltonen's user avatar
1 vote

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

The "extcodesize check" is a check that decides whether the target address (token0 in this example) is a contract (non-zero code size) or a EOA (zero code size). Low level calls to EOA are ...
kfx's user avatar
  • 1,750

Only top scored, non community-wiki answers of a minimum length are eligible