Skip to content

feat: maximum slippage tolerance enforcement - #676

Merged
Sadeequ merged 1 commit into
StellarFlow-Network:mainfrom
Stanley-Owoh:enforce-maximum-slippage-tolerance-601
Jul 26, 2026
Merged

Sadeequ merged 1 commit into
StellarFlow-Network:mainfrom
Stanley-Owoh:enforce-maximum-slippage-tolerance-601

Conversation

@Stanley-Owoh

Copy link
Copy Markdown
Contributor

Slippage-Protection | Maximum Slippage Tolerance Enforcement

Protect users from sandwich attacks and market volatility by enforcing minimum payout thresholds on swap outputs.

Changes

New files:

  • src/amm/mod.rs — Module declaration for the AMM subsystem
  • src/amm/slippage.rs — Core slippage enforcement logic with enforce_slippage(amount_out, min_amount_out) function

Modified files:

  • src/lib.rs — Added pub mod amm; and ContractError::SlippageExceeded = 47 error variant

Details

The enforce_slippage function validates the final calculated output against the caller's min_amount_out parameter. If amount_out < min_amount_out, the transaction aborts with ContractError::SlippageExceeded, reverting all state changes and preventing the user from receiving less than their specified minimum.

Includes seven unit tests covering pass/fail conditions, boundary cases, zero values, and large values.

Closes #601

@drips-wave

drips-wave Bot commented Jul 26, 2026

Copy link
Copy Markdown

@Stanley-Owoh Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Sadeequ
Sadeequ merged commit c5d2608 into StellarFlow-Network:main Jul 26, 2026
1 check failed
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.

📉 Slippage-Protection | Maximum Slippage Tolerance Enforcement

2 participants