Skip to content

feat(convert): warn on high slippage tolerance (>=5%), hard-cap input at 49% - #1146

Merged
tjcloa merged 2 commits into
developfrom
claude/elated-swartz-6d8d47
Aug 6, 2026
Merged

feat(convert): warn on high slippage tolerance (>=5%), hard-cap input at 49%#1146
tjcloa merged 2 commits into
developfrom
claude/elated-swartz-6d8d47

Conversation

@tjcloa

@tjcloa tjcloa commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

What

Tightens the slippage tolerance input on the Convert page:

  • Warning at >= 5% (inclusive, so a fat-fingered 5 typed instead of 0.5 is flagged): amber ErrorBadge"High slippage tolerance: your transaction may be frontrun and result in an unfavorable trade". The swap remains allowed.
  • Hard cap at 49%: values above 49 are a validation error — the input is flagged invalid, a critical ErrorBadge shows "Slippage tolerance must be 49% or less", and the Confirm button is disabled. Enforced in logic (new ConvertPage.slippage.ts predicates), not just via the input's max attribute, because HTML max does not block typed values. The max attribute is also lowered from 100 to 49.
  • Default stays 0.5 (DEFAULT_SLIPPAGE_TOLERANCE unchanged). The error state replaces the warning rather than stacking.

Why

Follow-up to #1144 / advisory GHSA-jx33-xg6c-px39. With the Ambient bps encoding fixed, the input still accepted up to 100%, and a 100% tolerance encodes a zero minimum output — this closes that remaining top-of-range footgun. UI-only: the SDK and the unrelated price-impact gate (MAXIMUM_ALLOWED_SLIPPAGE = 1.5) are untouched.

Notes for review

  • Policy constants + predicates live in a small dependency-free module (ConvertPage.slippage.ts) so the boundaries are unit-testable; a comment there disambiguates it from MAXIMUM_ALLOWED_SLIPPAGE in ConvertPage.constants.ts.
  • 15 boundary tests (ConvertPage.slippage.test.ts): 0.5 / 4.99 / empty → clean · 5 / 5.01 / 6 / 49 → warn, allowed · 49.01 / 50 / 100 → blocked. Full frontend suite green, eslint clean.
  • All four UI states verified on the dev server (default clean · 5% warn · 49% warn · 50% blocked, Confirm disabled).
  • New locale keys added to en only; es has no convertPage keys and falls back to en.

tjcloa added 2 commits August 6, 2026 19:52
Post GHSA-jx33-xg6c-px39 (#1144) the Ambient route encodes slippage
correctly, but a 100% tolerance still encodes a zero minimum output.
Close the top-of-range footgun in the Convert page UI:

- warning badge (frontrun risk) when entered tolerance exceeds 5%
- >49% is invalid: input flagged, error badge shown, confirm disabled;
  enforced in logic because the HTML max attribute alone does not
  block typed values (max lowered from 100 to 49 as well)
- boundary tests: 5 / 5.01 / 6 / 49 / 49.01 / 50 / 100

DEFAULT_SLIPPAGE_TOLERANCE (0.5) and the unrelated price-impact gate
MAXIMUM_ALLOWED_SLIPPAGE (1.5) are unchanged. UI-only; SDK untouched.
Tyrone's call: warn at exactly 5% too, to catch 5 typed instead of 0.5.
Boundary tests updated: 4.99 no warning, 5 warns; visually verified on
the dev server (badge shows at exactly 5%).
@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f4c21ca

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify

netlify Bot commented Aug 6, 2026

Copy link
Copy Markdown

Deploy Preview for sovryn-dapp ready!

Name Link
🔨 Latest commit f4c21ca
🔍 Latest deploy log https://app.netlify.com/projects/sovryn-dapp/deploys/6a750f0bb324d5000817f4dc
😎 Deploy Preview https://deploy-preview-1146.preview.sovryns.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@tjcloa
tjcloa merged commit afe6b92 into develop Aug 6, 2026
4 checks passed
@tjcloa
tjcloa deleted the claude/elated-swartz-6d8d47 branch August 6, 2026 23:43
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