Execute token swaps and broadcast transactions using the LiberFi CLI.
See bootstrap.md for CLI installation and connectivity verification.
This skill's auth requirements:
| Command | Requires Auth |
|---|---|
| --------- | -------------- |
lfi swap chains | No |
lfi swap tokens | No |
lfi swap quote | No |
lfi tx estimate | No |
lfi swap execute | Yes (JWT, uses TEE wallet) |
lfi tx send | Yes (JWT, uses TEE wallet) |
Authentication pre-flight for swap execute / tx send:
lfi status --jsonlfi login key --role AGENT --jsonlfi login --json → lfi verify --json lfi whoami --json to confirm wallet addressesAdditional pre-flight for swap operations:
lfi swap tokens or lfi token search)--account is now optional for swap execute. If omitted, the server uses the authenticated user's TEE wallet address automatically.| If user asks about... | Route to |
|---|---|
| ----------------------- | ---------- |
| Token search, price, details, security | liberfi-token |
| Token K-line, candlestick chart | liberfi-token |
| Token holders, smart money traders | liberfi-token |
| Trending tokens, market rankings | liberfi-market |
| Newly listed tokens | liberfi-market |
| Wallet holdings, balance, PnL | liberfi-portfolio |
| Wallet activity, transaction history | liberfi-portfolio |
| Command | Description | Auth |
|---|---|---|
| --------- | ------------- | ------ |
lfi swap chains | List all supported swap chains | No |
lfi swap tokens [--chain-id | List available swap tokens | No |
| Command | Description | Auth |
|---|---|---|
| --------- | ------------- | ------ |
lfi swap quote --in | Get a swap quote | No |
lfi swap execute --in | Execute swap via TEE wallet | Yes |
lfi swap sign-and-send --chain-family | Build, sign, and broadcast swap in one step via TEE wallet | Yes |
lfi tx estimate --chain-family | Estimate transaction fee / gas | No |
lfi tx send --chain-family | Broadcast a signed transaction | Yes |
Swap quote & execute (shared parameters):
--in — Required. Input token address--out — Required. Output token address--amount — Required. Input amount in smallest unit (lamports, wei, etc.)--chain-family — Required. evm or svm--chain-id — Required. Numeric chain ID (e.g. 0 for Solana mainnet, 1 for Ethereum)--slippage-bps — Slippage tolerance in basis points (e.g. 100 = 1%)--swap-mode — ExactIn (default) or ExactOutExecute-only additional parameter:
--account — Optional. Wallet address override. If omitted, the server uses the authenticated user's TEE wallet automatically. Requires authentication.--quote-result — Opaque quote result JSON from a prior swap quote call (pass through without modification)Tx estimate parameters:
--chain-family — Required. evm or svm--chain-id — Required. Numeric chain ID--data — Required. Transaction data as JSON string (structure depends on chain family)Sign-and-send parameters:
--chain-family — Required. evm or svm--chain-id — Required. Numeric chain ID--quote-result — Required. Full quote result JSON from a prior lfi swap quote call (pass through without modification)--slippage-bps — Override slippage tolerance in basis pointsTx send parameters:
--chain-family — Required. evm or svm--chain-id — Required. Numeric chain ID--signed-tx — Required. Signed transaction in base64 or hex encodinglfi swap chains --jsonlfi swap tokens --chain-id --json lfi token security --json lfi swap quote --in --out --amount --chain-family --chain-id --json Authentication pre-flight (do this first):
lfi status --json # check session
# If not authenticated:
lfi login key --role AGENT --json # agent
# or: lfi login <email> --json → lfi verify <otpId> <code> --json
lfi whoami --json # confirm evmAddress / solAddress
lfi token security --json lfi swap quote --in --out --amount --chain-family --chain-id --json lfi swap execute --in --out --amount --chain-family --chain-id --quote-result '' --json Use this when you already have a quote result and want to build, sign, and broadcast in a single call — no separate swap execute needed.
Authentication pre-flight (do this first):
lfi status --json # check session
# If not authenticated:
lfi login key --role AGENT --json # agent
# or: lfi login <email> --json → lfi verify <otpId> <code> --json
swap quote calllfi swap sign-and-send --chain-family --chain-id --quote-result '' --json When to use sign-and-send vs execute:
sign-and-send when you already have a quote_result and want a single atomic call.execute when you want to specify input/output tokens and amount directly (it internally fetches a quote).lfi tx estimate --chain-family --chain-id --data '' --json When the user has signed the transaction externally (not using TEE wallet):
lfi status --jsonlfi tx send --chain-family --chain-id --signed-tx --json > Full flow: auth → token → swap
lfi status --json — Check session; if not authed → lfi login key --jsonlfi whoami --json — Confirm solAddresslfi token search --q "USDC" --chains sol --json — Find USDC address on Solanalfi token security sol --json — Security check (mandatory)lfi swap quote --in So11111111111111111111111111111111111111112 --out --amount --chain-family svm --chain-id 0 --json — Get quotelfi swap execute --in ... --out ... --amount ... --chain-family svm --chain-id 0 --json — Server signs via TEE wallet> Full flow: auth → market → token → swap
lfi status --json — Check session; if not authed → lfi login key --jsonlfi ranking trending sol 1h --limit 5 --json — Get trending tokenslfi token security sol --json — Mandatory security checklfi swap quote --in --out --amount --chain-family svm --chain-id 0 --json lfi swap execute --in ... --out ... --json — Server signs via TEE wallet> Full flow: auth → portfolio → token → swap
lfi status --json — Check session; if not authed → lfi login key --jsonlfi whoami --json — Get solAddress / evmAddresslfi wallet holdings sol --json — Get holdingslfi token security sol --json — Security checklfi swap quote --in --out --amount --chain-family svm --chain-id 0 --json lfi swap execute --in ... --out ... --json — Server signs via TEE wallet| Just completed | Suggest to user |
|---|---|
| ---------------- | ----------------- |
| Chain list | "Which chain do you want to trade on?" / "想在哪条链上交易?" |
| Token list | "Which tokens do you want to swap?" / "想兑换哪些代币?" |
| Swap quote | "Want to execute this swap?" / "要执行这笔兑换吗?" |
| Swap execute (TEE) | "Swap submitted via your LiberFi TEE wallet!" / "已通过LiberFi TEE钱包提交兑换!" |
| Swap sign-and-send | "Swap built, signed, and broadcast in one step!" / "兑换已一步完成构建、签名并广播!" |
| Fee estimate | "Ready to send?" / "准备好发送了吗?" |
| Tx send | "Transaction submitted! Track it on the block explorer." / "交易已提交!可在区块浏览器上查看。" |
| Not authenticated | "Please log in first: lfi login key --json" / "请先登录:lfi login key --json" |
lfi wallet holdingsevm and svm are supported; if user mentions a chain, map it to the correct family (e.g. Solana → svm, Ethereum/BSC/Base → evm)| Pitfall | Correct Approach |
|---|---|
| --------- | ----------------- |
| Using human-readable amounts (e.g. "1 SOL") | Convert to smallest unit first: 1 SOL = 1,000,000,000 lamports |
| Skipping security check before swap | ALWAYS run lfi token security on the output token first |
| Executing swap without user confirmation | ALWAYS show quote summary and wait for explicit "yes" |
| Passing modified quote_result to execute / sign-and-send | Pass the quote_result JSON through WITHOUT any modification |
Calling swap execute or swap sign-and-send without authentication | Check lfi status --json first; re-authenticate if needed |
| Assuming a wallet address without checking | Call lfi whoami --json to get the confirmed evmAddress / solAddress |
| Retrying failed tx send without checking | The tx may have been submitted; check on-chain status first |
Using sign-and-send when you don't yet have a quote | Call swap quote first to get the quote result, then pass it to sign-and-send |
See security-policy.md for global security rules.
Skill-specific rules:
swap execute or tx send without explicit user confirmationtoken security on the output token before presenting a swap quotequote_result field is opaque — pass it through as-is; do not interpret, modify, or display its raw content共 1 个版本