feat: dex math native port - #1168
Conversation
| bitmap_range_upper: start_i16 + range, | ||
| variant, | ||
| }) | ||
| } |
There was a problem hiding this comment.
Duplicated pool state builder in Rust NAPI layer
Low Severity
build_pool_state (line 245) and RustPoolHandle::create (line 133) contain identical conversion logic from JsPoolStateInit to PoolState. Any future fix applied to one must be mirrored in the other, creating a maintenance risk. RustPoolHandle::create could delegate to build_pool_state to eliminate the duplication.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 609d863. Configure here.
…raswap/paraswap-dex-lib into feat/uni-math-native-port
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
There are 3 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e2b41a7. Configure here.
…-port # Conflicts: # package.json
…b.com:paraswap/paraswap-dex-lib into feat/uni-math-native-port # Conflicts: # package.json
…y3' into feat/uni-math-native-port # Conflicts: # package.json


Note
High Risk
Changes core swap quote math and default install/build path; incorrect Rust/JS parity or native build failures would affect pricing accuracy or deployments, though fallbacks and
useRust/PARASWAP_V3_MATHmitigate some risk.Overview
Adds a Rust NAPI-RS native addon (
native/) that ports concentrated-liquidity V3-stylequeryOutputs(and a separate V4 path) with fork-specific math viaMathVariant(Uniswap, PancakeSwap, Solidly).TypeScript
native-bridgemodules load the addon when present (PARASWAP_V3_MATH=jsforces JS) and expose per-pool handles plusRustPoolRegistry/RustV4PoolRegistryfor rayon-parallel multi-pool pricing. Uniswap V3, PancakeSwap V3, and Solidly V3 wire registries into event pools on state updates and refactorgetPricesVolumeto batch Rust queries whenuseRust !== false, with JS fallback and existing balance caps.IDex.getPricesVolumegains an optionaluseRustparameter.postinstallbuilds the native crate;.gitignore/.npmignoreexclude generated.nodeartifacts while shippingnative/sources. Benchmark scripts compare JS vs Rust end-to-end. Aave GSM mainnet pool addresses are updated (unrelated config).Reviewed by Cursor Bugbot for commit 45ba22e. Bugbot is set up for automated code reviews on this repo. Configure here.