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

# Split a deposit across vaults

> Split USDC 60/40 and deposit each portion into a different vault (Aave v3 and Morpho Steakhouse).

## Scenario

A user divides 10,000 USDC 60/40 and deposits the portions into Aave v3 `aEthUSDC` and Morpho's Steakhouse USDC vault, in one transaction. A [`core.partition`](https://docs.li.fi/composer/composer-api/ops) splits the input by basis-point shares: 2 to 16 shares that sum to 10000. Each part feeds its own [`lifi.zap`](https://docs.li.fi/composer/composer-api/ops/lifi-zap) with its own [`slippage` guard](https://docs.li.fi/composer/composer-api/guards/slippage). Every part but the last rounds down, and the last takes the remainder, so no wei is lost.

For two destinations, `core.split` is the two-way form of `core.partition`; see [the op catalog](https://docs.li.fi/composer/composer-api/ops.md).

## Full example

Install the SDK with `npm install @lifi/composer-sdk @lifi/compose-spec` and set `LIFI_API_KEY`; see [Before you start](https://docs.li.fi/composer/composer-api/overview.md#before-you-start). Adapted from [`splitAndZap.ts`](https://github.com/lifinance/composer-sdk-examples/blob/main/examples/splitAndZap.ts).

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

const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
// Aave v3 aEthUSDC receipt token on Ethereum mainnet
const A_ETH_USDC = '0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c';
// Steakhouse USDC (Morpho MetaMorpho vault) on Ethereum mainnet
const STEAKHOUSE_USDC = '0xBEEF01735c132Ada46AA9aA4c54623cAA92A64CB';

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

const builder = sdk.flow(1, {
  name: 'split-usdc-to-two-vaults',
  inputs: {
    amountIn: resources.erc20(USDC, 1),
  },
});

const [toAave, toMorpho] = builder.core.partition('split', {
  bind: { source: builder.inputs.amountIn },
  config: { bps: [6000, 4000] },
}).parts;

builder.lifi.zap('zap-aave', {
  bind: { amountIn: toAave },
  config: {
    resourceOut: resources.erc20(A_ETH_USDC, 1),
  },
  guards: [guards.slippage({ port: 'amountOut', bps: 100 })],
});

builder.lifi.zap('zap-morpho', {
  bind: { amountIn: toMorpho },
  config: {
    resourceOut: resources.erc20(STEAKHOUSE_USDC, 1),
  },
  guards: [guards.slippage({ port: 'amountOut', bps: 100 })],
});

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

console.log('Aave:', result.outputs['zap-aave.amountOut']?.amount);
console.log('Morpho:', result.outputs['zap-morpho.amountOut']?.amount);
```

## Run it

Save the file as `split-deposit.mts` and run `node split-deposit.mts`. The script compiles the flow; it sends nothing.

## What to check

* `result.outputs['zap-aave.amountOut']` and `result.outputs['zap-morpho.amountOut']` are the two terminal positions. Each has its own `amount.estimate` (simulated) and `amount.minimum` (its 1% guard floor). Both are swept to the sender.
* `split.parts.0` (6,000 USDC) and `split.parts.1` (4,000 USDC) appear as `consumed` entries, with `consumedBy` naming the zap that spends each part.

## Related

* [Swap and deposit](https://docs.li.fi/composer/composer-api/recipes/swap-and-deposit.md): one deposit, after a swap.
* [`lifi.zap`](https://docs.li.fi/composer/composer-api/ops/lifi-zap): the deposit op and its routing edges.


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