The sellProfits function in the smart contract includes an unnecessary variable assignment, which does not impact the functionality of the contract but leads to suboptimal gas usage. This report highlights the issue, its potential impact, and provides recommendations for optimizing the code.
In the sellProfits function, the variable amount
is assigned the return value of the swapRouter.exactInputSingle(params) function call. However, this amount variable is not used anywhere else in the function. The assignment is redundant and does not serve any purpose in the contract's logic.
The impact of this vulnerability is primarily related to gas optimization. Since the amount variable is not utilized after the assignment, the extra step of assigning its value consumes unnecessary gas during contract execution. While the gas cost may be negligible for individual transactions, it can add up and affect the overall efficiency of the contract, especially when dealing with multiple transactions.
Remix IDE
To optimize gas usage and improve the efficiency of the contract, it is recommended to remove the unnecessary assignment of the amount variable in the sellProfits function. The updated function would look as follows:
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.