Discrete curve migration #16
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates the iOS bonding curve implementation from a continuous exponential formula to a discrete step-based curve using pre-computed lookup tables. This ensures deterministic, consistent pricing across all clients (Solana program, backend, iOS, Android).
Motivation
The Rust flipcash-program migrated to a discrete bonding curve to ensure exact consistency across all platforms. The continuous exponential curve had potential for floating-point drift between different implementations. The discrete curve:
Changes
New Files
Modified Files
Key Implementation Details
UInt128 Custom Type
Swift doesn't have native UInt128, so we implemented a custom struct with:
Binary Resource Storage
Tables stored as binary files loaded at runtime to avoid Swift compiler memory issues. The original approach of embedding tables as Swift array literals caused 100GB+ memory usage during compilation.
API Methods
Test Coverage
101+ tests across 14 suites: