I'm testing a simple example of flash swap v3 on a mainnet fork using Ganache and Truffle.
All tests passed successfully except the "swap" function executed on the UniswapV3Pool.
Before reaching my callback's code, the swap function in the Pool performs a SafeTransfer to my contract's address. In my test, I'm using the Pool WETH/DAI, fee 3000.
I'm trying to ask 1000 DAI from the pool, so I'm passing value '0' for WETH (token0) and '1000000000000000000000' for DAI (token1).
My callback is not even called, since it fails when attempting to transfer DAIs to my contract and from Ganache logs I get this error:
Gas usage: 89447
Block number: 14540211
Block time: Thu Apr 07 2022 20:08:55 GMT+0200 (Central European Summer Time)
Runtime error: revert
Revert reason: TF
I verified the correct address of my contract (recipient of the transfer).
I also tried to execute a SafeTransfer to the same contract creating a test contract and it works.
What could be the reason why UniswapV3Pool fails sending tokens to my contract?
I cannot find more info about it, so I hope you guys might give me a different point of view in finding a solution.
Thanks in advance!