lifi-stablecoin-swap
O que ela faz
Este guia mostra como criar uma troca de stablecoins em que o usuário envia 100 USDC e recebe 100 USDC, na mesma cadeia ou entre cadeias. Ele explica como a rede de solvers da LI.FI preenche a ordem e como verificá-la na blockchain, para equipes que criam produtos de pagamento ou fintech.
Quando usar
- ✓Quando você quer que os usuários troquem uma stablecoin por outra em um valor exato de um para um.
- ✓Quando você está criando um app de pagamentos ou neobanco que precisa de um valor fixo e claro.
- ✓Quando você quer uma transferência de stablecoin entre cadeias em que o usuário vê um só número.
Link da skill
https://github.com/internet-court/internet-court-skill/blob/main/vendored/lifi/lifi-stablecoin-swap/SKILL.mdCopie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.
Como usar
O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.
Mensagem pronta para colar
Para Claude Code, Codex ou Cursor: rode na pasta do projeto e a skill fica instalada.
Baixe o SKILL.md e coloque na pasta de skills do seu agente.
Exemplo do que pedir para a IA
“Quero que meu app fintech permita que os usuários enviem 100 USDC e que exatamente 100 USDC cheguem em outra cadeia.”
5 skills novas por semana. 1 minuto de leitura.
Como funciona
O agente configura uma conta de integrador na LI.FI e depois usa o SDK TypeScript de Intents para solicitar a cotação, montar a ordem na blockchain e acompanhá-la. Cotações de um para um só são retornadas com a sua chave de integrador, para pares de stablecoins suportados.
Conteúdo técnico (SKILL.md original)
Texto original do autor, em inglês, direto do 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
Perguntas frequentes
Por que o valor seria diferente em uma transferência normal?
Taxas de gás e spreads consomem uma pequena parte, então uma transferência normal pode entregar um pouco menos do que você enviou.
O que preciso ter antes de obter cotações de um para um?
Um ID de integrador do LI.FI Partner Portal e um acordo de integração com a LI.FI.
Posso usar isso fora do TypeScript?
Sim. A skill inclui a API REST pura para backends que não usam TypeScript.
Detalhes
Descrição original do autor
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
Popularidade
- Estrelas no GitHub
- 7,0 mil
- Posição no ranking
- #13639
- Licença
- —
- Atualizada em
- 26/10/2026
Comentários
- …
Mais skills deste repositório
internet-court
7,0 milAjuda seu agente a pagar, contratar ou negociar com segurança outro agente de IA ou um serviço pago, e o direciona para o guia especializado certo.
genlayer-erc7710-connector
7,0 milAjuda seu agente a conectar o resultado de uma revisão de IA a um sistema de permissões, para que uma revisão ruim possa limitar ou cancelar as permissões de um agente.
genlayer-intelligent-contracts
7,0 milAjuda seu agente a definir as regras, as evidências e os resultados de um juiz de IA que verifica se outro agente seguiu o seu mandato.
x402-erc7710
7,0 milAjuda seu agente a pagar por serviços web uma requisição de cada vez, e a configurar gastos contínuos que fiquem dentro de um orçamento de permissão.
Skills parecidas
api-connector-builder
280 milFaz seu agente construir novas conexões com APIs seguindo o padrão já existente. Use quando precisar adicionar mais uma integração sem criar um novo jeito de fazer.
api-design
280 milAjuda seu agente a projetar APIs REST seguindo as melhores práticas. É útil para definir como as APIs se comunicam, como os erros são mostrados e como organizar os dados.
backend-patterns
280 milAjuda seu agente com padrões de arquitetura do lado do servidor e otimização de banco de dados. É útil para construir ou revisar o código que roda no servidor.