Skip to content

Fail with error 'Pancake: K' on FeeOnTransfer token #130

@LucaZanatta

Description

@LucaZanatta

Here is my code

`from uniswap import Uniswap
from web3 import Web3
from decimal import *

wallet_address = "xxx"
private_key = "yyy"
address = Web3.toChecksumAddress(wallet_address)
version = 2

bsc = "https://bsc-dataseed.binance.org/"
web3 = Web3(Web3.HTTPProvider(bsc))
print(web3.isConnected())
uniswap = Uniswap(address=address, private_key=private_key, version=version, web3=web3, default_slippage=.5)

wbnb = "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"
token = "0xa872960bc3393b2a19aa1e784ab7f385d543ce37"

wbnb_w = Web3.toChecksumAddress(wbnb)
token_w = Web3.toChecksumAddress(token)

qty = int(.01 * 10**18)
decimals_wbnb = uniswap.get_token(wbnb_w).decimals
decimals_token = uniswap.get_token(token_w).decimals

uniswap.make_trade(wbnb_w, token_w, qty) # THIS WORKS

qty_token = uniswap.get_token_balance(token_w)
print(qty_token)

uniswap.make_trade(token_w, wbnb_w, qty_token) # DOESN'T WORK
`

In this link, it's written that the problem can be slippage.
https://www.followchain.org/pancake-k-pancakeswap/

Here there is the transaction
https://bscscan.com/tx/0x472895b975f80c38c9bc87f29902ab35add7f312b64ead6c2b20fffbf8a04c61

I already saw that slippage is not tested. My question is: there are some problems in my code, or it can be a problem of slippage?

I apologize if the problem is trivial, but I'm just beginning :D

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions