You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just tried to execute a trade with eth to a token using make_trade
For some reason, it attempted to approve the token before. I would like to omit this behavior, and approve the token later.
Also, for some reason it also tried to approve it even when it was already approved.
It needs to approve the token if you are going to trade with it, you can't do it after the trade. If you read the code you can find the approval condition which is checked.
If it tries to approve the token again, that's probably because the previous transaction hadn't gone through yet (or for whatever reason your node wasn't aware of it yet) and maybe you had restarted your program so it wasn't aware of the pending TX.
Well, but the thing is that it seems to approve it before trading back. Let me explain
if I want to swap eth for a token (I tried CVP), it tried to approve CVP before swapping eth for CVP. Normally when you trade with Uniswap you do like this:
Swap eth for the token
Approve
Swap token for eth.
So I don't understand why it tried to approve it even before swapping eth for the token.
It needs to approve the token if you are going to trade with it, you can't do it after the trade. If you read the code you can find the approval condition which is checked.
If it tries to approve the token again, that's probably because the previous transaction hadn't gone through yet (or for whatever reason your node wasn't aware of it yet) and maybe you had restarted your program so it wasn't aware of the pending TX.
Thanks. Keep in mind that for the most part you might not be interested to approve, or you might want to approve manually. So either a parameter on the make trade function to optionally approve
If you want to trade fast, you're interested on swapping eth for the token, then approving, then swap back. Not to approve first.
Activity
ErikBjare commentedon Mar 19, 2021
It needs to approve the token if you are going to trade with it, you can't do it after the trade. If you read the code you can find the approval condition which is checked.
If it tries to approve the token again, that's probably because the previous transaction hadn't gone through yet (or for whatever reason your node wasn't aware of it yet) and maybe you had restarted your program so it wasn't aware of the pending TX.
alb2001 commentedon Mar 19, 2021
Well, but the thing is that it seems to approve it before trading back. Let me explain
if I want to swap eth for a token (I tried CVP), it tried to approve CVP before swapping eth for CVP. Normally when you trade with Uniswap you do like this:
Swap eth for the token
Approve
Swap token for eth.
So I don't understand why it tried to approve it even before swapping eth for the token.
Thanks
alb2001 commentedon Mar 19, 2021
Is it possible to reopen this? Thanks
ErikBjare commentedon Mar 20, 2021
Ah, yeah you're right that might not be necessary. If so, we welcome a PR with a fix.
[-]make_trade automatically approves a token[/-][+]Overly eager to approve tokens[/+]alb2001 commentedon Mar 30, 2021
Thanks. Keep in mind that for the most part you might not be interested to approve, or you might want to approve manually. So either a parameter on the make trade function to optionally approve
If you want to trade fast, you're interested on swapping eth for the token, then approving, then swap back. Not to approve first.
TomasBelo commentedon Jun 16, 2021
Any updates on this?
ErikBjare commentedon Jun 21, 2021
@MrSp4nky No, PRs appreciated.
jornx commentedon Jul 6, 2021
Running into this problem aswell, makes fast trades really hard
Issue uniswap-python#73 fix