Skip to content

fix(swap): raise default --slippage from 50 to 100 bps for thin-liquidity broadcasts - #20

Merged
Hiksang merged 1 commit into
mainfrom
fix/swap-default-slippage-100bps
May 7, 2026
Merged

fix(swap): raise default --slippage from 50 to 100 bps for thin-liquidity broadcasts#20
Hiksang merged 1 commit into
mainfrom
fix/swap-default-slippage-100bps

Conversation

@Hiksang

@Hiksang Hiksang commented May 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

defi --chain monad swap --provider kyber --broadcast reverted on-chain inside the KyberSwap MetaAggregator's minOut check, even though the dry-run simulation succeeded. Reproduced live on Monad on 2026-05-07 (failure tx: 0x4fe39977…).

Root cause: the default --slippage of 50 bps (0.5%) is too tight for thin-liquidity chains and high-volatility moments. dry-run runs eth_call against the current block; the real broadcast lands one or more blocks later when the spot price has drifted past the 50 bps floor encoded in the aggregator-built calldata.

Fix

ts/packages/defi-cli/src/commands/swap.ts:222:

-    .option("--slippage <bps>", "Slippage tolerance in bps", "50")
+    .option("--slippage <bps>", "Slippage tolerance in bps", "100")

100 bps is the SSOT 7.3 ceiling defined in qa/slippage.test.ts:

"user-facing slippage knobs default to <= 100 bps (1%)"

Keeping the default at the ceiling — which the slippage guard explicitly allows — gives broadcast paths breathing room without exceeding the safe-default invariant. Users wanting tighter control still pass --slippage explicitly.

A doc-comment above the option records the rationale and links the Monad failure tx for future archaeology.

Live verification

Same wallet, same swap (0.1 MON → USDC on Monad), only the default slippage changed:

tx status gas_used notes
pre-fix 0x4fe39977… failed 69,095 revert inside router
post-fix 0x35310bb3… confirmed 427,255 success

Test plan

  • pnpm -C ts -r build — clean.
  • pnpm -C ts -r lint — 3 packages, tsc --noEmit clean.
  • pnpm -C ts -r test — defi-core 32/32, defi-protocols 43/43, defi-cli 102/102. The existing qa/slippage.test.ts ceiling check still passes because 100 == ceiling.
  • Live on-chain kyber broadcast on Monad post-fix: success.
  • Reviewer: confirm 100 bps default is acceptable for the user persona (the slippage guard says yes; this is more about UX expectation).

Sibling — already merged in this session

The two together unblock kyber's full broadcast path on Monad and any other thin-liquidity chain that joins the registry next.

🤖 Generated with Claude Code

…dity broadcasts

Pre-fix behaviour: `defi --chain monad swap --from MON --to USDC --provider kyber
--broadcast` reverted on-chain inside the KyberSwap MetaAggregator's minOut
check, even though the dry-run simulation succeeded. Reproduced live on
Monad on 2026-05-07 (tx 0x4fe39977eab47de942e7aefd540f12d4f9c56ae340813e6a46bd63c8f0a30e7f).

Root cause: the default --slippage of 50 bps (0.5%) is too tight for
thin-liquidity chains and high-volatility moments. The dry-run uses
eth_call against the current block; the real broadcast lands one or
more blocks later when the spot price has drifted past the 50 bps
floor encoded in the kyber-built calldata.

Fix:
  - Raise the default --slippage from 50 to 100 bps. 100 bps is the
    SSOT 7.3 ceiling for "safe default" defined by qa/slippage.test.ts:
    "user-facing slippage knobs default to <= 100 bps (1%)". This
    change keeps the default at the ceiling, which the slippage guard
    explicitly allows.
  - Users wanting tighter control still pass --slippage explicitly;
    the lower bound is unchanged.
  - Comment block above the option documents the rationale + the
    Monad failure tx for future archaeology.

Live re-verification post-fix (same swap, same wallet, default
slippage now 100 bps):
  pre  : tx 0x4fe39977…  status=failed,    gas_used=69095   (revert)
  post : tx 0x35310bb3…  status=confirmed, gas_used=427255  (success)

Verified:
  - pnpm -C ts -r build  — clean.
  - pnpm -C ts -r lint   — 3 packages, tsc --noEmit clean.
  - pnpm -C ts -r test   — defi-core 32/32, defi-protocols 43/43,
                           defi-cli 102/102 (the existing
                           qa/slippage.test.ts ceiling check still passes
                           because 100 == ceiling).
  - Live on-chain kyber broadcast on Monad (above): success.
@Hiksang
Hiksang merged commit 8213de1 into main May 7, 2026
4 checks passed
@Hiksang
Hiksang deleted the fix/swap-default-slippage-100bps branch May 7, 2026 06:22
Hiksang added a commit that referenced this pull request May 16, 2026
Closes 5 Dependabot alerts on ts/pnpm-lock.yaml:

  high    fast-uri  3.1.0  -> 3.1.2  (#19 path traversal, #23 host confusion)
  medium  hono      4.12.16 -> 4.12.19 (#22 CSS injection in JSX SSR)
  medium  hono      4.12.16 -> 4.12.19 (#20 cache leak: Vary ignored)
  low     hono      4.12.16 -> 4.12.19 (#21 JWT NumericDate validation)

Both are transitive via @modelcontextprotocol/sdk:
  fast-uri  : @modelcontextprotocol/sdk -> ajv -> fast-uri
  hono      : @modelcontextprotocol/sdk -> {hono, @hono/node-server -> hono}

Existing hono override (>=4.12.12) was below the fix line; bumped to
>=4.12.18. fast-uri had no override; added >=3.1.2.

Verified: pnpm install + pnpm -r build + pnpm -r test all green
(defi-core 49 / defi-protocols 147 / defi-cli 235 = 431 passed).
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