feat: add computePriceChange helper for key price percentage change#436
Merged
Chucks1093 merged 1 commit intoJun 26, 2026
Merged
Conversation
- Add computePriceChange(current: bigint, previous: bigint) in src/utils/priceChange.utils.ts
- Returns { percent: number, direction: 'up' | 'down' | 'flat' }
- Returns flat when previous is zero or current equals previous
- 7 unit tests covering: price up, price down, no change, zero previous, both zero
Closes accesslayerorg#429
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add computePriceChange(current: bigint, previous: bigint) in src/utils/priceChange.utils.ts
Returns { percent: number, direction: 'up' | 'down' | 'flat' }
Returns flat when previous is zero or current equals previous
7 unit tests covering: price up, price down, no change, zero previous, both zero
Closes #429
Summary
i. Adds computePriceChange(current: bigint, previous: bigint) in src/utils/priceChange.utils.ts as a shared helper for computing key price movement across the creator list and creator detail pages
ii. Returns { percent: number, direction: 'up' | 'down' | 'flat' } so formatting and sign logic are consistent wherever price change is displayed
iii. Returns flat with percent: 0 in both edge cases: when previous is zero (undefined division) and when current equals previous (no movement)
iv. Converts bigint inputs to number at the division boundary only, preserving precision for the comparison logic
Closes #429
Testing
-[x] pnpm lint
-[x] pnpm build
-[x] 7 unit tests added covering: price increase, price decrease, large increase, large decrease, equal values, zero previous, both zero
Checklist
-[x] Linked issue or backlog item
-[x] Scope is limited to the stated change
-[x] Updated docs if behavior or setup changed
-[ ] Added screenshots for UI changes when relevant — N/A, pure utility function with no UI- Add
Closes #429