Skip to content
Business logic Audit finding Intermediate

Fee calculation is slightly off

The fee calculation uses a simple interest formula that does not compound, so collecting fees more frequently results in slightly less total fee than collecting less frequently. An attacker could exploit this by triggering frequent fee collections to reduce the amount paid.

gzeon Follow

Originally disclosed on Code4rena

Submitted by gzeon

The fee calculation

uint256 timeDiff = (block.timestamp - lastFee);
uint256 feePct = timeDiff * licenseFee / ONE_YEAR;
uint256 fee = startSupply * feePct / (BASE - feePct);

tries to calculate a fee such that fee/(supply+fee) = %fee using a simple interest formula (i.e. no compounding), this lead to slightly less fee collected when fee are collected more frequently (small timeDiff) vs less frequently (big timeDiff).

Proof of Concept

Basket.sol#L133

frank-beard (Kuiper) acknowledged, but disagreed with Medium severity and commented:

While this is technically true, the actual precision loss should be very negligible.

0xleastwood (judge) commented:

I think any precision loss or value leakage qualifies for a medium severity issue. This seems like it would lead to an inconsistent fee calculation and is probably worthwhile fixing long-term.


The original report as published on Code4rena, by gzeon. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the fee formula uses simple interest instead of compound interest, causing precision loss when time intervals are small.

Impact

The precision loss is very negligible according to the developer, but the judge considered it a medium severity issue because it leads to inconsistent fee calculation and value leakage.

What the attacker needed

Ability to trigger fee collection

The fix

The fee calculation should be adjusted to use compound interest or otherwise ensure consistent fees regardless of collection frequency.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A smart contract charges a fee based on how much time has passed since the last fee was taken. The formula used is like simple interest, which doesn't account for compounding. If fees are taken very often, the total fee ends up a tiny bit lower than if taken rarely, so someone could deliberately trigger frequent fee collections to pay less.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by gzeon

View all

46 more disclosed reports, best first.

More from Kuiper contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.