Skip to content

feat(currency-math): move discrete bonding curve engine to shared KMP module - #1423

Merged
bmc08gt merged 14 commits into
code/cashfrom
feat/shared-core-discrete-curve
Sep 11, 2026
Merged

feat(currency-math): move discrete bonding curve engine to shared KMP module#1423
bmc08gt merged 14 commits into
code/cashfrom
feat/shared-core-discrete-curve

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add :libs:currency-math:discrete-curve, a new KMP commonMain module holding the discrete bonding curve engine (table parsing, high-precision arithmetic, binary-search/step pricing).
  • Port the curve math from the JVM-only implementation, folding in two precision-bug fixes found during the port.
  • Port the curve.json/curve_fractional.json fixture vectors to commonTest, plus a valueToTokens/tokensForValueExchange edge-case gate.
  • Export the module through SharedCore via a SharedDiscreteCurve Kotlin/Native facade, with a cross-platform gate test.
  • Reduce Android's DiscreteBondingCurve to a thin adapter that delegates pricing to the shared engine and converts to/from java.math.BigDecimal at the boundary; the deleted LazyBigDecimalTable/TableLoader are replaced by AndroidTableLoader/ClasspathTableLoader/FileTableLoader (TableByteLoader).

This is one of two companion PRs — the other is in code-ios-app — for the shared bonding-curve migration. Landing requires: this PR merging to code/cash, then a SharedCore publish (new flipcash-shared-core-spm version), then the iOS PR's pin bump to that version.

@bmc08gt
bmc08gt requested a review from jeffyanta as a code owner September 6, 2026 13:05
@bmc08gt bmc08gt self-assigned this Sep 6, 2026
@github-actions github-actions Bot added type: feature New functionality area: build-system Gradle, convention plugins, build-logic labels Sep 6, 2026
:libs:currency-math:discrete-curve uses com.android.kotlin.multiplatform.library
with withHostTest {}, so its Android-target unit tests run under
testAndroidHostTest, not testDebugUnitTest. It was missing from
kmpUnitTestModules in settings.gradle.kts, so it fell through to
androidUnitTestModules by default and the flipcashTestDebug aggregate task
looked for a testDebugUnitTest task that doesn't exist on it, failing CI's
Run Flipcash Tests job at dependency-resolution time.
:libs:currency-math:discrete-curve's test-fixture generator compiles two
~4.5MB base64 tables into a single ~8.7MB TestFixtures.kt on commonTest.
apps:flipcash:app:lintDebug aggregates dependency modules' test sources
straight off disk, and lint's PSI/UAST parser hard-caps source files
around 20MB pre-escaping headroom, so it fails the whole build with
"Source file too large for lint to process" on that generated file.

Set ignoreTestSources on the module so lint drops its test sources from
the aggregated scan; commonMain/androidMain are still checked.
@bmc08gt
bmc08gt merged commit 4a31dd3 into code/cash Sep 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: build-system Gradle, convention plugins, build-logic type: feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant