First Flight #21: KittyFi

First Flight #21
Beginner FriendlyDeFiFoundry
100 EXP
View results
Submission Details
Severity: high
Invalid

KittyVault::executeDepawsit logic formular is flawed

Summary

In KittyVault::executeDepawsit, the user share in the vault is calculated with the wrong formular _cattyNipGenerated = _ameownt.mulDiv(totalCattyNip, _totalMeowllateral) because the numerator totalCattyNip and denominator _totalMeowllateral are used interchangeably.

Vulnerability Details

Impact

  • loss of funds for users

Tools Used

  • manual review

  • foundry chisel

Recommendations

function executeDepawsit(address _user, uint256 _ameownt) external onlyPool {
uint256 _totalMeowllateral = getTotalMeowllateral();
uint256 _cattyNipGenerated;
if (_totalMeowllateral == 0) {
_cattyNipGenerated = _ameownt;
}
else {
- _cattyNipGenerated = _ameownt.mulDiv(totalCattyNip, _totalMeowllateral);
+ _cattyNipGenerated = _ameownt.mulDiv(_totalMeowllateral, totalCattyNip);
}
userToCattyNip[_user] += _cattyNipGenerated;
totalCattyNip += _cattyNipGenerated;
totalMeowllateralInVault += _ameownt * PRECISION;
IERC20(i_token).safeTransferFrom(_user, address(this), _ameownt);
}
Updates

Lead Judging Commences

shikhar229169 Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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