1

I am going to running swap transactions. At first, we are going to running an approval transaction. And then we are going to running a swap transaction. These repeat. I made the transaction data.

approval transaction data

var data = iface.encodeFunctionData('approve', [config[config.network].addresses.router, ethers.BigNumber.from("115792089237316195423570985008687907853269984665640564039457584007913129639935")]);

swap data....

....

repeat

I hope to have only one running an approval transaction.

for example

approval transaction
swap transaction
swap transaction
swap transaction
swap transaction
swap transaction

...

Do you have away?

1 Answer 1

0

If I understand what you're trying to do correctly, you should be fine since you are already approving the maximum uint. You can just call approve once and you should be able to swap that token as many times as you'd like.

If you want to swap multiple tokens, just approve them all in the same way before you start swapping.

Of course this is slightly less secure than approving only the required amount.

2
  • I know about that. But if I had depended on this mode, I have a fee for transactions every time. I have to avoid this fee. I need that approve many transactions only one time. I'll wait for your reply.
    – Alex Weber
    Commented Aug 11, 2021 at 0:12
  • Each token will require an approve() call to it's contract, so if you have 10 tokens to approve, that means you need to pay gas for 10 separate approval transactions. There is no way around this.
    – MoonGusto
    Commented Aug 12, 2021 at 6:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.