Uniswap is a decentralized finance protocol that is used to exchange cryptocurrencies. Questions should relate to programming. General questions about Uniswap should be asked on https://ethereum.stackexchange.com
Questions tagged [uniswap]
255 questions
6
votes
4 answers
Uniswap V3: what does price mean at a given tick?
I'm looking at the uniswap docs which states this example:
An example of finding the price of WETH in a WETH / USDC pool, where
WETH is token0 and USDC is token1:
You have an oracle reading that shows a return of tickCumulative as
[70_000,…

Ritzy Dev
- 387
- 3
- 10
6
votes
1 answer
How to calculate Uniswap v3 pool's Total Value Locked (TVL) on chain?
I want to calculate the total value locked in a particular pool in Uniswap v3. I can't use the subgraph API for this.
I can get current liquidity / in range liquidity using uniswapV3pool contract function:
in_range_liquidity =…

AtiqGauri
- 1,483
- 13
- 26
6
votes
1 answer
Can't import the named export 'XXX' (imported as 'XXX') from default-exporting module (only default export is available)
I'm having an issue importing this in my TypeScript React project.
import { SwapWidget } from '@uniswap/widgets';
Getting this error on compilation yarn build:
Can't import the named export 'SwapWidget' (imported as 'SwapWidget') from…

Evandro Pomatti
- 13,341
- 16
- 97
- 165
5
votes
1 answer
How is uniswap assembly create2 function working?
I was going through uniswap code trying to understand the code and most of it is pretty clear but I do have a few questions.
in this function:
function createPair(address tokenA, address tokenB) external returns (address pair) {
require(tokenA…

Kuly14
- 496
- 3
- 12
5
votes
3 answers
Deploying Uniswap v2 / Sushiswap or similar in Brownie, Hardhat or Truffle test suite
I am writing an automated test suite that needs to test functions against Uniswap v2 style automated market marker: do swaps and use different order routing. Thus, routers need to be deployed.
Are there any existing examples of how to deploy a…

Mikko Ohtamaa
- 82,057
- 50
- 264
- 435
5
votes
1 answer
What does Invariant failed: PRICE_BOUNDS means?
I am trying to create an instance of a v3 uniswap Pool.
I am using hardhat and a fork of mumbai testnet.
When I try to create the pool instance :
const poolExample = new Pool(
TokenA,
TokenB,
immutables.fee,
state.sqrtPriceX96.toString(),
…

gpasse
- 4,380
- 7
- 44
- 75
4
votes
2 answers
How do I determine whether a recipient is a liquidity pool?
I'm creating a token which when sold on a liquidity pool, takes fees and burns a certain amount.
Given that I have a recipient address, how would I check whether it is a liquidity pool?
I think I may be able to use this:…

Ayudh
- 1,673
- 1
- 22
- 55
4
votes
1 answer
Uniswap getAmountsOut() rounds value down to nearest Ether
I'm calling getAmountsOut() from the UniswapV2Router02 contract using ethers.js, where I'm checking the amount of ETH I can get for 50000 DAI.
Using the below code, the output amount tells me I can currently get exactly 15 ETH. For testing purposes…

Jasperan
- 2,154
- 1
- 16
- 40
4
votes
0 answers
Getting an SafeTransferFrom(STF) error even after approving spender for contract
I have created a swap contract for superfluid(https://superfluid.finance) super tokens, which swaps anySuperToken <-> anySuperToken, Essentially its just an ERC20 token with additional capabilities.
My swap contract works the following way -
To…

Shreyas Papinwar
- 55
- 10
4
votes
2 answers
Why am I getting this error Error: Transaction reverted without a reason string. When trying to swap tokens on uniswap?
I'm trying to swap tokens on uniswap unsing hardhat's mainnet fork but I'm getting this error: Error: Transaction reverted without a reason string. And I don't really know why.
Here is my swap function:
function swap(address router, address…

Kuly14
- 496
- 3
- 12
4
votes
3 answers
How to fix 'TransferHelper: ETH_TRANSFER_FAILED' when interacting with Uni V2
I'm dealing with a strange issue with the safeTransferETH helper function in Uniswap V2's router contract.
I'm trying to swap tokens held by the contract to Uniswap for Ether, using the swapExactTokensForETH function provided by the Uniswap V2…

computersAreHard
- 43
- 5
3
votes
1 answer
Is it possible in solidity to check if a contract has specific function before calling it and not revert or avoid revert 0x0dfe1681
I am implementing a token that takes fees on buy/sell but not on transfer. I rely on checking the 'from' and 'to' for being uniswap pairs (V2 or V3) to detect it as a buy/sell transaction.
For V2, it's fairly simply as I can use factory function to…

ssp
- 403
- 1
- 4
- 7
3
votes
1 answer
typechain --target ethers-v5 is not recognized as an internal command
I have in my package.json file :
"scripts": {
"compile-contract-types": "yarn compile-external-abi-types && yarn compile-v3-contract-types",
"compile-external-abi-types": "typechain --target ethers-v5 --out-dir src/abis/types…

Software14
- 155
- 1
- 9
3
votes
0 answers
Uniswap V3 Adding liquidity fails
Code have to trade on Uniswap v3 and create new positions then close. No problems with trading and closing positions which out of range. But always problem with creating new position, transaction failed. After 30-40 times, it creates. Cannot…

Dajeir
- 51
- 1
3
votes
0 answers
Gas estimation error - execution reverted { "originalError": { "code": 3, "data": "0xfb7f5079", "message": "execution reverted" } }
I have a contract deployed on the rinkeby testnet. It is basically a clone of uniswapV2.
Whenever I try to call the router contract's addLiquidity/ removeLiquidity/ swapTokens functions this error pops up. All other functions in other contracts are…

newbie
- 41
- 3