The protocol(based on the PreMarkets.t.sol
and constants) consider that every ERC20 token has 18 decimals. One clear example is the Constants file where several values are defined like platform fee, trade tax, collateral rate, etc. All of them considering a token with 18 decimals:
Those values are used across the protocol to calculate fees, revenue, points, etc. I.e: the PreMarkets.sol
use extensively those:
As the protocol will accept different ERC20 tokens and already has in its tests the USDC
, it is necessary to implement a solution that considers the difference in decimals of the ERC20s.
Miscalculation of prices
Loss of funds
Underpayment/Overpayment of fees
Bad debt for the protocol once the user exploits the miscalculation with tokens > 18 decimals.
Manual Review
A safe and effective solution is to use a **fixed-point math library like **https://github.com/PaulRBerg/prb-math.
All tokens can be safely brought to 18 decimals.
Reference case: https://github.com/sablier-labs/v2-core
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.