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

# directDeposit

> Fund a flow input from the signer's wallet: an exact amount, a capped amount, or the whole approved balance

`directDeposit` is the default way to fund a flow input. When the transaction executes, it moves tokens from the signer's wallet into the execution proxy: native tokens arrive as the transaction's `msg.value`, ERC-20 tokens through `transferFrom`. For ERC-20 inputs, the signer must first approve the execution proxy; the compile result lists that approval in `actions`.

## Three forms

| Form | Config | What arrives | Check on chain |
| - | - | - | - |
| **Exact** | `{ amount }` | Exactly `amount`. | Reverts unless exactly `amount` arrived. |
| **Capped** | `{ amount, allowNonExact: true }` | Up to `amount`. The flow spends what actually arrives. | None. |
| **Sweep** | `{ allowNonExact: true, simAmount?, minAmount? }` | Everything the signer approved to the proxy, clamped to the signer's balance. | Reverts if less than `minAmount` arrived. |

`amount`, `simAmount` and `minAmount` are decimal strings of base units: `'1000000000000000000'` is 1 WETH.

**Sweep** spends what the user holds without knowing the amount up front. Composer simulates with `simAmount` and assumes the signer holds and approved that much. `minAmount` is a floor the transaction enforces after the pull; it needs a `simAmount` at or above it. The floor also becomes the input's committed minimum, which ops such as `continuation.settle` need.

The capped and sweep forms are ERC-20 only; `allowNonExact` on a native input is rejected.

Some tokens credit a wei or two less than the amount sent, such as stETH and Aave aTokens. For these, Composer turns an exact deposit into a capped one with a floor just below `amount`.

To spend tokens already on the execution proxy, use [`balanceOf`](https://docs.li.fi/composer/composer-api/materialisers/balance-of).

## Example

Swap WETH to USDC, funded either with exactly 1 WETH or with all the WETH the signer holds:

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

const WETH = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';

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

const builder = sdk.flow(1, {
  name: 'swap-weth-to-usdc',
  inputs: { amountIn: resources.erc20(WETH, 1) },
});

builder.lifi.swap('swap', {
  bind: { amountIn: builder.inputs.amountIn },
  config: { resourceOut: resources.erc20(USDC, 1) },
});

// Exact: pull exactly 1 WETH from the signer.
const exact = materialisers.directDeposit({ amount: '1000000000000000000' });

// Sweep: pull all the WETH the signer holds, up to its allowance to the proxy.
// Simulate with 1 WETH and revert on chain if less than 0.9 WETH arrives.
const sweep = materialisers.directDeposit({
  allowNonExact: true,
  simAmount: '1000000000000000000',
  minAmount: '900000000000000000',
});

await builder.compile({
  signer: '0xYourSignerAddress',
  inputs: { amountIn: exact }, // or `sweep`
  sweepTo: builder.context.sender,
});
```

For a sweep, approve the execution proxy for the amount you want it to be able to pull. An unlimited approval lets it pull the signer's entire balance.


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