I could not find any explanation about this so I'm reverse engineering it, the 3rd tx is the most interesting,
If you look at this transaction https://etherscan.io/tx/0x33a00225ba2d73059ade4f737d2dc8f8b565ec914872242fc0189448c5b84e22 which swaps 0.3 WETH to 6,082,510.622368052762688738 THINO you can see in the logs :
Deposit 300000000000000000 WETH
Transfer 300000000000000000 WETH
Transfer 6082510622368052762688738 RHINO
Sync with reseve0(3856933319958440611) and reserve1(72333950858248340856148449)
Swap amount0In(300000000000000000) amount1In(null) amount0Out(null) amount1Out(6082510622368052762688738)
So I'm guessing it works like this Then first transfert event indicate what the user want to swap, and the second transfert, what he gets
But then I looked at an other transaction which was different https://etherscan.io/tx/0x5bb712b83409b6516ae48f638605191c5bd792d752190798ddede83209dcb9c8 :
So here he swaps 0.3 WETH for 624,840,188.817931 TUSK
In the logs you get :
Deposit 300000000000000000 WETH
Transfer 300000000000000000 WETH
Transfert 624840188817931 TUSK
Sync reserve0(46698654279810799) reserve1(22094803627722313771)
Swap amount0In(374092255868) amount1In(300000000000000000) amount0Out(640861732120931) amount1Out(0)
So look like it works the same way, transfert 1 is what he wants to swap and transfert 2 what he gets, but what is amount0In(374092255868)
in the swap call?
And then I saw this transaction https://etherscan.io/tx/0xfc95b0c4026ab356b36076ca624d3bf49ace40bdf3ca54a91ddad0ef128330af
From Uniswap V2: Router 2To Uniswap V2: FMA 8 For 0.3 ($548.82) Wrapped Ethe... (WETH)
From Uniswap V2: FMA 8To 0x0000000000000000000000000000000000000000 For 356.737164711807397228 ($5.12) FLAMA (FMA)
From Uniswap V2: FMA 8To 0x9b7b6bbd7d87e381f07484ea104fcc6a0363df39 For 178.368582355903698614 ($2.56) FLAMA (FMA)
From Uniswap V2: FMA 8To 0x71749af1e6a25ddf6f5c9711ea46fcbebfd1fb75 For 17,301.752488522658765611 ($248.13) FLAMA (FMA)
There is actually 4 transferts before the swap
Transfert 300000000000000000 WETH
Transfert 356737164711807397228 FMA
Transfert 178368582355903698614 FMA
Transfert 17301752488522658765611 FMA
Sync reserve0(1725598126065671219938761) reserve1(29235947838414793028)
Swap amount0In(0) amount1In(300000000000000000) amount0Out(17836858235590369861453) amount1Out(0)
I checked his balance is 17301752488522658765611 FMA (third transfert)
So I'm guessing you have to read it this way :
first transfert event is the coin and its amount being exchanged
then read all transfert events untill the swap event, user will receive the last transfert event amount
Is this right?
Thanks