I noticed that swapping some tokens in Uniswap to exactly the same amount of ETH, at the same time, has much higher gas fees than other tokens. Why is this? Aren't the swap transactions identical for all tokens?
Some token transfer() function has more instructions (if clauses) than others.
Plus it also depends on if the Ethereum Virtual Machine storage can ...
It sounds like you're facing one of two problems - either you're using a local dev chain and haven't deployed a Uniswap to it, or you're using a testing fork of a chain, and haven't told your test suite where to lookf for it. You probably have code in your tests for deploying the notSafeMoon contracts using something like const tokenArtifacts = await ethers....
This has been a pain for me for a long time. You basically have to compare the liquidity of the different pairs and run the Uniswap formula for calculating the price.
Y * I / (X + I)
I is your input amount of source tokens
X is the balance of the pool
in the source token
Y is the balance of the pool in the target token
In the end, the process we came up to ...
The mistake was to set the deadline outside the function that calls swapExactETHForTokens, so it was set according to the time the contract was deployed.
If a time variable needs to be used according to actual parameters at run time, then it is necessary to declare it or set it at the time of use. Silly mistake, but important after all.
Always check price and slippage before signing a swap.
Check price, because it might be off. (For example, someone might have bought a huge amount just before you, causing the price to rise too high.)
Check slippage, because there might not be enough liquidity in the pool.
It is leftover ETH that was returned to your wallet as a change.
For more detail, you chose to swap by specifying the exact output amount (Doge Reload), so the web calculated the ETH input needed (~0.092 ETH) which was a little more than actual use (~0.089 ETH). So the router returned ~0.002 ETH.
Read more: https://uniswap.org/docs/v2/smart-contracts/...
You did not approve USDT to the router address before attempting the swap.
The USDT contract uses assert instead of revert or throw to cancel the transaction because of the lack of approval. Using assert will consume all the gas left. It's bad practice by Tether to use assert, but it's probably because their contract is really old.
EDIT: Also, the USDT ...
In the future, if you wanted to cancel a pending transaction you need to frontrun your own transaction by posting some other transaction with the same nonce. It can be the same transaction, or it can be a different, unrelated transaction. The important thing is that you need to use the same nonce, but a higher gas price. The idea is that by posting a more ...
Is there a way to provide liquidity to Uniswap-like contracts without initial funds on one side of the trade?
No. Because by definition, this would not be liquidity.
For example, if I create my own token called Token, I believe this token should be worth one dollar each.
have one thousand tokens, but I don't have one thousand dollars.
You cannot do such ...
There is a bunch of functions on the smart contract that explains how to use the liquidity field:
In Uniswap V3 core repository, in Position.sol line 60:
// calculate accumulated fees
uint128 tokensOwed0 =
feeGrowthInside0X128 - _self.feeGrowthInside0LastX128,
It seems to be a problem with the deadline, maybe the timestamp you are running the function on your computer is higher than the time you are setting as deadline.
Print the block.timestamp to know its value and get an idea of the possible error.