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

# deposit: Parameters and types

> Parameters and types: 14 exports of the deposit module of @eco-incorp/sauce, including Address, AddressInput, AmountInput, Hex, ApprovalPolicy, BeneficiarySupport.

The `deposit` namespace emits deposit programs from protocol templates listed under `DepositKey`. Compile with `baseDirs: [...deposit.DEPOSIT_BASE_DIRS]`, or `COMPOSED_BASE_DIRS` for a swap-then-deposit program.

```typescript theme={null}
import { deposit } from "@eco-incorp/sauce";
```

This page covers `sdk/dist/swap/types.d.ts`, `sdk/dist/deposit/types.d.ts`, `sdk/dist/deposit/params.d.ts`.

<Note>
  Generated from the type declarations shipped in `@eco-incorp/sauce` 0.99.4. Each entry shows the package authors' JSDoc and declaration for this SDK version. For runtime compatibility and deployed addresses, see [architecture and deployments](/programmable-transactions/sauce/architecture-and-deployments).
</Note>

### `deposit.Address`

*Type* · `sdk/dist/swap/types.d.ts`

A 20-byte EVM address, as an ordinary `0x`-prefixed hex string.

```typescript theme={null}
export type Address = `0x${string}`;
```

### `deposit.AddressInput`

*Type* · `sdk/dist/swap/types.d.ts`

Anything `toSwapParams` accepts for an address-shaped field.

```typescript theme={null}
export type AddressInput = Address | bigint;
```

### `deposit.AmountInput`

*Type* · `sdk/dist/swap/types.d.ts`

Anything `toSwapParams` accepts for a numeric-shaped field.

```typescript theme={null}
export type AmountInput = bigint | number | string;
```

### `deposit.Hex`

*Type* · `sdk/dist/swap/types.d.ts`

A `0x`-prefixed hex byte string (used for `SwapParams.callback`).

```typescript theme={null}
export type Hex = `0x${string}`;
```

### `deposit.ApprovalPolicy`

*Type* · `sdk/dist/deposit/types.d.ts`

How much of `spec.amount` to approve, when `funding === "erc20-approve"`.

```typescript theme={null}
export type ApprovalPolicy = "exact" | "max" | "none";
```

### `deposit.BeneficiarySupport`

*Type* · `sdk/dist/deposit/types.d.ts`

Whether a template's protocol call accepts a caller-chosen beneficiary/recipient address.

```typescript theme={null}
export type BeneficiarySupport = "supported" | "unsupported";
```

### `deposit.DepositSpec`

*Interface* · `sdk/dist/deposit/types.d.ts`

The chain-agnostic deposit SPEC a caller builds - the input to `toDeposit` /
`depositCallStatement` / `depositSource`.

`token` names the asset for a typed-ABI template. Omit it for WETH wrap/unwrap and Lido stake;
WETH unwrap uses `target` as its token address, while wrap and stake use native ETH.
`beneficiary` defaults to `ctx.self()` and must be omitted on a `beneficiary: "unsupported"`
template (every such protocol credits `msg.sender` unconditionally - accepting one would silently
send the position to the wrong account).

```typescript theme={null}
export interface DepositSpec {
    protocol: string;
    action: string;
    target: AddressInput;
    token?: AddressInput;
    amount: AmountInput;
    beneficiary?: AddressInput;
    approvalPolicy?: ApprovalPolicy;
    extra?: Readonly<Record<string, AmountInput>>;
}
```

### `deposit.DepositSourceSpec`

*Type* · `sdk/dist/deposit/types.d.ts`

The extra shapes `depositCallStatement`/`depositSource` accept beyond a concrete
`DepositSpec`:

* `amount: "balance"` - emit a RUNTIME balance read instead of a baked-in literal (`IERC20.
  balanceOf(ctx.self())` on `token` or the WETH unwrap `target`, `ctx.selfBalance()` for a
  native-funded template) - the shape
  a swap-then-deposit program needs when the deposit amount is an earlier leg's (unknown at
  compile time) output.
* `amount: "delta"` - only meaningful inside `swapThenDepositSource` (it needs a pre-swap balance
  snapshot to compute against); `depositCallStatement`/`depositSource` alone reject it.
