admin管理员组文章数量:1345707
In Uniswap V3, retrieving the pool's current price (sqrtPriceX96) was straightforward using the slot0() function from the pool contract:
let pool_instance = get_pool_contract(
factory_address,
nft_pos_return.token0,
nft_pos_return.token1,
FeeAmount::from(nft_pos_return.fee),
provider.clone()
);
let slot0_opt = pool_instance.slot0().call().await.unwrap();
However, in Uniswap V4, the architecture has changed, and this functionality is now handled via external libraries such as:
- StateLibrary.get ( Docs )
- Extsload ( Docs )
Since these are Solidity libraries rather than contract functions, calling them directly from Rust is not as straightforward.
My Question: Is there a way to retrieve the current pool price (sqrtPriceX96) from Rust without having to write custom Solidity contracts?
Unfortunately, the existing Rust SDK for Uniswap V4 (uniswap-v4-sdk) does not yet cover all required functionality.
Has anyone successfully fetched sqrtPriceX96 from Uniswap V4 using Rust, and if so, what approach did you take? Any insights or workarounds would be greatly appreciated!
本文标签: rustHow to fetch current pool price without rewriting code to solidityStack Overflow
版权声明:本文标题:rust - How to fetch current pool price without rewriting code to solidity? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743788124a2539061.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论