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 Sep 17, 2023. It is now read-only.
sherlock-admin opened this issue
Mar 13, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
Wrong calculation of collateral ratio with the collateral tokens which are not in decimals 18
Summary
Wrong calculation of collateral ratio with the collateral tokens which has decimals < 18
Vulnerability Detail
Function _computeCR in library TauMath is used to calculate the collateral ratio of an account. But the formula in this function will be incorrect if collateral tokens has decimals != 18.
TAU token is the debt token, which is in 18 decimals. But the collateral can be not in decimals 18, example WBTC is in 8 decimals. Then this formula will calculate incorrectly the ratio for these token, since the decimals of token is not mentioned.
Example:
Token WBTC is in 8 decimals, and the Oracle is Chainlink WBTC-USD, which has priceDecimals = 8
Assume price of 1 WBTC is 20000$, it means price = 20000 * 1e8
The collRatio of 1 WBTC (1e8 wei) and 1 TAU debt (1e18 wei) is:
Collateral tokens which has < 18 decimals (like WBTC) can't be supported. It's very bad behavior since the sponsors confirm that Taurus was built having in mind to support any collateral tokens.
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` labelHighA valid High severity issueRewardA payout will be made for this issue
duc
medium
Wrong calculation of collateral ratio with the collateral tokens which are not in decimals 18
Summary
Wrong calculation of collateral ratio with the collateral tokens which has decimals < 18
Vulnerability Detail
Function
_computeCR
in libraryTauMath
is used to calculate the collateral ratio of an account. But the formula in this function will be incorrect if collateral tokens hasdecimals
!= 18.TAU token is the debt token, which is in 18 decimals. But the collateral can be not in decimals 18, example WBTC is in 8 decimals. Then this formula will calculate incorrectly the ratio for these token, since the decimals of token is not mentioned.
Example:
priceDecimals
= 8price
= 20000 * 1e8Constants.PRECISION
(1e18), and it's incorrect since WBTC is very expensive.There is a similar problem when convert debt asset (TAU tokens) to collateral in function
_calcLiquidation
of contractBaseVault.sol
:Impact
Collateral tokens which has < 18 decimals (like WBTC) can't be supported. It's very bad behavior since the sponsors confirm that Taurus was built having in mind to support any collateral tokens.
Code Snippet
https://github.com/sherlock-audit/2023-03-taurus/blob/main/taurus-contracts/contracts/Libs/TauMath.sol#L18
https://github.com/sherlock-audit/2023-03-taurus/blob/main/taurus-contracts/contracts/Vault/BaseVault.sol#L406
Tool used
Manual review
Recommendation
Convert collateral amount to decimals 18 before calculation.
Duplicate of #35
The text was updated successfully, but these errors were encountered: