> ## Documentation Index
> Fetch the complete documentation index at: https://docs.li.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# SDK Integration

> Use the LI.FI TypeScript SDK for managed Composer execution with automatic allowance handling, status tracking, hooks, and events.

The LI.FI SDK runs the Composer lifecycle for you: allowance checks and approvals, transaction submission, status tracking and, for two-transaction routes, chain switching. Install and configure it as described in [Installing the SDK](https://docs.li.fi/sdk/installing-the-sdk.md) and [Configure SDK](https://docs.li.fi/sdk/configure-sdk.md), and register an [EVM provider](https://docs.li.fi/sdk/configure-sdk-providers.md#setup-evm-provider) for the chains you use.

***

## Deposit with `getQuote`

Deposit 1 USDC into a Morpho vault on Base:

```ts theme={"system"}
import {
  createClient,
  getQuote,
  convertQuoteToRoute,
  executeRoute,
} from "@lifi/sdk";
import { EthereumProvider } from "@lifi/sdk-provider-ethereum";

// Configure once at app startup.
// walletClient: a viem WalletClient for the user's account (https://viem.sh/docs/clients/wallet)
const client = createClient({ integrator: "YourAppName" });
client.setProviders([
  EthereumProvider({ getWalletClient: () => Promise.resolve(walletClient) }),
]);

const quote = await getQuote(client, {
  fromChain: 8453, // Base
  toChain: 8453, // Base
  fromToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base
  toToken: "0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A", // Morpho vault token
  fromAmount: "1000000", // 1 USDC
  fromAddress: "0xYOUR_WALLET_ADDRESS",
});

const usesComposer = quote.includedSteps.some((step) => step.tool === "composer");

// executeRoute handles allowance, submission and status tracking.
const executedRoute = await executeRoute(client, convertQuoteToRoute(quote), {
  // Called on every state change; use it to update your UI.
  updateRouteHook(updatedRoute) {
    for (const step of updatedRoute.steps) {
      for (const action of step.execution?.actions ?? []) {
        switch (action.status) {
          case "STARTED":
            console.log(`${action.type} started`);
            break;
          case "PENDING":
            console.log(`${action.type} pending - tx: ${action.txHash}`);
            break;
          case "DONE":
            if (action.substatus === "PARTIAL") {
              // The bridge delivered, but the destination deposit did not run
              console.warn(`${action.type} partial: ${action.substatusMessage}`);
            } else {
              console.log(`${action.type} complete`);
            }
            break;
          case "FAILED":
            console.error(`${action.type} failed: ${action.error?.message}`);
            break;
        }
      }
    }
  },
});
```

`toToken` is the **position token address** of the target protocol, such as a vault share token; take it from [Supported Protocols & Chains](https://docs.li.fi/composer/protocols-and-chains.md). The routing engine compares the Composer route with DEX routes into the same token, so check `includedSteps` for `tool: "composer"` to see which one you got.

`executeRoute` throws when execution fails. Keep the latest route from `updateRouteHook` and read `action.error` on its `FAILED` actions for details. For every execution option, see [Execute Routes/Quotes](https://docs.li.fi/sdk/execute-routes.md).

## Compare routes with `getRoutes`

`getRoutes` returns several options and uses different parameter names:

```ts theme={"system"}
import { getRoutes } from "@lifi/sdk";

const result = await getRoutes(client, {
  fromChainId: 8453,
  toChainId: 8453,
  fromTokenAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
  toTokenAddress: "0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A",
  fromAmount: "1000000",
  fromAddress: "0xYOUR_WALLET_ADDRESS",
});

const route = result.routes[0]; // Routes are sorted best first
```

Pass the selected route to `executeRoute` as above.

***

## Cross-chain deposits

Use different `fromChain` and `toChain` values. A cross-chain route has one of two shapes:

* **One transaction:** the bridge runs the Composer deposit as a destination call. `getQuote` always returns this shape.
* **Two transactions:** a bridge step, then a separate Composer step on the destination chain. `getRoutes` can return this shape; the SDK switches the wallet to the destination chain and asks the user to sign the second transaction. Pass `options: { allowSwitchChain: false }` to `getRoutes` to exclude it.

```ts theme={"system"}
const crossChainQuote = await getQuote(client, {
  fromChain: 1, // Ethereum
  toChain: 8453, // Base
  fromToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum
  toToken: "0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A", // Morpho vault on Base
  fromAmount: "1000000000", // 1000 USDC
  fromAddress: "0xYOUR_WALLET_ADDRESS",
  slippage: 0.01,
});

await executeRoute(client, convertQuoteToRoute(crossChainQuote), {
  updateRouteHook(updatedRoute) {
    console.log("Route updated:", updatedRoute.steps.map((s) => s.tool));
  },
});
```

If the bridge delivers but the destination deposit does not run, the receiving action ends with status `DONE` and substatus `PARTIAL`, and the user holds the bridged token on the destination chain. See [Cross-chain deposits](https://docs.li.fi/composer/lifi-api/guides/cross-chain-compose.md#partial-failure-handling) for how to handle it.

***

## Next steps

> [card] [Vault Deposit Recipes](https://docs.li.fi/composer/lifi-api/recipes/vault-deposits.md)
>
> Quote parameters for each supported protocol

> [card] [Widget Integration](https://docs.li.fi/composer/lifi-api/guides/widget-integration.md)
>
> Composer through the drop-in Widget


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.