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

# 储蓄账户概览

> 以美元计价的托管储蓄账户

## 什么是储蓄账户？

KillB 中的储蓄账户是以美元计价的托管账户，允许用户从存款中赚取收益。KillB 管理托管，而用户保持完全所有权。

<Info>
  储蓄账户通过合作银行获得 FDIC 保险，提供安全的美元价值持有方式。
</Info>

## 主要功能

<CardGroup cols={2}>
  <Card title="美元计价" icon="dollar-sign">
    以美元持有价值，免受本地货币波动影响
  </Card>

  <Card title="多种存款方式" icon="arrows-down-to-line">
    通过 ACH、电汇或加密货币存款
  </Card>

  <Card title="轻松提款" icon="money-bill-transfer">
    随时提款到银行账户或加密货币钱包
  </Card>

  <Card title="交易历史" icon="clock-rotate-left">
    跟踪所有存款和提款
  </Card>
</CardGroup>

## 创建储蓄账户

```bash theme={null}
POST /api/v2/savings
```

```json theme={null}
{
  "userId": "user-id",
  "acceptedTermsAndConditions": true
}
```

<CodeGroup>
  ```javascript Node.js theme={null}
  const createSavingsAccount = async (userId) => {
    const response = await fetch(
      'https://sandbox.killb.app/api/v2/savings',
      {
        method: 'POST',
        headers: {
          'Authorization': `Bearer ${token}`,
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({
          userId: userId,
          acceptedTermsAndConditions: true
        })
      }
    );
    
    return await response.json();
  };
  ```

  ```python Python theme={null}
  def create_savings_account(user_id, api_key, access_token):
      response = requests.post(
          'https://sandbox.killb.app/api/v2/savings',
          headers={
              'Authorization': f'Bearer {access_token}',
              'Content-Type': 'application/json'
          },
          json={
              'userId': user_id,
              'acceptedTermsAndConditions': True
          }
      )
      return response.json()
  ```
</CodeGroup>

**响应：**

```json theme={null}
{
  "id": "savings-account-id",
  "userId": "user-id",
  "status": "PENDING",
  "createdAt": "2024-01-15T10:30:00.000Z"
}
```

## 检查余额

```bash theme={null}
GET /api/v2/savings/{savingsAccountId}/balance
```

```javascript theme={null}
const getBalance = async (savingsAccountId) => {
  const response = await fetch(
    `https://sandbox.killb.app/api/v2/savings/${savingsAccountId}/balance`,
    {
      headers: {
        'Authorization': `Bearer ${token}`
      }
    }
  );
  
  const balance = await response.json();
  console.log(`余额: $${balance.amount} ${balance.currency}`);
  return balance;
};
```

## 存款方式

### ACH 存款

获取 ACH 存款说明：

```bash theme={null}
GET /api/v2/savings/{savingsAccountId}/deposit-instructions/ACH
```

```json 响应 theme={null}
{
  "type": "ACH",
  "currency": "USD",
  "accountHolderName": "Bridge Bank",
  "accountNumber": "123456789",
  "routingNumber": "987654321",
  "memo": "ABC123"
}
```

**重要：** 用户必须在转账中包含 `memo` 以便正确入账。

### 电汇存款

```bash theme={null}
GET /api/v2/savings/{savingsAccountId}/deposit-instructions/WIRE
```

### 加密货币存款

获取加密货币存款的钱包地址：

```bash theme={null}
GET /api/v2/savings/{savingsAccountId}/crypto-deposit-instructions
```

```json 响应 theme={null}
{
  "address": "0x123...",
  "network": "POLYGON",
  "currency": "USDC"
}
```

用户将 USDC 发送到此地址，自动转换为 USD。

## 提款

创建到外部账户的提款：

```bash theme={null}
POST /api/v2/savings/withdrawal
```

```json theme={null}
{
  "source": {
    "savingsAccountId": "savings-id"
  },
  "destination": {
    "savingsAccountId": "savings-id",
    "externalAccountId": "bank-or-wallet-id"
  },
  "amount": 1000,
  "comment": "提款到银行账户"
}
```

## 交易历史

获取所有储蓄交易：

```bash theme={null}
GET /api/v2/savings/transactions?userId=user-id
```

```json 响应 theme={null}
{
  "transactions": [
    {
      "id": "txn-1",
      "type": "DEPOSIT",
      "amount": "1000.00",
      "currency": "USD",
      "createdAt": "2024-01-15T10:30:00.000Z"
    }
  ],
  "totalPage": 1
}
```

## 下一步

<CardGroup cols={2}>
  <Card title="创建账户" icon="plus" href="/zh/guides/savings/create-account">
    设置储蓄账户
  </Card>

  <Card title="存款" icon="arrow-down" href="/zh/guides/savings/deposits">
    为储蓄账户充值
  </Card>

  <Card title="提款" icon="arrow-up" href="/zh/guides/savings/withdrawals">
    从储蓄账户提款
  </Card>

  <Card title="API 参考" icon="code" href="/api-reference/endpoint/savings-create">
    储蓄 API 文档
  </Card>
</CardGroup>
