fix(swap): raise default --slippage from 50 to 100 bps for thin-liquidity broadcasts - #20
Merged
Merged
Conversation
…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
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
defi --chain monad swap --provider kyber --broadcastreverted on-chain inside the KyberSwap MetaAggregator'sminOutcheck, even though the dry-run simulation succeeded. Reproduced live on Monad on 2026-05-07 (failure tx:0x4fe39977…).Root cause: the default
--slippageof 50 bps (0.5%) is too tight for thin-liquidity chains and high-volatility moments. dry-run runseth_callagainst 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:100 bps is the SSOT 7.3 ceiling defined in
qa/slippage.test.ts: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
--slippageexplicitly.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:
0x4fe39977…0x35310bb3…Test plan
pnpm -C ts -r build— clean.pnpm -C ts -r lint— 3 packages,tsc --noEmitclean.pnpm -C ts -r test— defi-core 32/32, defi-protocols 43/43, defi-cli 102/102. The existingqa/slippage.test.tsceiling check still passes because100 == ceiling.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