OrderBook

First Flight #43
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: low
Valid

Fee Calculation Rounding Can Cause Protocol Revenue Loss Due to Precision TruncationDescription

Integer division in fee computation causes rounding loss, leading to permanent undercollection of protocol revenue

  • The protocol earns money by taking a fee from each order’s priceInUSDC

uint256 protocolFee = (order.priceInUSDC * FEE) / PRECISION;

However, due to integer truncation, any fractional remainder is silently discarded. Over time, this causes the protocol to lose revenue, especially on:

  • Low-priced orders (where rounding loss is proportionally large)

  • High-volume systems (where dust adds up)

  • Repeated micro-orders (e.g. bots or retail users)

In fee-sensitive systems like this, even tiny rounding errors directly affect earnings.

Risk

Likelihood:

  • Happens deterministically across all orders with fractional fees

  • Solidity has no built-in rounding — protocol leaves money on the table

  • Anyone can trigger this unintentionally (or intentionally with low-value orders)

Impact:

  • Protocol earns less than expected fee revenue

  • Buyers pay correct amounts, but seller receives more than they should

  • Over thousands of orders, fee slippage compounds

  • May impact long-term sustainability or tokenomics if fees are relied upon for funding ops/staking/incentives

Proof of Concept

Shows how the loss can affect protocol

// Suppose FEE = 3, PRECISION = 100 (i.e., 3%)
// Order priced at 199 USDC (199e6)
protocolFee = (199e6 * 3) / 100 = 5.97e6 → truncated to 5e6
// Seller receives 194e6 instead of 193.03e6
// Protocol loses ~0.97e6 = $0.97

Recommended Mitigation

Include this rather

- uint256 protocolFee = (order.priceInUSDC * FEE) / PRECISION;
+ protocolFee = (order.priceInUSDC * FEE + PRECISION - 1) / PRECISION;
Updates

Lead Judging Commences

yeahchibyke Lead Judge 5 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Fee can be bypassed

Protocol Suffers Potential Revenue Leakage due to Precision Loss in Fee Calculation

Support

FAQs

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

Give us feedback!