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

# depositFunds

Transfer tokens from the user's EOA to their Smart Wallet. Waits for transaction confirmation.

On the **first deposit**, this is also how a user is onboarded onto Zyfai: a **pre-deployed** Safe with an already-signed session key is assigned to them, live on **Base, Arbitrum, and Ethereum Mainnet** at once. No separate `deploySafe` or `createSessionKey` call is needed (or supported).

**Supported assets:**

* **USDC**: 6 decimals — e.g., `"100000000"` = 100 USDC
* **WETH**: 18 decimals — e.g., `"1000000000000000000"` = 1 WETH
* **EURC**: 6 decimals — e.g., `"100000000"` = 100 EURC (Mainnet and Base only)

<Warning title="First deposit assigns a pre-deployed account">
  The first time a user deposits into Zyfai, the backend associates their EOA with a **pre-deployed Smart Account** that already has a **signed session key**.

  That Smart Account becomes available **immediately on Base (8453), Arbitrum (42161), and Ethereum Mainnet (1)** — not only on the `chainId` you pass to `depositFunds`. The user is the owner of that Safe.

  This does **not** change how their EOA works: the EOA remains a normal wallet. Depositing only links a Zyfai Smart Wallet (with session) to that EOA as owner.
</Warning>

<Warning title="Important for WETH deposits">
  You must deposit **WETH** (Wrapped ETH), not native ETH. If the user has ETH, they must wrap it to WETH first before depositing.
</Warning>

<Info title="Minimum portfolio balance">
  Minimums apply to the **total Safe balance after the deposit** (current Safe balance + deposit amount). Top-ups smaller than the minimum are allowed if the Safe already holds enough of the asset to meet it. Pairs without a configured threshold are not checked.

  | Chain            | USDC     | WETH       | EURC           |
  | ---------------- | -------- | ---------- | -------------- |
  | Base / Arbitrum  | \$5      | 0.001 WETH | €5 (Base only) |
  | Ethereum Mainnet | \$10,000 | 5 WETH     | €5             |
</Info>

## Signature

```typescript theme={null}
depositFunds(
  userAddress: string,
  chainId: SupportedChainId,
  amount: string,
  asset: string,
  strategy?: Strategy
): Promise<DepositResponse>
```

## Parameters

| Parameter     | Type               | Required | Description                                                           |
| ------------- | ------------------ | -------- | --------------------------------------------------------------------- |
| `userAddress` | `string`           | ✅        | User's EOA address (owner of the Safe)                                |
| `chainId`     | `SupportedChainId` | ✅        | Chain to deposit on                                                   |
| `amount`      | `string`           | ✅        | Amount in least decimal units (6 decimals for USDC/EURC, 18 for WETH) |
| `asset`       | `string`           | ✅        | Asset to deposit: `"USDC"`, `"WETH"`, or `"EURC"`                     |
| `strategy`    | `Strategy`         | ❌        | First-deposit strategy: `"conservative"` (default) or `"aggressive"`  |

## What happens under the hood

1. Resolves the Safe address for the EOA (backend-assigned for pre-deployed wallets — not derived from the EOA).
2. Ensures the Safe is available on-chain.
3. **First-deposit protocol patching** (see below), then transfers the token from the EOA to the Safe and logs the deposit.

### First-deposit protocol patching

Runs only when the USDC profile has **no `chains` configured yet** (later deposits and `pauseAgent` do not re-trigger it):

* Patches **USDC, WETH, and EURC** with chains `[1, 8453, 42161]` (EURC limited to `[1, 8453]`).
* Fetches protocols, filters by strategy / chain / asset + pool availability, and persists via `updateUserProfile` → `assetTypeSettings.[usdc|eth|eurc]`.
* Failures are non-fatal (`console.warn`); the deposit still proceeds.

Protocols / chains are set on this first `depositFunds` call — not by any separate deploy or session-key step.

## Returns

Deposit response with transaction hash and confirmation

## Return Type

```typescript theme={null}
interface DepositResponse {
  success: boolean;
  txHash: string;
  smartWallet: string;
  amount: string;
}
```

## Example

### Deposit USDC

```typescript theme={null}
// Deposit 100 USDC (6 decimals) to Safe on Base
// Optional strategy applies on first deposit only (default: "conservative")
const result = await sdk.depositFunds(
  "0xUser...",
  8453,
  "100000000", // 100 USDC = 100 * 10^6
  "USDC",
  "conservative"
);
console.log("Deposit confirmed:", result.txHash);
console.log("Smart Wallet:", result.smartWallet);
```

### Deposit WETH

```typescript theme={null}
// Deposit 0.5 WETH (18 decimals) to Safe on Base
// IMPORTANT: User must have WETH, not ETH. Wrap ETH to WETH first if needed.
const result = await sdk.depositFunds(
  "0xUser...",
  8453,
  "500000000000000000", // 0.5 WETH = 0.5 * 10^18
  "WETH"
);
console.log("WETH deposit confirmed:", result.txHash);
```

### Deposit EURC

```typescript theme={null}
// Deposit 100 EURC (6 decimals) on Base (also supported on Mainnet)
const result = await sdk.depositFunds(
  "0xUser...",
  8453,
  "100000000",
  "EURC"
);
console.log("EURC deposit confirmed:", result.txHash);
```
