Skip to content

Add Support for Scaled UI Amount Extension to JS Library #427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 19, 2025

Conversation

gitteri
Copy link
Contributor

@gitteri gitteri commented May 8, 2025

Add Support for Scaled UI Amount Extension to JS Library

This PR adds support for the Scaled UI Amount extension to the js ibrary, enabling conversion between raw token amounts and UI representation based on a configurable multiplier.

Changes

Client Library

  • Added amountToUiAmountForScaledUiAmountMintWithoutSimulation function to convert raw amounts to UI amounts using a configurable multiplier
  • Added uiAmountToAmountForScaledUiAmountMintWithoutSimulation function for reverse conversion
  • Updated main utility functions to detect and handle mints with the Scaled UI Amount extension
  • Improved code organization with clear section headers and extracted common helper functions
  • Enhanced documentation throughout the codebase

Tests

  • Added comprehensive test suite for the Scaled UI Amount extension functionality
  • Tests cover basic integer multipliers (2x, 3x) and decimal multipliers (0.5x, 1.5x, 0.001x)
  • Added tests for time-based multiplier transitions (current vs. future multipliers)
  • Verified compatibility with large token amounts
  • Ensured consistent behavior with decimal places and edge cases

Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great overall! Just some nits on the tests

Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, just need to pass CI -- looks like the code needs to be formatted

Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@joncinque joncinque merged commit 71c988f into solana-program:main May 19, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants