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

Open
code423n4 opened this issue Jun 26, 2022 · 0 comments
Open

Gas Optimizations #113

code423n4 opened this issue Jun 26, 2022 · 0 comments
Labels
bug Something isn't working G (Gas Optimization)

Comments

@code423n4
Copy link
Contributor

State variable COW_SETTLEMENT and COW_RELAYER declared in StakingStorage could be declared as constant

COW_SETTLEMENT and COW_RELAYER are initialized in Staking.sol initialize function with a constant address.

The initialization of those variable could be moved directly in their definition and transform those variables in constants, optimizing the gas usage for portion of code that use them.

Staking _sendAffiliateFee should avoid sending fee when the amount is zero

feeAmount in _sendAffiliateFee could be zero because of rounding if (_amount * affiliateFee) < BASIS_POINTS.

The function could check feeAmount > 0 and perform IERC20Upgradeable(TOKE_TOKEN).safeTransfer(FEE_ADDRESS, feeAmount) only in that case

Staking transferToke should avoid sending Toke when the amount is zero

If totalTokeAmount is equal to zero, avoid to call safeTransfer and waste gas sending 0 transferring zero tokens.

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Jun 26, 2022
code423n4 added a commit that referenced this issue Jun 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)
Projects
None yet
Development

No branches or pull requests

1 participant