Skip to content

Latest commit

 

History

History
30 lines (27 loc) · 3.04 KB

112.md

File metadata and controls

30 lines (27 loc) · 3.04 KB

Tangy Butter Antelope

High

Division Before Multiplication Can Cause Precision Loss

Summary

Multiple functions in the Axiom protocol contain a bug related to performing division before multiplication. This flaw can lead to unnecessary precision loss in calculations involving reserves, token amounts, and price-related values, potentially impacting the protocol's ability to accurately manage liquidity, rewards, and other financial operations.

Vulnerability Details

The issue arises from the improper ordering of operations, where division is performed before multiplication. This introduces a risk of precision loss, especially when dealing with integer arithmetic in Solidity. Since Solidity handles only integer division, performing division before multiplication can result in rounding errors that degrade accuracy. This can be particularly harmful in DeFi protocols, where precise calculations are essential for balancing liquidity pools, managing token prices, and distributing rewards.

Code Snippet

https://github.com/sherlock-audit/2024-10-axion/blob/main/liquidity-amo/contracts/MasterAMO.sol#L336-L338 https://github.com/sherlock-audit/2024-10-axion/blob/main/liquidity-amo/contracts/SolidlyV2AMO.sol#L345 https://github.com/sherlock-audit/2024-10-axion/blob/main/liquidity-amo/contracts/SolidlyV2AMO.sol#L358-L364 https://github.com/sherlock-audit/2024-10-axion/blob/main/liquidity-amo/contracts/SolidlyV2AMO.sol#L390-L393 https://github.com/sherlock-audit/2024-10-axion/blob/main/liquidity-amo/contracts/SolidlyV3AMO.sol#L347 https://github.com/sherlock-audit/2024-10-axion/blob/main/liquidity-amo/contracts/SolidlyV3AMO.sol#L350 https://github.com/sherlock-audit/2024-10-axion/blob/main/liquidity-amo/contracts/SolidlyV3AMO.sol#L352 https://github.com/sherlock-audit/2024-10-axion/blob/main/solidly-utils/contracts/AerodromeUtils.sol#L21-L25 https://github.com/sherlock-audit/2024-10-axion/blob/main/solidly-utils/contracts/MasterUtils.sol#L71 https://github.com/sherlock-audit/2024-10-axion/blob/main/solidly-utils/contracts/MasterUtils.sol#L79-L83 https://github.com/sherlock-audit/2024-10-axion/blob/main/solidly-utils/contracts/MasterUtils.sol#L135

Impact

Precision Loss: Incorrect calculations for reserves, liquidity, token amounts, and prices could lead to inaccurate financial operations. Imbalance in Liquidity Pools: A small miscalculation could result in unbalanced liquidity, affecting users' liquidity contributions and rewards. Incorrect Price Computation: Price discrepancies could impact trading and liquidity management, leading to potential economic loss. Inefficient Reward Distribution: Miscalculations in reward amounts could lead to over- or under-distribution, potentially affecting users' earnings.

Recommendation Details

Reorder Operations: Ensure multiplication is performed before division to preserve precision, especially when dealing with integer arithmetic in Solidity. Example fix: Instead of value / divisor * multiplier, use (value * multiplier) / divisor to maintain precision in calculations.