lifi-stablecoin-swap
Skill này làm gì
Hướng dẫn này chỉ cách xây dựng một hoán đổi stablecoin trong đó người dùng gửi 100 USDC và nhận 100 USDC, trên cùng chuỗi hoặc xuyên chuỗi. Nó giải thích cách mạng lưới solver của LI.FI khớp lệnh và cách xác minh trên chuỗi, dành cho đội xây dựng sản phẩm thanh toán hoặc fintech.
Khi nào nên dùng
- ✓Khi bạn muốn người dùng hoán đổi một stablecoin lấy một stablecoin khác theo tỷ lệ một đổi một chính xác.
- ✓Khi bạn đang xây một ứng dụng thanh toán hoặc neobank cần số tiền cố định và rõ ràng.
- ✓Khi bạn muốn chuyển stablecoin xuyên chuỗi mà người dùng chỉ thấy một con số.
Liên kết skill
https://github.com/internet-court/internet-court-skill/blob/main/vendored/lifi/lifi-stablecoin-swap/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Tôi muốn ứng dụng fintech của mình cho người dùng gửi 100 USDC và nhận đúng 100 USDC trên một chuỗi khác.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent thiết lập tài khoản integrator với LI.FI, rồi dùng SDK TypeScript Intents để yêu cầu báo giá, tạo lệnh trên chuỗi và theo dõi nó. Báo giá một đổi một chỉ trả về với khóa integrator của bạn, cho các cặp stablecoin được hỗ trợ.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Build a 1:1 Stablecoin Swap with LI.FI Intents
A normal crypto transfer leaks value to gas and spreads — send 100 USDC, ~99.8 arrives. For a neobank, payment processor, or regulated fintech, that's a non-starter: their users expect that sending 100 means 100 arrives.
LI.FI Intents lets you offer exactly that — send 100 USDC, receive 100 USDC (or USDT, or another supported stablecoin), same-chain or cross-chain. A solver from LI.FI's network fronts the destination gas and sources the liquidity, then settles against the user's deposit, so the end user sees one number from start to finish, provable on a public block explorer.
The primary integration is the @lifi/intent TypeScript SDK — it requests the quote, builds
the on-chain order, and tracks it. The raw REST API is in §7 for non-TypeScript backends.
1. Enable 1:1 quoting on your integrator account
1:1 stablecoin quoting is a capability provisioned on your LI.FI integrator account:
- Register an integrator ID on the LI.FI Partner Portal — https://portal.li.fi
- Complete an integration agreement with LI.FI. As part of onboarding, 1:1 stablecoin quoting is enabled for your integrator.
- Quote requests made under your integrator key then return 1:1 amounts for supported stablecoin pairs.
The integration code below is identical regardless — what makes the quote come back 1:1 is your onboarded integrator. See https://docs.li.fi/lifi-intents/introduction or contact LI.FI to enable it.
2. The flow
order.li.fi is the Intents API. The escrow flow is the recommended default and takes four steps:
1. Quote getQuotes(...) -> guaranteed output amount (1:1)
2. Approve ERC-20 approve(InputSettlerEscrow, amount) -> let the settler pull the input token
3. Open escrow.open(StandardOrder) on-chain -> locks funds, emits Open(orderId)
4. Track GET /orders/status?onChainOrderId=... -> Signed -> Delivered -> Settled
Opening the order emits Open(bytes32 indexed orderId, ...); solvers watch for that event and fill
on the destination chain, so the escrow flow needs no order-submission call. You poll status
until the funds land, then show the user the destination transaction. The orderId is the
receipt — anyone can independently verify the deposit and the delivery matched.
(There is also a Compact / gasless flow — deposit once into The Compact, then sign and submit each order off-chain. Use escrow unless you specifically want gasless after a one-time deposit.)
npm install @lifi/intent viem
(The runnable interface in the quickstart also uses wagmi + @tanstack/react-query for the
wallet — its install line includes them.)
Setup note: the SDK uses
bigintliterals (100_000_000n).create-next-appdefaultstsconfig.jsonto"target": "ES2017", which rejects them — set"target": "ES2020"(or higher).
3. Quote (1:1)
getQuotes with your integrator key. IntentApi(true) targets mainnet / the production solver
network. Amounts are bigint in the token's smallest units (100 USDC = 100_000_000n, 6 decimals).
Under a 1:1-enabled integrator on a supported stablecoin pair, the output equals the input.
import { IntentApi } from "@lifi/intent";
const api = new IntentApi(true);
const res = await api.getQuotes({
user, // the user's 0x address
userChainId: 8453, // source chain (Base)
integratorKey: process.env.LIFI_INTEGRATOR_KEY, // your onboarded integrator key
inputs: [{ sender: user, asset: usdcOnBase, chainId: 8453, amount: 100_000_000n }],
outputs: [{ receiver: user, asset: usdcOnArb, chainId: 42161, amount: 0n }],
});
const quote = res.quotes[0];
if (!quote) throw new Error("No quote available for this pair");
const received = BigInt(quote.preview.outputs[0].amount); // == 100_000_000n for a 1:1 pair
const quoteId = quote.quoteId;
4. Build & open the order
The SDK builds the StandardOrder for you — pass plain token addresses + chain ids; it computes
the nonce, deadlines, oracle, and EIP-7930 encoding. getOracle supplies the verifier oracle
(Polymer addresses below). Then call open(order) on the escrow settler the SDK gives you.
import { Intent, type IntentDeps, type StandardEVM } from "@lifi/intent";
import type { WalletClient } from "viem";
const POLYMER_ORACLE = "0x0000003E06000007A224
Câu hỏi thường gặp
Vì sao số tiền có thể khác trong một chuyển khoản thông thường?
Gas và chênh lệch giá chiếm một phần nhỏ, nên chuyển khoản thông thường có thể nhận được ít hơn một chút so với số bạn đã gửi.
Tôi cần gì trước khi nhận được báo giá một đổi một?
Một ID integrator từ LI.FI Partner Portal và một thỏa thuận tích hợp với LI.FI.
Tôi có thể dùng ngoài TypeScript không?
Có. Skill bao gồm REST API thuần cho các backend không dùng TypeScript.
Chi tiết
Mô tả gốc của tác giả
Build a production 1:1 stablecoin swap with LI.FI Intents — an interface or backend where the amount the user sends equals the amount they receive (no visible gas or solver fees), same-chain or cross-chain, filled by LI.FI's solver network and verifiable on-chain. USE THIS SKILL WHEN USER WANTS TO: - Build a 1:1 stablecoin swap interface ("send 100 USDC, receive 100 USDC"), same- or cross-chain - Add stablecoin transfers with a guaranteed output amount to an app, backend, or bot - Build enterprise/fintech-grade transfers with no visible gas or solver fees for the end user - Implement the LI.FI
Độ phổ biến
- Sao GitHub
- 7.0k
- Vị trí xếp hạng
- #13639
- Giấy phép
- —
- Cập nhật
- 26/10/2026
Bình luận
- …
Thêm skill từ kho mã này
internet-court
7.0kGiúp agent của bạn thanh toán, thuê hoặc giao dịch an toàn với một agent AI khác hoặc dịch vụ trả phí, và chỉ đến hướng dẫn chuyên sâu phù hợp.
genlayer-erc7710-connector
7.0kGiúp agent của bạn kết nối kết quả đánh giá AI với hệ thống quyền hạn, để một đánh giá xấu có thể hạn chế hoặc hủy quyền của agent.
genlayer-intelligent-contracts
7.0kGiúp agent của bạn xác định quy tắc, bằng chứng và đầu ra của một AI judge kiểm tra xem agent khác có làm đúng nhiệm vụ được ủy quyền hay không.
x402-erc7710
7.0kGiúp agent của bạn trả tiền cho dịch vụ web theo từng yêu cầu, và thiết lập chi tiêu định kỳ nằm trong ngân sách quyền hạn.
Skill tương tự
api-connector-builder
280kGiúp agent của bạn xây dựng kết nối API mới theo đúng mẫu đã có, dùng khi bạn cần thêm một tích hợp mà không tạo cách làm mới.
api-design
280kGiúp agent của bạn thiết kế REST API theo các thực hành tốt nhất, hữu ích để định nghĩa cách API giao tiếp, hiển thị lỗi và tổ chức dữ liệu.
backend-patterns
280kGiúp agent của bạn với các mẫu kiến trúc phía máy chủ và tối ưu cơ sở dữ liệu, hữu ích khi xây dựng hoặc rà soát code chạy trên máy chủ.