Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Best way to calculate price?

未关闭
#273 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
28/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
停滞
技术栈
python
领域
api, fintech-quant

调研方向

Read the issue’s example using uniswap_wrapper.get_price_input and the discussion in its four comments to understand the unanswered question about token decimals. Check the library’s price calculation entry points and related tests, if present, to establish how input and output amounts are represented. Done means documenting a correct way to calculate a price for one input unit and whether output token decimals are needed.

由索引模型根据 Issue 内容生成。

描述

Hi

I am currently rewriting an application using the latest versoin of the library and I always had some issues in the past with checking the prices, due to the decimals of the tokens. So I want to know if there's a better approach to this one that I have in mind, or if I am just overcomplicating things. But I assume that if you want to get the price (not just the output amount of tokens you would get), you need the decimals

I always use the input price method, so I would go like this for only one input unit

price = 1 / (uniswap_wrapper.get_price_input(eth, token, 1 * 10 ** "input token decimals") / (1 * 10 ** "Output token decimals"))

Example (assuming the token I want to get the price from has 9 decimals:
price = 1 / (uniswap_wrapper.get_price_input(eth, token, 1 * 10 ** 18) / (1 * 10 ** 9))

Is this correct? Or is there a better way to do this without getting the decimals of the token you want to get?

Thanks

主要语言
Python
星标
1k
派生
373
平均合并
2 天 6 小时
30 天内合并 PR
6

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

uniswap-python/uniswap-python 的其他 Issue

查看 uniswap-python/uniswap-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。