Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: high
Valid

beneficiaries are not correctly paid out in `buyOutEstateNFT`

Summary

IMPACT : HIGH
Likelihood : High

The finalAmount is beeing correctly calculated inside the buyOutEstateNft function. But the amount that each beneficiery gets is incorrectly calculated:

IERC20(assetToPay).safeTransfer(
beneficiaries[i],
finalAmount / divisor

instead of finalAmount/divisor it should be finalAmount/muliplier or finalAmount/(divisor - 1)

Impact

If someone buys out a EstateNft, the other beneficiaries would get less than they should get. to be exact they would only get "(benefieriary.length-1)/beneficiary.length" percent of their share they should get.

Recommendation

replace /divisor by /multiplier and add an extra

function buyOutEstateNFT(
uint256 _nftID
) external onlyBeneficiaryWithIsInherited {
uint256 value = nftValue[_nftID];
uint256 divisor = beneficiaries.length;
uint256 multiplier = beneficiaries.length - 1;
uint256 finalAmount = (value / divisor) * multiplier;
IERC20(assetToPay).safeTransferFrom(
msg.sender,
address(this),
finalAmount
);
for (uint256 i = 0; i < beneficiaries.length; i++) {
if (msg.sender == beneficiaries[i]) {
return;
} else {
IERC20(assetToPay).safeTransfer(
beneficiaries[i],
- finalAmount / divisor
+ finalAmount / multiplier
);
}
}
nft.burnEstate(_nftID);
}
Updates

Lead Judging Commences

0xtimefliez Lead Judge 3 months ago
Submission Judgement Published
Validated
Assigned finding tags:

buyOutNFT has wrong denominator

buyOutNFT has return instead of continue

Support

FAQs

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