sherlock-audit / 2024-05-midas-judging

13 stars 6 forks source link

USE OF CUSTOM MADE ERROR #188

Closed sherlock-admin4 closed 6 months ago

sherlock-admin4 commented 6 months ago

USE OF CUSTOM MADE ERROR

Low/Info issue submitted by dvyneEth

Summary

Require Statement where majorly used for Error Handling, this can be replaced with custom made error

Vulnerability Detail

Require Statement where used in majority of the codebase why this is good, it makes each function expensive to call which doesnt adhere to gas optimizations tips

Impact

Gas

Code Snippet

this are references from DepositVault.sol this happened throughout the code base but this are a few reference

  1. https://github.com/sherlock-audit/2024-05-midas/blob/main/midas-contracts/contracts/DepositVault.sol#L98
  2. https://github.com/sherlock-audit/2024-05-midas/blob/main/midas-contracts/contracts/DepositVault.sol#L77
  3. https://github.com/sherlock-audit/2024-05-midas/blob/main/midas-contracts/contracts/DepositVault.sol#L106
  4. https://github.com/sherlock-audit/2024-05-midas/blob/main/midas-contracts/contracts/DepositVault.sol#L118

Tool used

Manual Review

Recommendation

custom made error such as if statements can be introduced this makes each function cheaper to call than when a require stament is being used e.g in https://github.com/sherlock-audit/2024-05-midas/blob/main/midas-contracts/contracts/DepositVault.sol#L118 it can be replaced with

if(!isFreeFromMinDeposit[user]){
revert DV_alreadyFree();