Closed thegitparticle closed 2 years ago
Once you call the trade() function on the Factory, it will return you with a bunch of things, in there is an approvalTransaction you may call. If the approvalTransaction is undefined, then they are already approved for that token and amount.
Would the trade go through if I do not call the approvalTransaction?
I won't be able to swap if that approvalTransaction function exists since you haven't approved the contract to spend your tokens yet. If the user has approved before and didn't swap, and comes back later on, that approvalTransaction will be null and you can just go ahead and swap.
Uniswap requires a wallet give it access/approval to use ERC-20 tokens in the wallet to be accessed before executing a swap. This has be done once for each new token you would use for a swap.
How do I get this approval part using this library or is it already taken care while executing the trade?