Giter Site home page Giter Site logo

Comments (10)

alb2001 avatar alb2001 commented on May 18, 2024 1

Hello @ErikBjare

Thanks a lot. Correct. WHat I did was creating a w3 instance like this:

w3 = Web3(Web3.HTTPProvider(eth_infura_node, request_kwargs={"timeout": 60})) w3.eth.setGasPriceStrategy(fast_gas_price_strategy)

Then pass it through the w3 argument of the Uniswap constructor class. Seems it worked. But would you add this as a parameter on the class where we can specify the gwei directly? I think it's much easier.

from uniswap-python.

ErikBjare avatar ErikBjare commented on May 18, 2024

Duplicate of #23.

You need to pass in a custom Web3 instance to the constructor, with the gas strategy that you want. See the Web3 docs for how to do that: https://web3py.readthedocs.io/en/stable/gas_price.html

also have same question with slippage setting.

There's a constructor parameter for that as well: https://github.com/shanefontaine/uniswap-python/blob/672ce87c9f330a20bb5f17742d65eafbaf484e80/uniswap/uniswap.py#L132

from uniswap-python.

tanpv avatar tanpv commented on May 18, 2024

many thanks @ErikBjare

from uniswap-python.

stamatelou avatar stamatelou commented on May 18, 2024

@ErikBjare were you able to pass the instance to the constructor? And if yes, in which part of the uniswap.py script you added the instance from web3 ?

from uniswap-python.

alb2001 avatar alb2001 commented on May 18, 2024

@ErikBjare Could you please provide an example on this
I've been taking a look at the uniswap.py class, but I cannot seem to figure out how you would pass that w3 parameter in the constructor and what you would need to put there.

something like this doesn't work
uniswap_wrapper = Uniswap(address=eth_address, private_key=eth_priv_key, provider=eth_infura_node, web3=web3.gas_strategies.time_based.fast_gas_price_strategy)

from uniswap-python.

ErikBjare avatar ErikBjare commented on May 18, 2024

You need to pass a Web3 object, not a gas strategy object. Read the Web3py docs:

The provider and web3 parameters are mutually exclusive. The former is essentially just a shorthand for the latter.

For specifics on the behavior, see the first few lines of Uniswap.__init__:
https://github.com/shanefontaine/uniswap-python/blob/5ec7a1c5c6d861f90d935ab5faf680d2ab3aa112/uniswap/uniswap.py#L143-L150

from uniswap-python.

ErikBjare avatar ErikBjare commented on May 18, 2024

But would you add this as a parameter on the class where we can specify the gwei directly? I think it's much easier.

That would not be appropriate. It might make your code slightly shorter, but it unnecessarily complicates the code for uniswap-python to handle all the complexities of Web3 initialization and gas pricing strategies.

As the Zen of Python states: "there should be one, and preferably only one, obvious way to do it"

from uniswap-python.

alb2001 avatar alb2001 commented on May 18, 2024

Thank you

from uniswap-python.

Marsh-James avatar Marsh-James commented on May 18, 2024

I'm happy to make a PR for overwriting the default gas limit if you have a preference for how it should be passed in. Such as in the constructor or with each individual make_trade call or by some other means.

@Weizilla Makes an interesting point, any thoughts @ErikBjare? Was there a particular rationale behind this?

from uniswap-python.

troublesprouter avatar troublesprouter commented on May 18, 2024

Was a simple and quick way to make the transaction very fast found? I'm finding that using a custom web3 makes the process much slower, defeating the process of making the transaction faster.

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.