> ## 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: the declaration and description of each of the 14 exports of @eco-incorp/sauce.

The `deposit` namespace emits a program that makes protocol deposits, withdrawals, stakes or wraps from data. `deposit.depositSource(spec)` returns a `function main()` program with each call and its approval, which `routes.compileSauceProgram` compiles; `deposit.listDepositTemplates()` lists the supported calls, one template per protocol and action (`aave-v3` `supply`, `lido` `stake`, `weth` `unwrap`, ...).

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

Generated from the type declarations of `@eco-incorp/sauce`.

### `deposit.toDeposit`

*Function* · `@eco-incorp/sauce`

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

`spec.amount` may be `"balance" | "max"` - see `DepositSourceSpec` - in which case it
passes through unresolved (the caller, `depositCallStatement`, 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); a `weth` template whose `target` is known not to be a WETH9 (a chain's native
ERC-20, or a registry token on a chain with no canonical wrapped native - Arc); 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" | "max";
})): NormalizedDeposit;
```

### `deposit.Address`

*Type* · `@eco-incorp/sauce`

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

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

### `deposit.AddressInput`

*Type* · `@eco-incorp/sauce`

Anything the builders accept for an address-shaped field.

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

### `deposit.AmountInput`

*Type* · `@eco-incorp/sauce`

Anything the builders accept for a numeric-shaped field.

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

### `deposit.Hex`

*Type* · `@eco-incorp/sauce`

A `0x`-prefixed hex byte string.

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

### `deposit.ApprovalPolicy`

*Type* · `@eco-incorp/sauce`

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

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

### `deposit.BeneficiarySupport`

*Type* · `@eco-incorp/sauce`

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

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

### `deposit.DepositSpec`

*Interface* · `@eco-incorp/sauce`

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 the Pot 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* · `@eco-incorp/sauce`

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 program needs when the deposit amount is only known when
  it runs, such as what an earlier swap delivered.
* `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" | "max";
});
```

### `deposit.DepositTemplate`

*Interface* · `@eco-incorp/sauce`

One per-protocol call template - data + a small pure emitter, deliberately not a class
hierarchy.

```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* · `@eco-incorp/sauce`

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* · `@eco-incorp/sauce`

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)`. 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* · `@eco-incorp/sauce`

A `DepositSpec`, fully normalized - bigint scalars (+ the `"pot"` sentinel for a defaulted
`beneficiary`), 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" | "max";
    beneficiary: bigint | "pot" | null;
    approvalPolicy: ApprovalPolicy;
    extra: Readonly<Record<string, bigint>>;
}
```

### `deposit.SkippedProtocolNote`

*Interface* · `@eco-incorp/sauce`

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;
}
```


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