PATCH /v1/wallets/{wallet}/auto-balance
修改 Solana 钱包自动平衡设置
需要 copytrade:write 权限。只更新提供的字段。开启后可能触发真实兑换。金额用最小单位的十进制字符串,比例用整数基点。并发冲突或结果未知时请先重新读取设置。
所需 Scope:copytrade:write 路径参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
wallet | string | ✓ | Solana wallet address owned by the caller. |
请求体 application/json
| 字段 | 类型 | 必填 | 约束 | 说明 |
|---|---|---|---|---|
enabled | boolean | Whether auto-balance is enabled for this wallet. Defaults to false. | ||
mode | enum ("fixed" | "ratio") | Fixed balances or target USDC share. Defaults to fixed. | ||
sol_floor | string | pattern: ^\d{1,20}$ | SOL reserve floor, in lamports. Defaults to 100000000. | |
sol_min | string | pattern: ^\d{1,20}$ | SOL refill threshold, in lamports. Defaults to 100000000. | |
sol_refill | string | pattern: ^\d{1,20}$ | SOL refill target, in lamports. Defaults to 200000000. | |
usdc_target | string | pattern: ^\d{1,20}$ | Fixed USDC balance target, in millionths of a USDC. Defaults to 0. | |
usdc_ratio_bps | integer | min: 100, max: 9000 | Target USDC share in basis points. Defaults to 3000. | |
band_bps | integer | min: 100, max: 5000 | Allowed deviation from the target share in basis points. Defaults to 1000. | |
max_loss_bps | integer | min: 50, max: 300 | Maximum loss against the reference price in basis points, including pool fees. Defaults to 100. |
响应
200 — OK
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
data | object | ✓ | Response payload. |
data.rule | object | ✓ | Current auto-balance settings for this wallet; defaults when never set. |
data.rule.enabled | boolean | ✓ | Whether auto-balance is enabled for this wallet. Defaults to false. |
data.rule.mode | enum ("fixed" | "ratio") | ✓ | Fixed balances or target USDC share. Defaults to fixed. |
data.rule.sol_floor | string | ✓ | SOL reserve floor, in lamports. Defaults to 100000000. |
data.rule.sol_min | string | ✓ | SOL refill threshold, in lamports. Defaults to 100000000. |
data.rule.sol_refill | string | ✓ | SOL refill target, in lamports. Defaults to 200000000. |
data.rule.usdc_target | string | ✓ | Fixed USDC balance target, in millionths of a USDC. Defaults to 0. |
data.rule.usdc_ratio_bps | integer | ✓ | Target USDC share in basis points. Defaults to 3000. |
data.rule.band_bps | integer | ✓ | Allowed deviation from the target share in basis points. Defaults to 1000. |
data.rule.max_loss_bps | integer | ✓ | Maximum loss against the reference price in basis points, including pool fees. Defaults to 100. |
data.version | integer | null | ✓ | Settings version; null when never saved. |
data.sync | enum ("off" | "syncing" | "active" | "publish_failed") | ✓ | Whether the executor has applied the current version. |
data.has_live_task | boolean | ✓ | Whether an enabled live Solana strategy task uses this wallet; auto-balance only runs when true. |
data.sol_to_usdc | enum ("off" | "syncing" | "not_effective" | "effective") | ✓ | SOL to USDC swaps only take effect when a live task on this wallet has USDC trading on. |
meta | object | ✓ | Request id, plus paging fields when this operation is a list. |
meta.request_id | string | ✓ | Id of this request. Also sent as the X-Request-Id response header. |
400 — Invalid settings or cursor
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
error | object | ✓ | Why the request failed. |
error.code | string | ✓ | Stable machine-readable error code. |
error.message | string | ✓ | Human-readable explanation of the error. |
error.total | number | Number of distinct blacklisted wallets the account would have on this chain after saving. | |
error.limit | number | Maximum distinct blacklisted wallets per account on this chain. | |
error.details | array<object> | Only present when at least one field-level validation issue exists. | |
error.details[].field | string | ✓ | Request field this issue refers to, or a dotted path such as buy.amount. |
error.details[].reason | string | ✓ | Why that field was rejected. |
error.details[].code | string | Stable machine-readable reason for a strategy spec issue, for example unsupported_leaf or pump_callers_required. Present only on strategy spec validation errors; reason may change. | |
meta | object | ✓ | Request id for this failure. |
meta.request_id | string | ✓ | Id of this request. Also sent as the X-Request-Id response header. |
401 — unauthorized (missing/invalid/revoked/expired Bearer token)
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
error | object | ✓ | Why the request failed. |
error.code | string | ✓ | Stable machine-readable error code. |
error.message | string | ✓ | Human-readable explanation of the error. |
error.total | number | Number of distinct blacklisted wallets the account would have on this chain after saving. | |
error.limit | number | Maximum distinct blacklisted wallets per account on this chain. | |
error.details | array<object> | Only present when at least one field-level validation issue exists. | |
error.details[].field | string | ✓ | Request field this issue refers to, or a dotted path such as buy.amount. |
error.details[].reason | string | ✓ | Why that field was rejected. |
error.details[].code | string | Stable machine-readable reason for a strategy spec issue, for example unsupported_leaf or pump_callers_required. Present only on strategy spec validation errors; reason may change. | |
meta | object | ✓ | Request id for this failure. |
meta.request_id | string | ✓ | Id of this request. Also sent as the X-Request-Id response header. |
403 — insufficient_scope / ip_not_allowed
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
error | object | ✓ | Why the request failed. |
error.code | string | ✓ | Stable machine-readable error code. |
error.message | string | ✓ | Human-readable explanation of the error. |
error.total | number | Number of distinct blacklisted wallets the account would have on this chain after saving. | |
error.limit | number | Maximum distinct blacklisted wallets per account on this chain. | |
error.details | array<object> | Only present when at least one field-level validation issue exists. | |
error.details[].field | string | ✓ | Request field this issue refers to, or a dotted path such as buy.amount. |
error.details[].reason | string | ✓ | Why that field was rejected. |
error.details[].code | string | Stable machine-readable reason for a strategy spec issue, for example unsupported_leaf or pump_callers_required. Present only on strategy spec validation errors; reason may change. | |
meta | object | ✓ | Request id for this failure. |
meta.request_id | string | ✓ | Id of this request. Also sent as the X-Request-Id response header. |
404 — Wallet not found
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
error | object | ✓ | Why the request failed. |
error.code | string | ✓ | Stable machine-readable error code. |
error.message | string | ✓ | Human-readable explanation of the error. |
error.total | number | Number of distinct blacklisted wallets the account would have on this chain after saving. | |
error.limit | number | Maximum distinct blacklisted wallets per account on this chain. | |
error.details | array<object> | Only present when at least one field-level validation issue exists. | |
error.details[].field | string | ✓ | Request field this issue refers to, or a dotted path such as buy.amount. |
error.details[].reason | string | ✓ | Why that field was rejected. |
error.details[].code | string | Stable machine-readable reason for a strategy spec issue, for example unsupported_leaf or pump_callers_required. Present only on strategy spec validation errors; reason may change. | |
meta | object | ✓ | Request id for this failure. |
meta.request_id | string | ✓ | Id of this request. Also sent as the X-Request-Id response header. |
409 — Settings changed concurrently
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
error | object | ✓ | Why the request failed. |
error.code | string | ✓ | Stable machine-readable error code. |
error.message | string | ✓ | Human-readable explanation of the error. |
error.total | number | Number of distinct blacklisted wallets the account would have on this chain after saving. | |
error.limit | number | Maximum distinct blacklisted wallets per account on this chain. | |
error.details | array<object> | Only present when at least one field-level validation issue exists. | |
error.details[].field | string | ✓ | Request field this issue refers to, or a dotted path such as buy.amount. |
error.details[].reason | string | ✓ | Why that field was rejected. |
error.details[].code | string | Stable machine-readable reason for a strategy spec issue, for example unsupported_leaf or pump_callers_required. Present only on strategy spec validation errors; reason may change. | |
meta | object | ✓ | Request id for this failure. |
meta.request_id | string | ✓ | Id of this request. Also sent as the X-Request-Id response header. |
429 — rate_limited (Retry-After response header set)
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
error | object | ✓ | Why the request failed. |
error.code | string | ✓ | Stable machine-readable error code. |
error.message | string | ✓ | Human-readable explanation of the error. |
error.total | number | Number of distinct blacklisted wallets the account would have on this chain after saving. | |
error.limit | number | Maximum distinct blacklisted wallets per account on this chain. | |
error.details | array<object> | Only present when at least one field-level validation issue exists. | |
error.details[].field | string | ✓ | Request field this issue refers to, or a dotted path such as buy.amount. |
error.details[].reason | string | ✓ | Why that field was rejected. |
error.details[].code | string | Stable machine-readable reason for a strategy spec issue, for example unsupported_leaf or pump_callers_required. Present only on strategy spec validation errors; reason may change. | |
meta | object | ✓ | Request id for this failure. |
meta.request_id | string | ✓ | Id of this request. Also sent as the X-Request-Id response header. |
500 — internal_error
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
error | object | ✓ | Why the request failed. |
error.code | string | ✓ | Stable machine-readable error code. |
error.message | string | ✓ | Human-readable explanation of the error. |
error.total | number | Number of distinct blacklisted wallets the account would have on this chain after saving. | |
error.limit | number | Maximum distinct blacklisted wallets per account on this chain. | |
error.details | array<object> | Only present when at least one field-level validation issue exists. | |
error.details[].field | string | ✓ | Request field this issue refers to, or a dotted path such as buy.amount. |
error.details[].reason | string | ✓ | Why that field was rejected. |
error.details[].code | string | Stable machine-readable reason for a strategy spec issue, for example unsupported_leaf or pump_callers_required. Present only on strategy spec validation errors; reason may change. | |
meta | object | ✓ | Request id for this failure. |
meta.request_id | string | ✓ | Id of this request. Also sent as the X-Request-Id response header. |
请求示例
curl -X PATCH "https://api.apm.fun/v1/wallets/cfg_8f2a1c9b/auto-balance" \
-H "Authorization: Bearer apm_live_<prefix>.<secret>" \
-H "Content-Type: application/json" \
-d '{
"enabled": true,
"mode": "fixed",
"sol_floor": "string",
"sol_min": "string",
"sol_refill": "string",
"usdc_target": "string",
"usdc_ratio_bps": 0,
"band_bps": 0,
"max_loss_bps": 0
}' 响应示例 200
{
"data": {
"rule": {
"enabled": true,
"mode": "fixed",
"sol_floor": "string",
"sol_min": "string",
"sol_refill": "string",
"usdc_target": "string",
"usdc_ratio_bps": 0,
"band_bps": 0,
"max_loss_bps": 0
},
"version": null,
"sync": "off",
"has_live_task": true,
"sol_to_usdc": "off"
},
"meta": {
"request_id": "cfg_8f2a1c9b"
}
}