如何从 Hardhat 主网分叉获取 Uniswap 数据?
我正在使用 Uniswap SDK 使用 Hardhat 的主网分叉从 Uniswap 获取 DAI/ETH 池中 ETH 的价格,但查询返回 ETH 的当前价格,而不是从挂钩区块中获取这是几个月前的事。
如何从 Hardhat 的主网分支获取 Uniswap 池信息?如果无法使用 Uniswap SDK,是否有任何解决方法?
提前致谢!
I'm using the Uniswap SDK to fetch the price of ETH in the DAI/ETH pool from Uniswap using Hardhat's mainnet fork, except the query is returning the current price of ETH, instead of from the pegged block which is from a few months ago.
How do I fetch Uniswap pool information from Hardhat's mainnet fork? If it's not possible using the Uniswap SDK, is there any workarounds?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
经过一番搜索,我认为 Uniswap SDK 无法连接到本地主网分支。然而,一个好的解决方法是直接从 Uniswap 合约调用方法。
例如,这将从挂钩区块中获取 ETH 的正确价格:
After some searching I don't think the Uniswap SDK can be connected to a local mainnet fork. However, a good workaround is to call methods directly from the Uniswap contract.
For example, this would fetch the correct price of ETH from a pegged block:
https://github.com/defi- Wonderland/solidity-boilerplate/blob/main/test/utils/uniswap.ts
代码在这里
https://github.com/defi-wonderland/solidity-boilerplate/blob/main/test/utils/uniswap.ts
code here