You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.
sherlock-admin opened this issue
Jul 1, 2023
· 1 comment
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issueWill FixThe sponsor confirmed this issue will be fixed
In D3VaultFunding.sol and D3VaultLiquidation.sol contracts, Multiplication after Division can cause larger Precision loss
Summary
There are multiple instances in the D3VaultFunding.sol and D3VaultLiquidation.sol contracts code where multiplication is done after the division which is causing larger precision loss.
As seen above, the final calculated values of variables will result in precision loss because the division is happening first. Solidity does not support floating numbers and truncates it. For example, a value 0.75 will be truncated to 0. It is recommended to perform multiplication first and division at last.
Impact
Larger precision loss leading to wrong calculations
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issueWill FixThe sponsor confirmed this issue will be fixed
MohammedRizwan
high
In D3VaultFunding.sol and D3VaultLiquidation.sol contracts, Multiplication after Division can cause larger Precision loss
Summary
There are multiple instances in the D3VaultFunding.sol and D3VaultLiquidation.sol contracts code where multiplication is done after the division which is causing larger precision loss.
Vulnerability Detail
In D3VaultFunding.sol,
In D3VaultFunding.sol,
As seen above, the final calculated values of variables will result in precision loss because the division is happening first. Solidity does not support floating numbers and truncates it. For example, a value 0.75 will be truncated to 0. It is recommended to perform multiplication first and division at last.
Impact
Larger precision loss leading to wrong calculations
Code Snippet
Instance 1:
https://github.com/sherlock-audit/2023-06-dodo/blob/a8d30e611acc9762029f8756d6a5b81825faf348/new-dodo-v3/contracts/DODOV3MM/D3Vault/D3VaultFunding.sol#L79
Instance 2:
https://github.com/sherlock-audit/2023-06-dodo/blob/a8d30e611acc9762029f8756d6a5b81825faf348/new-dodo-v3/contracts/DODOV3MM/D3Vault/D3VaultFunding.sol#L99
Instance 3:
https://github.com/sherlock-audit/2023-06-dodo/blob/a8d30e611acc9762029f8756d6a5b81825faf348/new-dodo-v3/contracts/DODOV3MM/D3Vault/D3VaultFunding.sol#L122
Instance 4:
https://github.com/sherlock-audit/2023-06-dodo/blob/a8d30e611acc9762029f8756d6a5b81825faf348/new-dodo-v3/contracts/DODOV3MM/D3Vault/D3VaultFunding.sol#L198
Instance 5:
https://github.com/sherlock-audit/2023-06-dodo/blob/a8d30e611acc9762029f8756d6a5b81825faf348/new-dodo-v3/contracts/DODOV3MM/D3Vault/D3VaultFunding.sol#L244
Instance 6:
https://github.com/sherlock-audit/2023-06-dodo/blob/a8d30e611acc9762029f8756d6a5b81825faf348/new-dodo-v3/contracts/DODOV3MM/D3Vault/D3VaultFunding.sol#L255
Instance 7:
https://github.com/sherlock-audit/2023-06-dodo/blob/a8d30e611acc9762029f8756d6a5b81825faf348/new-dodo-v3/contracts/DODOV3MM/D3Vault/D3VaultFunding.sol#L354
Instance 8:
https://github.com/sherlock-audit/2023-06-dodo/blob/a8d30e611acc9762029f8756d6a5b81825faf348/new-dodo-v3/contracts/DODOV3MM/D3Vault/D3VaultLiquidation.sol#L53
Instance 9:
https://github.com/sherlock-audit/2023-06-dodo/blob/a8d30e611acc9762029f8756d6a5b81825faf348/new-dodo-v3/contracts/DODOV3MM/D3Vault/D3VaultLiquidation.sol#L82
Instance 10:
https://github.com/sherlock-audit/2023-06-dodo/blob/a8d30e611acc9762029f8756d6a5b81825faf348/new-dodo-v3/contracts/DODOV3MM/D3Vault/D3VaultLiquidation.sol#L144
Tool used
Manual Review
Recommendation
Recommend to perform the Multiplication first and division last.
Duplicate of #45
The text was updated successfully, but these errors were encountered: