Skip to content

Add helper for computing bonding curve price at any given supply step without mutating contract state #537

Merged
Chucks1093 merged 1 commit into
accesslayerorg:devfrom
Menjay7:mjay
Jul 20, 2026
Merged

Add helper for computing bonding curve price at any given supply step without mutating contract state #537
Chucks1093 merged 1 commit into
accesslayerorg:devfrom
Menjay7:mjay

Conversation

@Menjay7

@Menjay7 Menjay7 commented Jul 19, 2026

Copy link
Copy Markdown

PR Description
Summary

Introduces a pure helper function for calculating the bonding curve price at any specified supply step without mutating contract state. This enables off-chain price estimation, previews, and testing while preserving contract state integrity.

Changes
Added a helper function to compute the bonding curve price for any given supply value.
Implemented the calculation as a read-only operation with no state mutations.
Reused the existing bonding curve pricing logic to ensure consistency with buy/sell operations.
Added validation for edge cases, including:
Zero supply.
Initial supply.
Large supply values.
Boundary and overflow scenarios (where applicable).
Refactored pricing logic where necessary to minimize code duplication.
Why

Clients, frontends, and tests often need to estimate token prices before executing transactions. A pure helper provides deterministic pricing without requiring a state-changing contract call, improving developer experience while ensuring pricing logic remains consistent across the codebase.

Testing
Added unit tests verifying price calculations across multiple supply levels.
Confirmed the helper produces the same results as the existing contract pricing logic.
Verified that invoking the helper does not modify contract state.
Tested edge cases, including zero, initial, and high supply values.
Closed #552

@Chucks1093
Chucks1093 merged commit 822de33 into accesslayerorg:dev Jul 20, 2026
1 check 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.

3 participants