Skip to content

[fix] bid/ask unbounded loop while preserving no-overshoot #264

Open
cryptomilkbeard wants to merge 1 commit into
MeteoraAg:mainfrom
cryptomilkbeard:fix/bidask-unbounded-loop
Open

[fix] bid/ask unbounded loop while preserving no-overshoot #264
cryptomilkbeard wants to merge 1 commit into
MeteoraAg:mainfrom
cryptomilkbeard:fix/bidask-unbounded-loop

Conversation

@cryptomilkbeard

Copy link
Copy Markdown

What

  • Replace the unbounded decrement loop in findY0AndDeltaY with a bounded, formula-based adjustment that preserves the no‑overshoot guarantee.
  • Add a regression test that demonstrates the pathological bid-side case and enforces a 15s max runtime.

Why

  • The previous while (true) loop could run excessively long for certain parameter combinations. This causes hangs in certain cases.
  • We still need the “totalAmountY ≤ amountY” behavior.

Notes

  • The adjustment computes the total-amount coefficient and reduces baseDeltaY in a single step when overshoot occurs.
  • New test: ts-client/src/test/liquidity_strategy_timeout.test.ts.

How to test

  • cd ts-client && npx jest src/test/liquidity_strategy_timeout.test.ts

@cryptomilkbeard cryptomilkbeard force-pushed the fix/bidask-unbounded-loop branch 2 times, most recently from 0a4ccab to 4bbc607 Compare January 1, 2026 15:07
@cryptomilkbeard cryptomilkbeard force-pushed the fix/bidask-unbounded-loop branch from 4bbc607 to 352078a Compare June 4, 2026 13:25
@codewithgun

Copy link
Copy Markdown
Contributor

Is there a chance you still have the parameters that causes infinite loop?

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