4
votes
Accepted
What is the quote function in UniswapV2Library used for?
Both functions return the price of asset in an Uniswap pool which has token composition as specified by the reserveA and reserveB (or reserveIn and reserveOut) arguments.
The quote function returns ...
2
votes
Accepted
Uniswap WETH_WBTC price is orders of magnitude off when using constant product market maker formula
I was getting a similar issue when looking at USDC and WETH and using ethers.js . This is how I was originally converting my Big Numbers:
const reserve0 = Number(ethers.utils.formatUnits(reserves[0], ...
2
votes
Accepted
Curve AMM - How is fee calculated when adding liquidity?
Posting answer from Twitter
Simple derivation for the multiplier. We want 2 things:
Zero fee when all assets are added/removed in proportion to their balances (maintain same price)
Adding/removing ...
2
votes
Accepted
uniswap price for pair
You're mistaken, Uniswap v3 does not use the formula x*y=k for real amounts of assets. It's a concentrated liquidity AMM and uses a concentrated liquidity formula.
Read Uniswap v3 whitepaper. ...
1
vote
Accepted
Does the sqrtPricex96 on the Uniswap V3 swap-event represent the average price paid by the swapper, or the new price of the pool after swap?
sqrtPricesX96 for a evetn swaap is the price of the pool after swap
Here a screenshot from uniswap doc:
See docs from Uniswap https://docs.uniswap.org/contracts/v3/reference/core/interfaces/pool/...
1
vote
Accepted
how to make a contract compatible with different ERC-20 Decimals
Look at how other contracts that deal with ERC20s do it, but you just have to call decimals() on that specific token and do all your calculations taking it into account, or ignore them altogether. ...
1
vote
Accepted
Can someone explain Uniswap's v2 getAmountIn?
You can take a look at this calculation for the version of the contract:
what is math for uniswap calculates the amountout and amountin why 997 and 1000
In addition, the contract's version also added +...
1
vote
UniSwap v2 Subgraph return 0 for Volume in USD and ETH
Hopefully it will help someone who is looking for the answear.
I've been facing the same issue and spent a couple of days figuring out the reason.
So the issue is the addresses you provide all over ...
1
vote
Swap exact ETH for min tokens not accurate?
If you're swapping tokens with hard coded tax inside on their smart contract (in your case 10%). The "minimum token" appearing on the website is wrong, because it is based on normal token ...
1
vote
PancakeSwap charges a fee to mint LP according to their code?
I was able to get an answer on Telegram from PancakeSwap.
1
vote
Is there a way to find out how much I earned in fees from just the UniswapPair V2 contract?
Assuming you are asking about Uniswap V3 - You can call positions:
function positions(bytes32 key)
external
view
returns (
uint128 _liquidity,
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
amm × 29uniswap × 14
solidity × 8
decentralized-exchange × 7
pancakeswap × 4
liquidity-provider × 4
erc-20 × 3
defi × 3
uniswapv3 × 3
web3js × 2
math × 2
curve × 2
contract-development × 1
tokens × 1
oracles × 1
ethers.js × 1
hardhat × 1
erc-1155 × 1
bignumber × 1
price × 1
swaps × 1
staking × 1
layer-2 × 1
constant × 1
sushiswap × 1