Skip to content

feat: add computePriceChange helper for key price percentage change#436

Merged
Chucks1093 merged 1 commit into
accesslayerorg:devfrom
Ghadaffijr:feat/compute-price-change
Jun 26, 2026
Merged

feat: add computePriceChange helper for key price percentage change#436
Chucks1093 merged 1 commit into
accesslayerorg:devfrom
Ghadaffijr:feat/compute-price-change

Conversation

@Ghadaffijr

@Ghadaffijr Ghadaffijr commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

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

- 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
@Chucks1093 Chucks1093 merged commit 759d811 into accesslayerorg:dev Jun 26, 2026
7 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.

Add helper for computing percentage price change between two key price values

2 participants