Skip to content
Skillpedia
APIs & servers (backend)7.0k Β· #13639

lifi-stablecoin-swap

What it does

This guide shows how to build a stablecoin swap where a user sends 100 USDC and receives 100 USDC, on the same chain or across chains. It explains how the LI.FI solver network fills the order and how to verify it on-chain, for teams building payment or fintech products.

When to use it

  • βœ“When you want users to swap one stablecoin for another at an exact one-to-one amount.
  • βœ“When you are building a payment or neobank app that needs a clear, fixed amount.
  • βœ“When you want a cross-chain stablecoin transfer where the user sees one number.

Skill link

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

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/internet-court/internet-court-skill/blob/main/vendored/lifi/lifi-stablecoin-swap/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œI want my fintech app to let users send 100 USDC and have exactly 100 USDC arrive on another chain.”

5 new skills a week. 1 minute to read.

How it works

The agent sets up an integrator account with LI.FI, then uses the Intents TypeScript SDK to request the quote, build the on-chain order and track it. One-to-one quotes come back only under your integrator key, for supported stablecoin pairs.

Technical content (original SKILL.md)

Original text by the author, straight from 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
FAQ

Why would the amount be different in a normal transfer?

Gas and spreads take a small share, so a normal transfer may deliver a little less than you sent.

What do I need before I can get one-to-one quotes?

An integrator ID from the LI.FI Partner Portal and an integration agreement with LI.FI.

Can I use this outside TypeScript?

Yes. The skill includes the raw REST API for non-TypeScript backends.

Details

Original description by the author

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

Popularity

GitHub stars
7.0k
Ranking position
#13639
License
β€”
Updated
10/26/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills