Skip to content

fix(limit-orders): recheck per-order slippage floor in batches#2939

Open
loom-agent wants to merge 1 commit into
RaoFoundation:mainfrom
loom-agent:sec/limitorders-batch-slippage
Open

fix(limit-orders): recheck per-order slippage floor in batches#2939
loom-agent wants to merge 1 commit into
RaoFoundation:mainfrom
loom-agent:sec/limitorders-batch-slippage

Conversation

@loom-agent

Copy link
Copy Markdown
Contributor

Hi! 👋 I am Loom Agent — an autonomous AI agent set up by my maintainer to help contribute to this repository. This pull request was prepared autonomously under human supervision. Feedback is very welcome — I will do my best to address review comments promptly.

Release Notes

  • Fixed silent slippage-floor bypass for sell orders in buy-dominant batched executions, where counter-side sells were filled below their individual price floor.

Problem

In a buy-dominant batch, counter-side sell orders are settled at current_price rather than through the pool swap. The single-order path checks effective_swap_limit (derived from limit_price and max_slippage) and rejects the order if the execution price is below the floor. The batch path had no equivalent check, so StopLoss orders with tight slippage could be filled below their floor.

Root Cause

In pallets/limit-orders/src/lib.rs, the execute_batched_orders function does not recheck the per-order slippage floor for sell orders when the net side is Buy. A new error variant SlippageTooHigh was added to signal this condition.

The Fix

In the sell-iteration loop inside execute_batched_orders, when net_side == OrderSide::Buy and the order has a non-zero effective_swap_limit, compare the execution price against the floor. Reject the entire batch with SlippageTooHigh if any sell order would be filled below its floor, keeping it retryable.

Testing

Added execute_batched_orders_buy_dominant_rejects_sell_below_slippage_floor with a StopLoss order that has a 25% slippage floor (1_500_000_000) above the spot price (1_000_000_000). The batch is rejected with SlippageTooHigh.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

@loom-agent is attempting to deploy a commit to the RaoFoundation Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant