> For the complete documentation index, see [llms.txt](https://docs.gammaswap.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gammaswap.com/developers/api-reference/deposit-methods.md).

# Deposit Methods

`DepositClient` communicates directly with on-chain contracts through the configured RPC URL.

Use it to read deposit state, inspect token balances and allowances, submit approvals, sign permits, and deposit settlement tokens.

```ts
import { createDepositClient } from "@gammaswap/v2-exchange-sdk";
import { Wallet } from "ethers";

const wallet = new Wallet(process.env.PRIVATE_KEY!);

const deposit = createDepositClient({
  rpcUrl: process.env.RPC_URL!,
  wallet,
  chainId: "84532",
});
```

The client verifies that the RPC network matches the configured `chainId` before performing contract reads or transactions.

On-chain integers are returned as TypeScript `bigint` values rather than JSON numbers.

### `getSettlementToken`

Returns the settlement-token contract address.

```ts
const settlementToken =
  await deposit.getSettlementToken();
```

SDK response:

```ts
"0x1111111111111111111111111111111111111111"
```

### `getPermit2`

Returns the Permit2 contract address used by the deposit system.

```ts
const permit2 = await deposit.getPermit2();
```

SDK response:

```ts
"0x2222222222222222222222222222222222222222"
```

### `getAccountLedger`

Returns the account-ledger contract address.

```ts
const accountLedger =
  await deposit.getAccountLedger();
```

SDK response:

```ts
"0x3333333333333333333333333333333333333333"
```

### `getPendingBalance`

Returns the connected account’s pending deposit balance.

```ts
const pendingBalance =
  await deposit.getPendingBalance();
```

SDK response:

```ts
100250000n
```

With six settlement-token decimals, this represents `100.25` tokens.

### `getProcessedBalance`

Returns the connected account’s processed deposit balance.

```ts
const processedBalance =
  await deposit.getProcessedBalance();
```

SDK response:

```ts
50000000n
```

With six settlement-token decimals, this represents `50` tokens.

### `getPendingDepositCount`

Returns the number of pending deposits.

```ts
const pendingCount =
  await deposit.getPendingDepositCount();
```

SDK response:

```ts
3n
```

### `getNextPendingDepositId`

Returns the next pending deposit ID.

```ts
const nextDepositId =
  await deposit.getNextPendingDepositId();
```

SDK response:

```ts
42n
```

### `getProcessedDepositIndex`

Returns the processed-deposit index.

```ts
const processedIndex =
  await deposit.getProcessedDepositIndex();
```

SDK response:

```ts
38n
```

### `getMinBlockWait`

Returns the minimum number of blocks that must pass before the next deposit can be processed.

```ts
const minBlockWait =
  await deposit.getMinBlockWait();
```

SDK response:

```ts
5n
```

### `canProcessNext`

Checks whether the next pending deposit can be processed.

```ts
const canProcess =
  await deposit.canProcessNext();
```

SDK response:

```ts
true
```

If processing requirements have not been met:

```ts
false
```

### `getSettlementTokenBalance`

Returns a settlement-token balance.

When no owner is supplied, the configured wallet address is used.

```ts
const balance =
  await deposit.getSettlementTokenBalance();
```

SDK response:

```ts
250000000n
```

With six settlement-token decimals, this represents `250` tokens.

An owner address can also be supplied:

```ts
const balance =
  await deposit.getSettlementTokenBalance(
    "0x4444444444444444444444444444444444444444",
  );
```

SDK response:

```ts
100250000n
```

### `getSettlementTokenAllowance`

Returns the settlement-token allowance for a spender.

```ts
const allowance =
  await deposit.getSettlementTokenAllowance();
```

SDK response:

```ts
1000000000n
```

Optional spender and owner addresses can be supplied:

```ts
const allowance =
  await deposit.getSettlementTokenAllowance(
    "0x2222222222222222222222222222222222222222",
    "0x4444444444444444444444444444444444444444",
  );
```

SDK response:

```ts
500000000n
```

### `approveDepositLedger`

Approves the deposit ledger to spend settlement tokens.

```ts
const result =
  await deposit.approveDepositLedger({
    // Approval input
  });
```

This method submits an on-chain transaction.

The supplied SDK documentation does not publish its complete input fields or return type. The exact response object should be copied from the SDK’s exported TypeScript definition before publishing a response example.

### `approvePermit2`

Approves Permit2 to spend settlement tokens.

```ts
const result =
  await deposit.approvePermit2({
    // Approval input
  });
```

This method submits an on-chain transaction.

### `deposit`

Submits an on-chain deposit transaction.

```ts
const result = await deposit.deposit({
  // Deposit input
});
```

The method logs the deposit transaction ID by default.

To suppress the log:

```ts
const result = await deposit.deposit({
  // Deposit input
  logTxId: false,
});
```

The SDK confirms that the method submits the transaction and logs the deposit `txId` by default.

### `signDepositPermit`

Creates a signed Permit2 deposit authorization without submitting an on-chain transaction.

```ts
const permit =
  await deposit.signDepositPermit({
    // Permit input
  });
```

### `depositWithPermit`

Submits an on-chain deposit using a signed Permit2 authorization.

```ts
const result =
  await deposit.depositWithPermit({
    // Deposit and permit input
  });
```

### `parseAmount`

Converts a human decimal amount into settlement-token base units.

```ts
const amount = deposit.parseAmount("100.25");
```

SDK response:

```ts
100250000n
```

The settlement token uses six decimals.

Additional examples:

```ts
deposit.parseAmount("1");
```

Response:

```ts
1000000n
```

```ts
deposit.parseAmount("0.01");
```

Response:

```ts
10000n
```

Invalid precision, zero amounts, negative values, and out-of-range values are rejected before a transaction is submitted.

### Available methods

| Method                        | Operation                                     |
| ----------------------------- | --------------------------------------------- |
| `getSettlementToken`          | Read settlement-token address                 |
| `getPermit2`                  | Read Permit2 address                          |
| `getAccountLedger`            | Read account-ledger address                   |
| `getPendingBalance`           | Read pending deposit balance                  |
| `getProcessedBalance`         | Read processed deposit balance                |
| `getPendingDepositCount`      | Read pending-deposit count                    |
| `getNextPendingDepositId`     | Read next pending deposit ID                  |
| `getProcessedDepositIndex`    | Read processed-deposit index                  |
| `getMinBlockWait`             | Read minimum block wait                       |
| `canProcessNext`              | Check whether the next deposit is processable |
| `getSettlementTokenBalance`   | Read settlement-token balance                 |
| `getSettlementTokenAllowance` | Read token allowance                          |
| `approveDepositLedger`        | Approve the deposit ledger                    |
| `approvePermit2`              | Approve Permit2                               |
| `deposit`                     | Submit a deposit                              |
| `signDepositPermit`           | Sign a deposit permit                         |
| `depositWithPermit`           | Deposit using a permit                        |
| `parseAmount`                 | Convert a human amount into base units        |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gammaswap.com/developers/api-reference/deposit-methods.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
