keyring-agent-core 0.1.0 → 0.2.0
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/dist/agent/AgentCore.d.ts +37 -1
- package/dist/agent/AgentCore.d.ts.map +1 -1
- package/dist/agent/AgentCore.js +287 -144
- package/dist/agent/AgentCore.js.map +1 -1
- package/dist/agent/QueryRewriter.d.ts +17 -0
- package/dist/agent/QueryRewriter.d.ts.map +1 -1
- package/dist/agent/QueryRewriter.js +48 -4
- package/dist/agent/QueryRewriter.js.map +1 -1
- package/dist/agent/Router.d.ts.map +1 -1
- package/dist/agent/Router.js +73 -35
- package/dist/agent/Router.js.map +1 -1
- package/dist/agent/Subagent.d.ts +17 -0
- package/dist/agent/Subagent.d.ts.map +1 -1
- package/dist/agent/Subagent.js +32 -0
- package/dist/agent/Subagent.js.map +1 -1
- package/dist/agent/chatGraph.d.ts +364 -0
- package/dist/agent/chatGraph.d.ts.map +1 -0
- package/dist/agent/chatGraph.js +184 -0
- package/dist/agent/chatGraph.js.map +1 -0
- package/dist/agent/subagents/AiAgent.d.ts +1 -1
- package/dist/agent/subagents/AiAgent.d.ts.map +1 -1
- package/dist/agent/subagents/AiAgent.js +24 -20
- package/dist/agent/subagents/AiAgent.js.map +1 -1
- package/dist/agent/subagents/NftAgent.d.ts +1 -1
- package/dist/agent/subagents/NftAgent.d.ts.map +1 -1
- package/dist/agent/subagents/NftAgent.js +36 -26
- package/dist/agent/subagents/NftAgent.js.map +1 -1
- package/dist/agent/subagents/PoolSubgraphAgent.d.ts +6 -0
- package/dist/agent/subagents/PoolSubgraphAgent.d.ts.map +1 -0
- package/dist/agent/subagents/PoolSubgraphAgent.js +117 -0
- package/dist/agent/subagents/PoolSubgraphAgent.js.map +1 -0
- package/dist/agent/subagents/TokenAgent.d.ts +1 -1
- package/dist/agent/subagents/TokenAgent.d.ts.map +1 -1
- package/dist/agent/subagents/TokenAgent.js +23 -22
- package/dist/agent/subagents/TokenAgent.js.map +1 -1
- package/dist/agent/subagents/WalletActionAgent.d.ts +6 -0
- package/dist/agent/subagents/WalletActionAgent.d.ts.map +1 -0
- package/dist/agent/subagents/WalletActionAgent.js +55 -0
- package/dist/agent/subagents/WalletActionAgent.js.map +1 -0
- package/dist/agent/subagents/WalletAgent.d.ts +1 -1
- package/dist/agent/subagents/WalletAgent.d.ts.map +1 -1
- package/dist/agent/subagents/WalletAgent.js +18 -17
- package/dist/agent/subagents/WalletAgent.js.map +1 -1
- package/dist/agent/subagents/index.d.ts +23 -3
- package/dist/agent/subagents/index.d.ts.map +1 -1
- package/dist/agent/subagents/index.js +42 -11
- package/dist/agent/subagents/index.js.map +1 -1
- package/dist/constants/abi.d.ts +31 -0
- package/dist/constants/abi.d.ts.map +1 -1
- package/dist/constants/abi.js +24 -1
- package/dist/constants/abi.js.map +1 -1
- package/dist/functions/web3.d.ts +0 -1
- package/dist/functions/web3.d.ts.map +1 -1
- package/dist/functions/web3.js +0 -45
- package/dist/functions/web3.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/llm/GeminiProvider.d.ts.map +1 -1
- package/dist/llm/GeminiProvider.js +115 -34
- package/dist/llm/GeminiProvider.js.map +1 -1
- package/dist/memory/UpstashKnowledgeBase.d.ts +1 -1
- package/dist/memory/UpstashKnowledgeBase.js +1 -1
- package/dist/services/MoralisService.d.ts +3 -25
- package/dist/services/MoralisService.d.ts.map +1 -1
- package/dist/services/MoralisService.js +7 -132
- package/dist/services/MoralisService.js.map +1 -1
- package/dist/services/PantographService.d.ts +61 -1
- package/dist/services/PantographService.d.ts.map +1 -1
- package/dist/services/PantographService.js +264 -12
- package/dist/services/PantographService.js.map +1 -1
- package/dist/services/PoolService.d.ts +1 -4
- package/dist/services/PoolService.d.ts.map +1 -1
- package/dist/services/PoolService.js +18 -40
- package/dist/services/PoolService.js.map +1 -1
- package/dist/services/UniswapSubgraphService.d.ts +144 -0
- package/dist/services/UniswapSubgraphService.d.ts.map +1 -0
- package/dist/services/UniswapSubgraphService.js +606 -0
- package/dist/services/UniswapSubgraphService.js.map +1 -0
- package/dist/services/rpc.d.ts +35 -0
- package/dist/services/rpc.d.ts.map +1 -0
- package/dist/services/rpc.js +110 -0
- package/dist/services/rpc.js.map +1 -0
- package/dist/services/swap/DebridgeAdapter.d.ts +17 -0
- package/dist/services/swap/DebridgeAdapter.d.ts.map +1 -1
- package/dist/services/swap/DebridgeAdapter.js +74 -6
- package/dist/services/swap/DebridgeAdapter.js.map +1 -1
- package/dist/services/swap/SwapServiceFactory.d.ts +1 -0
- package/dist/services/swap/SwapServiceFactory.d.ts.map +1 -1
- package/dist/services/swap/SwapServiceFactory.js +8 -3
- package/dist/services/swap/SwapServiceFactory.js.map +1 -1
- package/dist/tools/builtin/ai/GeminiSearchAiTool.d.ts +36 -0
- package/dist/tools/builtin/ai/GeminiSearchAiTool.d.ts.map +1 -0
- package/dist/tools/builtin/ai/GeminiSearchAiTool.js +91 -0
- package/dist/tools/builtin/ai/GeminiSearchAiTool.js.map +1 -0
- package/dist/tools/builtin/ai/index.d.ts +2 -4
- package/dist/tools/builtin/ai/index.d.ts.map +1 -1
- package/dist/tools/builtin/ai/index.js +3 -5
- package/dist/tools/builtin/ai/index.js.map +1 -1
- package/dist/tools/builtin/index.d.ts +2 -0
- package/dist/tools/builtin/index.d.ts.map +1 -1
- package/dist/tools/builtin/index.js +2 -0
- package/dist/tools/builtin/index.js.map +1 -1
- package/dist/tools/builtin/nft/BaseNftMessageTool.d.ts +35 -0
- package/dist/tools/builtin/nft/BaseNftMessageTool.d.ts.map +1 -0
- package/dist/tools/builtin/nft/BaseNftMessageTool.js +45 -0
- package/dist/tools/builtin/nft/BaseNftMessageTool.js.map +1 -0
- package/dist/tools/builtin/nft/NFTContractInfoTool.d.ts +7 -13
- package/dist/tools/builtin/nft/NFTContractInfoTool.d.ts.map +1 -1
- package/dist/tools/builtin/nft/NFTContractInfoTool.js +8 -43
- package/dist/tools/builtin/nft/NFTContractInfoTool.js.map +1 -1
- package/dist/tools/builtin/nft/NFTMetadataTool.d.ts +7 -113
- package/dist/tools/builtin/nft/NFTMetadataTool.d.ts.map +1 -1
- package/dist/tools/builtin/nft/NFTMetadataTool.js +9 -148
- package/dist/tools/builtin/nft/NFTMetadataTool.js.map +1 -1
- package/dist/tools/builtin/nft/SendNftTool.d.ts +14 -0
- package/dist/tools/builtin/nft/SendNftTool.d.ts.map +1 -0
- package/dist/tools/builtin/nft/SendNftTool.js +20 -0
- package/dist/tools/builtin/nft/SendNftTool.js.map +1 -0
- package/dist/tools/builtin/nft/WalletNFTsTool.d.ts +7 -74
- package/dist/tools/builtin/nft/WalletNFTsTool.d.ts.map +1 -1
- package/dist/tools/builtin/nft/WalletNFTsTool.js +9 -161
- package/dist/tools/builtin/nft/WalletNFTsTool.js.map +1 -1
- package/dist/tools/builtin/pool/EstimatePoolYieldTool.d.ts.map +1 -1
- package/dist/tools/builtin/pool/EstimatePoolYieldTool.js +4 -3
- package/dist/tools/builtin/pool/EstimatePoolYieldTool.js.map +1 -1
- package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.d.ts +1 -0
- package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.d.ts.map +1 -1
- package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.js +8 -5
- package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.js.map +1 -1
- package/dist/tools/builtin/pool/PoolByAddressTool.d.ts.map +1 -1
- package/dist/tools/builtin/pool/PoolByAddressTool.js +4 -3
- package/dist/tools/builtin/pool/PoolByAddressTool.js.map +1 -1
- package/dist/tools/builtin/pool/PoolDetailTool.d.ts.map +1 -1
- package/dist/tools/builtin/pool/PoolDetailTool.js +4 -3
- package/dist/tools/builtin/pool/PoolDetailTool.js.map +1 -1
- package/dist/tools/builtin/pool/PoolSearchTool.d.ts.map +1 -1
- package/dist/tools/builtin/pool/PoolSearchTool.js +4 -3
- package/dist/tools/builtin/pool/PoolSearchTool.js.map +1 -1
- package/dist/tools/builtin/pool/PreviewAddLiquidityTool.d.ts +1 -0
- package/dist/tools/builtin/pool/PreviewAddLiquidityTool.d.ts.map +1 -1
- package/dist/tools/builtin/pool/PreviewAddLiquidityTool.js +5 -3
- package/dist/tools/builtin/pool/PreviewAddLiquidityTool.js.map +1 -1
- package/dist/tools/builtin/pool/TopPoolsTool.d.ts.map +1 -1
- package/dist/tools/builtin/pool/TopPoolsTool.js +4 -3
- package/dist/tools/builtin/pool/TopPoolsTool.js.map +1 -1
- package/dist/tools/builtin/pool-subgraph/SubgraphCoinPoolPairsTool.d.ts +54 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphCoinPoolPairsTool.d.ts.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphCoinPoolPairsTool.js +98 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphCoinPoolPairsTool.js.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByAddressTool.d.ts +63 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByAddressTool.d.ts.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByAddressTool.js +82 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByAddressTool.js.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByPositionIdTool.d.ts +79 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByPositionIdTool.d.ts.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByPositionIdTool.js +97 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolByPositionIdTool.js.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolSearchTool.d.ts +77 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolSearchTool.d.ts.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolSearchTool.js +190 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPoolSearchTool.js.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPositionDetailTool.d.ts +107 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPositionDetailTool.d.ts.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPositionDetailTool.js +92 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphPositionDetailTool.js.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphTrendingPoolsTool.d.ts +56 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphTrendingPoolsTool.d.ts.map +1 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphTrendingPoolsTool.js +94 -0
- package/dist/tools/builtin/pool-subgraph/SubgraphTrendingPoolsTool.js.map +1 -0
- package/dist/tools/builtin/pool-subgraph/index.d.ts +13 -0
- package/dist/tools/builtin/pool-subgraph/index.d.ts.map +1 -0
- package/dist/tools/builtin/pool-subgraph/index.js +18 -0
- package/dist/tools/builtin/pool-subgraph/index.js.map +1 -0
- package/dist/tools/builtin/token/TokenAnalyticsTool.d.ts.map +1 -1
- package/dist/tools/builtin/token/TokenAnalyticsTool.js +4 -3
- package/dist/tools/builtin/token/TokenAnalyticsTool.js.map +1 -1
- package/dist/tools/builtin/token/TokenHoldersTool.d.ts.map +1 -1
- package/dist/tools/builtin/token/TokenHoldersTool.js +4 -3
- package/dist/tools/builtin/token/TokenHoldersTool.js.map +1 -1
- package/dist/tools/builtin/token/TokenInfoTool.d.ts +6 -2
- package/dist/tools/builtin/token/TokenInfoTool.d.ts.map +1 -1
- package/dist/tools/builtin/token/TokenInfoTool.js +66 -8
- package/dist/tools/builtin/token/TokenInfoTool.js.map +1 -1
- package/dist/tools/builtin/token/TokenScoreTool.d.ts.map +1 -1
- package/dist/tools/builtin/token/TokenScoreTool.js +4 -3
- package/dist/tools/builtin/token/TokenScoreTool.js.map +1 -1
- package/dist/tools/builtin/token/TopGainersTool.d.ts +10 -19
- package/dist/tools/builtin/token/TopGainersTool.d.ts.map +1 -1
- package/dist/tools/builtin/token/TopGainersTool.js +44 -54
- package/dist/tools/builtin/token/TopGainersTool.js.map +1 -1
- package/dist/tools/builtin/token/TopLosersTool.d.ts.map +1 -1
- package/dist/tools/builtin/token/TopLosersTool.js +3 -2
- package/dist/tools/builtin/token/TopLosersTool.js.map +1 -1
- package/dist/tools/builtin/token/TrendingTokensTool.d.ts +1 -1
- package/dist/tools/builtin/token/TrendingTokensTool.d.ts.map +1 -1
- package/dist/tools/builtin/token/TrendingTokensTool.js +20 -12
- package/dist/tools/builtin/token/TrendingTokensTool.js.map +1 -1
- package/dist/tools/builtin/token/index.d.ts +0 -2
- package/dist/tools/builtin/token/index.d.ts.map +1 -1
- package/dist/tools/builtin/token/index.js +1 -3
- package/dist/tools/builtin/token/index.js.map +1 -1
- package/dist/tools/builtin/wallet/TransactionByHashTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/TransactionByHashTool.js +4 -3
- package/dist/tools/builtin/wallet/TransactionByHashTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletApprovalsTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/WalletApprovalsTool.js +4 -3
- package/dist/tools/builtin/wallet/WalletApprovalsTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletDefiPositionsTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/WalletDefiPositionsTool.js +4 -3
- package/dist/tools/builtin/wallet/WalletDefiPositionsTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.js +4 -3
- package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletDefiSummaryTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/WalletDefiSummaryTool.js +4 -3
- package/dist/tools/builtin/wallet/WalletDefiSummaryTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletHistoryTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/WalletHistoryTool.js +5 -4
- package/dist/tools/builtin/wallet/WalletHistoryTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletNetWorthTool.js +1 -1
- package/dist/tools/builtin/wallet/WalletNetWorthTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletNftTransfersTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/WalletNftTransfersTool.js +5 -4
- package/dist/tools/builtin/wallet/WalletNftTransfersTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletPnlSummaryTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/WalletPnlSummaryTool.js +4 -3
- package/dist/tools/builtin/wallet/WalletPnlSummaryTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletPnlTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/WalletPnlTool.js +4 -3
- package/dist/tools/builtin/wallet/WalletPnlTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletTokenBalancesTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/WalletTokenBalancesTool.js +4 -3
- package/dist/tools/builtin/wallet/WalletTokenBalancesTool.js.map +1 -1
- package/dist/tools/builtin/wallet/WalletTokenTransfersTool.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/WalletTokenTransfersTool.js +5 -4
- package/dist/tools/builtin/wallet/WalletTokenTransfersTool.js.map +1 -1
- package/dist/tools/builtin/wallet/index.d.ts +3 -0
- package/dist/tools/builtin/wallet/index.d.ts.map +1 -1
- package/dist/tools/builtin/wallet/index.js +5 -1
- package/dist/tools/builtin/wallet/index.js.map +1 -1
- package/dist/tools/builtin/wallet-action/ApproveTokenTool.d.ts +25 -0
- package/dist/tools/builtin/wallet-action/ApproveTokenTool.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/ApproveTokenTool.js +98 -0
- package/dist/tools/builtin/wallet-action/ApproveTokenTool.js.map +1 -0
- package/dist/tools/builtin/wallet-action/BaseWalletActionTool.d.ts +211 -0
- package/dist/tools/builtin/wallet-action/BaseWalletActionTool.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/BaseWalletActionTool.js +499 -0
- package/dist/tools/builtin/wallet-action/BaseWalletActionTool.js.map +1 -0
- package/dist/tools/builtin/wallet-action/BuyTokenTool.d.ts +240 -0
- package/dist/tools/builtin/wallet-action/BuyTokenTool.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/BuyTokenTool.js +1257 -0
- package/dist/tools/builtin/wallet-action/BuyTokenTool.js.map +1 -0
- package/dist/tools/builtin/wallet-action/SendNativeTool.d.ts +41 -0
- package/dist/tools/builtin/wallet-action/SendNativeTool.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/SendNativeTool.js +127 -0
- package/dist/tools/builtin/wallet-action/SendNativeTool.js.map +1 -0
- package/dist/tools/builtin/wallet-action/SendTokenTool.d.ts +63 -0
- package/dist/tools/builtin/wallet-action/SendTokenTool.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/SendTokenTool.js +294 -0
- package/dist/tools/builtin/wallet-action/SendTokenTool.js.map +1 -0
- package/dist/tools/builtin/wallet-action/SwapTokenTool.d.ts +247 -0
- package/dist/tools/builtin/wallet-action/SwapTokenTool.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/SwapTokenTool.js +1258 -0
- package/dist/tools/builtin/wallet-action/SwapTokenTool.js.map +1 -0
- package/dist/tools/builtin/wallet-action/UnwrapNativeTool.d.ts +20 -0
- package/dist/tools/builtin/wallet-action/UnwrapNativeTool.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/UnwrapNativeTool.js +36 -0
- package/dist/tools/builtin/wallet-action/UnwrapNativeTool.js.map +1 -0
- package/dist/tools/builtin/wallet-action/WrapNativeTool.d.ts +23 -0
- package/dist/tools/builtin/wallet-action/WrapNativeTool.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/WrapNativeTool.js +54 -0
- package/dist/tools/builtin/wallet-action/WrapNativeTool.js.map +1 -0
- package/dist/tools/builtin/wallet-action/amountSpec.d.ts +62 -0
- package/dist/tools/builtin/wallet-action/amountSpec.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/amountSpec.js +93 -0
- package/dist/tools/builtin/wallet-action/amountSpec.js.map +1 -0
- package/dist/tools/builtin/wallet-action/gasReserve.d.ts +42 -0
- package/dist/tools/builtin/wallet-action/gasReserve.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/gasReserve.js +103 -0
- package/dist/tools/builtin/wallet-action/gasReserve.js.map +1 -0
- package/dist/tools/builtin/wallet-action/index.d.ts +9 -0
- package/dist/tools/builtin/wallet-action/index.d.ts.map +1 -0
- package/dist/tools/builtin/wallet-action/index.js +20 -0
- package/dist/tools/builtin/wallet-action/index.js.map +1 -0
- package/dist/tools/chainResolver.d.ts +98 -0
- package/dist/tools/chainResolver.d.ts.map +1 -0
- package/dist/tools/chainResolver.js +302 -0
- package/dist/tools/chainResolver.js.map +1 -0
- package/dist/types/index.d.ts +218 -7
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +7 -3
- package/dist/tools/builtin/ai/MoralisCortexTool.d.ts +0 -33
- package/dist/tools/builtin/ai/MoralisCortexTool.d.ts.map +0 -1
- package/dist/tools/builtin/ai/MoralisCortexTool.js +0 -76
- package/dist/tools/builtin/ai/MoralisCortexTool.js.map +0 -1
- package/dist/tools/builtin/ai/SolanaCortexTool.d.ts +0 -22
- package/dist/tools/builtin/ai/SolanaCortexTool.d.ts.map +0 -1
- package/dist/tools/builtin/ai/SolanaCortexTool.js +0 -80
- package/dist/tools/builtin/ai/SolanaCortexTool.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SendTokenTool.js","sourceRoot":"","sources":["../../../../src/tools/builtin/wallet-action/SendTokenTool.ts"],"names":[],"mappings":";;;AAEA,iEAAkF;AAElF;;;;;;;;;;GAUG;AACH,MAAa,aAAc,SAAQ,2CAAoB;IACrD,IAAI,GAAG,sBAAsB,CAAC;IAC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AUG;IACK,eAAe,CAAC,QAAgB,EAAE,MAAc,EAAE,MAAqB,EAAE,SAAwB;QACvG,MAAM,GAAG,GAAG,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,gCAAgC,CAAC;QACpG,IAAI,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,IAAI,EAAE,CAAC,CAAC;QAClF,IAAI,SAAS,EAAE,CAAC;YACd,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAC1C,CAAC;aAAM,CAAC;YACN,yEAAyE;YACzE,yEAAyE;YACzE,yEAAyE;YACzE,GAAG,GAAG,GAAG;iBACN,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;iBAC/B,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;iBAC/B,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QAC5B,CAAC;QACD,yDAAyD;QACzD,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACzC,CAAC;CACF;AA/SD,sCA+SC"}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { BaseTool } from '../../BaseTool';
|
|
2
|
+
import { type MoralisServiceConfig } from '../../../services/MoralisService';
|
|
3
|
+
import type { ToolKind, ToolParameter, ToolResult, UIPayload, UserContext } from '../../../types';
|
|
4
|
+
/**
|
|
5
|
+
* Tool: open-swap-token-form
|
|
6
|
+
*
|
|
7
|
+
* A STANDALONE wallet-action tool (NOT a `BaseWalletActionTool`), built as the
|
|
8
|
+
* mirror of {@link BuyTokenTool}: it does the quote + approval work itself and
|
|
9
|
+
* ships a custom `SwapTokenConfirmTx` UI payload the FE executes directly. That's
|
|
10
|
+
* why `swap_token` is intentionally NOT a member of `WalletActionType`.
|
|
11
|
+
*
|
|
12
|
+
* The defining difference from BUY: the SOURCE is a token the user ALREADY HOLDS.
|
|
13
|
+
* Buy starts from a destination ("buy PEPE") and asks which wallet token to pay
|
|
14
|
+
* with; swap starts from the user's own token ("swap USDC") and asks what to
|
|
15
|
+
* receive. The source is therefore always balance-checked — we never quote a
|
|
16
|
+
* swap the user can't fund.
|
|
17
|
+
*
|
|
18
|
+
* - "swap usdc to usdt" → from = USDC (held), to = USDT.
|
|
19
|
+
* - "swap usdc" → from = USDC (held); destination unknown ⇒ trending
|
|
20
|
+
* picker so the user picks what to receive.
|
|
21
|
+
* - "swap" → nothing named ⇒ source picker built from the wallet's
|
|
22
|
+
* own holdings so the user picks what to swap FROM.
|
|
23
|
+
*
|
|
24
|
+
* Branches, picked deterministically from the args:
|
|
25
|
+
*
|
|
26
|
+
* 0. **Source picker** — the user named NO source (`from_symbol`/`from_address`
|
|
27
|
+
* empty). The tool fetches the wallet's native + ERC-20 holdings and emits
|
|
28
|
+
* `actionButtons` so the user picks which token to swap FROM. A click
|
|
29
|
+
* re-submits a prompt like `"swap USDC"` which routes back here.
|
|
30
|
+
*
|
|
31
|
+
* 1. **Destination picker (trending)** — the user named the source only. The
|
|
32
|
+
* tool fetches the chain's live trending list (minus the source token) and
|
|
33
|
+
* emits `actionButtons` so the user picks what to receive. A click submits a
|
|
34
|
+
* prompt like `"swap USDC to PEPE"` which routes back for the standard flow.
|
|
35
|
+
*
|
|
36
|
+
* 1.4 **Balance check** — the source token is named (amount optional). Runs
|
|
37
|
+
* before anything else so we never proceed with a token the user can't fund:
|
|
38
|
+
* if the wallet holds NONE of it, the tool offers the tokens the user DOES
|
|
39
|
+
* hold instead (source picker); if it holds SOME but less than the requested
|
|
40
|
+
* amount, it reports the shortfall and emits 25/50/75/100% buttons sized off
|
|
41
|
+
* the real balance. Skipped for the native source token.
|
|
42
|
+
*
|
|
43
|
+
* 1.5 **Amount picker** — source + dest known but no amount given. The tool
|
|
44
|
+
* reads the source balance and emits 25/50/75/100% buttons so the user sizes
|
|
45
|
+
* the swap in one tap (or types a custom amount).
|
|
46
|
+
*
|
|
47
|
+
* 1.75 **Confirm tx** — source + dest + a SOURCE amount are all known. The tool
|
|
48
|
+
* fetches a swap quote (estimated receive amount + the raw swap tx), checks
|
|
49
|
+
* allowance, and emits a `SwapTokenConfirmTx` payload bundling the estimate,
|
|
50
|
+
* the raw swap transaction, and the approve transaction (when one is needed).
|
|
51
|
+
* The FE executes approve (if any) then swap itself.
|
|
52
|
+
*
|
|
53
|
+
* When none of the above produces a result (couldn't resolve a token, quote
|
|
54
|
+
* failed, …) the tool returns an error/_instructions object — it never opens a
|
|
55
|
+
* generic form.
|
|
56
|
+
*
|
|
57
|
+
* Amount disambiguation mirrors BuyTokenTool. The swap is EXACT_INPUT (deBridge),
|
|
58
|
+
* so the amount that seeds the quote is the SOURCE amount:
|
|
59
|
+
* - "swap 10 USDC to USDT" → from_amount = "10"
|
|
60
|
+
* - "swap USDC to 5 USDT" → to_amount = "5" (converted to a source amount via
|
|
61
|
+
* live USD prices, like BuyTokenTool's buy side).
|
|
62
|
+
*/
|
|
63
|
+
export declare class SwapTokenTool extends BaseTool {
|
|
64
|
+
name: string;
|
|
65
|
+
kind: ToolKind;
|
|
66
|
+
category: string;
|
|
67
|
+
noSuggestions: boolean;
|
|
68
|
+
private readonly moralis?;
|
|
69
|
+
/** Trending tokens come from Pantograph (top-gainers), not Moralis. */
|
|
70
|
+
private readonly pantograph?;
|
|
71
|
+
/** Branch-tracing on/off — shares AgentCore's `debug` flag (passed in). */
|
|
72
|
+
private readonly debug;
|
|
73
|
+
constructor(config?: MoralisServiceConfig, options?: {
|
|
74
|
+
debug?: boolean;
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* Branch-tracing logger. Prints which branch the tool takes and the key
|
|
78
|
+
* values feeding that decision. Enabled by AgentCore's shared `debug` flag.
|
|
79
|
+
*/
|
|
80
|
+
private dbg;
|
|
81
|
+
description: string;
|
|
82
|
+
parameters: ToolParameter[];
|
|
83
|
+
execute(args: Record<string, unknown>, userContext?: UserContext): Promise<ToolResult>;
|
|
84
|
+
protected run(args: Record<string, unknown>, userContext?: UserContext): Promise<{
|
|
85
|
+
actionButtons: {
|
|
86
|
+
label: string;
|
|
87
|
+
prompt: string;
|
|
88
|
+
}[];
|
|
89
|
+
_instructions: string;
|
|
90
|
+
} | {
|
|
91
|
+
ui: UIPayload;
|
|
92
|
+
_instructions: string;
|
|
93
|
+
} | {
|
|
94
|
+
error: string;
|
|
95
|
+
_instructions: string;
|
|
96
|
+
}>;
|
|
97
|
+
private buildResult;
|
|
98
|
+
private normaliseAddress;
|
|
99
|
+
private normaliseAmount;
|
|
100
|
+
private requireChain;
|
|
101
|
+
/**
|
|
102
|
+
* Resolve a token reference (symbol "USDC" or address "0x…") on a chain.
|
|
103
|
+
* Wallet balances first (most reliable), then Pantograph search. Decimals come
|
|
104
|
+
* from the API — never from the LLM.
|
|
105
|
+
*/
|
|
106
|
+
private resolveContractAddress;
|
|
107
|
+
/**
|
|
108
|
+
* Resolve one side of the swap (from or to). Honours the `"native"` sentinel
|
|
109
|
+
* the swap providers expect. Never errors — a side that can't be resolved
|
|
110
|
+
* just comes back with `address: null`.
|
|
111
|
+
*/
|
|
112
|
+
private resolveSide;
|
|
113
|
+
/**
|
|
114
|
+
* Source token + dest token + a source-token amount are known. Fetch a swap
|
|
115
|
+
* quote (estimated receive amount + raw swap tx), check approval, and return a
|
|
116
|
+
* `SwapTokenConfirmTx` UI payload the FE executes itself. Returns `null` when
|
|
117
|
+
* anything we need can't be produced (bad chain, quote failed, non-EVM tx).
|
|
118
|
+
*/
|
|
119
|
+
private buildConfirmTx;
|
|
120
|
+
/**
|
|
121
|
+
* deBridge only quotes EXACT_INPUT, so a "swap to X of the dest token" request
|
|
122
|
+
* has no input amount to seed the quote. Convert the desired output into a
|
|
123
|
+
* source-token amount using each side's live USD price:
|
|
124
|
+
*
|
|
125
|
+
* fromAmount ≈ (toAmount × toPriceUsd) / fromPriceUsd × (1 + buffer)
|
|
126
|
+
*
|
|
127
|
+
* The +2% buffer covers slippage + fees so the user receives AT LEAST roughly
|
|
128
|
+
* the requested amount (the confirm panel still shows the REAL estimate from
|
|
129
|
+
* the quote, not this derived figure). Returns `null` when either token's USD
|
|
130
|
+
* price can't be fetched — the caller then asks for a from amount instead.
|
|
131
|
+
*/
|
|
132
|
+
private deriveFromAmountFromTo;
|
|
133
|
+
/**
|
|
134
|
+
* Best-effort live USD price for one side of the swap, sourced from
|
|
135
|
+
* Pantograph (via `MoralisService.getTokenMetadata`). The native coin
|
|
136
|
+
* (`'native'`) is looked up with the zero address. Returns `null` when no
|
|
137
|
+
* positive price is available so the caller can degrade gracefully.
|
|
138
|
+
*/
|
|
139
|
+
private getUsdPrice;
|
|
140
|
+
/**
|
|
141
|
+
* Resolve the FROM-side amount, which may be plain ("10"), a PERCENT of the
|
|
142
|
+
* held source-token balance ("50%"), or a USD value ("5$"). Percent reads the
|
|
143
|
+
* wallet's source-token balance; usd divides by the source token's USD price.
|
|
144
|
+
* Returns a plain token amount string, or `null` when nothing usable was given
|
|
145
|
+
* / the balance or price needed for a percent/usd couldn't be fetched.
|
|
146
|
+
*/
|
|
147
|
+
private resolveFromAmountSpec;
|
|
148
|
+
/**
|
|
149
|
+
* Resolve the TO-side amount, which may be plain ("5") or a USD value ("5$").
|
|
150
|
+
* USD divides by the DEST token's price to get how many dest tokens "$X worth"
|
|
151
|
+
* is — that token figure then flows through Branch 1.3 to derive the from
|
|
152
|
+
* amount. A PERCENT on the to side is meaningless, so it's ignored (returns
|
|
153
|
+
* null). Returns a plain token amount string or `null`.
|
|
154
|
+
*/
|
|
155
|
+
private resolveToAmountSpec;
|
|
156
|
+
/**
|
|
157
|
+
* Check whether the source token needs an allowance for this swap and, if so,
|
|
158
|
+
* return a ready-to-sign ERC-20 approve tx. deBridge only reports the spender
|
|
159
|
+
* (`tx.to`), so we encode the approve calldata ourselves; integrated providers
|
|
160
|
+
* (Relay) hand back the approve tx directly.
|
|
161
|
+
*/
|
|
162
|
+
private buildApproveTx;
|
|
163
|
+
/** Human amount → smallest-unit decimal string (no float drift via BigInt). */
|
|
164
|
+
private toRawAmount;
|
|
165
|
+
/**
|
|
166
|
+
* Pull a human-readable failure reason out of a failed quote. Adapters set
|
|
167
|
+
* `errorMessage` (string) and `error` (string or a provider object). deBridge
|
|
168
|
+
* also nests a reason in `raw.errorMessage` / `raw.error`. Falls back to a
|
|
169
|
+
* generic line so the caller always has something to show.
|
|
170
|
+
*/
|
|
171
|
+
private extractQuoteError;
|
|
172
|
+
/**
|
|
173
|
+
* Estimated receive amount in the dest token's smallest units. Shape differs
|
|
174
|
+
* per provider — deBridge same-chain: `raw.tokenOut.minAmount`; deBridge
|
|
175
|
+
* cross-chain: `raw.estimation.dstChainTokenOut.amount`; Relay:
|
|
176
|
+
* `raw.details.currencyOut.{amount|minimumAmount}`.
|
|
177
|
+
*/
|
|
178
|
+
private extractOutRaw;
|
|
179
|
+
private buildSourcePicker;
|
|
180
|
+
private buildToTrendingPicker;
|
|
181
|
+
/**
|
|
182
|
+
* Guard the swap flow against a source token the user can't fund. Returns:
|
|
183
|
+
* - `null` when the user holds enough (or no amount yet, or balances can't be read).
|
|
184
|
+
* - `no_from_balance` (+ source picker buttons) when the wallet holds none of it.
|
|
185
|
+
* - `insufficient_from_balance` (+ percentage buttons) when it holds some but
|
|
186
|
+
* less than the requested amount.
|
|
187
|
+
*/
|
|
188
|
+
private checkFromBalance;
|
|
189
|
+
/**
|
|
190
|
+
* Read the connected wallet's balance of the source token. Returns the held
|
|
191
|
+
* amount + on-chain symbol, or `null` when balances can't be fetched / the
|
|
192
|
+
* token isn't held (zero balance or not held at all).
|
|
193
|
+
*
|
|
194
|
+
* For the NATIVE source coin the returned balance is the SPENDABLE figure —
|
|
195
|
+
* the held balance minus a silently-estimated swap gas reserve (gasLimit
|
|
196
|
+
* 1_000_000 × gasPrice) — so the percent buttons, amount picker, and balance
|
|
197
|
+
* check all stay within what the user can actually swap while still covering
|
|
198
|
+
* gas. The reserve is never surfaced; callers only ever expose the spendable
|
|
199
|
+
* number. ERC-20 sources are returned at their raw held balance (gas is paid
|
|
200
|
+
* in the native coin, not the source token).
|
|
201
|
+
*/
|
|
202
|
+
private readFromBalance;
|
|
203
|
+
/**
|
|
204
|
+
* 25/50/75/100% quick-spend buttons sized off a held balance. 100% spends the
|
|
205
|
+
* EXACT held string; the partial fractions are float-trimmed. The amount rides
|
|
206
|
+
* in the prompt; the label is a bare percent.
|
|
207
|
+
*/
|
|
208
|
+
private percentSpendButtons;
|
|
209
|
+
private buildAmountPicker;
|
|
210
|
+
/**
|
|
211
|
+
* Trim IEEE-754 noise from a computed amount (≤8 significant digits) and
|
|
212
|
+
* ALWAYS return plain decimal notation — never exponential ("1.5e-7").
|
|
213
|
+
*/
|
|
214
|
+
private trimAmount;
|
|
215
|
+
/** Format a number as a plain decimal string, expanding any e-notation. */
|
|
216
|
+
private toPlainDecimal;
|
|
217
|
+
/**
|
|
218
|
+
* Sanitize an amount STRING from an external source (e.g. Moralis
|
|
219
|
+
* `balance_formatted`): expand e-notation to plain decimal; else pass through.
|
|
220
|
+
*/
|
|
221
|
+
private cleanAmountString;
|
|
222
|
+
/**
|
|
223
|
+
* Build the source-picker click-prompt ("swap {token}") from the LLM-supplied,
|
|
224
|
+
* already-localized template. Falls back to English when the LLM omits one.
|
|
225
|
+
*/
|
|
226
|
+
private buildSwapFromPrompt;
|
|
227
|
+
/**
|
|
228
|
+
* Build the "swap X to Y" click-prompt from the LLM-supplied, already-localized
|
|
229
|
+
* template by substituting placeholders:
|
|
230
|
+
* {from} → source token {to} → destination token
|
|
231
|
+
* {from_amount} → quantity swapped (next to {from})
|
|
232
|
+
* {to_amount} → quantity received (next to {to})
|
|
233
|
+
* The localized verb and "to" preposition live INSIDE the template, so we only
|
|
234
|
+
* substitute concrete values. Only one side ever carries an amount; the unused
|
|
235
|
+
* amount placeholder is replaced with '' (no preposition is attached to it, so
|
|
236
|
+
* nothing dangles). Falls back to an English template when the LLM omits one.
|
|
237
|
+
*/
|
|
238
|
+
private buildSwapToPrompt;
|
|
239
|
+
/**
|
|
240
|
+
* Format a 24h price-change percentage: ~6 significant digits, no trailing
|
|
241
|
+
* noise, and always plain decimal (never exponential for a tiny change).
|
|
242
|
+
*/
|
|
243
|
+
private formatPercent;
|
|
244
|
+
/** Compact price string: e.g. 0.00001234 → "0.00001234", 1234.5 → "1,234.50". */
|
|
245
|
+
private formatPrice;
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=SwapTokenTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwapTokenTool.d.ts","sourceRoot":"","sources":["../../../../src/tools/builtin/wallet-action/SwapTokenTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAkB,KAAK,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAI7F,OAAO,KAAK,EAGV,QAAQ,EACR,aAAa,EACb,UAAU,EACV,SAAS,EAET,WAAW,EACZ,MAAM,gBAAgB,CAAC;AAcxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,qBAAa,aAAc,SAAQ,QAAQ;IACzC,IAAI,SAA0B;IAC9B,IAAI,EAAE,QAAQ,CAAY;IAC1B,QAAQ,SAAmB;IAE3B,aAAa,UAAQ;IAErB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAiB;IAC1C,uEAAuE;IACvE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAoB;IAChD,2EAA2E;IAC3E,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;gBAEpB,MAAM,CAAC,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;IASxE;;;OAGG;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