-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Description
There is a potential precision loss issue in the treasury amount calculation within the MarkFeesCollected method in internal/service/fees.go.
Problem
The conversion from big.Float to uint64 using the Uint64() method truncates the value and ignores the accuracy flag, which could lead to incorrect treasury amounts being calculated.
Location: internal/service/fees.go around lines 162-165
Current problematic code:
treasuryAmount := big.NewFloat(0).SetUint64(fee.Amount)
treasuryAmount = treasuryAmount.Mul(treasuryAmount, big.NewFloat(treasurySplit))
treasuryAmountUint64, _ := treasuryAmount.Uint64() // <- Ignores accuracy flag
developerAmountUint64 := fee.Amount - treasuryAmountUint64Solution
The code should check the accuracy returned by Uint64() and apply proper rounding before converting to uint64 to ensure the treasury amount is correctly calculated without truncation errors.
Backlinks
- Related PR: Treasury records #287
- Original comment: Treasury records #287 (comment)
Reported by: @garry-sharp
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels