Skip to content

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

Description

@Chucks1093

Summary

Off-chain tools and tests both need to predict prices and fees without triggering state-mutating transactions. A read-only price query function and thorough fee unit tests at boundary supply values address both needs and together verify the bonding curve formula end to end.

Scope

  • Add query_price(supply: u64) -> i128 read-only contract function — returns the same value the buy path computes for that supply step, requires no auth, performs no storage writes
  • Add unit tests for query_price at supply 0, 1, and a mid-range value confirming output matches the inline formula
  • Add protocol fee unit tests at supply 0, 1, and 1000 asserting the computed fee matches expected bps-based value; assert fee floors (rounds down) on non-whole stroop results

Acceptance Criteria

  • query_price is read-only, requires no auth, performs no writes
  • query_price output matches buy-path formula at supply 0, 1, and mid-range
  • Protocol fee correct at supply 0, 1, and 1000
  • Fee rounds down on non-whole stroop results
  • Fee tests use configured bps, not a hardcoded percentage

ETA: 12 hours


Coordinate on Telegram

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions