BriVault

First Flight #52
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Impact: low
Likelihood: medium
Invalid

Redundant implementation

Root + Impact

Description

  • There is a function called "_convertToShares" in briVault.sol that duplicates functionality of the function "_convertToShares" in ERC4626

  • Intead of duplicating functionality the "_convertToShares" from ERC4626, it can be used with proper params.Risk

Likelihood:

  • Reason 1: When users deposit


Impact:

  • Impact 1: Increases bytecode size of the contract


Proof of Concept

Byte code size changes after optimization (run with forge build --sizes)

BEFORE:
--------------+------------------+-------------------+--------------------+---------------------
| Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) |
+================================================================================================+
| BriVault | 16,502 | 18,754 | 8,074 | 30,398 |
AFTER:
--------------+------------------+-------------------+--------------------+---------------------
| Contract | Runtime Size (B) | Initcode Size (B) | Runtime Margin (B) | Initcode Margin (B) |
+================================================================================================+
| BriVault | 16,312 | 18,564 | 8,264 | 30,588 |

Recommended Mitigation

- function _convertToShares(
- uint256 assets
- ) internal view returns (uint256 shares) {
- uint256 balanceOfVault = IERC20(asset()).balanceOf(address(this));
- uint256 totalShares = totalSupply(); // total minted BTT shares so far
-
-
- if (totalShares == 0 || balanceOfVault == 0) {
- // First depositor: 1:1 ratio
- return assets;
- }
-
-
- shares = Math.mulDiv(assets, totalShares, balanceOfVault);
- }
-
- uint256 participantShares = _convertToShares(stakeAsset);
+ uint256 participantShares = _convertToAssets(stakeAsset, Math.Rounding.Floor);
Updates

Appeal created

bube Lead Judge 19 days 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!