Skip to content

fix: LaserStream-triggered gatedLiquidate calls no longer consume per-owner cap slots - #361

Open
Ayomisco wants to merge 1 commit into
dcccrypto:mainfrom
Ayomisco:fix/keeper-11-laserstream-owner-cap
Open

fix: LaserStream-triggered gatedLiquidate calls no longer consume per-owner cap slots#361
Ayomisco wants to merge 1 commit into
dcccrypto:mainfrom
Ayomisco:fix/keeper-11-laserstream-owner-cap

Conversation

@Ayomisco

@Ayomisco Ayomisco commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Closes #360

What

Add a source: "polling" | "laserstream" parameter to gatedLiquidate() and apply the per-owner cycle cap only on polling calls.

Why

MAX_LIQ_PER_OWNER_PER_CYCLE = 3 bounds how many of a single owner's positions the polling scan can liquidate in one cycle. LaserStream fires one event per position. Both paths shared the same _cycleOwnerCounts map, so a burst of LaserStream events exhausted the polling cap and blocked valid liquidations for that owner in the same window.

LaserStream calls are already protected against duplicates by _cycleSeenPositions and _inFlightPositions, so they do not need the polling cap.

Changes

  • src/services/liquidation.ts: added source parameter to gatedLiquidate(). Owner-count check and increment wrapped in if (source === "polling"). LaserStream call site passes "laserstream".

…-owner cap slots

The per-cycle MAX_LIQ_PER_OWNER_PER_CYCLE=3 cap in _cycleOwnerCounts was shared
between the polling scan and the LaserStream event path. A burst of LaserStream
events for three distinct positions of the same owner could exhaust the owner cap
before the polling scan reached a fourth underwater position, causing it to be
skipped for the cycle.

Add a source ("polling" | "laserstream") parameter to gatedLiquidate(). Only
polling-path calls increment _cycleOwnerCounts. Event-driven calls are still
deduplicated by _cycleSeenPositions and _inFlightPositions, preventing double
liquidation, but they no longer block the polling path from exercising the cap.
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Ayomisco, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 27 minutes and 39 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9276e519-12d6-4878-b320-0f31a82180d4

📥 Commits

Reviewing files that changed from the base of the PR and between 8ee810d and a7413d3.

📒 Files selected for processing (1)
  • src/services/liquidation.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

[HIGH] liquidation.ts: LaserStream event burst exhausts MAX_LIQ_PER_OWNER_PER_CYCLE before polling scan — underwater positions skip liquidation

1 participant