Pieces Protocol

First Flight #32
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Severity: low
Valid

Loss of funds for the Contract Admin Due to Miscalculation in Fee transfer in `buyOrder` Function.

Summary

The buyOrder function in the contract contains a logic flaw where the sellerFee (calculated as half of the transaction fee) is deducted from the seller's payout but is not sent to the contract owner. This results in the mismanagement of funds and a potential financial loss for the contract.

Vulnerability Details

function buyOrder(uint256 orderIndex, address seller) external payable {
uint256 fee = order.price / 100; // 1% transaction fee
uint256 sellerFee = fee / 2; // Seller Fee: 0.5% of the order price
if (msg.value < order.price + sellerFee) {
revert TokenDivider__InsufficientEtherForFees();
}
// Seller payout calculation
(bool success, ) = payable(order.seller).call{value: (order.price - sellerFee)}("");
if (!success) {
revert TokenDivider__TransferFailed();
}
// Owner receives only the 'fee'
--> (bool taxSuccess, ) = payable(owner()).call{value: fee}("");
if (!taxSuccess) {
revert TokenDivider__TransferFailed();
}

}

Impact

  1. The sellerFee is deducted from the seller's payout but is not transferred to any address, resulting in a loss of funds.

  2. Over time, the accumulation of lost seller fees may result in significant unaccounted funds.

Tools Used

Manual

Recommendations

- (bool taxSuccess, ) = payable(owner()).call{value: fee}("");
+ (bool taxSuccess, ) = payable(owner()).call{value: (fee + sellerFee)}("");

Updates

Lead Judging Commences

fishy Lead Judge 4 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Precision loss

Support

FAQs

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