Trading doesn't support margin Asset tokens which has more than 18 digit decimals and TradingLibrary doesn't support assets which chainlinkFeed for that asset's price has more than 18 digit decimals #350
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-533
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/code-423n4/2022-12-tigris/blob/588c84b7bb354d20cbca6034544c4faa46e6a80e/contracts/Trading.sol#L649-L651
https://github.com/code-423n4/2022-12-tigris/blob/588c84b7bb354d20cbca6034544c4faa46e6a80e/contracts/Trading.sol#L675
https://github.com/code-423n4/2022-12-tigris/blob/588c84b7bb354d20cbca6034544c4faa46e6a80e/contracts/utils/TradingLibrary.sol#L114-L117
Vulnerability details
Impact
Some tokens may have 18 digit decimal or have price feed more than 18 digit decimal and in current implementation code won't support them.
Proof of Concept
This is
verfiyPrice()
code in TradingLibrary:As you can see in the line
18 - IPrice(_chainlinkFeed).decimals()
if the chainlinkFeed's price has more than 18 digit decimals then code would revert. function_handleDeposit()
and_handleWithdraw()
in Trading contract has similar code for_marginAsset
(outputToken
) and they don't support tokens with more than 18 decimals.Tools Used
VIM
Recommended Mitigation Steps
support tokens with more than 18 decimals by adding IF based on token decimals and if decimals are bigger than 18 calculate like this (decimal-18).
The text was updated successfully, but these errors were encountered: