web3js Uniswap 处理事件日志数据
我正在构建一个抓取工具,以使用 web3js 从 Uniswap 获取所有 Swap 数据。 到目前为止,我通过 Swap() 事件订阅日志和过滤主题。 然后我解码数据并得到 amount0In、amount1In、amount0Out、amount1Out。
我的问题出在 swapExactETHForTokensSupportingFeeOnTransferTokens() 函数中。 通常交换有 token0 输入和 token1 输出,但这个函数给了我 4 个中的 3 个的值,我似乎不明白如何处理它。最终我想要的是知道他们花了什么、得到了什么以及我需要什么来更新该货币对的新储备。
如果有人了解 Uniswap RouterV2 合约交换功能,我想获得一些关于如何处理数据以使我的计算正确的指示。
I am building a scraper to get all Swap data from Uniswap using web3js.
So far I subscribe to the log and filter topics by Swap() event.
then I decode the data and get amount0In, amount1In, amount0Out, amount1Out.
My problem is in the swapExactETHForTokensSupportingFeeOnTransferTokens() function.
Normally a swap has token0 in and token1 out, but this function gives me values for 3 of the 4 and I can not seem to understand how to handle that. eventually what I want is to know what they spend, what they got and what I need to update the new reserves of that pair.
If someone has the understanding of the Uniswap RouterV2 contract swap functions, I would like to get some pointers on how to handle the data to get my calculations right.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在这里找到了解决方案 ethereum.stackexchange 任何有相同情况的人问题在那里得到了非常详细的答案。
一些合约实际上向接收者转移指定数量的代币减去 10%(5% 税费和 5% 流动性费用)208940457743532637 - 10% = 188046411969179375 并发出 Transfer 事件。然后,PancakePair _swap 函数会发出 Swap 事件,基值为 Amount0Out 208940457743532637
Amount0In 大于零,因为代币合约将部分代币作为 Pancake Swap 的流动性对返回。
I found the solution here ethereum.stackexchange Anyone with the same question gets a very detailed answer there.
some contracts actually transfers to recipient specified amount of tokens minus 10% (5% tax fee and 5% liquidity fee) 208940457743532637 - 10% = 188046411969179375 and emits Transfer event. Then, PancakePair _swap function emits Swap event with base value of Amount0Out 208940457743532637
Amount0In is greater than zero because the token contract returns part of tokens as a liquidity pair on Pancake Swap.