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

Adding an if check to avoid unnecessary call #38

Open
code423n4 opened this issue Nov 14, 2021 · 1 comment
Open

Adding an if check to avoid unnecessary call #38

code423n4 opened this issue Nov 14, 2021 · 1 comment
Labels
bug Something isn't working G (Gas Optimization) sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons

Comments

@code423n4
Copy link
Contributor

Handle

0xngndev

Vulnerability details

Impact

In the contract NestedBuybacker, the internal function trigger calculates how much NST to send to the reserve by doing:
uint256 toSendToReserve = balance - toBurn;
and then makes a safeTransfer for that amount to the nstReserve contract:
NST.safeTransfer(nstReserve, toSendToReserve);
Because there's a possibility of the burn rate set to 100%, there can exist situations where the contract ends up transferring 0 NST to the reserve. This would incur in unnecessary gas costs that can be avoided with a simple if check.
The if check increases the contract size from 6189 to 6195 bytes, and adds a small amount of gas cost. However, if the possibility of having the burn rate set to 100% is something feasible, avoiding that call should
end up being cheaper than adding an if check.

Mitigation steps

Simply add an if check to the NST.safeTransfer line that checks that toSendToReserve is not 0

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Nov 14, 2021
code423n4 added a commit that referenced this issue Nov 14, 2021
@adrien-supizet adrien-supizet added the sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons label Nov 18, 2021
@adrien-supizet
Copy link
Collaborator

This is true. Although we are not considering to set the the burn part to 100%.

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 acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Projects
None yet
Development

No branches or pull requests

2 participants