* `amount: "max"` - only accepted on a template with `allowsMaxAmount: true` (Aave/Spark
  `withdraw`'s documented `type(uint256).max` withdraw-all sentinel); rejected everywhere else.

```typescript theme={null}
export type DepositSourceSpec = DepositSpec | (Omit<DepositSpec, "amount"> & {
    amount: "balance" | "delta" | "max";
});
```

### `deposit.DepositTemplate`

*Interface* · `sdk/dist/deposit/types.d.ts`

One per-protocol call template - data + a small pure emitter, deliberately not a class
hierarchy. See `sdk/src/deposit/templates.ts` for the concrete registry and
`sdk/src/deposit/index.ts` for which protocols are included/skipped and why.

```typescript theme={null}
export interface DepositTemplate {
    readonly protocol: string;
    readonly action: string;
    readonly source: {
        readonly module: string;
        readonly exportName: string;
    } | null;
    readonly signature: string;
    readonly selector: `0x${string}`;
    readonly funding: Funding;
    readonly beneficiary: BeneficiarySupport;
    readonly allowsMaxAmount: boolean;
    readonly imports: readonly string[];
    readonly binding: string | null;
    readonly extras: Readonly<Record<string, ExtraFieldSpec>>;
    emit(d: NormalizedDeposit, amountExpr: string, varSuffix: string): readonly string[];
}
```

### `deposit.ExtraFieldSpec`

*Interface* · `sdk/dist/deposit/types.d.ts`

A single extra, protocol-specific field a template accepts beyond the common shape.

```typescript theme={null}
export interface ExtraFieldSpec {
    readonly defaultValue: bigint;
    normalize(value: AmountInput, fieldName: string): bigint;
}
```

### `deposit.Funding`

*Type* · `sdk/dist/deposit/types.d.ts`

How a template's protocol call pulls in the token amount being deposited.

* `"erc20-approve"` - an ERC20 asset; `depositCallStatement` emits `IERC20.approve(target,
  amount)` immediately before the protocol call (see `ApprovalPolicy`).
* `"native-value"` - no ERC20 leg at all; the amount rides as `msg.value` on a raw
  `evm.call(target, value, calldata)` (a typed ABI binding can never attach value - see
  `sdk/src/deposit/index.ts`'s "native vs ERC20" note). No approve is ever emitted.
* `"none"` - a redeem/withdraw leg that burns a balance this contract already holds (e.g. Aave's
  `withdraw`, which burns aTokens). No approve, no value.

```typescript theme={null}
export type Funding = "erc20-approve" | "native-value" | "none";
```

### `deposit.NormalizedDeposit`

*Interface* · `sdk/dist/deposit/types.d.ts`

A `DepositSpec`, fully normalized - bigint scalars (+ the `"self"` sentinel for a defaulted
`beneficiary`, matching `SwapParams`'s own convention), plus the resolved `DepositTemplate`.
`amount` stays a passthrough of whatever `toDeposit` was handed for the runtime-amount shapes
(`"balance"` etc.) so a caller can tell a concrete deposit from a source-only one apart.

```typescript theme={null}
export interface NormalizedDeposit {
    template: DepositTemplate;
    target: bigint;
    token: bigint | null;
    amount: bigint | "balance" | "delta" | "max";
    beneficiary: bigint | "self" | null;
    approvalPolicy: ApprovalPolicy;
    extra: Readonly<Record<string, bigint>>;
}
```

### `deposit.SkippedProtocolNote`

*Interface* · `sdk/dist/deposit/types.d.ts`

A short, human-readable note on a protocol considered but not registered as a template.

```typescript theme={null}
export interface SkippedProtocolNote {
    readonly protocol: string;
    readonly reason: string;
}
```

### `deposit.toDeposit`

*Function* · `sdk/dist/deposit/params.d.ts`

The whole normalization/defaulting/guard decision: lowers a chain-agnostic `DepositSpec`
into a fully normalized `NormalizedDeposit` - plain bigints (+ the `"self"` sentinel for a
defaulted `beneficiary`), with its resolved `DepositTemplate` attached.

`spec.amount` may be `"balance" | "delta" | "max"` - see `DepositSourceSpec` - in which case
it passes through unresolved (the caller, `depositCallStatement`/`swapThenDepositSource`, decides
the actual amount EXPRESSION; this function only validates every OTHER field and, for `"max"`,
checks `allowsMaxAmount`).

Throws (never emits a program that would misbehave on-chain) for: an unknown `protocol:action`;
`token` supplied to a raw-call template or omitted from a typed-ABI template;
`beneficiary` supplied to a `beneficiary: "unsupported"` template; `amount: "max"` on a template
with `allowsMaxAmount: false`; an unrecognized `extra` field name; an `amount` given as a `number`
that is not a safe integer (past 2^53-1 pass a bigint or a string, since the double has already
been rounded); and whatever the field's own `ExtraFieldSpec.normalize` throws for an out-of-range
extra value.

```typescript theme={null}
export declare function toDeposit(spec: DepositSpec | (Omit<DepositSpec, "amount"> & {
    amount: "balance" | "delta" | "max";
})): NormalizedDeposit;
```
