> ## 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.

# lifiIntents.order

> Move tokens to another chain through a LI.FI Intents order that a solver fills, optionally for an exact output amount

`lifiIntents.order` opens a [LI.FI Intents](https://docs.li.fi/lifi-intents/introduction.md) order from the flow's chain: a solver fills it by delivering the `resourceOut` token on the destination chain. It consumes a resource on `amountIn` and produces `amountOut`, a resource of the `resourceOut` token that arrives on the destination chain after the transaction. With `exactAmountOut`, the order delivers exactly that amount and spends only the input the solver asks for.

For a bridge through the LI.FI aggregator, use [`lifi.bridge`](https://docs.li.fi/composer/composer-api/ops/lifi-bridge). For a swap on the same chain, use [`lifi.swap`](https://docs.li.fi/composer/composer-api/ops/lifi-swap).

## Ports

| Port | Kind | Meaning |
| - | - | - |
| `amountIn` | input resource | The tokens the order spends, on the flow's chain. |
| `amountOut` | output resource, **future** | The tokens the solver delivers on the destination chain. It carries the order's minimum (`providesMinimum`). |
| `unspentIn` | output resource | Input the order does not spend, in the input token. Omitted when zero. |

`amountOut` is a [future output](https://docs.li.fi/composer/composer-api/ops.md#future-outputs): it takes no guards and can't feed another op in the same flow, except a [`continuation.settle`](https://docs.li.fi/composer/composer-api/ops/continuation-settle) node. Its `delivery.trackingId` is the order id. `unspentIn` follows the [`lifi.swap` rules](https://docs.li.fi/composer/composer-api/ops/lifi-swap#understanding-unspentin): leave it unbound and `sweepTo` returns it.

## Config

The live schema above shows every field and its range. The table adds what each one does.

| Field | Type | Required | Meaning |
| - | - | - | - |
| `resourceOut` | resource | yes | Token and chain to receive, e.g. `resources.erc20(BASE_USDC, 8453)` or `resources.native(8453)`. |
| `destination` | address | no | Address that receives `amountOut` on the destination chain. Required unless `amountOut` funds a `continuation.settle` node, in which case you must omit it. |
| `exactAmountOut` | decimal string, base units | no | Deliver exactly this amount. The order then spends the input the solver quotes for it, and the rest of `amountIn` comes back on `unspentIn`. |
| `slippage` | number in `[0, 1)` | no | The auction floor below the quote, as a fraction: `0.005` is 0.5%. Default `0.03`. Whole basis points only. Can't be combined with `exactAmountOut`: setting both fails with `validation_error`. |
| `validitySeconds` | integer, 1 to 300 | no | How long the compiled transaction keeps the solver's quoted price, in seconds. Default and maximum `300`. |
| `exclusiveSeconds` | integer, 0 to 120 | no | How long only the quoting solver can fill the order after `validitySeconds` ends, in seconds. Default `90`, maximum `120`. |

### Fund a cross-chain flow

`amountOut` can fund a [`continuation.settle`](https://docs.li.fi/composer/composer-api/ops/continuation-settle) node on the destination chain. Bind the settle node's `input` to `order.amountOut` and omit the order's `destination`; the solver then delivers into the settle node's escrow. With `exactAmountOut: N`, the escrow's minimum funding is exactly `N`, with no margin; see [Funding rules](https://docs.li.fi/composer/composer-api/ops/continuation-settle.md#funding-rules). The [Pay cross-chain](https://docs.li.fi/composer/composer-api/recipes/pay-cross-chain.md) recipe uses this to pay exact amounts on Base from ETH on Arbitrum.

## Example

Send 1,000 USDC from Arbitrum to a recipient on Base through an Intents order:

```ts theme={"system"}
import { createComposeSdk, materialisers, resources } from '@lifi/composer-sdk';

const ARBITRUM = 42161;
const BASE = 8453;
const ARB_USDC = '0xaf88d065e77c8cC2239327C5EDb3A432268e5831';
const BASE_USDC = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913';
const RECIPIENT = '0xYourRecipientAddress';

const sdk = createComposeSdk({
  baseUrl: 'https://composer.li.quest',
  apiKey: process.env.LIFI_API_KEY!,
});

const builder = sdk.flow(ARBITRUM, {
  name: 'order-usdc-to-base',
  inputs: { amountIn: resources.erc20(ARB_USDC, ARBITRUM) },
});
builder.lifiIntents.order('order', {
  bind: { amountIn: builder.inputs.amountIn },
  config: {
    resourceOut: resources.erc20(BASE_USDC, BASE),
    destination: RECIPIENT, // where the USDC lands on Base
    slippage: 0.005, // 0.5%
  },
});

const result = await builder.compile({
  signer: '0xYourSignerAddress',
  inputs: { amountIn: materialisers.directDeposit({ amount: '1000000000' }) }, // 1,000 USDC
  sweepTo: builder.context.sender,
});

const out = result.outputs['order.amountOut'];
if (out?.role === 'terminal' && out.delivery.when === 'future') {
  console.log('minimum on Base:', out.amount.minimum?.value);
  console.log('order id:', out.delivery.trackingId);
}
```

For an exact-output order that funds a cross-chain flow, see the [Pay cross-chain](https://docs.li.fi/composer/composer-api/recipes/pay-cross-chain.md) recipe.

### Track and refund the order

The order id is `outputs['order.amountOut'].delivery.trackingId`. To follow the order, see [Track status](https://docs.li.fi/lifi-intents/intents-api/track-status.md) in the LI.FI Intents docs. A cross-chain order expires 48 hours after it opens. If no solver fills it, recover the input with `lifiIntents.refund` after the order expires; the refund pays the order's user, the signer. The refund is not automatic: someone has to call it. For an early refund, run `lifiIntents.attestNonFill` on the output chain after the fill deadline, then `lifiIntents.refundOnNonFill` on the input chain; a `resolution_error` from that second step means the proof is not ready yet, so retry later.

## Errors

| Error | Cause | Fix |
| - | - | - |
| `no_route_error` | No solver quotes this pair and amount. | Try another amount or token. |
| `preparation_error` (422) naming two amounts | With `exactAmountOut`, the input the solver asks for is more than `amountIn` guarantees, for example a swap's minimum output. | Fund `amountIn` with more; the rest returns on `unspentIn`. |
| `validation_error` | `destination` is missing and `amountOut` funds no `continuation.settle` node. | Set `destination`, or bind `amountOut` to a settle node. |
| `validation_error` | The flow's chain or the `resourceOut` chain is not served by LI.FI Intents. | Pick a pair of chains that LI.FI Intents serves, or use [`lifi.bridge`](https://docs.li.fi/composer/composer-api/ops/lifi-bridge). |
| `validation_error` | `slippage` is set together with `exactAmountOut`. | Remove `slippage`: an exact-output order has no auction floor. |
| `delivery_error` | The order funds a settle escrow, and its second quote, to the escrow, no longer fits it. | See [`continuation.settle` errors](https://docs.li.fi/composer/composer-api/ops/continuation-settle#errors). |

## Related

* [`lifi.bridge`](https://docs.li.fi/composer/composer-api/ops/lifi-bridge): the other cross-chain op.
* [`continuation.settle`](https://docs.li.fi/composer/composer-api/ops/continuation-settle): run more steps on the destination chain when the order delivers.
* [Pay cross-chain](https://docs.li.fi/composer/composer-api/recipes/pay-cross-chain.md): an exact-output order that funds an exact destination flow.
* [LI.FI Intents](https://docs.li.fi/lifi-intents/introduction.md): how orders and solvers work.


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