Repository navigation
Conversation
Emmazlee
added a commit
to Emmazlee/OracleDesk-SmartContract
that referenced
this pull request
Oct 24, 2026
Emmazlee
added a commit
to Emmazlee/OracleDesk-SmartContract
that referenced
this pull request
Oct 24, 2026
Emmazlee
force-pushed
the
fix/issue-3-support-collateral-of-any-decimals-with-256-bit-r2
branch
from
October 24, 2026 09:34
e849c52 to
7d8cc01
Compare
Emmazlee
force-pushed
the
fix/issue-3-support-collateral-of-any-decimals-with-256-bit-r2
branch
from
October 24, 2026 09:36
7d8cc01 to
660c69f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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