Hi guys, I jave a question for solidity developers. I'm coding a smart contract that implement a token swap, and my code works but is not good because for my business I have to check how much tokens I'll have back from the swap before to trigger the swap. Example: require(return > 10, "revert"). How can I check the amouts back before the swap?

Feb 28, 2022, 8:10 PM
getAmountsOut
Feb 28, 2022, 8:22 PM
I tryed but it seem to be an impossible value. Maybe I'm doing something wrong? This function shoud calculate the difference of a double swap in two dex
Feb 28, 2022, 8:25 PM
so you need to calculate the returned amount
getAmountsOut return the max amount you can receive
Feb 28, 2022, 9:31 PM
Yes, its an arbitrage so i need to calculate the "profit" before the real swap
Feb 28, 2022, 9:31 PM
yep then you already found the solution
ah Italian I see
Feb 28, 2022, 9:32 PM
So the code is right?
Yes ahahahah
Feb 28, 2022, 9:32 PM
Shouldn't that be joe - amtPangolin?
Now you are doing joe - amt (which is input amount...)
Feb 28, 2022, 10:02 PM
joe represents the final output
Feb 28, 2022, 10:03 PM
Yeah and he is trying to find out difference in two dex
So it should be joe - amtPangolin
Feb 28, 2022, 10:04 PM
he uses amtPangolin to calculate it
it's like

if I put X --> I get Y
if I put Y --> I get Z

==> Z - X
if Z - X > 0 then profit
Feb 28, 2022, 10:04 PM
Oh wait path was interchanged. Ignore my answer :')
Feb 28, 2022, 10:05 PM
amtPangolin and joe represnets 2 different amounts if I am not wrong
yep
Feb 28, 2022, 10:05 PM

© 2024 Draquery.com All rights reserved.