Skip to content

Replace 7k swap with Cetus, drop @7kprotocol/sdk-ts - #172

Merged
jangid merged 1 commit into
mainfrom
chore/replace-7k-swap-with-cetus
Aug 9, 2026
Merged

Replace 7k swap with Cetus, drop @7kprotocol/sdk-ts#172
jangid merged 1 commit into
mainfrom
chore/replace-7k-swap-with-cetus

Conversation

@11felix

@11felix 11felix commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Removes the last 7k usage (zapOutWithdraw, getSwapTransactionBlock) in favor of the existing Cetus aggregator paths, deletes sevenKSwap.ts, and drops @7kprotocol/sdk-ts (removes @flowx-finance/sdk and @bluefin-exchange/bluefin7k-aggregator-sdk from the tree with it). Adds bn.js as a direct dep — it was only installed transitively via 7k but is imported by cetusSwap.ts.

Breaking: getSwapTransactionBlock now takes a Cetus RouterDataV3 instead of a 7k QuoteResponse (consistent with getSwapQuote's rawQuote).

Verified: 58/58 tests, clean build, mainnet dry-runs of zapOutWithdraw (stSUI→USDC) and getSwapTransactionBlock (SUI→USDC) both succeed.

@11felix
11felix requested review from Zorag44 and jangid August 8, 2026 12:22
@jangid

jangid commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

operate.md review — head c136f1d (2026-08-10). First operate pass; no prior bot review to dedup against.

Verified-safe core (checked against Cetus SDK source, not the PR text): slippage is fraction 0–1 on both sides (no bps mismatch; fe already passes slippage/100); min-out enforced (amountLimit = expectedOut × (1−slippage) → on-chain abort on shortfall); quote and swap use the same RouterDataV3 in the same PTB; zapOutWithdraw output goes to params.address, not a hardcoded recipient; @cetusprotocol/aggregator-sdk@1.5.5 + bn.js@5.2.5 are registry-resolved, no git refs; no leftover 7k imports in src/. CI green.

Advisory findings (non-blocking — no org repo currently calls the affected branch):

  1. 🟡 getSwapTransactionBlock without coinIn ignores the address arg: the fastRouterSwap branch sources from the tx sender and (signer is "") disposes output to the sender — in sponsored/build-for-another-address flows output goes to the sender, not address. Return type also silently widens to TransactionObjectArgument | Transaction. Document or guard.
  2. 🟡 slippage || 0.01 coerces an explicit 0 to 1% (cetusSwap.ts:77,86) — ?? intended; the zapOutWithdraw path passes slippage raw, so the class is internally inconsistent.
  3. 🟡 The coinIn path now aborts on-chain if the supplied coin exceeds router.amountIn (routerSwapWithMaxAmountIn semantics); old 7k buildTx tolerated oversized coins. Worth a line in the PR body as the permanent record.
  4. 🟢 sevenKGateway public-field removal is an unlisted (minor) API break; stale "via 7k Protocol" JSDoc + ~70 commented-out 7k lines in getSwapQuote; RouterDataV3 not exported from the package root so TS consumers must depend on the Cetus SDK directly to name it.

Recommend a small follow-up (fix ??, export the type, purge stale 7k docs). Approving — none of the above blocks.

@jangid jangid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

operate.md: clean — CI green, slippage/min-out/recipient safety verified against the Cetus SDK source, deps registry-pinned. Advisory notes in the review comment (slippage-0 coercion, unconsumed no-coinIn branch semantics) — follow-up material, not blockers. Approvals: 2/2 — merge-ready.

@jangid
jangid merged commit 32ca413 into main Aug 9, 2026
3 checks 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.

3 participants