Skip to content

fix: replace assert! panics with error returns in sqrt_price_math#1

Closed
tvinagre wants to merge 1712 commits into
die-herdplatte:mainfrom
propeller-heads:tl/replace-assert-panics-in-sqrt-price-math
Closed

fix: replace assert! panics with error returns in sqrt_price_math#1
tvinagre wants to merge 1712 commits into
die-herdplatte:mainfrom
propeller-heads:tl/replace-assert-panics-in-sqrt-price-math

Conversation

@tvinagre
Copy link
Copy Markdown

Summary

  • Replace 6 assert!() calls in sqrt_price_math.rs with SimulationError::FatalError returns
  • These assertions could panic in production when swap math receives edge-case inputs (e.g. zero sqrt_price, zero liquidity, arithmetic overflow)
  • Fix ordering bug in get_amount0_delta: move zero check before the subtraction that depends on it
  • Add 6 tests covering each error path

Context

Fynd crashed in production with assertion failed: price_limit < self.sqrt_price in the uniswap_v4 swap path (v0.234.0). That specific assertion was already fixed in v0.250.0, but 6 more assert!() calls remained in sqrt_price_math.rs on the same code path.

Test plan

  • cargo test --lib -- sqrt_price_math::tests — 25 pass (19 existing + 6 new)
  • cargo clippy clean
  • Full workspace compiles

louise-poole and others added 30 commits January 14, 2026 13:14
fix: use correct "ticks/" prefix when handling deleted tick attributes
## [0.228.1](0.228.0...0.228.1) (2026-01-14)

### Bug Fixes

* use correct "ticks/" prefix when handling deleted tick attributes ([287f3e1](287f3e1))
fix: Add bounds checking to observations
Previous fix in #507 didn't trigger a release because it wasn't using sementic release commit names
## [0.228.2](0.228.1...0.228.2) (2026-01-16)

### Bug Fixes

* dummy commit ([a5f59c3](a5f59c3))
…cies

feat: update tycho-client, tycho-common, and tycho-ethereum to version 0.129.1
## [0.229.0](0.228.2...0.229.0) (2026-01-20)

### Features

* update tycho-client, tycho-common, and tycho-ethereum to version 0.129.1 ([b4d92b8](b4d92b8))
…est-local-run

chore: improve integration test local runs
## [0.229.1](0.229.0...0.229.1) (2026-01-20)

### Bug Fixes

* record block count instead of block number ([3a0c281](3a0c281))
…ion-0.154.0

feat: update tycho-execution version
## [0.230.0](0.229.1...0.230.0) (2026-01-21)

### Features

* Bump tycho-execution ([9698dbe](9698dbe))
semantic-release-bot and others added 29 commits March 3, 2026 10:28
## [0.247.2](0.247.1...0.247.2) (2026-03-03)

### Bug Fixes

* add rocketpool back to integration test ([eaab73a](eaab73a))
feat: update execution version for new rocketpool executor
## [0.248.0](0.247.2...0.248.0) (2026-03-04)

### Features

* update execution version for new rocketpool executor ([3233e45](3233e45))
… changes

TransitionError generic was removed in tycho-common 0.144.0. This PR adjust tycho-simulation to work with the latest version.
…er-breaking-changes

fix: update dependencies and adjust interfaces with upstream breaking changes
## [0.248.1](0.248.0...0.248.1) (2026-03-06)

### Bug Fixes

* update dependencies and adjust interfaces with upstream breaking changes ([2953077](2953077))
Dispatches the compatibility-check workflow in propeller-heads/tycho
whenever a release is published, keeping the meta-crate in sync.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…workflow

chore: add notify-tycho-compat workflow
…checks

Replace assert! panics with SimulationError::InvalidInput returns in the
swap price limit validation for UniswapV3, UniswapV4, Velodrome, and
Aerodrome slipstreams. Prevents crashes during depth calculation when
price moves beyond the maximum trade amount.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Test that out-of-range price limits return SimulationError::InvalidInput
instead of panicking, including the depth calculation scenario where
pool sqrt_price reaches MIN_SQRT_RATIO + 1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fix: replace assert! panics with SimulationError in swap price limit checks
## [0.248.2](0.248.1...0.248.2) (2026-03-12)

### Bug Fixes

* replace assert! panics with SimulationError in swap price limit checks ([bcaa584](bcaa584))
…rwrite

fix: overwrite existing accounts on ChangeType::Creation
## [0.248.3](0.248.2...0.248.3) (2026-03-12)

### Bug Fixes

* force-overwrite proxy token accounts to prevent stale placeholders ([45f87ae](45f87ae))
* overwrite existing accounts on ChangeType::Creation ([af6bb78](af6bb78))
* split proxy account updates by change type for proper handling ([1061193](1061193))
…est CLI

Add --min-token-quality and --max-days-since-last-trade CLI args to the
integration test binary, wiring them into the load_all_tokens call
instead of the previous hardcoded None defaults.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add --tvl-buffer-ratio CLI arg (default 1.1) to support TVL hysteresis
filtering, matching the tycho-solver pattern. The lower bound of the TVL
filter is now tvl_threshold / tvl_buffer_ratio instead of tvl_threshold.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…se-filtering-config

feat: expose filtering config on integration test CLI
## [0.249.0](0.248.3...0.249.0) (2026-03-16)

### Features

* add TVL buffer ratio to integration test CLI ([647875a](647875a))
* expose token quality and traded days filtering on integration test CLI ([0fa87c0](0fa87c0))
This is needed to be compatible with latest tycho-client version (see propeller-heads/tycho@3e0e75f)
## [0.250.0](0.249.0...0.250.0) (2026-03-16)

### Features

* update lru dependency ([87a6694](87a6694))
Replace 6 assert\!() calls in production swap math with proper
SimulationError::FatalError returns. These assertions could crash
Fynd when derived computations hit pools with extreme states.

Add 6 tests covering each error path.
@tvinagre tvinagre closed this Mar 23, 2026
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.