@agentlayer.tech/wallet 0.1.16 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.openclaw/extensions/agent-wallet/dist/index.js +3 -3
- package/.openclaw/extensions/agent-wallet/index.ts +3 -3
- package/.openclaw/extensions/agent-wallet/package.json +1 -1
- package/.openclaw/extensions/pay-bridge/package.json +1 -1
- package/CHANGELOG.md +14 -0
- package/agent-wallet/README.md +1 -1
- package/agent-wallet/agent_wallet/openclaw_adapter.py +3 -3
- package/agent-wallet/agent_wallet/providers/flash_sdk_bridge.py +50 -4
- package/agent-wallet/agent_wallet/wallet_layer/solana.py +9 -9
- package/agent-wallet/pyproject.toml +1 -1
- package/agent-wallet/scripts/flash-sdk-bridge/README.md +2 -2
- package/agent-wallet/scripts/flash-sdk-bridge/bridge.mjs +17 -17
- package/package.json +1 -1
|
@@ -1448,7 +1448,7 @@ const solanaToolDefinitions = [
|
|
|
1448
1448
|
},
|
|
1449
1449
|
{
|
|
1450
1450
|
name: "flash_trade_open_position",
|
|
1451
|
-
description: "Preview, prepare, or execute a Flash Trade
|
|
1451
|
+
description: "Preview, prepare, or execute a Flash Trade perpetual open on Solana mainnet using a supported Flash collateral.",
|
|
1452
1452
|
optional: true,
|
|
1453
1453
|
parameters: {
|
|
1454
1454
|
type: "object",
|
|
@@ -1463,7 +1463,7 @@ const solanaToolDefinitions = [
|
|
|
1463
1463
|
},
|
|
1464
1464
|
collateral_symbol: {
|
|
1465
1465
|
type: "string",
|
|
1466
|
-
description: "
|
|
1466
|
+
description: "Flash collateral symbol, for example SOL for SOL longs or USDC for SOL shorts.",
|
|
1467
1467
|
},
|
|
1468
1468
|
collateral_amount_raw: {
|
|
1469
1469
|
type: "string",
|
|
@@ -1498,7 +1498,7 @@ const solanaToolDefinitions = [
|
|
|
1498
1498
|
},
|
|
1499
1499
|
{
|
|
1500
1500
|
name: "flash_trade_close_position",
|
|
1501
|
-
description: "Preview, prepare, or execute a Flash Trade
|
|
1501
|
+
description: "Preview, prepare, or execute a Flash Trade perpetual close on Solana mainnet.",
|
|
1502
1502
|
optional: true,
|
|
1503
1503
|
parameters: {
|
|
1504
1504
|
type: "object",
|
|
@@ -1448,7 +1448,7 @@ const solanaToolDefinitions = [
|
|
|
1448
1448
|
},
|
|
1449
1449
|
{
|
|
1450
1450
|
name: "flash_trade_open_position",
|
|
1451
|
-
description: "Preview, prepare, or execute a Flash Trade
|
|
1451
|
+
description: "Preview, prepare, or execute a Flash Trade perpetual open on Solana mainnet using a supported Flash collateral.",
|
|
1452
1452
|
optional: true,
|
|
1453
1453
|
parameters: {
|
|
1454
1454
|
type: "object",
|
|
@@ -1463,7 +1463,7 @@ const solanaToolDefinitions = [
|
|
|
1463
1463
|
},
|
|
1464
1464
|
collateral_symbol: {
|
|
1465
1465
|
type: "string",
|
|
1466
|
-
description: "
|
|
1466
|
+
description: "Flash collateral symbol, for example SOL for SOL longs or USDC for SOL shorts.",
|
|
1467
1467
|
},
|
|
1468
1468
|
collateral_amount_raw: {
|
|
1469
1469
|
type: "string",
|
|
@@ -1498,7 +1498,7 @@ const solanaToolDefinitions = [
|
|
|
1498
1498
|
},
|
|
1499
1499
|
{
|
|
1500
1500
|
name: "flash_trade_close_position",
|
|
1501
|
-
description: "Preview, prepare, or execute a Flash Trade
|
|
1501
|
+
description: "Preview, prepare, or execute a Flash Trade perpetual close on Solana mainnet.",
|
|
1502
1502
|
optional: true,
|
|
1503
1503
|
parameters: {
|
|
1504
1504
|
type: "object",
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## v0.1.17 - 2026-05-17
|
|
6
|
+
|
|
7
|
+
- Added Flash Trade collateral-aware perp opens so the Solana wallet flow can
|
|
8
|
+
use the collateral supported by the selected Flash market instead of forcing
|
|
9
|
+
`collateral_symbol == market_symbol`.
|
|
10
|
+
- Unblocked docs-aligned short-position previews, prepares, and execution for
|
|
11
|
+
markets such as `SOL short / USDC collateral`.
|
|
12
|
+
- Tightened Flash market selection to match on `market_symbol + side +
|
|
13
|
+
collateral_symbol`, preventing incorrect market resolution when the same
|
|
14
|
+
asset has multiple collateral paths.
|
|
15
|
+
- Updated the OpenClaw tool descriptions and Flash SDK bridge docs to reflect
|
|
16
|
+
supported Flash collateral paths instead of the earlier same-symbol-only
|
|
17
|
+
limitation.
|
|
18
|
+
|
|
5
19
|
## v0.1.16 - 2026-05-16
|
|
6
20
|
|
|
7
21
|
- Added Flash Trade perpetuals support to the Solana wallet flow, including
|
package/agent-wallet/README.md
CHANGED
|
@@ -546,7 +546,7 @@ Operational notes:
|
|
|
546
546
|
- `FLASH_SDK_BRIDGE_MODE=mock` provides deterministic smoke behavior without SDK dependencies
|
|
547
547
|
- `FLASH_SDK_BRIDGE_MODE=real` now produces real Flash SDK quotes for preview and real versioned transaction builds for prepare/execute
|
|
548
548
|
- the backend locally verifies the provider-built Flash transaction, applies only the wallet signature, and requires a host-issued approval token before broadcast; tool-level `prepare` still strips signed transaction bytes before returning to the agent
|
|
549
|
-
- current real-mode constraints are intentionally narrow: mainnet only,
|
|
549
|
+
- current real-mode constraints are intentionally narrow: mainnet only, Flash-supported market collateral only, and whole-number raw collateral strings for opens
|
|
550
550
|
|
|
551
551
|
## Native staking coverage
|
|
552
552
|
|
|
@@ -1956,7 +1956,7 @@ class OpenClawWalletAdapter:
|
|
|
1956
1956
|
AgentToolSpec(
|
|
1957
1957
|
name="flash_trade_open_position",
|
|
1958
1958
|
description=(
|
|
1959
|
-
"Preview, prepare, or execute a Flash Trade
|
|
1959
|
+
"Preview, prepare, or execute a Flash Trade perpetual open on Solana mainnet using a supported Flash collateral."
|
|
1960
1960
|
),
|
|
1961
1961
|
input_schema={
|
|
1962
1962
|
"type": "object",
|
|
@@ -1971,7 +1971,7 @@ class OpenClawWalletAdapter:
|
|
|
1971
1971
|
},
|
|
1972
1972
|
"collateral_symbol": {
|
|
1973
1973
|
"type": "string",
|
|
1974
|
-
"description": "
|
|
1974
|
+
"description": "Flash collateral symbol, for example SOL for SOL longs or USDC for SOL shorts.",
|
|
1975
1975
|
},
|
|
1976
1976
|
"collateral_amount_raw": {
|
|
1977
1977
|
"type": "string",
|
|
@@ -2023,7 +2023,7 @@ class OpenClawWalletAdapter:
|
|
|
2023
2023
|
AgentToolSpec(
|
|
2024
2024
|
name="flash_trade_close_position",
|
|
2025
2025
|
description=(
|
|
2026
|
-
"Preview, prepare, or execute a Flash Trade
|
|
2026
|
+
"Preview, prepare, or execute a Flash Trade perpetual close on Solana mainnet."
|
|
2027
2027
|
),
|
|
2028
2028
|
input_schema={
|
|
2029
2029
|
"type": "object",
|
|
@@ -127,7 +127,7 @@ async def _call_bridge(payload: dict[str, Any]) -> dict[str, Any]:
|
|
|
127
127
|
return decoded
|
|
128
128
|
|
|
129
129
|
|
|
130
|
-
async def
|
|
130
|
+
async def preview_open_position(
|
|
131
131
|
*,
|
|
132
132
|
owner: str,
|
|
133
133
|
pool_name: str,
|
|
@@ -139,7 +139,7 @@ async def preview_open_position_same_collateral(
|
|
|
139
139
|
network: str,
|
|
140
140
|
) -> dict[str, Any]:
|
|
141
141
|
payload = {
|
|
142
|
-
"action": "
|
|
142
|
+
"action": "preview_open_position",
|
|
143
143
|
"owner": owner,
|
|
144
144
|
"pool_name": pool_name,
|
|
145
145
|
"market_symbol": market_symbol,
|
|
@@ -153,6 +153,29 @@ async def preview_open_position_same_collateral(
|
|
|
153
153
|
return _unwrap_bridge_payload(response, operation="Flash open-position preview")
|
|
154
154
|
|
|
155
155
|
|
|
156
|
+
async def preview_open_position_same_collateral(
|
|
157
|
+
*,
|
|
158
|
+
owner: str,
|
|
159
|
+
pool_name: str,
|
|
160
|
+
market_symbol: str,
|
|
161
|
+
collateral_symbol: str,
|
|
162
|
+
collateral_amount_raw: str,
|
|
163
|
+
leverage: str,
|
|
164
|
+
side: str,
|
|
165
|
+
network: str,
|
|
166
|
+
) -> dict[str, Any]:
|
|
167
|
+
return await preview_open_position(
|
|
168
|
+
owner=owner,
|
|
169
|
+
pool_name=pool_name,
|
|
170
|
+
market_symbol=market_symbol,
|
|
171
|
+
collateral_symbol=collateral_symbol,
|
|
172
|
+
collateral_amount_raw=collateral_amount_raw,
|
|
173
|
+
leverage=leverage,
|
|
174
|
+
side=side,
|
|
175
|
+
network=network,
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
|
|
156
179
|
async def get_markets(
|
|
157
180
|
*,
|
|
158
181
|
pool_name: str | None,
|
|
@@ -205,7 +228,7 @@ async def preview_close_position_same_collateral(
|
|
|
205
228
|
return _unwrap_bridge_payload(response, operation="Flash close-position preview")
|
|
206
229
|
|
|
207
230
|
|
|
208
|
-
async def
|
|
231
|
+
async def prepare_open_position(
|
|
209
232
|
*,
|
|
210
233
|
owner: str,
|
|
211
234
|
pool_name: str,
|
|
@@ -217,7 +240,7 @@ async def prepare_open_position_same_collateral(
|
|
|
217
240
|
network: str,
|
|
218
241
|
) -> dict[str, Any]:
|
|
219
242
|
payload = {
|
|
220
|
-
"action": "
|
|
243
|
+
"action": "prepare_open_position",
|
|
221
244
|
"owner": owner,
|
|
222
245
|
"pool_name": pool_name,
|
|
223
246
|
"market_symbol": market_symbol,
|
|
@@ -231,6 +254,29 @@ async def prepare_open_position_same_collateral(
|
|
|
231
254
|
return _unwrap_bridge_payload(response, operation="Flash open-position prepare")
|
|
232
255
|
|
|
233
256
|
|
|
257
|
+
async def prepare_open_position_same_collateral(
|
|
258
|
+
*,
|
|
259
|
+
owner: str,
|
|
260
|
+
pool_name: str,
|
|
261
|
+
market_symbol: str,
|
|
262
|
+
collateral_symbol: str,
|
|
263
|
+
collateral_amount_raw: str,
|
|
264
|
+
leverage: str,
|
|
265
|
+
side: str,
|
|
266
|
+
network: str,
|
|
267
|
+
) -> dict[str, Any]:
|
|
268
|
+
return await prepare_open_position(
|
|
269
|
+
owner=owner,
|
|
270
|
+
pool_name=pool_name,
|
|
271
|
+
market_symbol=market_symbol,
|
|
272
|
+
collateral_symbol=collateral_symbol,
|
|
273
|
+
collateral_amount_raw=collateral_amount_raw,
|
|
274
|
+
leverage=leverage,
|
|
275
|
+
side=side,
|
|
276
|
+
network=network,
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
|
|
234
280
|
async def prepare_close_position_same_collateral(
|
|
235
281
|
*,
|
|
236
282
|
owner: str,
|
|
@@ -2600,10 +2600,6 @@ class SolanaWalletBackend(AgentWalletBackend):
|
|
|
2600
2600
|
collateral_symbol,
|
|
2601
2601
|
field_name="collateral_symbol",
|
|
2602
2602
|
)
|
|
2603
|
-
if normalized_collateral_symbol != normalized_market_symbol:
|
|
2604
|
-
raise WalletBackendError(
|
|
2605
|
-
"Phase 2 Flash preview currently supports only same-collateral opens where collateral_symbol matches market_symbol."
|
|
2606
|
-
)
|
|
2607
2603
|
normalized_collateral_amount_raw = _require_positive_integer_string(
|
|
2608
2604
|
collateral_amount_raw,
|
|
2609
2605
|
field_name="collateral_amount_raw",
|
|
@@ -2616,15 +2612,19 @@ class SolanaWalletBackend(AgentWalletBackend):
|
|
|
2616
2612
|
item
|
|
2617
2613
|
for item in market_snapshot["markets"]
|
|
2618
2614
|
if isinstance(item, dict)
|
|
2619
|
-
and str(item.get("symbol") or "").strip().upper()
|
|
2615
|
+
and str(item.get("market_symbol") or item.get("symbol") or "").strip().upper()
|
|
2616
|
+
== normalized_market_symbol
|
|
2617
|
+
and str(item.get("side") or "").strip().lower() == normalized_side
|
|
2618
|
+
and str(item.get("collateral_symbol") or "").strip().upper()
|
|
2619
|
+
== normalized_collateral_symbol
|
|
2620
2620
|
),
|
|
2621
2621
|
None,
|
|
2622
2622
|
)
|
|
2623
2623
|
if matching_market is None:
|
|
2624
2624
|
raise WalletBackendError(
|
|
2625
|
-
"Requested Flash market is not available in the selected pool."
|
|
2625
|
+
"Requested Flash market is not available in the selected pool for the requested collateral and side."
|
|
2626
2626
|
)
|
|
2627
|
-
bridge_preview = await flash_sdk_bridge.
|
|
2627
|
+
bridge_preview = await flash_sdk_bridge.preview_open_position(
|
|
2628
2628
|
owner=owner,
|
|
2629
2629
|
pool_name=normalized_pool_name,
|
|
2630
2630
|
market_symbol=normalized_market_symbol,
|
|
@@ -2927,7 +2927,7 @@ class SolanaWalletBackend(AgentWalletBackend):
|
|
|
2927
2927
|
leverage=leverage,
|
|
2928
2928
|
side=side,
|
|
2929
2929
|
)
|
|
2930
|
-
bridge_prepared = await flash_sdk_bridge.
|
|
2930
|
+
bridge_prepared = await flash_sdk_bridge.prepare_open_position(
|
|
2931
2931
|
owner=str(preview["owner"]),
|
|
2932
2932
|
pool_name=str(preview["pool_name"]),
|
|
2933
2933
|
market_symbol=str(preview["market_symbol"]),
|
|
@@ -2948,7 +2948,7 @@ class SolanaWalletBackend(AgentWalletBackend):
|
|
|
2948
2948
|
self,
|
|
2949
2949
|
preview: dict[str, Any],
|
|
2950
2950
|
) -> dict[str, Any]:
|
|
2951
|
-
bridge_prepared = await flash_sdk_bridge.
|
|
2951
|
+
bridge_prepared = await flash_sdk_bridge.prepare_open_position(
|
|
2952
2952
|
owner=str(preview["owner"]),
|
|
2953
2953
|
pool_name=str(preview["pool_name"]),
|
|
2954
2954
|
market_symbol=str(preview["market_symbol"]),
|
|
@@ -13,7 +13,7 @@ Current goals:
|
|
|
13
13
|
- `FLASH_SDK_BRIDGE_MODE=mock`
|
|
14
14
|
Returns deterministic payloads for local smoke checks without installing SDK dependencies.
|
|
15
15
|
- `FLASH_SDK_BRIDGE_MODE=real`
|
|
16
|
-
Loads `flash-sdk` and validates runtime config. This mode now supports market discovery, user-position discovery, open/close previews, and unsigned transaction preparation for the
|
|
16
|
+
Loads `flash-sdk` and validates runtime config. This mode now supports market discovery, user-position discovery, open/close previews, and unsigned transaction preparation for Flash perps using the collateral supported by the selected Flash market.
|
|
17
17
|
|
|
18
18
|
## Command
|
|
19
19
|
|
|
@@ -28,6 +28,6 @@ For local smoke:
|
|
|
28
28
|
```bash
|
|
29
29
|
FLASH_SDK_BRIDGE_MODE=mock \
|
|
30
30
|
node agent-wallet/scripts/flash-sdk-bridge/bridge.mjs <<'EOF'
|
|
31
|
-
{"action":"
|
|
31
|
+
{"action":"preview_open_position","owner":"Fake11111111111111111111111111111111111111111","pool_name":"Crypto.1","market_symbol":"SOL","collateral_symbol":"USDC","collateral_amount_raw":"5000000","leverage":"2","side":"short","network":"mainnet"}
|
|
32
32
|
EOF
|
|
33
33
|
```
|
|
@@ -110,7 +110,7 @@ function mockResponse(normalized) {
|
|
|
110
110
|
pool_name: normalized.poolName ?? "Crypto.1",
|
|
111
111
|
symbol: "SOL",
|
|
112
112
|
market_symbol: "SOL",
|
|
113
|
-
collateral_symbol: "
|
|
113
|
+
collateral_symbol: "USDC",
|
|
114
114
|
side: "short",
|
|
115
115
|
market_address: "MockFlashMarketShort1111111111111111111111111",
|
|
116
116
|
},
|
|
@@ -145,7 +145,10 @@ function mockResponse(normalized) {
|
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
if (
|
|
148
|
+
if (
|
|
149
|
+
normalized.action === "preview_open_position" ||
|
|
150
|
+
normalized.action === "preview_open_position_same_collateral"
|
|
151
|
+
) {
|
|
149
152
|
return {
|
|
150
153
|
ok: true,
|
|
151
154
|
preview: {
|
|
@@ -177,7 +180,10 @@ function mockResponse(normalized) {
|
|
|
177
180
|
};
|
|
178
181
|
}
|
|
179
182
|
|
|
180
|
-
if (
|
|
183
|
+
if (
|
|
184
|
+
normalized.action === "prepare_open_position" ||
|
|
185
|
+
normalized.action === "prepare_open_position_same_collateral"
|
|
186
|
+
) {
|
|
181
187
|
return {
|
|
182
188
|
ok: true,
|
|
183
189
|
prepared: {
|
|
@@ -608,12 +614,6 @@ async function getOpenPositionPreview(runtime, normalized) {
|
|
|
608
614
|
"collateral_symbol, collateral_amount_raw, and leverage are required for open preview",
|
|
609
615
|
);
|
|
610
616
|
}
|
|
611
|
-
if (normalized.collateralSymbol !== normalized.marketSymbol) {
|
|
612
|
-
throw new Error(
|
|
613
|
-
"Current bridge MVP supports only same-collateral opens where collateral_symbol matches market_symbol",
|
|
614
|
-
);
|
|
615
|
-
}
|
|
616
|
-
|
|
617
617
|
const { BN } = runtime;
|
|
618
618
|
const privilege = runtime.flashSdk.Privilege.None;
|
|
619
619
|
const ownerPublicKey = runtime.provider.wallet.publicKey;
|
|
@@ -810,12 +810,6 @@ async function prepareOpenPosition(runtime, normalized) {
|
|
|
810
810
|
"collateral_symbol, collateral_amount_raw, and leverage are required for open prepare",
|
|
811
811
|
);
|
|
812
812
|
}
|
|
813
|
-
if (normalized.collateralSymbol !== normalized.marketSymbol) {
|
|
814
|
-
throw new Error(
|
|
815
|
-
"Current bridge MVP supports only same-collateral opens where collateral_symbol matches market_symbol",
|
|
816
|
-
);
|
|
817
|
-
}
|
|
818
|
-
|
|
819
813
|
const { BN } = runtime;
|
|
820
814
|
const privilege = runtime.flashSdk.Privilege.None;
|
|
821
815
|
const ownerPublicKey = runtime.provider.wallet.publicKey;
|
|
@@ -1113,13 +1107,19 @@ async function realResponse(normalized) {
|
|
|
1113
1107
|
return getPositionsReal(normalized);
|
|
1114
1108
|
}
|
|
1115
1109
|
const runtime = await buildRuntimeContext(normalized);
|
|
1116
|
-
if (
|
|
1110
|
+
if (
|
|
1111
|
+
normalized.action === "preview_open_position" ||
|
|
1112
|
+
normalized.action === "preview_open_position_same_collateral"
|
|
1113
|
+
) {
|
|
1117
1114
|
return getOpenPositionPreview(runtime, normalized);
|
|
1118
1115
|
}
|
|
1119
1116
|
if (normalized.action === "preview_close_position_same_collateral") {
|
|
1120
1117
|
return getClosePositionPreview(runtime, normalized);
|
|
1121
1118
|
}
|
|
1122
|
-
if (
|
|
1119
|
+
if (
|
|
1120
|
+
normalized.action === "prepare_open_position" ||
|
|
1121
|
+
normalized.action === "prepare_open_position_same_collateral"
|
|
1122
|
+
) {
|
|
1123
1123
|
return prepareOpenPosition(runtime, normalized);
|
|
1124
1124
|
}
|
|
1125
1125
|
if (normalized.action === "prepare_close_position_same_collateral") {
|