The issue with the unwrap fee rounding down can have several detrimental impacts on the Ocean protocol:
Revenue Loss: Due to rounding down, the contract loses out on potential unwrap fees, particularly for smaller unwrap amounts. This can significantly reduce the protocolβs revenue and limit its ability to operate and maintain its services.
Unfairness to Users: Smaller users who unwrap smaller amounts are disproportionately affected by the rounding down, leading to a sense of unfairness and potentially discouraging them from using the platform.
Reduced User Confidence: The presence of this issue can erode user confidence in the protocolβs accuracy and fairness, potentially leading to decreased user engagement and adoption.
function calculateUnwrapFee(uint256 unwrapAmount, uint256 unwrapFeeDivisor) public pure returns (uint256) {
return unwrapAmount / unwrapFeeDivisor; // Integer division causes rounding down.
}
This code snippet demonstrates how the integer division in the calculateUnwrapFee function results in rounding down the fee, leading to potential loss.
Modify the calculateUnwrapFee function to use truncation instead of integer division.
This ensures the fee is always rounded towards zero, eliminating revenue loss for smaller unwrap amounts.
function calculateUnwrapFee(uint256 unwrapAmount, uint256 unwrapFeeDivisor) public pure returns (uint256) {
return truncate(unwrapAmount / unwrapFeeDivisor);
}
Define a minimum unwrap fee that applies regardless of the unwrap amount.
This guarantees the contract always collects some fee, even for very small unwrap transactions.
function calculateUnwrapFee(uint256 unwrapAmount, uint256 unwrapFeeDivisor) public pure returns (uint256) {
uint256 fee = unwrapAmount / unwrapFeeDivisor;
if (fee < minimumUnwrapFee) {
fee = minimumUnwrapFee;
}
return fee;
}
Error
The text was updated successfully, but these errors were encountered:
All reactions