Skip to content

[codex] Allow exact standard stableswap bounds#21

Open
caydyan wants to merge 1 commit into
BitflowFinance:mainfrom
caydyan:codex/allow-standard-stableswap-exact-bounds
Open

[codex] Allow exact standard stableswap bounds#21
caydyan wants to merge 1 commit into
BitflowFinance:mainfrom
caydyan:codex/allow-standard-stableswap-exact-bounds

Conversation

@caydyan

@caydyan caydyan commented Jun 22, 2026

Copy link
Copy Markdown

Summary

This PR lets the standard stableswap.clar accept exact user-provided lower bounds instead of requiring outputs to be strictly greater than the bound.

Changed standard pool checks from > to >= for:

  • swap-x-for-y min-y-amount
  • swap-y-for-x min-x-amount
  • add-liquidity min-lp-amount
  • withdraw-liquidity min-x-amount and min-y-amount

Because the withdraw bound now accepts equality, I added an explicit lp-amount > 0 guard so a zero-LP no-op cannot pass with zero minimums.

Why

A minimum output/slippage bound normally means "at least this amount." The previous strict comparisons rejected successful swaps, mints, and withdrawals when the realized amount matched the user bound exactly.

Validation

  • git diff --check
  • clarinet check (passes for all 12 contracts; existing warnings only)
  • Manual clarinet console replay for exact-bound swap-x-for-y, exact-bound swap-y-for-x, exact-bound add-liquidity, and exact-bound withdraw-liquidity

Notes

I kept this scoped to the standard stableswap contract. The StackingDAO variant is covered separately in #18.

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