Skip to content

feat: dex math native port - #1168

Open
0xNazarii wants to merge 55 commits into
feat/aerodrome-slipstream-factory3from
feat/uni-math-native-port
Open

feat: dex math native port#1168
0xNazarii wants to merge 55 commits into
feat/aerodrome-slipstream-factory3from
feat/uni-math-native-port

Conversation

@0xNazarii

@0xNazarii 0xNazarii commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

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_MATH mitigate some risk.

Overview
Adds a Rust NAPI-RS native addon (native/) that ports concentrated-liquidity V3-style queryOutputs (and a separate V4 path) with fork-specific math via MathVariant (Uniswap, PancakeSwap, Solidly).

TypeScript native-bridge modules load the addon when present (PARASWAP_V3_MATH=js forces JS) and expose per-pool handles plus RustPoolRegistry / RustV4PoolRegistry for rayon-parallel multi-pool pricing. Uniswap V3, PancakeSwap V3, and Solidly V3 wire registries into event pools on state updates and refactor getPricesVolume to batch Rust queries when useRust !== false, with JS fallback and existing balance caps. IDex.getPricesVolume gains an optional useRust parameter.

postinstall builds the native crate; .gitignore / .npmignore exclude generated .node artifacts while shipping native/ 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.

@0xNazarii
0xNazarii marked this pull request as ready for review April 6, 2026 12:27
Comment thread native/src/v4_query_outputs.rs
Comment thread native/src/lib.rs
bitmap_range_upper: start_i16 + range,
variant,
})
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 609d863. Configure here.

Comment thread src/dex/uniswap-v3/uniswap-v3.ts
Comment thread src/dex/pancakeswap-v3/pancakeswap-v3.ts
Comment thread src/dex/pancakeswap-v3/pancakeswap-v3-pool.ts
Comment thread src/dex/pancakeswap-v3/pancakeswap-v3.ts
@0xNazarii
0xNazarii changed the base branch from master to chore/pnpm-11-migration May 13, 2026 12:40
Base automatically changed from chore/pnpm-11-migration to master May 19, 2026 09:33
Comment thread src/dex/solidly-v3/contract-math/native-bridge.ts
@0xNazarii
0xNazarii changed the base branch from master to feat/encode-is128-flag-executor-01-02 May 25, 2026 14:04

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

There are 3 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ 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.

Comment thread native/src/v4_query_outputs.rs
Comment thread src/dex/uniswap-v3/uniswap-v3.ts
Base automatically changed from feat/encode-is128-flag-executor-01-02 to master May 25, 2026 14:38
@0xNazarii
0xNazarii changed the base branch from master to fix/beneficiary-optimization June 3, 2026 12:19
Base automatically changed from fix/beneficiary-optimization to master June 3, 2026 12:55
@0xNazarii
0xNazarii changed the base branch from master to chore/aerodrome-slipstream-new-factory-quoter June 4, 2026 10:44
…b.com:paraswap/paraswap-dex-lib into feat/uni-math-native-port

# Conflicts:
#	package.json
Base automatically changed from chore/aerodrome-slipstream-new-factory-quoter to master June 4, 2026 10:46
@0xNazarii
0xNazarii changed the base branch from master to feat/aerodrome-slipstream-factory3 June 10, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants