Skip to content

Overly eager to approve tokens #73

Closed

Description

@alb2001

Hello

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.

Thank you.

Activity

  1. ErikBjare commented on Mar 19, 2021

    @ErikBjare
    Member

    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.

  2. alb2001 commented on Mar 19, 2021

    @alb2001
    Author

    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

  3. alb2001 commented on Mar 19, 2021

    @alb2001
    Author

    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.

    Is it possible to reopen this? Thanks

  4. ErikBjare commented on Mar 20, 2021

    @ErikBjare
    Member

    Ah, yeah you're right that might not be necessary. If so, we welcome a PR with a fix.

  5. changed the title [-]make_trade automatically approves a token[/-] [+]Overly eager to approve tokens[/+] on Mar 20, 2021
  6. alb2001 commented on Mar 30, 2021

    @alb2001
    Author

    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.

  7. TomasBelo commented on Jun 16, 2021

    @TomasBelo

    Any updates on this?

  8. ErikBjare commented on Jun 21, 2021

    @ErikBjare
    Member

    @MrSp4nky No, PRs appreciated.

  9. jornx commented on Jul 6, 2021

    @jornx

    Running into this problem aswell, makes fast trades really hard

  10. added a commit that references this issue on Jul 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions