Skip to content
This repository has been archived by the owner on Jun 30, 2024. It is now read-only.

Rounding issue as the contract does not return accurate value #4

Open
ThembaniDube opened this issue Dec 10, 2023 · 0 comments
Open

Comments

@ThembaniDube
Copy link

Summary

Using a division sign, does not round up or down and return correct value
Decimals need to be handled in a safe way

Vulnerability Detail

Impact

Code Snippet

if (asset.useMovingAverage) prices[numFeeds] = asset.cumulativeObs / asset.numObservations;

return (assetPrice * 10 ** decimals) / basePrice;

return (assetPrice * 10 ** decimals) / basePrice;

uint256 price = (assetPrice * 10 ** decimals) / basePrice;

uint16 numObservations = uint16(movingAverageDuration_ / observationFrequency);

Tool used

Manual Review

Recommendation

Use Solidity's SafeMath to mitigate these errors

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant