Skip to content

uniswapv3 get_raw_price error #269

Open

Description

@YANGXIAO-LI

raw_price = (sqrtPriceX96 * sqrtPriceX96 * 10 ** den1 >> (96 * 2)) / (
10 ** den0
)

DAI USDT The calculation results is 0?

Activity

  1. YANGXIAO-LI commented on Aug 5, 2022

    @YANGXIAO-LI
    Author

    sqrtPriceX961 = pool_contract.functions.slot0().call()[0]
    sqrtPriceX961 is 79224306130848112672356

  2. YANGXIAO-LI commented on Aug 5, 2022

    @YANGXIAO-LI
    Author

    DAI decimal is 18
    USDT decimal is 6

  3. ytoast commented on Oct 14, 2022

    @ytoast
    Contributor

    I believe the calculation is correct though, seems like den0 and den1 might have been switched in your calculations

    # DAI/USDT pool; t0 = DAI, t1 = USDT
    sqrtPriceX96 = 79224306130848112672356
    den1 = 18 # DAI (Token In)
    den0 = 6 # USDT (Token Out)
    (sqrtPriceX96 * sqrtPriceX96 * 10 ** den1 >> (96 * 2)) / 10 ** den0 # equals to 0.999902
  4. shakibaei65 commented on Oct 14, 2022

    @shakibaei65
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions