Skip to content

feat(monad): enable kyber, openocean, lifi, relay aggregators - #7

Merged
Hiksang merged 1 commit into
mainfrom
feat/monad-aggregators
May 6, 2026
Merged

feat(monad): enable kyber, openocean, lifi, relay aggregators#7
Hiksang merged 1 commit into
mainfrom
feat/monad-aggregators

Conversation

@Hiksang

@Hiksang Hiksang commented May 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Monad mainnet (chain id 143) was wired into the registry without any aggregator slugs, so defi --chain monad swap --provider <X> returned unsupported chain for every provider. Live API probes on 2026-05-06 showed 4 of 5 aggregators already route Monad — only LiquidSwap is genuinely HyperEVM-only. This PR populates the missing [chain.monad.aggregators] block in ts/config/chains.toml (SSOT, auto-synced to packages/defi-cli/config/ by prebuild).

Aggregator support matrix (verified live)

Provider Status Slug Evidence
KyberSwap monad Docs list chain 143 in 17-chain table; /monad/api/v1/routes returns route, dry-run produces real router 0x6131…7b5, amount_out=32301 for 1 MON → USDC
OpenOcean monad Supported-chain list contains monad, monad_test, 143; /v4/monad/tokenList HTTP 200 with mainnet tokens; dry-run returns router 0x6352…e64, amount_out=33218
LI.FI auto /v1/chains includes { id:143, key:"mon", name:"Monad", coin:"MON" }; dry-run returns router 0x026F…C37, amount_out=32220
Relay auto /chains includes { id:143, name:"Monad", depositEnabled:true }; dry-run with 100 MON returns router 0xb92f…4f, amount_out=3225554
LiquidSwap Docs: "Liquid Labs builds core DeFi infrastructure on Hyperliquid's HyperEVM" — intentionally omitted

What's changed

ts/config/chains.toml — single 5-line addition under [chain.monad.aggregators]:

kyber = "monad"
openocean = "monad"
lifi = "auto"
relay = "auto"

auto for LI.FI / Relay matches the convention documented in packages/defi-core/src/registry/chain.ts:6 — those providers route by numeric chain_id, the slug value is advisory.

Test plan

  • pnpm -C ts -r buildprebuild re-syncs ts/config → packages/defi-cli/config; dist rebuild clean.
  • pnpm -C ts -r lint — 3 packages, tsc --noEmit clean.
  • pnpm -C ts -r test — 62 passing. 2 unrelated pre-existing failures in qa/slippage.test.ts:108 (reproduces on origin/main via git stash); flagged separately.
  • defi --chain monad status — still lists 4 protocols (unchanged: traderjoe-monad, uniswap-v2-monad, uniswap-v3-monad, morpho-blue-monad).
  • 4 live swap dry-runs (MON → USDC, placeholder wallet) — all return real router + calldata + non-zero amount_out. The expected simulation_failed revert is from the placeholder wallet's empty balance, orthogonal to chain support.
  • Reviewer to spot-check one provider against a funded Monad wallet if desired.

Out of scope

  • LiquidSwap remains HyperEVM-only by design — would need a different aggregator pivot.
  • The 2 failing slippage-guard tests in qa/slippage.test.ts are pre-existing on main and unrelated to chains.toml; flagging in conversation for a separate fix.

🤖 Generated with Claude Code

Hiksang added a commit that referenced this pull request May 6, 2026
PR #3 (feat/slippage-protection) closed 14 of the 15 sites that the
2026-05-05 baseline catalogued in qa/slippage.test.ts:KNOWN_INFINITE_SLIPPAGE.
The line numbers also shifted when PR #4 (viem-chain anchor) refactored
uniswap_v3.ts, so every entry in the original snapshot became stale on
2026-05-06 main and the test went red on every new PR (e.g. #7).

This commit re-grounds the snapshot against current main:

  Adapter scan (regex unchanged): exactly 1 hit remains in the entire
  defi-protocols/src tree —

    dex/uniswap_v3.ts:262   amountOutMinimum: 0n  (eth_call simulation
                            inside quote() fallback; never broadcasts a tx)

  PR #3 hardened the other 14 sites:
    algebra_v3.ts:86,273,278,304     -> applyMinSlippage / explicit min args
    balancer_v3.ts:37                -> applyMinSlippage
    thena_cl.ts:78,165,190           -> applyMinSlippage / explicit min args
    uniswap_v3.ts:90,242,343,344,    -> applyMinSlippage / explicit min args
                  363,364,403

In addition to refreshing the set, this commit fixes a self-trigger
bug: uniswap_v3.ts:94 carries a documentation comment that warns
against `amountOutMinimum: 0n`, and that comment matched the regex
on its own — driving a false-positive "novel site" failure. Adding a
`commentLinePattern` skip in both `it` blocks keeps the guard's
intent (catch real broadcast paths) while letting docs reference the
forbidden literal.

Verified:
  - pnpm -C ts -r build      — synced + dist rebuilt clean.
  - pnpm -C ts -r lint       — 3 packages, tsc --noEmit clean.
  - pnpm -C ts -r test       — 64/64 passing (was 62/64 before this fix).

Refs: PR #7 CI failure (3x Build & Test red) was the smoke; root cause
was the line-number drift, not anything Monad-related.
Monad mainnet (chain id 143) was wired into the registry without any
aggregator slugs, so `defi --chain monad swap` was returning
"unsupported chain" for every provider. Live API probes against each
aggregator on 2026-05-06 confirmed 4 of 5 already route Monad:

  - KyberSwap   — slug `monad`, docs explicitly list chain 143;
                  /monad/api/v1/routes accepts the chain segment
                  (HTTP 400 = token-level, not chain-level).
  - OpenOcean   — slug `monad`, present in the supported-chain list
                  alongside `monad_test` and `143`. /v4/monad/tokenList
                  returns mainnet tokens.
  - LI.FI       — chain 143 in /v1/chains as { key:"mon", coin:"MON" }.
  - Relay       — chain 143 in /chains, depositEnabled=true.
  - LiquidSwap  — HyperEVM-only by design; intentionally NOT enabled.

Smoke-tested all 4 against the dist build (MON -> USDC, --dry-run):

  provider     amount_in     amount_out          notes
  -----------  ------------  ------------------  ------------------------
  kyber        1e18 EEEE     32301 (6dp USDC)    real route + router
  openocean    1e18 native   33218               real route + router
  lifi         1e18 native   32220               real route + router
  relay        100e18 native 3225554             real route + router
                                                 (1e18 was below
                                                 AMOUNT_TOO_LOW gate)

All four return real tx calldata, confirming the chain is fully
routable. The "simulation_failed" result in dry-run is the executor's
expected output when the placeholder wallet has no balance — orthogonal
to chain support.

LI.FI / Relay use chainId numerically inside swap.ts (the slug value is
"auto" by the chains.toml convention documented in chain.ts:6); the
entries are still required so chain.test.ts and the future
slug-parity-style guards see Monad as supported.

Verified:
  - pnpm -C ts -r build       — synced ts/config -> packages/defi-cli/config
                                cleanly, dist rebuilt without warnings.
  - pnpm -C ts -r lint        — 3 packages, tsc --noEmit clean.
  - pnpm -C ts -r test        — 62 passing; 2 pre-existing failures in
                                qa/slippage.test.ts:108 reproduce on
                                origin/main with `git stash` and are
                                unrelated to chains.toml.
  - defi --chain monad status — 4 protocols listed (unchanged).
  - 4 swap dry-runs above.

Refs: aggregator-discovery probes captured in conversation
2026-05-06; SSOT chains.toml now matches every other chain that has
LI.FI/Relay enabled.
@Hiksang
Hiksang force-pushed the feat/monad-aggregators branch from 6db359e to e627e27 Compare May 6, 2026 10:42
@Hiksang
Hiksang merged commit f6fc09c into main May 6, 2026
4 checks passed
@Hiksang
Hiksang deleted the feat/monad-aggregators branch May 6, 2026 10:44
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