Skip to content

Add a bonding curve simulation view function that returns the buy and sell price for any supply and quantity without state mutation #836

Description

@Chucks1093

Summary

The client needs to show price previews for various quantities without triggering a transaction. A simulate_buy and simulate_sell view function that accepts a supply level and quantity and returns the computed price without mutating any state would power client-side price previews and the batch buy total cost estimate.

Scope

  • Add simulate_buy(key_id: BytesN<32>, quantity: u32) as a read-only view function
  • Add simulate_sell(key_id: BytesN<32>, quantity: u32) as a read-only view function
  • Both functions should read the current supply from storage and compute the price using the bonding curve formula
  • Return the total cost and per-unit price without writing to any storage entry
  • These functions must work during the auction phase, returning the auction price when applicable

Acceptance Criteria

  • simulate_buy returns correct total cost and per-unit price
  • simulate_sell returns correct total proceeds and per-unit price
  • Neither function mutates any storage entry
  • Auction-phase price returned correctly during auction
  • 404-equivalent panic with KeyNotFound for unknown key IDs

ETA: 24 hours


Coordinate on Telegram

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions