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

Code cleanup #17

Closed
wants to merge 7 commits into from
Closed

Code cleanup #17

wants to merge 7 commits into from

Conversation

Tranquil-Flow
Copy link
Collaborator

Minor cleanup of code. Reasoning for each commit given in its comments.

Will likely be picked up in audits as SWC-103 https://swcregistry.io/docs/SWC-103/
As per Solidity 0.8.0, ABI coder v2 is activated by default and as such it does not need to be specified in the code. Disregard this commit if wanting to be explicit in using ABI coder v2  instead of experimental ABIEncoderV2 or abicoder V1.
In `FeeCollector.sol`, `PositionFactory.sol` and `AdminService.sol`, both a fallback() and receive() function are specified. No code is executed in these contracts upon receiving ether, therefore, fallback() can be omitted as it is redundant.
Copy link
Contributor

@cucupac cucupac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment. Thank you.

/**
* @notice Executes when native is sent to this contract through a non-existent function.
*/
fallback() external payable { } // solhint-disable-line no-empty-blocks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. We can probably remove receive() everywhere too, right? I can't ever see a reason we want the contract to be able to accept ETH.

  2. If so, we can remove the unit tests for both receive() and fallback() everywhere in the tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. There is no reason for the contract to receive ETH as I see it, so receive() could also go. I think the only time ETH would be sent would be some kind of user error, sending to the wrong address or erroneously thinking they need to send ETH to interact with the protocol.

  2. Agreed. I can go through and remove those as well if that is what we want to do with removing both.

Copy link
Contributor

@cucupac cucupac Mar 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, let's just remove the unit tests for fallback.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fallback() removed, alongside the associated fuzz test for each.

src/FeeCollector.sol Show resolved Hide resolved
src/PositionFactory.sol Show resolved Hide resolved
src/services/AdminService.sol Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants