Open
Conversation
Author
|
I thought this would look more professional because it's in code format rather than text or PDF. If you like it, let me know. I have more ideas for you, both now and in the future. If something is wrong, please let me know, and I’ll correct it, as there’s always room for improvement." Let me know if you'd like any further changes! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Electisec CAP Pre-Mainnet Vault Review
Review Resources:
None beyond the code repositories
Auditors:
Table of Contents
Review Summary
CAP Pre-Mainnet Vault
The CAP Pre-Mainnet Vault serves as the core codebase for the CAP Pre-Mainnet campaign, allowing users to deposit USDC in exchange for boosted cUSD on the MegaEth testnet using LayerZero. Once the campaign concludes, users can withdraw their USDC.
46b0dda18490f74c81204185a11bd36fe0e66647of the cap-contracts repo.contracts/testnetCampaign/OAppMessenger.solandcontracts/testnetCampaign/PreMainnetVault.sol.Scope
The review focused on evaluating the security of two key contracts at a specific commit:
OAppMessenger.solPreMainnetVault.solThe review was limited to the latest commit, as the repository was under active development. After presenting the findings to the TODO_protocol_name team, fixes were implemented and added to several PRs.
Code Evaluation Matrix
Findings Explanation
Findings are categorized by their respective impact:
Critical Findings
None - No critical issues were identified.
High Findings
None - No high-priority issues were found.
Medium Findings
None - No medium-level issues were detected.
Low Findings
1. Smart contracts calling deposit can revert
Technical Details
The
deposit()function can revert if smart contracts don’t implement the_lzSend()function with thereceive()function as the last parameter.Impact
deposit()with excess gas will revert if it doesn't implement thereceive()function.Recommendation
refundAddressto thedeposit()function to enable smart contracts to work without areceive()function, or explicitly state in NatSpec that smart contracts must implementreceive().Developer Response
2. Missing verification for _destReceiver
Technical Details
The
deposit()function lacks verification for the input parameter_destReceiver. Ifaddress(0)is passed, no validation is performed before sending it to LayerZero.Impact
Recommendation
_destReceiveris set.Developer Response
3. Turn off the deposit when the campaign ends
Technical Details
The
maxCampaignEndvariable stores the campaign's end date. After this date, deposits should be disabled.Impact
Recommendation
Developer Response
Gas Saving Findings
1. Converting amount to shared decimals can be optimized
Technical Details
The
_toSD()function calculates10 ** (decimals - sharedDecimals())every time it is called. This constant value can be pre-calculated to save gas.Impact
Recommendation
_toSD()to use a pre-calculateddecimalConversionRate.