Ok. Here is my next question. Not related to OpenZeppelin. But, I am unable to solve this yet past 2 days.
I am trying to execute deposit and withdraw function from yDAI (yearn.finance) within the same transaction using web3 encodeFunctionCall. deposit function works, but, withdraw function fails. However, if I execute the withdraw function alone separately, then it works.
By the way, I am using ganache mainnet fork with truffle. May be its a bug in this setup? May be it will work in mainnet? Unfortunately, I cannot test this on public testnets like ropsten. I am scared to test it in mainnet cause, I will loose some eth for gas. So, how to solve this?
Ok. I burnt some heavy ether GAS and I tested this on mainnet. It works there. So, this is an issue with the ganache mainnet fork setup. I cant believe I wasted 3 days on this just to find out that the same code works fine on mainnet. This is scary to me for what I want to achieve. If something did not work on ganache mainnet fork setup how can I be sure that its NOT the issue with the setup itself?
Anyway, I have to accept this and move on.
Just wanted to let you people know about this if in case someone is stuck like me testing the code in ganache mainnet fork setup.