<!--
Sitemap:
- [Interop SDK Documentation](/index): Build multichain TypeScript apps with interoperable addresses, cross-chain quotes, transfer execution, and order tracking across providers.
- [Install Interop SDK](/installation): Install @wonderland/interop-addresses and @wonderland/interop-cross-chain, then choose the package that fits your multichain app.
- [Addresses Module](/addresses/): Parse, encode, and resolve chain-aware addresses that combine an account, chain, and optional ENS name into one unambiguous identifier.
- [Addresses: Getting Started](/addresses/getting-started): Parse an interoperable address and extract its components — go from a human-readable name like vitalik.eth@eip155:1 to address and chain ID.
- [Addresses: Concepts](/addresses/concepts): How EIP-7930, ERC-7828, and CAIP-350 combine address and chain into a single, unambiguous, validated identifier for multichain apps.
- [Parsing an Interoperable Name](/addresses/example): Walkthrough for wallet developers — extract the raw address and chain ID from an interop address so legacy contracts keep working.
- [Addresses: Advanced Usage](/addresses/advanced-usage): Advanced patterns for interoperable addresses — checksums, validation, error handling, and round-trip conversions between formats.
- [Addresses: API Reference](/addresses/api): Function signatures and types for the interop-addresses package — high-level helpers, name-layer methods, and binary-layer primitives.
- [Cross-Chain Module](/cross-chain/): One open source integration for cross-chain actions — compare quotes across providers, execute orders, and track completion.
- [Cross-Chain: Getting Started](/cross-chain/getting-started): Execute a cross-chain token transfer end-to-end — create a provider, fetch a quote, send the transaction, and track the order to completion.
- [Cross-Chain: Concepts](/cross-chain/concepts): The intent-based architecture behind the cross-chain package and how the SDK unifies heterogeneous bridge providers behind a common interface.
- [Supported Providers](/cross-chain/providers): Supported cross-chain providers (Across, Relay, OIF, Bungee, LiFi Intents) and how to configure each via createCrossChainProvider.
- [Across Provider](/cross-chain/across-provider): Configure and use the Across Protocol provider for cross-chain token transfers via the Across bridge infrastructure.
- [Relay Provider](/cross-chain/relay-provider): Configure and use the Relay Protocol provider for cross-chain transfers, including opt-in gasless execution via EIP-3009 signatures.
- [OIF Provider](/cross-chain/oif-provider): Direct integration with any OIF-compliant solver — submission modes, resource locks, and configuration for Open Intents Framework backends.
- [Bungee Provider](/cross-chain/bungee-provider): Cross-chain token transfers via Bungee — onchain transactions, gasless permit2 flow, and tier-based API access for sandbox or production.
- [LiFi Intents Provider](/cross-chain/lifi-intents-provider): Cross-chain transfers through the LI.FI intent solver marketplace, where competing solvers fulfill deposits at the best available rate.
- [Cross-Chain: Full Example](/cross-chain/example): End-to-end example of executing a cross-chain transfer — setup, quote, approval handling, transaction submission, and order tracking.
- [Cross-Chain: Frontend Integration](/cross-chain/frontend-integration): Wire the cross-chain SDK into a React/Next.js app with wagmi v2 — a useCrossChainSwap hook covering quotes, approvals, and submission.
- [Order Tracking](/cross-chain/order-tracking): Track cross-chain orders from initiation to completion via OIF OrderStatus events, with both onchain and offchain observation strategies.
- [Cross-Chain: Advanced Usage](/cross-chain/advanced-usage): Aggregator patterns for cross-chain transfers — multi-provider quote fetching, sorting strategies, timeouts, and built-in order tracking.
- [Cross-Chain: API Reference](/cross-chain/api): Function signatures and types for the interop-cross-chain package — providers, aggregator, approval service, and order tracking.
-->

# LiFi Intents Provider

