Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

incredible swap #198

speriamoBene started this conversation in General
Nov 11, 2021 · 4 comments · 11 replies
Discussion options

Hello, i did a swap a little while ago and inexplicably lost 13,900 usdt

i just used the instruction

uniswap.make_trade(usdt, symbolUniswap, 13900 * 1000000)

where:
usdt = Web3.toChecksumAddress("0xdac17f958d2ee523a2206206994597c13d831ec7")
symbolUniswap = Web3.toChecksumAddress("0x7d29a64504629172a429e64183d6673b9dacbfce")

But i only received the equialent of 17 usdt instead of 13,9k.
How is it possible?

You must be logged in to vote

Replies: 4 comments · 11 replies

Comment options

Impossible to say without looking at the tx.

Edit: Also, your address for the UNI token is not correct. Seems to be for something else called VXV: https://etherscan.io/token/0x7d29a64504629172a429e64183d6673b9dacbfce

Edit 2: Looks like you may have tried to swap using Uniswap v2, which has almost no liquidity for the VXV token: https://v2.info.uniswap.org/pair/0x0c9c5daf1d7cd8b10e9fc5e7a10762f0a8d1c335

TX should have failed though due to excessive slippage (unless you've set that to something high, or there's a bug). If price impact is expected, it wouldn't fail the slippage check.

Edit 3: Found the tx https://etherscan.io/tx/0xb6e8e667ed8489ae071c4327b24bdec1193e9e76ba767421e72370ece1859420/

Indeed, the estimated price was exactly what you got.

Sorry this happened to you. You need to be careful to use a pool that has liquidity (and always check the estimated price before executing!). Thinking of ways to make this clearer in the docs.

You must be logged in to vote
2 replies
@speriamoBene
Comment options

Thanks for the reply. In fact, when analyzing the transaction, I used a cashless pool.
Is there a way to check that there is liquidity before executing the trade?
Also, I used Uniswap V2 in this way:

uniswap = Uniswap (address = address, private_key = private_key, version = 2, provider = provider)

If I enter version = 3, is Uniswap V3 supported or do I need to update something?

Thank you very much

@ErikBjare
Comment options

Answered by @liquid-8 below. Working on improving docs and adding a estimate_price_impact helper function.

Comment options

You can define a method that returns the pool's contract for the given pair of tokens. Code snippet:

def get_pair_contract(self, token0: AddressLike, token1: AddressLike, fee: int) -> AddressLike:
    if self.version == 2:
        params = [web3.toChecksumAddress(token0), web3.toChecksumAddress(token1)]
        pair_token = self.factory_contract.functions.getPair(*params).call()
    elif self.version == 3:
        params = [web3.toChecksumAddress(token0), web3.toChecksumAddress(token1), fee]
        pair_token = self.factory_contract.functions.getPool(*params).call()
    else:
        pair_token = None
    return pair_token

Then just analyze this contract in the way you like: programmatically or via third-part tools like Etherscan.

If I enter version = 3, is Uniswap V3 supported or do I need to update something?

If you use the latest version then yes, that's all you need to do, basically.

Addition: you need direct pool @ uniV3 for your pair of tokens to trade as current version doesn't support multihop swaps. Also, you have to set proper value for V3 fee.

You must be logged in to vote
1 reply
@speriamoBene
Comment options

Thank you very much

Comment options

Sorry again, but i got this error:

object has no attribute 'factory_contract'

how can i solve it please?

You must be logged in to vote
8 replies
@speriamoBene
Comment options

Nope. Is there a way to get money back?

@FILAgiao
Comment options

I don't know. I contacted with them on twitter. Have no reply yet...

@speriamoBene
Comment options

who did you contact?

@ErikBjare
Comment options

I answered @FILAgiao in #208 (comment)

@FILAgiao
Comment options

who did you contact?

Just DM uniswap.

Comment options

The same problem comes to me...lost almost 1.5k$,i do should read that instruction carefully...

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.