Cyfrin / 2023-07-foundry-defi-stablecoin

38 stars 33 forks source link

Incorrect visibility function #581

Open codehawks-bot opened 1 year ago

codehawks-bot commented 1 year ago

Incorrect visibility function

Severity

Low Risk

Relevant GitHub Links

https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/d1c5501aa79320ca0aeaa73f47f0dbc88c7b77e2/src/DecentralizedStableCoin.sol#L46

Summary

The visibilty of the burn() function in is public is pure and shouldn't be.

Vulnerability Details

The visibility of the burn function is public. However, the function isn't called within the contract, so there's almost no need for it to be public. The visibility is better set as external. It saves gas costs and is also consistent with the mint function.

Impact

The impact isn't very much.

Tools Used

Code analysis

Recommendations

Change visibility from public to external

PatrickAlphaC commented 1 year ago

We are using OZ contracts and to override the function it must be public