Skip to main content

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 splits the input by basis-point shares: 2 to 16 shares that sum to 10000. Each part feeds its own lifi.zap with its own slippage guard. 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.

Full example

Install the SDK with npm install @lifi/composer-sdk @lifi/compose-spec and set LIFI_API_KEY; see Before you start. Adapted from splitAndZap.ts.

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.