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

# waitForDepositCredit

> Await deposit credit after logDeposit returns handover_pending.

Polls [`getDepositStatus`](/docs/sdk/api/get-deposit-status) until the deposit is credited to the Safe balance. Resolves when `balanceCredited === true` and `status !== "recovered_to_eoa"`. The returned record may already be `position_pending` or `positioned` if allocation started in the same poll window. Rejects if custody handover fails (`recovered_to_eoa`), polling errors, or the timeout elapses.

To wait for rebalance into a protocol position after credit, call [`waitForDepositPosition`](/docs/sdk/api/wait-for-deposit-position).

Requires `connectAccount()` on the **same** `ZyfaiSDK` instance.

## Signature

```typescript theme={null}
waitForDepositCredit(
  depositId: string,
  chainId: SupportedChainId,
  options?: WaitForDepositCreditOptions,
): Promise<DepositLifecycleResponse>
```

## Parameters

| Parameter | Type | Required | Description |
| - | - | :-: | - |
| `depositId` | `string` | ✅ | Lifecycle UUID from `logDeposit().deposit.id` or `sendDeposit().registration.id` |
| `chainId` | `SupportedChainId` | ✅ | Chain the deposit was registered on (`1`, `8453`, or `42161`) — selects default poll interval and timeout |
| `options` | `WaitForDepositCreditOptions` | ❌ | Poll interval and timeout overrides |

```typescript theme={null}
interface WaitForDepositCreditOptions {
  intervalMs?: number;  // default: chain-specific (see below)
  timeoutMs?: number;   // default: chain-specific (see below)
}
```

Default polling by chain:

| Chain | `intervalMs` | `timeoutMs` |
| - | - | - |
| Ethereum (`1`) | 2000 ms | 60000 ms (1 minute) |
| Base (`8453`) | 500 ms | 20000 ms (\~10 blocks) |
| Arbitrum (`42161`) | 250 ms | 20000 ms (\~10 blocks) |

These are normal user-facing completion windows. Pass a larger `timeoutMs` only
when an integration explicitly wants to wait through the backend recovery path.

## Returns

The final `DepositLifecycleResponse` when `balanceCredited === true` and the deposit was not recovered to the EOA. `status` may be `credited`, `position_pending`, or `positioned`.

## Errors

| Condition | Error |
| - | - |
| `status === "recovered_to_eoa"` | `Deposit {id} recovered to EOA (status=recovered_to_eoa); balance was not credited` |
| Timeout (chain-specific default) | `Timed out waiting for deposit {id} to be credited` |
| Poll failure | Original error from `getDepositStatus` |

## Example

### After logDeposit

```typescript theme={null}
await sdk.connectAccount(walletProvider, 8453);

const result = await sdk.logDeposit(8453, txHash, "100000000");

if (result.deposit.status === "handover_pending") {
  const credited = await sdk.waitForDepositCredit(result.deposit.id, 8453);
  console.log("Deposit credited:", credited.id);

  const positioned = await sdk.waitForDepositPosition(result.deposit.id, 8453);
  console.log("Allocation:", positioned.status, positioned.positionOutcome);
}
```

### With custom timeout

```typescript theme={null}
const credited = await sdk.waitForDepositCredit(depositId, 1, {
  intervalMs: 3_000,
  timeoutMs: 600_000, // 10 minutes
});
```

## Related methods

* [`getDepositStatus`](/docs/sdk/api/get-deposit-status) — single status fetch
* [`waitForDepositPosition`](/docs/sdk/api/wait-for-deposit-position) — poll until positioned or skipped


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