@onecraft/wallet 0.0.0-stage → 0.1.145
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/.claude-plugin/marketplace.json +20 -0
- package/.openclaw/AGENTS.md +100 -0
- package/.openclaw/extensions/agent-wallet/README.md +195 -0
- package/.openclaw/extensions/agent-wallet/dist/index.js +2198 -0
- package/.openclaw/extensions/agent-wallet/index.ts +2198 -0
- package/.openclaw/extensions/agent-wallet/openclaw.plugin.json +251 -0
- package/.openclaw/extensions/agent-wallet/package.json +49 -0
- package/.openclaw/extensions/agent-wallet/skills/cards/SKILL.md +211 -0
- package/.openclaw/extensions/agent-wallet/skills/wallet-operator/SKILL.md +30 -0
- package/CHANGELOG.md +1232 -0
- package/LICENSE +104 -0
- package/README.md +193 -2
- package/VERSION +1 -0
- package/agent-wallet/.env.example +63 -0
- package/agent-wallet/AGENTS.md +130 -0
- package/agent-wallet/CARD_VAULT.md +640 -0
- package/agent-wallet/README.md +615 -0
- package/agent-wallet/UPGRADE_COMPATIBILITY.md +66 -0
- package/agent-wallet/agent_wallet/__init__.py +16 -0
- package/agent-wallet/agent_wallet/approval.py +165 -0
- package/agent-wallet/agent_wallet/autonomous_permissions.py +281 -0
- package/agent-wallet/agent_wallet/autonomous_policy.py +305 -0
- package/agent-wallet/agent_wallet/autonomous_session.py +236 -0
- package/agent-wallet/agent_wallet/boot_key_migration.py +155 -0
- package/agent-wallet/agent_wallet/boot_key_recovery.py +57 -0
- package/agent-wallet/agent_wallet/bootstrap.py +194 -0
- package/agent-wallet/agent_wallet/card_catalog.py +243 -0
- package/agent-wallet/agent_wallet/card_runtime_secrets.py +108 -0
- package/agent-wallet/agent_wallet/card_vault.py +331 -0
- package/agent-wallet/agent_wallet/card_vault_cli.py +174 -0
- package/agent-wallet/agent_wallet/card_vault_import.py +65 -0
- package/agent-wallet/agent_wallet/card_vault_keychain.py +239 -0
- package/agent-wallet/agent_wallet/config.py +719 -0
- package/agent-wallet/agent_wallet/connector_cli.py +198 -0
- package/agent-wallet/agent_wallet/connectors/__init__.py +28 -0
- package/agent-wallet/agent_wallet/connectors/catalog.py +68 -0
- package/agent-wallet/agent_wallet/connectors/client.py +308 -0
- package/agent-wallet/agent_wallet/connectors/intent_policy.py +243 -0
- package/agent-wallet/agent_wallet/connectors/manifest.py +192 -0
- package/agent-wallet/agent_wallet/connectors/registry.py +341 -0
- package/agent-wallet/agent_wallet/encrypted_storage.py +314 -0
- package/agent-wallet/agent_wallet/evm_user_wallets.py +910 -0
- package/agent-wallet/agent_wallet/exceptions.py +10 -0
- package/agent-wallet/agent_wallet/file_ops.py +34 -0
- package/agent-wallet/agent_wallet/http_client.py +25 -0
- package/agent-wallet/agent_wallet/kernel_browser.py +479 -0
- package/agent-wallet/agent_wallet/kernel_cli.py +57 -0
- package/agent-wallet/agent_wallet/kernel_gateway.py +95 -0
- package/agent-wallet/agent_wallet/keystore.py +503 -0
- package/agent-wallet/agent_wallet/laso_card_vault.py +246 -0
- package/agent-wallet/agent_wallet/models.py +66 -0
- package/agent-wallet/agent_wallet/morpho_monitor.py +298 -0
- package/agent-wallet/agent_wallet/nonce_registry.py +59 -0
- package/agent-wallet/agent_wallet/openclaw_adapter.py +9129 -0
- package/agent-wallet/agent_wallet/openclaw_cli.py +658 -0
- package/agent-wallet/agent_wallet/openclaw_runtime.py +194 -0
- package/agent-wallet/agent_wallet/plugin_bundle.py +44 -0
- package/agent-wallet/agent_wallet/providers/__init__.py +1 -0
- package/agent-wallet/agent_wallet/providers/bags.py +202 -0
- package/agent-wallet/agent_wallet/providers/dexscreener.py +147 -0
- package/agent-wallet/agent_wallet/providers/evm_activity.py +257 -0
- package/agent-wallet/agent_wallet/providers/evm_portfolio.py +459 -0
- package/agent-wallet/agent_wallet/providers/imd.py +720 -0
- package/agent-wallet/agent_wallet/providers/jupiter.py +519 -0
- package/agent-wallet/agent_wallet/providers/kamino.py +404 -0
- package/agent-wallet/agent_wallet/providers/lifi.py +302 -0
- package/agent-wallet/agent_wallet/providers/solana_rpc.py +447 -0
- package/agent-wallet/agent_wallet/providers/tokenized_stocks.py +189 -0
- package/agent-wallet/agent_wallet/providers/wdk_evm_local.py +346 -0
- package/agent-wallet/agent_wallet/providers/x402.py +1972 -0
- package/agent-wallet/agent_wallet/sealed_keys.py +118 -0
- package/agent-wallet/agent_wallet/solana_stake.py +103 -0
- package/agent-wallet/agent_wallet/solana_tx.py +93 -0
- package/agent-wallet/agent_wallet/spending_limits.py +119 -0
- package/agent-wallet/agent_wallet/telemetry.py +481 -0
- package/agent-wallet/agent_wallet/transaction_policy.py +573 -0
- package/agent-wallet/agent_wallet/update_check.py +190 -0
- package/agent-wallet/agent_wallet/user_wallets.py +573 -0
- package/agent-wallet/agent_wallet/validation.py +31 -0
- package/agent-wallet/agent_wallet/vault_executor.py +456 -0
- package/agent-wallet/agent_wallet/wallet_layer/__init__.py +1 -0
- package/agent-wallet/agent_wallet/wallet_layer/base.py +1204 -0
- package/agent-wallet/agent_wallet/wallet_layer/base58.py +44 -0
- package/agent-wallet/agent_wallet/wallet_layer/factory.py +117 -0
- package/agent-wallet/agent_wallet/wallet_layer/solana.py +5246 -0
- package/agent-wallet/agent_wallet/wallet_layer/wdk_evm.py +2705 -0
- package/agent-wallet/examples/bootstrap_wallet.py +21 -0
- package/agent-wallet/examples/openclaw_runtime_onboarding.py +28 -0
- package/agent-wallet/examples/openclaw_user_wallet_example.py +31 -0
- package/agent-wallet/examples/openclaw_wallet_adapter_example.py +33 -0
- package/agent-wallet/openclaw.plugin.json +118 -0
- package/agent-wallet/pyproject.toml +36 -0
- package/agent-wallet/scripts/bootstrap_openclaw_evm.py +312 -0
- package/agent-wallet/scripts/build_release_bundle.py +210 -0
- package/agent-wallet/scripts/finalize_openclaw_local_wallet_config.py +121 -0
- package/agent-wallet/scripts/install_agent_wallet.py +1357 -0
- package/agent-wallet/scripts/install_openclaw_local_config.py +421 -0
- package/agent-wallet/scripts/install_openclaw_sealed_keys.py +117 -0
- package/agent-wallet/scripts/manage_openclaw_evm_wallet.py +333 -0
- package/agent-wallet/scripts/security_utils.py +37 -0
- package/agent-wallet/scripts/setup_evm_wallet.sh +140 -0
- package/agent-wallet/scripts/switch_openclaw_wallet_network.py +109 -0
- package/agent-wallet/skills/wallet-operator/SKILL.md +157 -0
- package/bin/lib/boot-key.mjs +184 -0
- package/bin/lib/evm-daemon.mjs +389 -0
- package/bin/lib/host-detection.mjs +259 -0
- package/bin/lib/integrations.mjs +578 -0
- package/bin/lib/release-python.mjs +9 -0
- package/bin/lib/update-transaction.mjs +235 -0
- package/bin/openclaw-agent-wallet.mjs +3354 -0
- package/claude-code/plugins/agent-wallet/.claude-plugin/plugin.json +19 -0
- package/claude-code/plugins/agent-wallet/.mcp.json +14 -0
- package/claude-code/plugins/agent-wallet/AGENTLAYER_AGENT_GUIDE.md +282 -0
- package/claude-code/plugins/agent-wallet/README.md +134 -0
- package/claude-code/plugins/agent-wallet/commands/agentlayer-autonomous-approve.md +39 -0
- package/claude-code/plugins/agent-wallet/commands/agentlayer-autonomous-revoke.md +17 -0
- package/claude-code/plugins/agent-wallet/commands/cards.md +129 -0
- package/claude-code/plugins/agent-wallet/commands/guide.md +40 -0
- package/claude-code/plugins/agent-wallet/commands/imd.md +125 -0
- package/claude-code/plugins/agent-wallet/commands/wallet-base.md +60 -0
- package/claude-code/plugins/agent-wallet/commands/wallet-ethereum.md +37 -0
- package/claude-code/plugins/agent-wallet/commands/wallet-evm.md +39 -0
- package/claude-code/plugins/agent-wallet/commands/wallet-setup.md +25 -0
- package/claude-code/plugins/agent-wallet/commands/wallet-sol.md +51 -0
- package/claude-code/plugins/agent-wallet/commands/wallet-statusline.md +34 -0
- package/claude-code/plugins/agent-wallet/commands/x402.md +121 -0
- package/claude-code/plugins/agent-wallet/commands/yield.md +62 -0
- package/claude-code/plugins/agent-wallet/hooks/hooks.json +16 -0
- package/claude-code/plugins/agent-wallet/scripts/bootstrap_backend.sh +136 -0
- package/claude-code/plugins/agent-wallet/scripts/enable_statusline.py +52 -0
- package/claude-code/plugins/agent-wallet/scripts/resolve_wallet_addresses.py +69 -0
- package/claude-code/plugins/agent-wallet/scripts/run_mcp.sh +66 -0
- package/claude-code/plugins/agent-wallet/scripts/wallet_statusline.py +130 -0
- package/claude-code/plugins/agent-wallet/scripts/wallet_statusline_setup.sh +40 -0
- package/claude-code/plugins/agent-wallet/skills/wallet-operator/SKILL.md +21 -0
- package/codex/plugins/agent-wallet/.codex-plugin/plugin.json +37 -0
- package/codex/plugins/agent-wallet/.mcp.json +15 -0
- package/codex/plugins/agent-wallet/README.md +158 -0
- package/codex/plugins/agent-wallet/scripts/run_mcp.sh +47 -0
- package/codex/plugins/agent-wallet/server.py +1797 -0
- package/codex/plugins/agent-wallet/skills/cards/SKILL.md +225 -0
- package/codex/plugins/agent-wallet/skills/imd/SKILL.md +145 -0
- package/codex/plugins/agent-wallet/skills/wallet-base/SKILL.md +56 -0
- package/codex/plugins/agent-wallet/skills/wallet-operator/SKILL.md +85 -0
- package/codex/plugins/agent-wallet/skills/wallet-sol/SKILL.md +29 -0
- package/codex/plugins/agent-wallet/skills/x402/SKILL.md +159 -0
- package/codex/plugins/agent-wallet/skills/yield/SKILL.md +65 -0
- package/connectors/AGENTS.md +37 -0
- package/connectors/DEVELOPER_GUIDE.md +131 -0
- package/connectors/README.md +139 -0
- package/connectors/READ_ONLY_BETA.md +54 -0
- package/connectors/RELEASING.md +48 -0
- package/connectors/conformance/README.md +31 -0
- package/connectors/conformance/package.json +54 -0
- package/connectors/conformance/scripts/sync-license.mjs +3 -0
- package/connectors/conformance/scripts/sync-spec.mjs +16 -0
- package/connectors/conformance/src/cli.ts +43 -0
- package/connectors/conformance/src/index.ts +7 -0
- package/connectors/conformance/src/runner.ts +314 -0
- package/connectors/conformance/src/types.ts +27 -0
- package/connectors/conformance/test/fixtures/invalid-response-identity.json +14 -0
- package/connectors/conformance/test/fixtures/missing-tool-fixture.json +4 -0
- package/connectors/conformance/test/runner.test.mjs +151 -0
- package/connectors/conformance/tsconfig.json +17 -0
- package/connectors/examples/reference-crypto-data/Dockerfile +21 -0
- package/connectors/examples/reference-crypto-data/README.md +51 -0
- package/connectors/examples/reference-crypto-data/conformance.json +11 -0
- package/connectors/examples/reference-crypto-data/connector.json +95 -0
- package/connectors/examples/reference-crypto-data/package.json +21 -0
- package/connectors/examples/reference-crypto-data/railway.toml +9 -0
- package/connectors/examples/reference-crypto-data/src/connector.ts +137 -0
- package/connectors/examples/reference-crypto-data/src/server.ts +13 -0
- package/connectors/examples/reference-crypto-data/test/connector.test.mjs +97 -0
- package/connectors/examples/reference-crypto-data/tsconfig.json +17 -0
- package/connectors/package-lock.json +561 -0
- package/connectors/package.json +19 -0
- package/connectors/scripts/smoke-packed-packages.mjs +121 -0
- package/connectors/sdk-typescript/README.md +47 -0
- package/connectors/sdk-typescript/package.json +49 -0
- package/connectors/sdk-typescript/scripts/sync-license.mjs +3 -0
- package/connectors/sdk-typescript/src/connector.ts +204 -0
- package/connectors/sdk-typescript/src/errors.ts +11 -0
- package/connectors/sdk-typescript/src/http.ts +116 -0
- package/connectors/sdk-typescript/src/index.ts +26 -0
- package/connectors/sdk-typescript/src/types.ts +101 -0
- package/connectors/sdk-typescript/test/sdk.test.mjs +181 -0
- package/connectors/sdk-typescript/tsconfig.json +21 -0
- package/connectors/spec/connector-manifest.schema.json +340 -0
- package/connectors/spec/connector-protocol.md +159 -0
- package/connectors/spec/transaction-intent.schema.json +281 -0
- package/connectors/templates/read-only/.env.example +1 -0
- package/connectors/templates/read-only/Dockerfile +11 -0
- package/connectors/templates/read-only/README.md +33 -0
- package/connectors/templates/read-only/conformance.json +11 -0
- package/connectors/templates/read-only/connector.json +64 -0
- package/connectors/templates/read-only/package.json +21 -0
- package/connectors/templates/read-only/railway.toml +9 -0
- package/connectors/templates/read-only/src/connector.ts +61 -0
- package/connectors/templates/read-only/src/server.ts +14 -0
- package/connectors/templates/read-only/test/connector.test.mjs +62 -0
- package/connectors/templates/read-only/tsconfig.json +17 -0
- package/cursor/plugins/agent-wallet/.cursor-plugin/plugin.json +14 -0
- package/cursor/plugins/agent-wallet/README.md +62 -0
- package/cursor/plugins/agent-wallet/mcp.json +16 -0
- package/cursor/plugins/agent-wallet/scripts/run_mcp.sh +33 -0
- package/cursor/plugins/agent-wallet/server.py +33 -0
- package/cursor/plugins/agent-wallet/skills/cards/SKILL.md +210 -0
- package/cursor/plugins/agent-wallet/skills/wallet-base/SKILL.md +56 -0
- package/cursor/plugins/agent-wallet/skills/wallet-operator/SKILL.md +23 -0
- package/cursor/plugins/agent-wallet/skills/wallet-sol/SKILL.md +29 -0
- package/cursor/plugins/agent-wallet/skills/x402/SKILL.md +130 -0
- package/hermes/plugins/agent_wallet/README.md +54 -0
- package/hermes/plugins/agent_wallet/__init__.py +55 -0
- package/hermes/plugins/agent_wallet/plugin.yaml +9 -0
- package/hermes/plugins/agent_wallet/schemas.py +211 -0
- package/hermes/plugins/agent_wallet/tools.py +622 -0
- package/install-from-github.sh +139 -0
- package/integrations/hedera/treasury-guard/README.md +92 -0
- package/integrations/hedera/treasury-guard/examples/treasury-policy.example.json +9 -0
- package/integrations/hedera/treasury-guard/package-lock.json +880 -0
- package/integrations/hedera/treasury-guard/package.json +8 -0
- package/integrations/hedera/treasury-guard/skills/onecraft-hedera-treasury/SKILL.md +22 -0
- package/integrations/hedera/treasury-guard/src/hedera-mirror-client.mjs +106 -0
- package/integrations/hedera/treasury-guard/src/hedera-signer.mjs +120 -0
- package/integrations/hedera/treasury-guard/src/treasury-cli.mjs +177 -0
- package/integrations/hedera/treasury-guard/src/treasury-policy.mjs +155 -0
- package/mcp/README.md +39 -0
- package/mcp/scripts/run_mcp.sh +37 -0
- package/mcp/server.py +33 -0
- package/package.json +106 -4
- package/scripts/check_release_version.mjs +72 -0
- package/scripts/version_targets.mjs +60 -0
- package/setup.sh +87 -0
- package/wdk-evm-wallet/.env.example +38 -0
- package/wdk-evm-wallet/README.md +254 -0
- package/wdk-evm-wallet/bootstrap.sh +8 -0
- package/wdk-evm-wallet/package-lock.json +2359 -0
- package/wdk-evm-wallet/package.json +43 -0
- package/wdk-evm-wallet/run-local.sh +12 -0
- package/wdk-evm-wallet/src/config.js +461 -0
- package/wdk-evm-wallet/src/imd.js +231 -0
- package/wdk-evm-wallet/src/json.js +35 -0
- package/wdk-evm-wallet/src/local_vault.js +407 -0
- package/wdk-evm-wallet/src/network_state.js +96 -0
- package/wdk-evm-wallet/src/pending_transactions.js +148 -0
- package/wdk-evm-wallet/src/server.js +849 -0
- package/wdk-evm-wallet/src/shutdown.js +63 -0
- package/wdk-evm-wallet/src/wdk_evm_wallet.js +10036 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"""Host-side onboarding helpers for wiring agent-wallet into OpenClaw."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from agent_wallet.approval import issue_approval_token
|
|
9
|
+
from agent_wallet.boot_key_migration import migrate_boot_key_to_keystore
|
|
10
|
+
from agent_wallet.config import (
|
|
11
|
+
normalize_evm_network,
|
|
12
|
+
resolve_wdk_evm_service_url,
|
|
13
|
+
settings,
|
|
14
|
+
)
|
|
15
|
+
from agent_wallet.evm_user_wallets import ensure_user_evm_wallet_ready
|
|
16
|
+
from agent_wallet.models import OpenClawWalletSessionMetadata
|
|
17
|
+
from agent_wallet.openclaw_adapter import OpenClawWalletAdapter
|
|
18
|
+
from agent_wallet.plugin_bundle import build_openclaw_plugin_bundle
|
|
19
|
+
from agent_wallet.providers.wdk_evm_local import WdkEvmLocalClient
|
|
20
|
+
from agent_wallet.user_wallets import create_openclaw_solana_backend
|
|
21
|
+
from agent_wallet.wallet_layer.base import AgentWalletBackend, WalletBackendError
|
|
22
|
+
from agent_wallet.wallet_layer.wdk_evm import WdkEvmLocalWalletBackend
|
|
23
|
+
|
|
24
|
+
_boot_key_migration_done = False
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def ensure_boot_key_migrated_once() -> None:
|
|
28
|
+
"""Run the boot-key keystore migration at most once per process. Never raises.
|
|
29
|
+
|
|
30
|
+
Best-effort: a failure here must never block wallet onboarding — the legacy
|
|
31
|
+
plaintext sources still resolve via ``resolve_boot_key``.
|
|
32
|
+
"""
|
|
33
|
+
global _boot_key_migration_done
|
|
34
|
+
if _boot_key_migration_done:
|
|
35
|
+
return
|
|
36
|
+
_boot_key_migration_done = True
|
|
37
|
+
try:
|
|
38
|
+
migrate_boot_key_to_keystore()
|
|
39
|
+
except Exception:
|
|
40
|
+
pass
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@dataclass(slots=True)
|
|
44
|
+
class OpenClawWalletRuntimeContext:
|
|
45
|
+
"""Runtime-ready wallet context for a single OpenClaw user session."""
|
|
46
|
+
|
|
47
|
+
user_id: str
|
|
48
|
+
wallet_info: dict[str, str]
|
|
49
|
+
created_now: bool
|
|
50
|
+
backend: AgentWalletBackend
|
|
51
|
+
adapter: OpenClawWalletAdapter
|
|
52
|
+
plugin_bundle: dict[str, Any]
|
|
53
|
+
|
|
54
|
+
def issue_execute_approval(
|
|
55
|
+
self,
|
|
56
|
+
*,
|
|
57
|
+
tool_name: str,
|
|
58
|
+
confirmation_summary: dict[str, Any],
|
|
59
|
+
mainnet_confirmed: bool = False,
|
|
60
|
+
ttl_seconds: int | None = None,
|
|
61
|
+
issued_by: str = "host",
|
|
62
|
+
) -> str:
|
|
63
|
+
"""Issue a host approval token bound to an exact execute operation."""
|
|
64
|
+
return issue_approval_token(
|
|
65
|
+
tool_name=tool_name,
|
|
66
|
+
network=str(getattr(self.backend, "network", "mainnet")),
|
|
67
|
+
summary=confirmation_summary,
|
|
68
|
+
mainnet_confirmed=mainnet_confirmed,
|
|
69
|
+
ttl_seconds=ttl_seconds,
|
|
70
|
+
issued_by=issued_by,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
def session_metadata(self) -> OpenClawWalletSessionMetadata:
|
|
74
|
+
"""Return serializable metadata for host runtime/session storage."""
|
|
75
|
+
tool_names = [tool["name"] for tool in self.plugin_bundle["tools"]]
|
|
76
|
+
capabilities = self.backend.get_capabilities()
|
|
77
|
+
return OpenClawWalletSessionMetadata(
|
|
78
|
+
user_id=self.user_id,
|
|
79
|
+
chain=capabilities.chain,
|
|
80
|
+
network=str(getattr(self.backend, "network", "mainnet")),
|
|
81
|
+
backend=self.backend.name,
|
|
82
|
+
address=self.wallet_info["address"],
|
|
83
|
+
wallet_path=self.wallet_info["path"],
|
|
84
|
+
storage_format=self.wallet_info["storage_format"],
|
|
85
|
+
created_now=self.created_now,
|
|
86
|
+
sign_only=bool(getattr(self.backend, "sign_only", True)),
|
|
87
|
+
rpc_provider_mode=getattr(self.backend, "rpc_provider_mode", None),
|
|
88
|
+
rpc_provider=getattr(self.backend, "rpc_provider", None),
|
|
89
|
+
rpc_transport=getattr(self.backend, "rpc_transport", None),
|
|
90
|
+
swap_provider=getattr(self.backend, "swap_provider", None),
|
|
91
|
+
swap_transport=getattr(self.backend, "swap_transport", None),
|
|
92
|
+
tool_names=tool_names,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
def serializable_bundle(self) -> dict[str, Any]:
|
|
96
|
+
"""Return the plugin bundle without the invoke callable for JSON/session transport."""
|
|
97
|
+
return {
|
|
98
|
+
"manifest": self.plugin_bundle["manifest"],
|
|
99
|
+
"instructions": self.plugin_bundle["instructions"],
|
|
100
|
+
"tools": self.plugin_bundle["tools"],
|
|
101
|
+
"session": self.session_metadata().model_dump(),
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def onboard_openclaw_user_wallet(
|
|
106
|
+
user_id: str,
|
|
107
|
+
*,
|
|
108
|
+
backend: str | None = None,
|
|
109
|
+
sign_only: bool | None = None,
|
|
110
|
+
read_only: bool = False,
|
|
111
|
+
network: str | None = None,
|
|
112
|
+
rpc_url: str | None = None,
|
|
113
|
+
wdk_evm_service_url: str | None = None,
|
|
114
|
+
wdk_evm_wallet_id: str | None = None,
|
|
115
|
+
wdk_evm_account_index: int | None = None,
|
|
116
|
+
) -> OpenClawWalletRuntimeContext:
|
|
117
|
+
"""Provision and assemble a runtime-ready wallet context for one OpenClaw user."""
|
|
118
|
+
ensure_boot_key_migrated_once()
|
|
119
|
+
backend_name = str(backend or settings.agent_wallet_backend).strip().lower()
|
|
120
|
+
effective_sign_only = True if read_only else (
|
|
121
|
+
settings.agent_wallet_sign_only if sign_only is None else sign_only
|
|
122
|
+
)
|
|
123
|
+
if backend_name in {"wdk_evm_local", "wdk-evm-local", "evm_local", "evm-local"}:
|
|
124
|
+
service_url = str(wdk_evm_service_url or resolve_wdk_evm_service_url()).strip()
|
|
125
|
+
account_index = (
|
|
126
|
+
settings.wdk_evm_account_index
|
|
127
|
+
if wdk_evm_account_index is None
|
|
128
|
+
else int(wdk_evm_account_index)
|
|
129
|
+
)
|
|
130
|
+
effective_network = normalize_evm_network(network or settings.solana_network)
|
|
131
|
+
wallet_id = str(wdk_evm_wallet_id or settings.wdk_evm_wallet_id).strip()
|
|
132
|
+
if not service_url:
|
|
133
|
+
raise WalletBackendError("wdk_evm_service_url is required for backend=wdk_evm_local.")
|
|
134
|
+
binding = ensure_user_evm_wallet_ready(
|
|
135
|
+
user_id,
|
|
136
|
+
network=effective_network,
|
|
137
|
+
service_url=service_url,
|
|
138
|
+
wallet_id=wallet_id or None,
|
|
139
|
+
account_index=account_index,
|
|
140
|
+
)
|
|
141
|
+
wallet_id = str(binding.get("wallet_id") or wallet_id).strip()
|
|
142
|
+
if not wallet_id:
|
|
143
|
+
raise WalletBackendError(
|
|
144
|
+
"wdk_evm_wallet_id is required for backend=wdk_evm_local, or create a bound user EVM wallet first."
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
client = WdkEvmLocalClient(service_url)
|
|
148
|
+
wallet_meta = client.post_sync("/v1/evm/wallets/get", {"walletId": wallet_id})
|
|
149
|
+
resolved_address = str(binding.get("address") or "").strip()
|
|
150
|
+
backend = WdkEvmLocalWalletBackend(
|
|
151
|
+
service_url=service_url,
|
|
152
|
+
wallet_id=wallet_id,
|
|
153
|
+
network=effective_network,
|
|
154
|
+
account_index=account_index,
|
|
155
|
+
sign_only=effective_sign_only,
|
|
156
|
+
address=resolved_address or None,
|
|
157
|
+
)
|
|
158
|
+
wallet_info = {
|
|
159
|
+
"user_id": user_id,
|
|
160
|
+
"address": resolved_address,
|
|
161
|
+
"path": f"{service_url}#walletId={wallet_id}",
|
|
162
|
+
"storage_format": "local_vault",
|
|
163
|
+
"key_scope": "host-managed",
|
|
164
|
+
"wallet_id": wallet_id,
|
|
165
|
+
"label": str(wallet_meta.get("label") or (binding or {}).get("label") or "EVM Wallet"),
|
|
166
|
+
}
|
|
167
|
+
adapter = OpenClawWalletAdapter(backend, user_id=user_id)
|
|
168
|
+
plugin_bundle = build_openclaw_plugin_bundle(backend, user_id=user_id)
|
|
169
|
+
return OpenClawWalletRuntimeContext(
|
|
170
|
+
user_id=user_id,
|
|
171
|
+
wallet_info=wallet_info,
|
|
172
|
+
created_now=False,
|
|
173
|
+
backend=backend,
|
|
174
|
+
adapter=adapter,
|
|
175
|
+
plugin_bundle=plugin_bundle,
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
backend, wallet_info, created_now = create_openclaw_solana_backend(
|
|
179
|
+
user_id,
|
|
180
|
+
sign_only=effective_sign_only,
|
|
181
|
+
read_only=read_only,
|
|
182
|
+
network=network,
|
|
183
|
+
rpc_url=rpc_url,
|
|
184
|
+
)
|
|
185
|
+
adapter = OpenClawWalletAdapter(backend, user_id=user_id)
|
|
186
|
+
plugin_bundle = build_openclaw_plugin_bundle(backend, user_id=user_id)
|
|
187
|
+
return OpenClawWalletRuntimeContext(
|
|
188
|
+
user_id=user_id,
|
|
189
|
+
wallet_info=wallet_info,
|
|
190
|
+
created_now=created_now,
|
|
191
|
+
backend=backend,
|
|
192
|
+
adapter=adapter,
|
|
193
|
+
plugin_bundle=plugin_bundle,
|
|
194
|
+
)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""Helpers for exposing agent-wallet as an OpenClaw-style plugin bundle."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from agent_wallet.openclaw_adapter import OpenClawWalletAdapter
|
|
10
|
+
from agent_wallet.wallet_layer.base import AgentWalletBackend
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _package_root() -> Path:
|
|
14
|
+
return Path(__file__).resolve().parents[1]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def get_plugin_manifest() -> dict[str, Any]:
|
|
18
|
+
"""Load the OpenClaw plugin manifest from disk."""
|
|
19
|
+
manifest_path = _package_root() / "openclaw.plugin.json"
|
|
20
|
+
return json.loads(manifest_path.read_text(encoding="utf-8"))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def get_skill_text() -> str:
|
|
24
|
+
"""Load the wallet operator skill text."""
|
|
25
|
+
skill_path = _package_root() / "skills" / "wallet-operator" / "SKILL.md"
|
|
26
|
+
return skill_path.read_text(encoding="utf-8")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def build_openclaw_plugin_bundle(
|
|
30
|
+
backend: AgentWalletBackend, *, user_id: str | None = None
|
|
31
|
+
) -> dict[str, Any]:
|
|
32
|
+
"""Build a runtime-ready bundle for OpenClaw-style plugin registration."""
|
|
33
|
+
adapter = OpenClawWalletAdapter(backend, user_id=user_id)
|
|
34
|
+
return {
|
|
35
|
+
"manifest": get_plugin_manifest(),
|
|
36
|
+
"instructions": "\n\n".join(
|
|
37
|
+
[
|
|
38
|
+
adapter.get_runtime_instructions(),
|
|
39
|
+
get_skill_text(),
|
|
40
|
+
]
|
|
41
|
+
),
|
|
42
|
+
"tools": [tool.model_dump() for tool in adapter.list_tools()],
|
|
43
|
+
"invoke": adapter.invoke,
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Wallet providers."""
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"""Bags launch helpers routed through the shared provider gateway."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from agent_wallet.config import settings
|
|
9
|
+
from agent_wallet.exceptions import ProviderError
|
|
10
|
+
from agent_wallet.http_client import get_client
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _gateway_base_url() -> str:
|
|
14
|
+
base_url = os.getenv("PROVIDER_GATEWAY_URL", settings.provider_gateway_url).strip()
|
|
15
|
+
if not base_url:
|
|
16
|
+
raise ProviderError(
|
|
17
|
+
"bags",
|
|
18
|
+
"Provider gateway URL is not configured for Bags integration.",
|
|
19
|
+
)
|
|
20
|
+
return base_url.rstrip("/")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _gateway_headers() -> dict[str, str]:
|
|
24
|
+
headers = {"Accept": "application/json"}
|
|
25
|
+
bearer = os.getenv(
|
|
26
|
+
"PROVIDER_GATEWAY_BEARER_TOKEN",
|
|
27
|
+
settings.provider_gateway_bearer_token,
|
|
28
|
+
).strip()
|
|
29
|
+
if bearer:
|
|
30
|
+
headers["Authorization"] = f"Bearer {bearer}"
|
|
31
|
+
return headers
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _unwrap_gateway_payload(
|
|
35
|
+
status_code: int,
|
|
36
|
+
payload: Any,
|
|
37
|
+
*,
|
|
38
|
+
operation: str,
|
|
39
|
+
) -> Any:
|
|
40
|
+
if isinstance(payload, dict) and payload.get("ok") is False:
|
|
41
|
+
message = str(payload.get("error") or f"{operation} failed.")
|
|
42
|
+
raise ProviderError("bags", f"{operation} failed via provider gateway: {message}")
|
|
43
|
+
|
|
44
|
+
if status_code != 200:
|
|
45
|
+
message = payload
|
|
46
|
+
if isinstance(payload, dict):
|
|
47
|
+
message = payload.get("error") or payload
|
|
48
|
+
raise ProviderError("bags", f"{operation} failed via provider gateway: {message}")
|
|
49
|
+
|
|
50
|
+
return payload
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _unwrap_bags_response(
|
|
54
|
+
payload: Any,
|
|
55
|
+
*,
|
|
56
|
+
operation: str,
|
|
57
|
+
) -> Any:
|
|
58
|
+
if not isinstance(payload, dict):
|
|
59
|
+
raise ProviderError("bags", f"Unexpected {operation} response from provider gateway.")
|
|
60
|
+
|
|
61
|
+
if "success" not in payload:
|
|
62
|
+
return payload
|
|
63
|
+
|
|
64
|
+
if not payload.get("success"):
|
|
65
|
+
error = payload.get("error") or payload.get("message") or f"{operation} failed."
|
|
66
|
+
raise ProviderError("bags", f"{operation} failed: {error}")
|
|
67
|
+
|
|
68
|
+
return payload.get("response")
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
async def _gateway_get_json(
|
|
72
|
+
path: str,
|
|
73
|
+
*,
|
|
74
|
+
params: dict[str, Any],
|
|
75
|
+
operation: str,
|
|
76
|
+
) -> Any:
|
|
77
|
+
client = get_client()
|
|
78
|
+
response = await client.get(
|
|
79
|
+
f"{_gateway_base_url()}{path}",
|
|
80
|
+
params=params,
|
|
81
|
+
headers=_gateway_headers(),
|
|
82
|
+
)
|
|
83
|
+
payload = response.json() if response.content else {}
|
|
84
|
+
gateway_payload = _unwrap_gateway_payload(
|
|
85
|
+
response.status_code,
|
|
86
|
+
payload,
|
|
87
|
+
operation=operation,
|
|
88
|
+
)
|
|
89
|
+
return _unwrap_bags_response(gateway_payload, operation=operation)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
async def _gateway_post_json(
|
|
93
|
+
path: str,
|
|
94
|
+
*,
|
|
95
|
+
body: dict[str, Any],
|
|
96
|
+
operation: str,
|
|
97
|
+
) -> Any:
|
|
98
|
+
client = get_client()
|
|
99
|
+
response = await client.post(
|
|
100
|
+
f"{_gateway_base_url()}{path}",
|
|
101
|
+
json=body,
|
|
102
|
+
headers={**_gateway_headers(), "Content-Type": "application/json"},
|
|
103
|
+
)
|
|
104
|
+
payload = response.json() if response.content else {}
|
|
105
|
+
gateway_payload = _unwrap_gateway_payload(
|
|
106
|
+
response.status_code,
|
|
107
|
+
payload,
|
|
108
|
+
operation=operation,
|
|
109
|
+
)
|
|
110
|
+
return _unwrap_bags_response(gateway_payload, operation=operation)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
async def fetch_trade_quote(
|
|
114
|
+
*,
|
|
115
|
+
input_mint: str,
|
|
116
|
+
output_mint: str,
|
|
117
|
+
amount_raw: int,
|
|
118
|
+
slippage_bps: int = 50,
|
|
119
|
+
) -> dict[str, Any]:
|
|
120
|
+
"""Fetch a Bags trade quote via the shared provider gateway."""
|
|
121
|
+
client = get_client()
|
|
122
|
+
response = await client.get(
|
|
123
|
+
f"{_gateway_base_url()}/v1/bags/trade/quote",
|
|
124
|
+
params={
|
|
125
|
+
"inputMint": input_mint,
|
|
126
|
+
"outputMint": output_mint,
|
|
127
|
+
"amount": str(amount_raw),
|
|
128
|
+
"slippageMode": "manual",
|
|
129
|
+
"slippageBps": str(slippage_bps),
|
|
130
|
+
},
|
|
131
|
+
headers=_gateway_headers(),
|
|
132
|
+
)
|
|
133
|
+
payload = response.json() if response.content else {}
|
|
134
|
+
gateway_payload = _unwrap_gateway_payload(
|
|
135
|
+
response.status_code,
|
|
136
|
+
payload,
|
|
137
|
+
operation="Bags trade quote",
|
|
138
|
+
)
|
|
139
|
+
quote = _unwrap_bags_response(gateway_payload, operation="Bags trade quote")
|
|
140
|
+
if not isinstance(quote, dict) or "outAmount" not in quote:
|
|
141
|
+
raise ProviderError("bags", "Unexpected trade quote response from Bags.")
|
|
142
|
+
return quote
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
async def build_swap_transaction(
|
|
146
|
+
*,
|
|
147
|
+
user_public_key: str,
|
|
148
|
+
quote_response: dict[str, Any],
|
|
149
|
+
) -> dict[str, Any]:
|
|
150
|
+
"""Build a serialized Bags swap transaction via the shared provider gateway."""
|
|
151
|
+
client = get_client()
|
|
152
|
+
response = await client.post(
|
|
153
|
+
f"{_gateway_base_url()}/v1/bags/trade/swap",
|
|
154
|
+
json={
|
|
155
|
+
"quoteResponse": quote_response,
|
|
156
|
+
"userPublicKey": user_public_key,
|
|
157
|
+
},
|
|
158
|
+
headers={**_gateway_headers(), "Content-Type": "application/json"},
|
|
159
|
+
)
|
|
160
|
+
payload = response.json() if response.content else {}
|
|
161
|
+
gateway_payload = _unwrap_gateway_payload(
|
|
162
|
+
response.status_code,
|
|
163
|
+
payload,
|
|
164
|
+
operation="Bags swap transaction",
|
|
165
|
+
)
|
|
166
|
+
swap = _unwrap_bags_response(gateway_payload, operation="Bags swap transaction")
|
|
167
|
+
if not isinstance(swap, dict) or "swapTransaction" not in swap:
|
|
168
|
+
raise ProviderError("bags", "Unexpected swap transaction response from Bags.")
|
|
169
|
+
return swap
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
async def create_token_info(payload: dict[str, Any]) -> dict[str, Any]:
|
|
173
|
+
response = await _gateway_post_json(
|
|
174
|
+
"/v1/bags/launch/token-info",
|
|
175
|
+
body=payload,
|
|
176
|
+
operation="Bags token info",
|
|
177
|
+
)
|
|
178
|
+
if not isinstance(response, dict):
|
|
179
|
+
raise ProviderError("bags", "Unexpected token info response from Bags.")
|
|
180
|
+
return response
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
async def create_fee_share_config(payload: dict[str, Any]) -> dict[str, Any]:
|
|
184
|
+
response = await _gateway_post_json(
|
|
185
|
+
"/v1/bags/launch/fee-share-config",
|
|
186
|
+
body=payload,
|
|
187
|
+
operation="Bags fee share config",
|
|
188
|
+
)
|
|
189
|
+
if not isinstance(response, dict):
|
|
190
|
+
raise ProviderError("bags", "Unexpected fee share config response from Bags.")
|
|
191
|
+
return response
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
async def create_launch_transaction(payload: dict[str, Any]) -> str:
|
|
195
|
+
response = await _gateway_post_json(
|
|
196
|
+
"/v1/bags/launch/transaction",
|
|
197
|
+
body=payload,
|
|
198
|
+
operation="Bags launch transaction",
|
|
199
|
+
)
|
|
200
|
+
if isinstance(response, str):
|
|
201
|
+
return response
|
|
202
|
+
raise ProviderError("bags", "Unexpected launch transaction response from Bags.")
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"""DexScreener provider for onchain token/pair discovery (price, volume, liquidity).
|
|
2
|
+
|
|
3
|
+
Public API, no key required: https://docs.dexscreener.com/api/reference. Used to
|
|
4
|
+
answer "which pairs exist for this token/ticker" the way app.uniswap.org's own
|
|
5
|
+
search box does, since the Uniswap Trading API itself only exposes quote/order/swap
|
|
6
|
+
for a pair you already know, not a search-by-name/address endpoint.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import time
|
|
12
|
+
from typing import Any
|
|
13
|
+
|
|
14
|
+
from agent_wallet.exceptions import ProviderError
|
|
15
|
+
from agent_wallet.http_client import get_client
|
|
16
|
+
|
|
17
|
+
DEXSCREENER_BASE_URL = "https://api.dexscreener.com"
|
|
18
|
+
|
|
19
|
+
# DexScreener's own responses are served with `cache-control: public, max-age=30`;
|
|
20
|
+
# mirroring that TTL avoids redundant lookups within a session without serving
|
|
21
|
+
# data staler than DexScreener itself would.
|
|
22
|
+
_CACHE_TTL_SECONDS = 30
|
|
23
|
+
_CACHE_MAX_ENTRIES = 128
|
|
24
|
+
_cache: dict[str, tuple[float, list[dict[str, Any]]]] = {}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _cache_get(key: str) -> list[dict[str, Any]] | None:
|
|
28
|
+
entry = _cache.get(key)
|
|
29
|
+
if entry is None:
|
|
30
|
+
return None
|
|
31
|
+
stored_at, pairs = entry
|
|
32
|
+
if time.monotonic() - stored_at > _CACHE_TTL_SECONDS:
|
|
33
|
+
_cache.pop(key, None)
|
|
34
|
+
return None
|
|
35
|
+
return pairs
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _cache_set(key: str, pairs: list[dict[str, Any]]) -> None:
|
|
39
|
+
if len(_cache) >= _CACHE_MAX_ENTRIES and key not in _cache:
|
|
40
|
+
oldest_key = min(_cache, key=lambda existing: _cache[existing][0])
|
|
41
|
+
_cache.pop(oldest_key, None)
|
|
42
|
+
_cache[key] = (time.monotonic(), pairs)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
async def _get(path: str, *, params: dict[str, Any] | None = None) -> Any:
|
|
46
|
+
client = get_client()
|
|
47
|
+
response = await client.get(f"{DEXSCREENER_BASE_URL}{path}", params=params)
|
|
48
|
+
if response.status_code != 200:
|
|
49
|
+
raise ProviderError("dexscreener", f"HTTP {response.status_code}: {response.text[:300]}")
|
|
50
|
+
try:
|
|
51
|
+
return response.json()
|
|
52
|
+
except ValueError as exc:
|
|
53
|
+
raise ProviderError("dexscreener", "Unexpected non-JSON response from DexScreener.") from exc
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _extract_pairs(data: Any) -> list[dict[str, Any]]:
|
|
57
|
+
if isinstance(data, dict):
|
|
58
|
+
pairs = data.get("pairs")
|
|
59
|
+
return pairs if isinstance(pairs, list) else []
|
|
60
|
+
if isinstance(data, list):
|
|
61
|
+
return [item for item in data if isinstance(item, dict)]
|
|
62
|
+
return []
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
async def search_pairs(query: str) -> list[dict[str, Any]]:
|
|
66
|
+
"""Free-text search across every chain/DEX DexScreener indexes."""
|
|
67
|
+
query = query.strip()
|
|
68
|
+
if not query:
|
|
69
|
+
raise ProviderError("dexscreener", "query must not be empty.")
|
|
70
|
+
cache_key = f"search:{query.lower()}"
|
|
71
|
+
cached = _cache_get(cache_key)
|
|
72
|
+
if cached is not None:
|
|
73
|
+
return cached
|
|
74
|
+
data = await _get("/latest/dex/search", params={"q": query})
|
|
75
|
+
pairs = _extract_pairs(data)
|
|
76
|
+
_cache_set(cache_key, pairs)
|
|
77
|
+
return pairs
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
async def get_pairs_for_token(*, chain: str, token_address: str) -> list[dict[str, Any]]:
|
|
81
|
+
"""All pairs for a single token address on one chain, across every DEX on it."""
|
|
82
|
+
chain = chain.strip().lower()
|
|
83
|
+
token_address = token_address.strip()
|
|
84
|
+
if not chain:
|
|
85
|
+
raise ProviderError("dexscreener", "chain must not be empty.")
|
|
86
|
+
if not token_address:
|
|
87
|
+
raise ProviderError("dexscreener", "token_address must not be empty.")
|
|
88
|
+
cache_key = f"token:{chain}:{token_address.lower()}"
|
|
89
|
+
cached = _cache_get(cache_key)
|
|
90
|
+
if cached is not None:
|
|
91
|
+
return cached
|
|
92
|
+
# /token-pairs/v1 lists every pool for the token; /tokens/v1 returns only one
|
|
93
|
+
# pair per token, which hid the deepest venue (e.g. Aerodrome) for some tokens.
|
|
94
|
+
data = await _get(f"/token-pairs/v1/{chain}/{token_address}")
|
|
95
|
+
pairs = _extract_pairs(data)
|
|
96
|
+
_cache_set(cache_key, pairs)
|
|
97
|
+
return pairs
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def normalize_pair(pair: dict[str, Any]) -> dict[str, Any]:
|
|
101
|
+
"""Flatten a DexScreener pair payload into the shape handed back to the agent."""
|
|
102
|
+
base_token = pair.get("baseToken") or {}
|
|
103
|
+
quote_token = pair.get("quoteToken") or {}
|
|
104
|
+
volume = pair.get("volume") or {}
|
|
105
|
+
liquidity = pair.get("liquidity") or {}
|
|
106
|
+
price_change = pair.get("priceChange") or {}
|
|
107
|
+
txns = pair.get("txns") or {}
|
|
108
|
+
return {
|
|
109
|
+
"chain_id": pair.get("chainId"),
|
|
110
|
+
"dex_id": pair.get("dexId"),
|
|
111
|
+
"pair_address": pair.get("pairAddress"),
|
|
112
|
+
"url": pair.get("url"),
|
|
113
|
+
"labels": pair.get("labels") or [],
|
|
114
|
+
"base_token": {
|
|
115
|
+
"address": base_token.get("address"),
|
|
116
|
+
"name": base_token.get("name"),
|
|
117
|
+
"symbol": base_token.get("symbol"),
|
|
118
|
+
},
|
|
119
|
+
"quote_token": {
|
|
120
|
+
"address": quote_token.get("address"),
|
|
121
|
+
"name": quote_token.get("name"),
|
|
122
|
+
"symbol": quote_token.get("symbol"),
|
|
123
|
+
},
|
|
124
|
+
"price_usd": pair.get("priceUsd"),
|
|
125
|
+
"price_native": pair.get("priceNative"),
|
|
126
|
+
"price_change_pct": {
|
|
127
|
+
"m5": price_change.get("m5"),
|
|
128
|
+
"h1": price_change.get("h1"),
|
|
129
|
+
"h6": price_change.get("h6"),
|
|
130
|
+
"h24": price_change.get("h24"),
|
|
131
|
+
},
|
|
132
|
+
"volume_usd": {
|
|
133
|
+
"m5": volume.get("m5"),
|
|
134
|
+
"h1": volume.get("h1"),
|
|
135
|
+
"h6": volume.get("h6"),
|
|
136
|
+
"h24": volume.get("h24"),
|
|
137
|
+
},
|
|
138
|
+
"txns": {
|
|
139
|
+
window: {"buys": counts.get("buys"), "sells": counts.get("sells")}
|
|
140
|
+
for window, counts in txns.items()
|
|
141
|
+
if isinstance(counts, dict)
|
|
142
|
+
},
|
|
143
|
+
"liquidity_usd": liquidity.get("usd"),
|
|
144
|
+
"fdv_usd": pair.get("fdv"),
|
|
145
|
+
"market_cap_usd": pair.get("marketCap"),
|
|
146
|
+
"pair_created_at": pair.get("pairCreatedAt"),
|
|
147
|
+
}
|