Skip to content

feat: add swidge (swap/bridge) via LI.FI SDK#30

Merged
arein merged 1 commit into
mainfrom
feat/swidge
Mar 5, 2026
Merged

feat: add swidge (swap/bridge) via LI.FI SDK#30
arein merged 1 commit into
mainfrom
feat/swidge

Conversation

@arein
Copy link
Copy Markdown
Contributor

@arein arein commented Mar 5, 2026

Summary

  • New companion-wallet swidge CLI operation for manual cross-chain bridging powered by @lifi/sdk
  • Auto-bridge in sendTransaction() — detects insufficient funds and bridges from another chain (prompts in TTY, auto-bridges in pipe/agent mode)
  • Pre-flight balance warning in WalletConnect CLI send-transaction for EVM chains
  • Supports ETH, USDC, WCT across Ethereum, Base, and Optimism

Demo: Bridge ETH from Optimism to Base

companion-wallet swidge \
  --from-chain eip155:10 --to-chain eip155:8453 \
  --from-token eth --to-token eth --amount 0.0001
{"fromChain":"eip155:10","toChain":"eip155:8453","fromToken":"ETH","toToken":"ETH","fromAmount":"0.0001","toAmount":"0.000099614025","txHash":"0xa4f1746c..."}

New files

File Purpose
packages/companion-wallet/src/swidge.ts Core swidge module
packages/companion-wallet/test/swidge.test.ts 16 unit tests
.changeset/swidge-feature.md Minor version bump changeset

Key changes

File Change
companion-wallet/package.json Added @lifi/sdk dependency
companion-wallet/src/types.ts Swidge types + "swidge" operation
companion-wallet/src/chains.ts resolveChainByNumericId()
companion-wallet/src/tokens.ts getLifiTokenAddress(), findTokenSymbolByAddress()
companion-wallet/src/prompt.ts Exported ask() with configurable output stream
companion-wallet/src/rpc.ts Auto-swidge check before sendTransaction()
companion-wallet/src/cli.ts handleSwidge() handler
cli-sdk/src/cli.ts Non-blocking balance warning

Test plan

  • Build passes (npm run build)
  • All 235 tests pass (npm run test)
  • Lint clean (npm run lint)
  • Manual test: bridged 0.0001 ETH from Optimism → Base successfully
  • Manual test: companion-wallet swidge USDC Base → Optimism (needs gas on Base)
  • Manual test: auto-bridge triggered via send-transaction on underfunded chain

🤖 Generated with Claude Code

Add cross-chain swap/bridge capability powered by @lifi/sdk:

- New `companion-wallet swidge` CLI operation for manual bridging
- Auto-detect insufficient funds in sendTransaction() and bridge
  from another chain (prompts in TTY, auto-bridges in pipe mode)
- Pre-flight balance warning in WalletConnect CLI send-transaction
- Core module: checkSufficiency, findBestSource, executeLifiRoute
- Supports ETH, USDC, WCT across Ethereum, Base, Optimism

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@arein arein merged commit 7cc1cbe into main Mar 5, 2026
4 checks passed
@github-actions github-actions Bot mentioned this pull request Mar 5, 2026
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