beeb / pancaketrade

Limit orders for PancakeSwap
GNU General Public License v3.0
200 stars 92 forks source link

Adding unit tests? #94

Closed sinancetinkaya closed 1 year ago

sinancetinkaya commented 1 year ago

Feature Request

I tried to write my own a DeFi bot but I failed because testing the code with BSC testnet was not working. Forking mainnet in Ganache, Hardhat was also problematic. LP pairs on testnets were always giving weird errors.

How do you test your code? Would you like to share your unit tests (if any)?

beeb commented 1 year ago

Hey there!

No unit tests exist (yet). I don't feel like adding them would bring much value at the moment as the bot has been pretty battle-tested (by me) but I'd be happy to consider a PR.

Good luck for your own bot!

sinancetinkaya commented 1 year ago

Thanks for replying back. Do you test your code with real money on the mainnet? Have you ever tried to use the testnet?

beeb commented 1 year ago

I test with real money on mainnet but setting it up for testnet is as simple as changing the RPC url to one of the testnet ones, and modifying the Dex router + factory address (currently hardcoded unfortunately).

sinancetinkaya commented 1 year ago

I tried your code and got similar errors. I think testnet has some weird problems with LP.

beeb commented 1 year ago

I edited my comment to mention you need to change the factory and router addresses in the code

beeb commented 1 year ago

I guess the token addresses also needs updating. Here are some addresses you can use: https://bsc.kiemtienonline360.com/

And the code https://github.com/beeb/pancaketrade/blob/1527f5babb6687e51d0bb98a33c5eb17ea8178ba/pancaketrade/network/bsc.py#L24

sinancetinkaya commented 1 year ago

Yes I know they are different on the testnet. I'll give it a try again. I might have forgotten to change one of these 👍