Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: medium
Invalid

Incorrect Visibility Modifier in TimeWeightedAverage Library Enables Direct Access

Summary

The TimeWeightedAverage library's calculateTimeWeightedAverage function is incorrectly marked as public when it should be internal since it's part of a library. This incorrect visibility could lead to confusion and potential misuse of the library functions.

library TimeWeightedAverage {
function calculateTimeWeightedAverage(
Period storage period,
uint256 currentTime
) public view returns (uint256) { // @audit should be internal
// ... function implementation
}
}

The issue exists because:

  1. Libraries are meant to be used by other contracts

  2. Library functions marked as public suggest they can be called directly

  3. This violates the intended usage pattern of library functions

Impact

  1. Code Clarity: Creates confusion about how the library should be used

  2. Gas Costs: Public functions in libraries require additional deployment overhead

  3. Maintenance Issues:

    • Makes it harder to refactor the library

    • Creates unclear boundaries between library and contract code

    • May lead to incorrect implementations by other developers

  4. Documentation Mismatch: Inconsistent with standard library implementation patterns

Recommendations

Change Visibility to Internal

library TimeWeightedAverage {
function calculateTimeWeightedAverage(
Period storage period,
uint256 currentTime
- ) public view returns (uint256) {
+ ) internal view returns (uint256) {
// ... function implementation
}
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!