fix: scale user input by token decimals before sending to contracts (#15) #720

Merged
PlasticDigits merged 1 commit from fix/issue-15-decimal-scaling into main 2026-03-13 06:58:53 +00:00
PlasticDigits commented 2026-03-13 06:57:24 +00:00 (Migrated from gitlab.com)

Summary

Closes #15

  • User-facing token amounts were passed directly to smart contracts without multiplying by 10^decimals, causing all swaps and liquidity operations to execute at dust amounts
  • Added toRawAmount/fromRawAmount utility functions for precise human↔raw conversion
  • Applied scaling in SwapPage (simulate, swap, balance check, Max button) and PoolPage (provide liquidity, withdraw liquidity, LP Max button)

Test plan

  • Enter a swap amount (e.g. 1000 EMBER) and verify the on-chain tx sends 1000000000 micro-units
  • Click Max on swap page — input should show human-readable balance, not raw micro-units
  • Provide liquidity with known amounts and verify pool reserves change by expected token amounts
  • Withdraw LP tokens and verify correct raw amount is sent
  • Verify insufficient balance check triggers correctly for amounts exceeding wallet balance
## Summary Closes #15 - User-facing token amounts were passed directly to smart contracts without multiplying by `10^decimals`, causing all swaps and liquidity operations to execute at dust amounts - Added `toRawAmount`/`fromRawAmount` utility functions for precise human↔raw conversion - Applied scaling in SwapPage (simulate, swap, balance check, Max button) and PoolPage (provide liquidity, withdraw liquidity, LP Max button) ## Test plan - [ ] Enter a swap amount (e.g. 1000 EMBER) and verify the on-chain tx sends 1000000000 micro-units - [ ] Click Max on swap page — input should show human-readable balance, not raw micro-units - [ ] Provide liquidity with known amounts and verify pool reserves change by expected token amounts - [ ] Withdraw LP tokens and verify correct raw amount is sent - [ ] Verify insufficient balance check triggers correctly for amounts exceeding wallet balance
PlasticDigits commented 2026-03-13 06:57:24 +00:00 (Migrated from gitlab.com)

requested review from @Brouie

requested review from @Brouie
PlasticDigits commented 2026-03-13 06:58:18 +00:00 (Migrated from gitlab.com)

restored source branch fix/issue-15-decimal-scaling

restored source branch `fix/issue-15-decimal-scaling`
PlasticDigits commented 2026-03-13 06:58:54 +00:00 (Migrated from gitlab.com)

mentioned in commit d1a230e1e4

mentioned in commit d1a230e1e432913cebb391f2d4b6b5b94b6f3062
PlasticDigits (Migrated from gitlab.com) merged commit d1a230e1e4 into main 2026-03-13 06:58:54 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-dex-terraclassic!720
No description provided.