Repository navigation
Conversation
e849c52 to
7d8cc01
Compare
7d8cc01 to
660c69f
Compare
|
Good work, Please resolve the branch conflicts |
99028e3 to
5e7836f
Compare
5e7836f to
e41c753
Compare
9a3717b to
c8b99b0
Compare
c8b99b0 to
2eeed93
Compare
2eeed93 to
c292941
Compare
|
Warning Possible malicious code: please review before merging. An automated security scan flagged files in this pull request that appear to contain malicious code. Code like this can run automatically when a project is opened in an editor or its dependencies are installed, so it could compromise the machine of anyone who checks out this branch. Automated scans can be wrong, so this may be a false positive. Maintainers: please review the flagged files carefully before merging, on GitHub in your browser rather than by checking out the branch. The malicious part is often hidden far off to the right of an ordinary-looking line, so scroll sideways through each file. @Emmazlee: this pull request adds or changes these files, possibly without your knowledge. Malware like this spreads by adding itself to repositories on machines it has infected, so your machine might be compromised. Please undo these changes in this pull request, and don't open or run other projects on that machine until you've checked it. Flagged files at commit
Only merge once you're confident these files are safe. ℹ️ Posted automatically by Drips Wave. Questions? Contact support@drips.network. |
Overview
This PR makes
market-coredecimals-aware: collateraldecimals()is read once at construction, the economic bounds (min_seed,max_sets) are derived from those decimals, and the fixed-point multiply-divide helpers move to 256-bit intermediates so correctness no longer depends on the 1e30 headroom argument. The Python and TypeScript mirrors are kept in lockstep so off-chain quoting matches on-chain behavior.Related Issue
Changes
🔢 Decimals-aware bounds
contracts/market-core/src/math.rsBounds { min_seed, max_sets }andbounds_for_decimals(d)derivingmin_seed = 100 * 10^dandmax_sets = 1e8 * 10^dviachecked_pow, withdin0..=18.math::MAX_SETSas a#[deprecated]7-decimal alias for tests only.🧮 256-bit widening arithmetic (Env-free)
contracts/market-core/src/math.rswidemodule withU256 { hi, lo },mul_u128, anddivrem_u256_by_u128(returnsOverflowwhen the quotient exceedsu128::MAX).mul_div_floor/mul_div_ceilto use 256-bit intermediates, preserving existing rounding directions; signatures unchanged so no caller changes.math.rsstill has nosoroban_sdkimports and its tests run natively.🐍 Python mirror
model/fpmm_model.pybounds_for_decimalsand an explicit_fits_i128assertion inmul_div_*so the model fails where the contract would.🟦 TypeScript mirror
agents/core/fpmm.tsboundsForDecimals(d)andI128_MAXchecks inmulDivFloor/mulDivCeil.📚 Docs
docs/architecture.md— updated the market size bound description to reflect decimals-derivedmax_sets.docs/STATUS.md— updated references that assumed 7 decimals.Verification Results
DataKey::Decimalsset in__constructor,Error::UnsupportedDecimalsadded,Config.decimalsreturned byget_configMIN_SEED/MAX_SETSno longer used by contract logic; bounds come frombounds_for_decimalsmul_div_floor/mul_div_ceiluse 256-bit intermediates with bit-identical results on the legacy domainmath.rshas nosoroban_sdkimports and its tests run nativelysettle_valueuses checked addition;redeem/claim_pool_remainderpropagate errorsbuyreportedcost_buy_7dp_vs_18dp)cargo test --workspace,make lint,python3 model/fpmm_model.py,agentsnpm test/npm run buildpassmath.rsheader,docs/architecture.mdanddocs/STATUS.mdupdated to describe decimals handlingCloses #3