Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gas Optimizations #83

Closed
code423n4 opened this issue May 1, 2022 · 4 comments
Closed

Gas Optimizations #83

code423n4 opened this issue May 1, 2022 · 4 comments
Assignees
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization)

Comments

@code423n4
Copy link
Contributor

The solidity version of the contract is 0.8.10.
Since Solidity 0.8, the overflow/underflow check is implemented on the language level, it doesn't need the use of SafeMath library. The code is doing some calculations and performing the same validations twice (one on the language level and one in the library).

I suggest removing the import of SafeMath, the using and replace the math operations sub, mul and div by -, * and / accordingly.

Gas comparison here: https://gist.github.com/miguelmtzinf/180e25788b0ea60eb84785717ecb4c7e

Good save of 1k gas avg in redeemToken, minor gas save in supplyTokenTo and 10k in deployment.

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels May 1, 2022
code423n4 added a commit that referenced this issue May 1, 2022
@PierrickGT PierrickGT self-assigned this May 4, 2022
@PierrickGT
Copy link
Member

Duplicate of #11

@PierrickGT PierrickGT marked this as a duplicate of #11 May 4, 2022
@PierrickGT PierrickGT added the duplicate This issue or pull request already exists label May 4, 2022
@JeeberC4 JeeberC4 removed the duplicate This issue or pull request already exists label May 6, 2022
@JeeberC4 JeeberC4 reopened this May 6, 2022
@gititGoro
Copy link
Collaborator

Good report. A gist of the gas savings results is a nice touch.

@gititGoro
Copy link
Collaborator

Duplicate of #91

@gititGoro gititGoro marked this as a duplicate of #91 May 12, 2022
@gititGoro
Copy link
Collaborator

Duplicate of #91

@gititGoro gititGoro added the duplicate This issue or pull request already exists label May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization)
Projects
None yet
Development

No branches or pull requests

4 participants