Giter Site home page Giter Site logo

Comments (4)

RoscoeTheDog avatar RoscoeTheDog commented on June 17, 2024 1

I resolved my issue. I think when trying this in the past I had an incorrect type, such as qty not being casted to int or some other issue. Swear I tried it before 😅

If this function returns the amount out for the amount in, with qty being in ether units of 10**18, then you simplify specify qty * 10**18 to return the trade rate between 2 tokens. If you want it relative a tokens price relative to USD, then target a stablecoin out with 1 * 10**18.

# estimate tokens out from amount in
price_usd = self.quickswap.get_price_input(token_in, token_out, 1 * 10**18) # assuming token_out is a stablecoin.
token_out_estimate = self.quickswap.get_price_input(token_in, token_out, int(qty))

from uniswap-python.

RoscoeTheDog avatar RoscoeTheDog commented on June 17, 2024

As an update: I realized that gas amounts have nothing to do with USD value, so I'm implementing the bot just to use spot amounts and thresholds.

But this question remains valid. How would you simulate a trade with BTC/USDT without on chain execution? I believe I heard something about doing that elsewhere...

from uniswap-python.

qraxiss avatar qraxiss commented on June 17, 2024

You cant calculate official pair price with uniswap-python library. Because uniswap v3 have lot of pair pools. And we dont know which pool is better price. U have to check prices on every pool.

from uniswap-python.

RoscoeTheDog avatar RoscoeTheDog commented on June 17, 2024

You cant calculate official pair price with uniswap-python library. Because uniswap v3 have lot of pair pools. And we dont know which pool is better price. U have to check prices on every pool.

When you say "you have to check prices on every pool", do you mean only for V3? My solution above seemed to work as intended. I'm currently using only V2 because V3 had issues initializing but I might come back to it.

Could I see an example of how to check prices for a swap on V3? I feel like there should be a helper function that takes care of this in the library already. get_price_input?

from uniswap-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.