-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swap without a query #5
Comments
Recently on the router, about 4% of trades fail. We can now do the math for identifying which is better for users. https://cchain.explorer.avax.network/address/0x187Cd11549a20ACdABd43992d01bfcF2Bfc3E18d/transactions |
Adding a low slippage (0.2%) the failure rate has become closer to zero. |
We could include both ways and let front-ends solve. For example, low slippage trades (higher chance to fail) should use the method which consumes less gas in revert scenarios and high slippage trades (lower chance to fail) should use the method which consumes less gas in success scenarios. |
That is a really good idea! |
Hey i have a question how do i get the amount out of when using findBestPath it provides the the path, amountin and not out |
Method |
@halo3mic, I'm really struggling here and could use your help.
The router is deployed on base blockchain at Any advice or pointers you could provide would be greatly appreciated. I'm really lost. |
I also did get the exact same issue. I posted it in the telegram dev community but got no helpful response on how to deal with that. Was even hoping to take a look at how the handle it on the front end part but nothing. Anyways if you somehow ever found an issue please tag me. |
I'm hoping to find solution, if you could share the telegram channel i'd appreciate that. |
@RedWilly I think I found out why, took a while to debug! |
Okay can you share your finding |
Hey, @RicqCodes thanks for reaching out! Sorry to hear you had no help on tg, personally not active there very much. Tokens with fee on transfer are not supported with this version of the router due to the way swap execution works. Swap execution runs the query before each swap which doesn't account for the fee on transfer - the query calculated amount will be higher than the actual amount. This has been discussed for some time now and I agree that it would be more practical to change the swap logic in favour of checking the balance after each swap instead of quoting. Would you be interested in implementing this? |
Was the first issue related to fee on transfer? If not, it could relate to the same pool being used twice (can happen with pool with multiple assets) |
Certainly! Here's a more professional rewrite suitable for a GitHub comment: Hello @halo3mic, Thank you for your quick reply. I've found a partial workaround for this issue. It effectively handles swaps from ETH to tokens with fees, but unfortunately, it doesn’t work for swapping in the reverse direction. Based on the results from However, when attempting to swap back to ETH, we encounter the I would appreciate any insights or suggestions you might have on this matter, especially regarding implementing the recommended Uniswap approach. |
Also instead of using the pair address to swap, we could use the dex routers, what do you think? |
Hi @RicqCodes, Could it be that you are not taking into account that there are two transfers involved when you are swapping from FeeToken to X? It goes User -> Adapter -> Pool, so it gets taxed twice I guess. |
The router that you referenced is a fork of YakSwap, so I would consult Artemis for help as they have their own version of the router and have possibly modified the adapters... |
The current version of YakRouter swap queries all adapters for their amounts before swapping. This ensures the correct amounts are used for swaps and saves user gas if the final amount-out is below the minimum amount-out specified by the user.
The queries however can be quite gas-intensive, for example:
To avoid such high gas costs queries could be removed and the swap amount for the next step could be derived from the token balance in the adapter.
ER20.balanceOf
costs 23k, so the gas reduction would be substantial.The big downside of this approach is that if price moved on the user to the point that the trade would fail. Now the trade would fail with relatively low gas cost after all the queries are completed, but with this approach, trade would fail in the last step costing the user substantially more gas.
The text was updated successfully, but these errors were encountered: