Skip to content

feat: add query_price helper and protocol fee boundary tests (#572) - #641

Merged
Chucks1093 merged 5 commits into
accesslayerorg:mainfrom
edehvictor:feat/query-price-protocol-fee-572
Jul 30, 2026
Merged

feat: add query_price helper and protocol fee boundary tests (#572)#641
Chucks1093 merged 5 commits into
accesslayerorg:mainfrom
edehvictor:feat/query-price-protocol-fee-572

Conversation

@edehvictor

Copy link
Copy Markdown
Contributor

Closes #572

Summary

Adds a read-only \query_price(env: Env, creator: Address, supply: u64)\ helper function to \CreatorKeysContract\ along with comprehensive unit tests for \query_price\ and protocol fee calculation at boundary supply values.

Changes

  • **\creator-keys/src/lib.rs**: Added \query_price(env: Env, creator: Address, supply: u64) -> Result<i128, ContractError>\ to \CreatorKeysContract. Computes the bonding curve price for a given supply step without requiring authorization or modifying storage state.
  • **\creator-keys/src/test_issues.rs**: Added unit tests:
    • \ est_query_price_at_boundary_supplies: Asserts \query_price\ output matches buy-path formula across supply steps 0, 1, and 50 for Flat, Linear, and Quadratic presets.
    • \ est_protocol_fee_calculation_at_boundary_supplies: Asserts protocol fee calculation at boundary supply values 0, 1, and 1000 against configured \protocol_bps.
    • \ est_protocol_fee_floors_on_non_whole_stroops: Asserts protocol fee calculation floors (rounds down) on non-whole stroop amounts.

Testing

@Chucks1093

Copy link
Copy Markdown
Contributor

Fix ci

@Chucks1093

Copy link
Copy Markdown
Contributor

I see what you have done here, the price check tool and fee edge case tests make it easy to verify the math holds at boundary values. Good work.

Storage access is only valid inside a contract execution context;
calling compute_bonding_curve_price bare in test code panics with
"this function is not accessible outside of a contract".
@Chucks1093
Chucks1093 merged commit 8ccb706 into accesslayerorg:main Jul 30, 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.

Add read-only price query helper and unit tests for protocol fee calculation at boundary supply values

2 participants