Giter Site home page Giter Site logo

unable to swap about uniswap-python HOT 7 CLOSED

nithesh10 avatar nithesh10 commented on June 9, 2024
unable to swap

from uniswap-python.

Comments (7)

nithesh10 avatar nithesh10 commented on June 9, 2024

works on usdt, but not working on custom tokens

from uniswap-python.

nithesh10 avatar nithesh10 commented on June 9, 2024

works on v2, but not on v3

from uniswap-python.

nithesh10 avatar nithesh10 commented on June 9, 2024

How to fix this , getting this on v2

exception:-
Could not identify the intended function with name swapExactETHForTokens, positional arguments with type(s) int,(address,address),int,int and keyword arguments with type(s) {}.
Found 1 function(s) with the name swapExactETHForTokens: ['swapExactETHForTokens(uint256,address[],address,uint256)']
Function invocation failed due to no matching argument types.

from uniswap-python.

nithesh10 avatar nithesh10 commented on June 9, 2024

def swap(self,public_key,private_key,from_address,to_address,amount,slippage,chain):
slippage=int(slippage)
public_key=self.w3.to_checksum_address(public_key)
uniswap = Uniswap(address=public_key, private_key=private_key, version=2,web3=self.w3,default_slippage=slippage)
print("amount is",amount)
#a=uniswap.get_price_input(from_address,to_address,int(amount))
a=uniswap.make_trade(from_address,to_address,int(amount/2),public_key,fee=10000)
tx = uniswap.w3.eth.wait_for_transaction_receipt(a, timeout=5)
return tx

Could not identify the intended function with name swapExactETHForTokens, positional arguments with type(s) int,(address,address),address,int and keyword arguments with type(s) {}.
Found 1 function(s) with the name swapExactETHForTokens: ['swapExactETHForTokens(uint256,address[],address,uint256)']

from uniswap-python.

nithesh10 avatar nithesh10 commented on June 9, 2024

please respond

from uniswap-python.

nithesh10 avatar nithesh10 commented on June 9, 2024

was a slippage issue, fixed it

but now im getting this error when i swap from the token to eth

Traceback (most recent call last):
File "f:\a.nithesh_clients\rff\volume\test.py", line 66, in
a=uniswap.make_trade(wasfb,ETH_ADDRESS,(int(token_balance)))
File "C:\Users\anith\AppData\Roaming\Python\Python310\site-packages\uniswap\decorators.py", line 38, in approved
return method(self, *args, **kwargs)
File "C:\Users\anith\AppData\Roaming\Python\Python310\site-packages\uniswap\uniswap.py", line 472, in make_trade
return self._token_to_eth_swap_input(
File "C:\Users\anith\AppData\Roaming\Python\Python310\site-packages\uniswap\uniswap.py", line 644, in _token_to_eth_swap_input
return self._build_and_send_tx(
File "C:\Users\anith\AppData\Roaming\Python\Python310\site-packages\uniswap\uniswap.py", line 1443, in _build_and_send_tx
transaction = function.build_transaction(tx_params)
File "C:\Users\anith\AppData\Roaming\Python\Python310\site-packages\web3\contract\contract.py", line 332, in build_transaction
return build_transaction_for_function(
File "C:\Users\anith\AppData\Roaming\Python\Python310\site-packages\web3\contract\utils.py", line 232, in build_transaction_for_function
prepared_transaction = fill_transaction_defaults(w3, prepared_transaction)
File "cytoolz\functoolz.pyx", line 249, in cytoolz.functoolz.curry.call
File "C:\Users\anith\AppData\Roaming\Python\Python310\site-packages\web3_utils\transactions.py", line 132, in fill_transaction_defaults
default_val = default_getter(w3, transaction)
File "C:\Users\anith\AppData\Roaming\Python\Python310\site-packages\web3_utils\transactions.py", line 72, in
"gas": lambda w3, tx: w3.eth.estimate_gas(tx),
File "C:\Users\anith\AppData\Roaming\Python\Python310\site-packages\web3\eth\eth.py", line 293, in estimate_gas
return self._estimate_gas(transaction, block_identifier)
File "C:\Users\anith\AppData\Roaming\Python\Python310\site-packages\web3\module.py", line 68, in caller
result = w3.manager.request_blocking(
File "C:\Users\anith\AppData\Roaming\Python\Python310\site-packages\web3\manager.py", line 232, in request_blocking
return self.formatted_response(
File "C:\Users\anith\AppData\Roaming\Python\Python310\site-packages\web3\manager.py", line 197, in formatted_response
apply_error_formatters(error_formatters, response)
File "C:\Users\anith\AppData\Roaming\Python\Python310\site-packages\web3\manager.py", line 72, in apply_error_formatters
formatted_resp = pipe(response, error_formatters)
File "cytoolz\functoolz.pyx", line 666, in cytoolz.functoolz.pipe
File "cytoolz\functoolz.pyx", line 641, in cytoolz.functoolz.c_pipe
File "C:\Users\anith\AppData\Roaming\Python\Python310\site-packages\web3_utils\contract_error_handling.py", line 131, in raise_contract_logic_error_on_revert

raise ContractLogicError(message, data=data)

web3.exceptions.ContractLogicError: execution reverted: UniswapV2: K

from uniswap-python.

nithesh10 avatar nithesh10 commented on June 9, 2024

fixed it with set fee to true

from uniswap-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.