Comments (10)
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.
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.
many thanks @ErikBjare
from uniswap-python.
@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.
@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.
You need to pass a Web3 object, not a gas strategy object. Read the Web3py docs:
- https://web3py.readthedocs.io/en/stable/quickstart.html
- https://web3py.readthedocs.io/en/stable/providers.html
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.
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.
Thank you
from uniswap-python.
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.
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)
- Uniswap v4 support HOT 6
- Slippage limit does not seem to hold, or price impact is incorrect HOT 4
- unable to swap HOT 7
- uni的py库好像不支持avax HOT 1
- execution reverted on Sepolia HOT 2
- domain uniswap-python.com is not resolving HOT 4
- "execution reverted: Insufficient WETH9" on Polygon HOT 4
- Could not transact with/call contract function, is contract deployed correctly and chain synced? HOT 2
- execution reverted by new coin (even after liquidity added) HOT 2
- Exception has occurred: TypeError swapped quantity must be an integer HOT 1
- How can i get history statistic? HOT 3
- about historical data; HOT 1
- uniswap.make_trade_output() - Arguments Type HOT 1
- web3.exceptions.ContractLogicError: execution reverted: Unexpected error uniswapv3 EUROC USDC pair HOT 8
- More helpful error messages for `ContractLogicError: execution reverted`
- Getting price based on pool?
- How to fetch or calculate price of an asset? HOT 4
- Fails when swapping USDT=>WBNB HOT 1
- eth_sendTransaction does not exist/is not available after calling mint_liquidity method.
- How to use with the Base chain? HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uniswap-python.