-
Notifications
You must be signed in to change notification settings - Fork 29
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
client-js: add JS helpers for interest bearing tokens' UIAmounts #53
client-js: add JS helpers for interest bearing tokens' UIAmounts #53
Conversation
There was a problem hiding this 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 overall! Mostly small things. @lorisleiva can you also take a quick look at the tests? I'm mostly interested in feedback on the test setup, and whether it aligns how we should write tests for these packages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, I would call this file amountToUiAmount.test.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
clients/js/test/extensions/interestBearingMint/getAmountToUiAmount.test.ts
Outdated
Show resolved
Hide resolved
clients/js/test/extensions/interestBearingMint/getAmountToUiAmount.test.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the changes!
There was a problem hiding this 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! Can you run pnpm format:fix
to fix the formatting issue? You might also need to rebase to pick up the recent changes to CI
Similar to this PR in solana-program-library, this adds helper functions for interest bearing tokens for getting amountToUiAmount and uiAmountToAmount without needing to simulate a transaction.
UiAmounts are provided with the token's decimals as its precision and truncated instead of rounded to avoid rounding issues.
Amounts are processed in the base unit of the token (if the token has 2 decimals 1.23 is represented as 123)