Chuyển đến nội dung
Skillpedia
API và máy chủ (backend)7.0k · #13639

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.md

Sao 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

Hãy dùng skill này để giúp tôi: https://github.com/internet-court/internet-court-skill/blob/main/vendored/lifi/lifi-stablecoin-swap/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

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:

  1. Register an integrator ID on the LI.FI Partner Portal — https://portal.li.fi
  2. Complete an integration agreement with LI.FI. As part of onboarding, 1:1 stablecoin quoting is enabled for your integrator.
  3. 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 bigint literals (100_000_000n). create-next-app defaults tsconfig.json to "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

repo: internet-court/internet-court-skill

Độ 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

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự