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
Failure when swapping from BNB to token on BSC chain #332
Comments
Well, first things first, I haven't used BSC for 1y+, but the fee value seems extremely weird. Default values are 500, 3000, and 10000 (0.05%, 0.3%, and 1%, respectively). They might vote for other fee levels, obv. However, this value is still way too big. I would double-check. Regarding your question, please provide a complete error message, as it is challenging to locate the problem. |
thx for your input. I tried with 10000 which is the fee (1%) and it failed with the same error message. here's the full error
|
so I was able to debug this a bit more and it looks like a discrepancy between bsc and ethereum... the failure is in this command w3.eth.get_block("latest")["baseFeePerGas"]
|
Seems like we need to make a fix or smth. In Also, you might need to add the following after the middleware injection
Not sure tho |
so I added it but am still getting the same error
|
I was able to get past the error after I added that line above as you suggested and also the lines of code post middleware injection. Had to tweak things a bit in order to get a successful swap thro. One of the issues I ran into is the assumption that BNB (equivalent to ETH - i.e. native token) has an address of all zeros in BSC - but that's not the case. I had to get creative in my code to make it work. |
Nice to see you've managed to resolve this issue. Regarding native tokens, I prefer to use wrapped versions anywhere if possible. This approach allows us to avoid extra wrap/unwrap calls during swaps. That saves some gas, making transactions cheaper. Regardless of the used network, you can get the wrapped token contract with the |
Anything to keep in mind when doing swaps on Optimism? I’m getting all kinds of errors when running this on Op. any advice, gotchas, minefields? I’ll collect my thoughts and post detailed errors etc tomorrow |
I do believe that most underwater stones regarding Optimism have been discussed already. Search here/in the discussion section. Also, I'd like to ask you to create a separate thread/issue if questions arise. |
@liquid-8 @nisilag excuse me, i have extremely low knowledge in python. with eth network everything works fine, but now i'm tryting to make swap on bsc network and getting same error with 'baseFeePerGas'. could you tell where exectly and how i need to add those lines so that the exchange works on bsc? |
Describe the bug
Running the make_trade_output returns the following error and fails - KeyError: 'baseFeePerGas'
To Reproduce
The text was updated successfully, but these errors were encountered: