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

Open
code423n4 opened this issue Jun 18, 2022 · 1 comment
Open

Gas Optimizations #71

code423n4 opened this issue Jun 18, 2022 · 1 comment
Assignees
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") valid

Comments

@code423n4
Copy link
Contributor

1. Can save gas when call _submitOutOrders() with _toReserve = false

In case _toReserve = false, it still calculates feesAmount using entryFees but do not use the result anywhere. We can save gas by calculating feesAmount only when _toReserve = true

Affected Code

https://github.com/code-423n4/2022-06-nested/blob/b4a153c943d54755711a2f7b80cbbf3a5bb49d76/contracts/NestedFactory.sol#L443

Recommended Mitigation Steps

Only calculate feesAmount only when _toReserve = true

if (_toReserve) {
	feesAmount = (amountBought * entryFees) / 10000;
_transferToReserveAndStore(_batchedOrders.outputToken, amountBought - feesAmount, _nftId);
}
@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Jun 18, 2022
code423n4 added a commit that referenced this issue Jun 18, 2022
@obatirou obatirou self-assigned this Jun 20, 2022
@Yashiru Yashiru added the sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label Jun 22, 2022
@Yashiru
Copy link
Collaborator

Yashiru commented Jun 27, 2022

1. Can save gas when call _submitOutOrders() with _toReserve = false (Confirmed)

Gas optimization confirmed

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") valid
Projects
None yet
Development

No branches or pull requests

4 participants