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 #111

Open
code423n4 opened this issue Feb 23, 2022 · 1 comment
Open

Gas Optimizations #111

code423n4 opened this issue Feb 23, 2022 · 1 comment
Labels
bug Something isn't working G (Gas Optimization) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")

Comments

@code423n4
Copy link
Contributor

G-01:

use uint256 for best gas saving
ClearingHouse.sol L#17,18,19,20
MarginAccount.sol L#47

G-02:

uint256 instead of bool
ClearingHouse.sol L#79,250

G-04:

Prefix increments are cheaper than postfix increments.
Further more, using unchecked {++x} is even more gas efficient, and the gas saving accumulates every iteration and can make a real change
ClearingHouse.sol L#122,130,170,194,251,263,278
MarginAccount.sol L#331,373,521

G-05:

immutable instead of constant
MarginAccount.sol L#34,15,

G-06:

use calldata instead of memory

G-07:

use memory instead of storage

G-03:

bytes32 instead of string

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Feb 23, 2022
code423n4 added a commit that referenced this issue Feb 23, 2022
@atvanguard
Copy link
Collaborator

G-05 is a good suggestioin

@atvanguard atvanguard added the sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label Feb 26, 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 G (Gas Optimization) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Projects
None yet
Development

No branches or pull requests

2 participants