Skip to content

Add Pancakeswap V3 trades support #376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JohnDoe424242
Copy link

It's not full support for Pancakeswap V3, but now it's possible to recognize prices and make trades. Pancakeswap V3 is almost the same, but there are some differences, support for which I have added. I also added the use_rpc_gas_price option to not send type 2 transactions to BSC. But since BSC is not POS blockchain, in Web3 object you have to manually add geth_poa_middleware.

Copy link

codecov bot commented Jan 20, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 16 lines in your changes missing coverage. Please review.

Project coverage is 83.93%. Comparing base (59fba76) to head (20ae24a).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
uniswap/uniswap.py 82.02% 16 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #376      +/-   ##
==========================================
- Coverage   84.20%   83.93%   -0.27%     
==========================================
  Files          11       11              
  Lines        1057     1139      +82     
==========================================
+ Hits          890      956      +66     
- Misses        167      183      +16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Dewald928
Copy link

Dewald928 commented Jan 25, 2024

Care to share an example script of how to call this?

Additionally, things that have to change are the pair contract ABI. To make the get_pool_state work.

@JohnDoe424242
Copy link
Author

@Dewald928 unfortunately pools management is not implemented in this patch, trading only.

Care to share an example script of how to call this?

Nothing in particular, just like the regular code, except for the POA middleware

import uniswap
from web3 import Web3
from web3.middleware import geth_poa_middleware

w3 = Web3(Web3.HTTPProvider('http://node.com', request_kwargs={"timeout": 10}))
w3.middleware_onion.inject(geth_poa_middleware, layer=0) # this

uswap = uniswap.Uniswap('0xADDR',
                        'private_key',
                        web3=w3,
                        version=3,
                        use_rpc_gas_price=True) # to use legacy type 0 transactions

price = uswap.get_price_output('0xTOKEN_ADDR_1',
                               '0xTOKEN_ADDR_2',
                               1000000000,
                               fee=500)

tx_hash = uswap.make_trade_output('0xTOKEN_ADDR_1',
                                  '0xTOKEN_ADDR_2',
                                  1000000000,
                                  fee=500)

@hahage21
Copy link

I use this code but wrong,i dont know how to use the code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy