4

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

3
  • Did you manage to find out the explanation for this? – Amree Apr 18 at 0:26
  • @Amree no, but I manage to decode some, what bugs me is that some tokens do deposit into a smart contract instead of a transfert, dunno why – Heetola Apr 18 at 1:58
  • I have multiple questions, but do you know how to derive the amount of token transferred from the swap event based on your second example? – Amree Apr 18 at 3:08
4
+50

In the last transaction (https://etherscan.io/tx/0xfc95b0c4026ab356b36076ca624d3bf49ace40bdf3ca54a91ddad0ef128330af),

multiple token transfers of ERC20 is due to the specific nature of the FLAMA contract, every time when _transfer is called in FLAMA, three events are emitted: (burns some amount, stakes some amount and transfers the rest)

        emit Transfer(sender, address(0), burnAmount);
        emit Transfer(sender, stakingAccount, stakeAmount);
        emit Transfer(sender, recipient, newTransferAmount);

Hence, you are seeing multiple outputs of FLAMA before Sync. Uniswap has no control over how the ERC20 contract handles the transfer, so it is not good to generalize how many logs will be generated for any specific function call.

event  Deposit(address indexed dst, uint wad);

is from WETH smart contract, deposit is an additional function in WETH from other erc20 smart contracts which allows the sender to swap ETH with WETH and withdraw to swap WETH with ETH. while transfer is a standard function in every erc20 (including WETH) smart contract.

PS: you can check the full trace at https://dashboard.tenderly.co/tx/main/0xfc95b0c4026ab356b36076ca624d3bf49ace40bdf3ca54a91ddad0ef128330af

2
  • some token do a deposit instead of a transfert, do you know why? – Heetola Apr 18 at 1:58
  • @Eildosa i have updated my answer – hack3r_0m Apr 18 at 18:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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