You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If there is sufficient liquidity in either the v2 pool or the v3 pool, this is the best code we have for now that gives the closest code to the real price. The reason I say the closest is that if the fee is taken from a different pool than 3000, there will be a price difference again, but in pools with a fee of 3000, he can get it perfectly. For this, you can also write a code that calculates different fee rates. But I don't know what we can do for liquidite. My web3 knowledge is insufficient here. If anyone knows how much we can get by calculating the current liquidity of the pool without asking for a price request, we can add them and reach the perfect price.
Activity
qraxiss commentedon Mar 9, 2023
This code is written for Uniswap, it works for forks. But it doesn't work for itself, very interesting
qraxiss commentedon Mar 10, 2023
If there is sufficient liquidity in either the v2 pool or the v3 pool, this is the best code we have for now that gives the closest code to the real price. The reason I say the closest is that if the fee is taken from a different pool than 3000, there will be a price difference again, but in pools with a fee of 3000, he can get it perfectly. For this, you can also write a code that calculates different fee rates. But I don't know what we can do for liquidite. My web3 knowledge is insufficient here. If anyone knows how much we can get by calculating the current liquidity of the pool without asking for a price request, we can add them and reach the perfect price.
qraxiss commentedon Mar 11, 2023
My solution is here. +- 1 in 1000 margin of error.
If a PR is requested, I can write a more professional one. But for me this is enough.
GitUserForMaster01 commentedon Nov 6, 2023
Hi, do I need to add an private key to use this example. I got "web3.exceptions.ContractLogicError: execution reverted" during execution
ErikBjare commentedon Nov 6, 2023
@GitUserForMaster01 No, just reading prices do not require a private key.
One or more of the parameters you pass are most likely wrong, have a look at this issue: #356