Omniscia Steadefi Audit

TraderJoeYieldFarmManager Code Style Findings

TraderJoeYieldFarmManager Code Style Findings

TJM-01C: Ineffectual Usage of Safe Arithmetics

TypeSeverityLocation
Language SpecificTraderJoeYieldFarmManager.sol:L370, L375

Description:

The linked mathematical operations are guaranteed to be performed safely by surrounding conditionals evaluated in either require checks or if-else constructs.

Example:

contracts/vaults/trader-joe/TraderJoeYieldFarmManager.sol
366if (_repayTokenAAmt > IERC20(tokenA()).balanceOf(address(this))) {
367 // if insufficient tokenA, swap B for A
368 swapPathForRepayDifference[0] = tokenB();
369 swapPathForRepayDifference[1] = tokenA();
370 swapAmountOut = _repayTokenAAmt - IERC20(tokenA()).balanceOf(address(this));
371} else if (_repayTokenBAmt > IERC20(tokenB()).balanceOf(address(this))) {
372 // if insufficient tokenB, swap A for B
373 swapPathForRepayDifference[0] = tokenA();
374 swapPathForRepayDifference[1] = tokenB();
375 swapAmountOut = _repayTokenBAmt - IERC20(tokenB()).balanceOf(address(this));
376}

Recommendation:

Given that safe arithmetics are toggled on by default in pragma versions of 0.8.X, we advise the linked statements to be wrapped in unchecked code blocks thereby optimizing their execution cost.

Alleviation (4325253d6de0ea91c1e9fb9e01d2e7e98f3d83a9):

The referenced calculations have been safely wrapped in unchecked code blocks, optimizing their execution cost.

TJM-02C: Variable Mutability Specifiers (Immutable)

TypeSeverityLocation
Gas OptimizationTraderJoeYieldFarmManager.sol:L65-L68, L70-L72

Description:

The linked variables are assigned to only once during the contract's constructor.

Example:

contracts/vaults/trader-joe/TraderJoeYieldFarmManager.sol
55constructor(
56 ITraderJoeYieldFarmVault _vault,
57 address _rewardToken,
58 ILendingPool _tokenALendingPool,
59 ILendingPool _tokenBLendingPool,
60 IJoeRouter02 _router,
61 IMasterChefJoeV3 _stakePool,
62 uint256 _stakePoolId,
63 IJoeOracle _joeOracle
64) {
65 vault = _vault;
66 rewardToken = _rewardToken;
67 tokenALendingPool = _tokenALendingPool;
68 tokenBLendingPool = _tokenBLendingPool;
69 router = _router;
70 stakePool = _stakePool;
71 stakePoolId = _stakePoolId;
72 joeOracle = _joeOracle;
73 IERC20(tokenA()).approve(address(router), type(uint256).max);
74 IERC20(tokenB()).approve(address(router), type(uint256).max);
75 IJoePair(lpToken()).approve(address(router), type(uint256).max);
76 IERC20(lpToken()).approve(address(stakePool), type(uint256).max);
77 IERC20(rewardToken).approve(address(router), type(uint256).max);
78 IERC20(tokenA()).approve(address(tokenALendingPool), type(uint256).max);
79 IERC20(tokenB()).approve(address(tokenBLendingPool), type(uint256).max);
80}

Recommendation:

We advise them to be set as immutable greatly optimizing their read-access gas cost.

Alleviation (4325253d6de0ea91c1e9fb9e01d2e7e98f3d83a9):

All variables have been set as immutable per our recommendation, greatly reducing their read-access gas cost.