Langsung ke konten
Skillpedia
API & server (backend)7.0k ยท #13639

lifi-stablecoin-swap

Fungsinya

Panduan ini menunjukkan cara membangun swap stablecoin di mana pengguna mengirim 100 USDC dan menerima 100 USDC, baik di rantai yang sama maupun lintas rantai. Panduan ini menjelaskan cara jaringan solver LI.FI mengisi order dan cara memverifikasinya on-chain, bagi tim yang membangun produk pembayaran atau fintech.

Kapan dipakai

  • โœ“Saat Anda ingin pengguna menukar satu stablecoin dengan yang lain dengan jumlah satu banding satu yang persis.
  • โœ“Ketika Anda membangun aplikasi pembayaran atau neobank yang memerlukan jumlah tetap dan jelas.
  • โœ“Ketika Anda menginginkan transfer stablecoin lintas rantai di mana pengguna hanya melihat satu angka.

Link skill

https://github.com/internet-court/internet-court-skill/blob/main/vendored/lifi/lifi-stablecoin-swap/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/internet-court/internet-court-skill/blob/main/vendored/lifi/lifi-stablecoin-swap/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit โ†’

Contoh permintaan ke AI

โ€œSaya ingin aplikasi fintech saya membiarkan pengguna mengirim 100 USDC dan tepat 100 USDC tiba di rantai lain.โ€

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Agent menyiapkan akun integrator di LI.FI, lalu memakai Intents TypeScript SDK untuk meminta kutipan, membangun order on-chain, dan melacaknya. Kutipan satu banding satu hanya dikembalikan dengan kunci integrator Anda, untuk pasangan stablecoin yang didukung.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

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
Pertanyaan umum

Mengapa jumlahnya bisa berbeda dalam transfer biasa?

Gas dan spread mengambil sebagian kecil, sehingga transfer biasa bisa mengirimkan sedikit lebih sedikit dari yang Anda kirim.

Apa yang saya butuhkan sebelum bisa mendapatkan kutipan satu banding satu?

ID integrator dari LI.FI Partner Portal dan perjanjian integrasi dengan LI.FI.

Apakah saya bisa memakainya di luar TypeScript?

Bisa. Skill ini mencakup REST API mentah untuk backend non-TypeScript.

Detail

Deskripsi asli dari pembuat

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

Popularitas

Bintang GitHub
7.0k
Peringkat
#13639
Lisensi
โ€”
Diperbarui
26/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • โ€ฆ

Skill lain dari repositori ini

Skill serupa