lifi-stablecoin-swap
ما الذي تفعله
يوضح هذا الدليل كيفية بناء تبادل عملات مستقرة يرسل فيه المستخدم 100 USDC ويستلم 100 USDC، على السلسلة نفسها أو عبر السلاسل. يشرح كيف تُنفّذ شبكة الحلّالين لدى LI.FI الأمر وكيف تتحقق منه على السلسلة، لفرق بناء منتجات المدفوعات والتكنولوجيا المالية.
متى تستخدمها
- ✓عندما تريد أن يبادل المستخدمون عملة مستقرة بعملة أخرى بمبلغ مساوٍ تمامًا بنسبة واحد إلى واحد.
- ✓عندما تبني تطبيق مدفوعات أو تكنولوجيا مالية يحتاج إلى مبلغ ثابت وواضح.
- ✓عندما تريد تحويل عملة مستقرة عبر السلاسل يرى فيه المستخدم رقمًا واحدًا.
رابط المهارة
https://github.com/internet-court/internet-court-skill/blob/main/vendored/lifi/lifi-stablecoin-swap/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“أريد أن يرسل المستخدمون في تطبيقي 100 USDC ويصل إلى سلسلة أخرى 100 USDC بالضبط.”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
يعدّ الوكيل حسابًا للمكامل مع LI.FI، ثم يستخدم SDK الخاص بـ Intents بلغة TypeScript لطلب عرض السعر وبناء الأمر على السلسلة وتتبعه. لا تأتي عروض الأسعار بنسبة واحد إلى واحد إلا بمفتاح المكامل الخاص بك، ولأزواج العملات المستقرة المدعومة.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من 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:
- 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
الأسئلة الشائعة
لماذا يختلف المبلغ في التحويل العادي؟
تأخذ رسوم الغاز والفروقات جزءًا صغيرًا، فقد يصل التحويل العادي بمبلغ أقل قليلًا مما أرسلت.
ماذا أحتاج قبل أن أحصل على عروض أسعار بنسبة واحد إلى واحد؟
معرّف المكامل من بوابة شركاء LI.FI، واتفاقية تكامل مع LI.FI.
هل أستطيع استخدام هذا خارج TypeScript؟
نعم. يتضمن الدليل واجهة REST الخام للخوادم الخلفية غير المبنية بـ TypeScript.
التفاصيل
الوصف الأصلي من المؤلف
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
الشعبية
- نجوم GitHub
- 7.0k
- الترتيب
- #13639
- الترخيص
- —
- آخر تحديث
- 26/10/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
internet-court
7.0kيساعد وكيلك على الدفع لوكيل ذكاء اصطناعي آخر أو لخدمة مدفوعة، أو التعامل معهما بأمان، ويوجهه إلى الدليل المتخصص المناسب.
genlayer-erc7710-connector
7.0kيساعد وكيلك على ربط نتيجة مراجعة الذكاء الاصطناعي بنظام الصلاحيات، بحيث يمكن لمراجعة سيئة أن تقيّد صلاحيات الوكيل أو تلغيها.
genlayer-intelligent-contracts
7.0kيساعد وكيلك على تحديد قواعد وأدلة ومخرجات قاضٍ بالذكاء الاصطناعي يتحقق مما إذا كان وكيل آخر التزم بتفويضه.
x402-erc7710
7.0kيساعد وكيلك على الدفع مقابل خدمات الويب طلبًا تلو الآخر، وعلى إعداد إنفاق مستمر يبقى ضمن ميزانية الصلاحيات.
مهارات مشابهة
api-connector-builder
280kيبني وكيلك اتصالات API جديدة على النمط الموجود، ويفيد عندما تحتاج إلى تكامل إضافي دون ابتكار طريقة جديدة للعمل.
api-design
280kيساعد وكيلك على تصميم واجهات REST API وفق أفضل الممارسات، ويوضح كيف تتواصل وكيف تُعرض الأخطاء وكيف تُنظَّم البيانات.
backend-patterns
280kيساعد وكيلك على أنماط بنية الخادم وتحسين قاعدة البيانات، ويفيد في بناء الشيفرة التي تعمل على الخادم أو مراجعتها.