📌 Description
src/utils/token.ts formats token amounts using each token's decimals; if a token reports an unexpected decimals value (e.g. 0, negative, or absurdly large), formatting can silently produce a wrong or misleading amount.
🧩 Requirements and context
- Validate that
decimals is a non-negative integer within a sane bound (e.g. 0-30) before using it in formatting.
- Throw or return a clear error for out-of-bound decimals rather than silently producing a malformed string.
- Add regression tests for 0 decimals, very large decimals, and negative decimals.
🛠️ Suggested execution
- Add a decimals-bounds check at the top of the relevant formatting function(s) in
src/utils/token.ts.
- Add/extend
src/utils/token.test.ts for the new edge cases.
✅ Acceptance criteria
🔒 Security notes
Prevents a malicious/malformed token contract from causing a misleading displayed amount downstream.
📋 Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
📌 Description
src/utils/token.tsformats token amounts using each token's decimals; if a token reports an unexpected decimals value (e.g. 0, negative, or absurdly large), formatting can silently produce a wrong or misleading amount.🧩 Requirements and context
decimalsis a non-negative integer within a sane bound (e.g. 0-30) before using it in formatting.🛠️ Suggested execution
src/utils/token.ts.src/utils/token.test.tsfor the new edge cases.✅ Acceptance criteria
🔒 Security notes
Prevents a malicious/malformed token contract from causing a misleading displayed amount downstream.
📋 Guidelines