# One Click 代发交易

适用于 API Key 已绑定用户钱包地址，并由服务端代发交易的场景。

## 授权流程

```mermaid
sequenceDiagram
    participant 用户
    participant 客户端
    participant API
    participant 链上

    客户端->>API: GET /1ct/status
    API-->>客户端: { status: "disabled" }
    客户端->>API: POST /1ct/prepare { deadline }
    API-->>客户端: signPayload (EIP-712)
    客户端->>用户: 请求签名
    用户->>客户端: signature (65 bytes)
    客户端->>API: POST /1ct/enable { signature, deadline }
    API->>链上: delegateBySig
    API-->>客户端: { status: "enable" }
```

## 操作步骤

1. 调用 `GET /api/v1/1ct/status` 查看授权状态。
2. 未启用时，调用 `POST /api/v1/1ct/prepare` 获取 `signPayload`。
3. 用户钱包对 `signPayload` 进行 **EIP-712 签名**。
4. 调用 `POST /api/v1/1ct/enable` 提交签名并开启 One Click。
5. 调用 `/send` 系列接口完成具体操作。

## 可用的 Send 接口

| 操作类型 | 接口                                     |
| ---- | -------------------------------------- |
| 下单   | `POST /api/v1/orders/send`             |
| 撤单   | `DELETE /api/v1/orders/{orderId}/send` |
| 入金   | `POST /api/v1/cash/deposits/send`      |
| 出金   | `POST /api/v1/cash/withdrawals/send`   |

## 入金前置要求

> \[!IMPORTANT] 用户钱包需先对现金 token 执行 ERC-20 `approve`。

授权 owner 为实际入金用户地址：

* 使用 `/cash/deposits/send` 时为 API Key 绑定的 `userAddress`
* 使用 `/cash/deposits/calldata` 自行提交时为交易发起钱包地址

Mainnet spender 地址见[现金出入金 - 入金前置授权](https://github.com/AnchoredLabs/anchored-gitbook/blob/main/zh/api/cash-operations/README.md#入金前置授权)。


---

# Agent Instructions: 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:

```
GET https://docs.anchored.finance/trading-api-docs-zh/jie-ru-liu-cheng/one-click-flow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
