There are two external calls to get weth balance in TSwapPool.deposit
, we can cache the value to save gas.
In TSwapPool.deposit
we get the weth balance https://github.com/Cyfrin/2024-06-t-swap/blob/main/src/TSwapPool.sol#L130
then when calling getPoolTokensToDepositBasedOnWeth
, it does the same external call to get weth balance https://github.com/Cyfrin/2024-06-t-swap/blob/main/src/TSwapPool.sol#L428
We can cache the value from first call to save gas.
Extra gas cost
Manual review
Make another private function that take wethReserves
as parameter, this can be called from the deposit
and getPoolTokensToDepositBasedOnWeth
.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.