web3js Uniswap 处理事件日志数据

发布于 2025-01-12 01:23:23 字数 375 浏览 2 评论 0原文

我正在构建一个抓取工具,以使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半边脸i 2025-01-19 01:23:23

我在这里找到了解决方案 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文