The [LiFi Intents](https://docs.li.fi/lifi-intents/introduction) provider enables cross-chain token transfers through the LI.FI intent solver marketplace, where solvers compete to fulfill users' transfer requests at the best rates.

**Status**: Active (mainnet)

## How It Works

LiFi Intents uses an intent-based architecture:

1. The user deposits tokens into a resource lock (escrow contract) via an onchain transaction
2. The LI.FI order server broadcasts the deposit proof to competing solvers
3. The winning solver delivers the destination-chain assets
4. Settlement verification releases the locked funds to the solver

All quotes return **transaction steps** (user-pays-gas). The provider does not support gasless/signature-based execution.

## Configuration

| Field            | Type                         | Required | Description                                                    |
| ---------------- | ---------------------------- | -------- | -------------------------------------------------------------- |
| `orderServerUrl` | string                       | No       | LI.FI order server URL (default: `https://order.li.fi`)        |
| `providerId`     | string                       | No       | Custom provider identifier (default: `"lifi-intents"`)         |
| `headers`        | Record\<string, string> | No       | Custom HTTP headers sent with all requests to the order server |

## Creating the Provider

### Mainnet

```ts twoslash
import { createCrossChainProvider } from "@wonderland/interop-cross-chain";

// orderServerUrl defaults to https://order.li.fi
const lifiProvider = createCrossChainProvider("lifi-intents");
```

### Dev Environment

```typescript
import {
    createCrossChainProvider,
    LIFI_INTENTS_ORDER_SERVER_DEV_URL,
} from "@wonderland/interop-cross-chain";

const lifiProvider = createCrossChainProvider("lifi-intents", {
    orderServerUrl: LIFI_INTENTS_ORDER_SERVER_DEV_URL, // https://order-dev.li.fi
});
```

### With Custom Headers

```typescript
import { createCrossChainProvider } from "@wonderland/interop-cross-chain";

const lifiProvider = createCrossChainProvider("lifi-intents", {
    headers: { "x-api-key": "your-api-key" },
});
```

## Getting Quotes

LiFi Intents only supports **exact-input** swaps with **ERC-20 tokens** (native token inputs are not supported):

```typescript
const quotes = await lifiProvider.getQuotes({
    user: "0xYourAddress",
    input: {
        chainId: 1, // Ethereum
        assetAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
        amount: "1000000", // 1 USDC
    },
    output: {
        chainId: 42161, // Arbitrum
        assetAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", // USDC
    },
    swapType: "exact-input",
});

const quote = quotes[0];
```

## Executing Transactions

LiFi Intents quotes contain transaction steps. The user sends the transaction directly — the order server detects the deposit via the onchain Open event:

```typescript
import { getTransactionSteps } from "@wonderland/interop-cross-chain";

const step = getTransactionSteps(quote.order)[0];
const hash = await walletClient.sendTransaction({
    to: step.transaction.to,
    data: step.transaction.data,
    value: step.transaction.value ? BigInt(step.transaction.value) : undefined,
});
console.log("Transaction sent:", hash);
```

## Approvals

Access approval information from the order checks:

```typescript
const allowances = quote.order.checks?.allowances ?? [];
for (const { spender, tokenAddress, required } of allowances) {
    // Approve token spend if needed
}
```

## Tracking

LiFi Intents uses a custom Open event parser on the origin chain combined with API-based fill tracking. The SDK polls the order server status endpoint at 5-second intervals:

```
GET /orders/status?onChainOrderId=<orderId>
```

The origin chain requires an RPC URL for parsing the Open event. Fill tracking is handled entirely through the LI.FI order server API.

### Order Statuses

The LI.FI order server reports the following statuses, mapped to SDK statuses:

| LI.FI Status | SDK Status | Description                                  |
| ------------ | ---------- | -------------------------------------------- |
| `Signed`     | Pending    | Order registered, awaiting solver pickup     |
| `Delivered`  | Settling   | Solver delivered assets, awaiting settlement |
| `Settled`    | Finalized  | Settlement complete, funds released          |
| `Expired`    | Failed     | Order deadline exceeded                      |
| `Failed`     | Failed     | Order failed for another reason              |

## Asset Discovery

The provider supports asset discovery via the LI.FI `/routes` endpoint, which returns the supported chains and tokens for cross-chain transfers.

## Next Step

See a complete working example: [Full Example](/cross-chain/example)

## References

* [LI.FI Intents Documentation](https://docs.li.fi/lifi-intents/introduction)
* [API Reference](/cross-chain/api) — full type definitions for quotes, fees, and orders
* [Concepts](/cross-chain/concepts) — how intent-based transfers work
