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

# Deposit and withdraw from AgentBank vaults

> Learn how to deposit assets into an AgentBank ERC-4626 vault and withdraw or redeem shares using the TypeScript SDK, Python SDK, or Byreal Skills CLI.

AgentBank vaults follow the ERC-4626 standard. You deposit an underlying asset (USDY) and receive vault shares. To exit, you either withdraw a specific asset amount (the vault burns the required shares) or redeem a specific number of shares for the equivalent assets.

This page shows how to perform these operations using the TypeScript SDK, Python SDK, and Byreal Skills CLI.

> [!NOTE]
>
> Withdrawals are subject to a **24-hour cooldown** after your deposit. You cannot withdraw within 24 hours of depositing.

## Deposit

**TypeScript**

```typescript theme={null}
import { AgentBankClient } from "@agentbank/sdk";
import { createPublicClient, createWalletClient, http } from "viem";
import { mantle } from "viem/chains";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const publicClient = createPublicClient({ chain: mantle, transport: http("https://rpc.mantle.xyz") });
const walletClient = createWalletClient({ chain: mantle, transport: http("https://rpc.mantle.xyz"), account });

const client = new AgentBankClient({
  publicClient,
  walletClient,
  addresses: {
    vault: "0xC44C061D257Af305dEAea2eD093E878a615d856d",
    signalBoard: "0x2A46cF6493b377D45908254B0528e38990AA323f",
    intentRouter: "0x9582d2dF303ec2B1fab104A77E249C05571fccC9",
    teeVerifier: "0x51E52dCBD0FBfaDaDB43ad1EB1Ea0d3A79f128c3",
  },
});

// Deposit 500 USDY
const txHash = await client.vault.deposit({ amount: "500" });
console.log("Deposit tx:", txHash);

// Check your shares
const shares = await client.vault.getShares(account.address);
console.log("ABV2 shares:", shares);
```

**Python**

```python theme={null}
from agentbank import AgentBankClient, Addresses

client = AgentBankClient(
    rpc_url="https://rpc.mantle.xyz",
    private_key="0x...",
    addresses=Addresses(
        vault="0xC44C061D257Af305dEAea2eD093E878a615d856d",
        signal_board="0x2A46cF6493b377D45908254B0528e38990AA323f",
        intent_router="0x9582d2dF303ec2B1fab104A77E249C05571fccC9",
        tee_verifier="0x51E52dCBD0FBfaDaDB43ad1EB1Ea0d3A79f128c3",
    ),
)

# Deposit 500 USDY (in wei, 18 decimals)
tx_hash = client.deposit(amount_wei=500 * 10**18)
print("Deposit tx:", tx_hash.hex())

# Check shares
shares = client.get_shares(client.account.address)
print("Shares:", shares)
```

**CLI**

```bash theme={null}
# Install the CLI
npm install -g @agentbank/skills

# Deposit 500 USDY
agentbank-cli vault deposit --amount 500 --confirm
```

## Withdraw by asset amount

Specify the exact amount of USDY you want to receive. The vault calculates and burns the corresponding shares.

**TypeScript**

```typescript theme={null}
// Withdraw 200 USDY worth of value
const txHash = await client.vault.withdraw({ amount: "200" });
console.log("Withdraw tx:", txHash);
```

**Python**

```python theme={null}
tx_hash = client.withdraw(amount_wei=200 * 10**18)
print("Withdraw tx:", tx_hash.hex())
```

**CLI**

```bash theme={null}
agentbank-cli vault withdraw --amount 200 --confirm
```

## Redeem by share amount

Specify the exact number of shares to burn and receive the proportional asset value.

**TypeScript**

```typescript theme={null}
// Redeem 100 shares
const txHash = await client.vault.redeem({ shares: "100" });
console.log("Redeem tx:", txHash);
```

## Read vault stats

```typescript theme={null}
// Total value locked
const tvl = await client.vault.getTVL();
console.log("TVL:", tvl, "USDY");

// Estimated APY (simplified share price model)
const apy = await client.vault.getAPY();
console.log("Estimated APY:", apy, "%");

// Underlying asset address
const asset = await client.vault.getUnderlyingAsset();
console.log("Underlying asset:", asset);
```

Via CLI:

```bash theme={null}
agentbank-cli vault stats -o json
```

Example output:

```json theme={null}
{
  "tvl": "4250000.00",
  "apy": "8.42",
  "totalOps": 1243,
  "totalBlocked": 87
}
```

## Deposit into a specific tier

If you want to deposit into a specific risk tier rather than the default vault:

```bash theme={null}
# List available tiers
agentbank-cli tier list

# Deposit 1000 USDY into the Balanced tier
agentbank-cli tier deposit --tier balanced --amount 1000 --confirm
```

See [Vault Tiers](https://0xcaptain.mintlify.site/vault/tiers.md) for a full comparison of each tier's parameters.


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