keyring-agent-core 0.1.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.
Files changed (318) hide show
  1. package/README.md +169 -0
  2. package/dist/agent/AgentCore.d.ts +220 -0
  3. package/dist/agent/AgentCore.d.ts.map +1 -0
  4. package/dist/agent/AgentCore.js +950 -0
  5. package/dist/agent/AgentCore.js.map +1 -0
  6. package/dist/agent/QueryRewriter.d.ts +67 -0
  7. package/dist/agent/QueryRewriter.d.ts.map +1 -0
  8. package/dist/agent/QueryRewriter.js +262 -0
  9. package/dist/agent/QueryRewriter.js.map +1 -0
  10. package/dist/agent/Router.d.ts +33 -0
  11. package/dist/agent/Router.d.ts.map +1 -0
  12. package/dist/agent/Router.js +191 -0
  13. package/dist/agent/Router.js.map +1 -0
  14. package/dist/agent/Subagent.d.ts +63 -0
  15. package/dist/agent/Subagent.d.ts.map +1 -0
  16. package/dist/agent/Subagent.js +240 -0
  17. package/dist/agent/Subagent.js.map +1 -0
  18. package/dist/agent/Synthesizer.d.ts +11 -0
  19. package/dist/agent/Synthesizer.d.ts.map +1 -0
  20. package/dist/agent/Synthesizer.js +86 -0
  21. package/dist/agent/Synthesizer.js.map +1 -0
  22. package/dist/agent/index.d.ts +10 -0
  23. package/dist/agent/index.d.ts.map +1 -0
  24. package/dist/agent/index.js +24 -0
  25. package/dist/agent/index.js.map +1 -0
  26. package/dist/agent/subagents/AiAgent.d.ts +6 -0
  27. package/dist/agent/subagents/AiAgent.d.ts.map +1 -0
  28. package/dist/agent/subagents/AiAgent.js +48 -0
  29. package/dist/agent/subagents/AiAgent.js.map +1 -0
  30. package/dist/agent/subagents/NftAgent.d.ts +6 -0
  31. package/dist/agent/subagents/NftAgent.d.ts.map +1 -0
  32. package/dist/agent/subagents/NftAgent.js +69 -0
  33. package/dist/agent/subagents/NftAgent.js.map +1 -0
  34. package/dist/agent/subagents/PoolAgent.d.ts +6 -0
  35. package/dist/agent/subagents/PoolAgent.d.ts.map +1 -0
  36. package/dist/agent/subagents/PoolAgent.js +184 -0
  37. package/dist/agent/subagents/PoolAgent.js.map +1 -0
  38. package/dist/agent/subagents/TokenAgent.d.ts +6 -0
  39. package/dist/agent/subagents/TokenAgent.d.ts.map +1 -0
  40. package/dist/agent/subagents/TokenAgent.js +75 -0
  41. package/dist/agent/subagents/TokenAgent.js.map +1 -0
  42. package/dist/agent/subagents/WalletAgent.d.ts +6 -0
  43. package/dist/agent/subagents/WalletAgent.d.ts.map +1 -0
  44. package/dist/agent/subagents/WalletAgent.js +92 -0
  45. package/dist/agent/subagents/WalletAgent.js.map +1 -0
  46. package/dist/agent/subagents/index.d.ts +14 -0
  47. package/dist/agent/subagents/index.d.ts.map +1 -0
  48. package/dist/agent/subagents/index.js +38 -0
  49. package/dist/agent/subagents/index.js.map +1 -0
  50. package/dist/constants/abi.d.ts +520 -0
  51. package/dist/constants/abi.d.ts.map +1 -0
  52. package/dist/constants/abi.js +667 -0
  53. package/dist/constants/abi.js.map +1 -0
  54. package/dist/functions/pool.d.ts +25 -0
  55. package/dist/functions/pool.d.ts.map +1 -0
  56. package/dist/functions/pool.js +151 -0
  57. package/dist/functions/pool.js.map +1 -0
  58. package/dist/functions/web3.d.ts +32 -0
  59. package/dist/functions/web3.d.ts.map +1 -0
  60. package/dist/functions/web3.js +277 -0
  61. package/dist/functions/web3.js.map +1 -0
  62. package/dist/index.d.ts +24 -0
  63. package/dist/index.d.ts.map +1 -0
  64. package/dist/index.js +65 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/llm/GeminiProvider.d.ts +16 -0
  67. package/dist/llm/GeminiProvider.d.ts.map +1 -0
  68. package/dist/llm/GeminiProvider.js +248 -0
  69. package/dist/llm/GeminiProvider.js.map +1 -0
  70. package/dist/llm/index.d.ts +2 -0
  71. package/dist/llm/index.d.ts.map +1 -0
  72. package/dist/llm/index.js +6 -0
  73. package/dist/llm/index.js.map +1 -0
  74. package/dist/memory/ChatHistory.d.ts +83 -0
  75. package/dist/memory/ChatHistory.d.ts.map +1 -0
  76. package/dist/memory/ChatHistory.js +143 -0
  77. package/dist/memory/ChatHistory.js.map +1 -0
  78. package/dist/memory/KnowledgeBase.d.ts +38 -0
  79. package/dist/memory/KnowledgeBase.d.ts.map +1 -0
  80. package/dist/memory/KnowledgeBase.js +139 -0
  81. package/dist/memory/KnowledgeBase.js.map +1 -0
  82. package/dist/memory/Summarizer.d.ts +12 -0
  83. package/dist/memory/Summarizer.d.ts.map +1 -0
  84. package/dist/memory/Summarizer.js +39 -0
  85. package/dist/memory/Summarizer.js.map +1 -0
  86. package/dist/memory/UpstashKnowledgeBase.d.ts +124 -0
  87. package/dist/memory/UpstashKnowledgeBase.d.ts.map +1 -0
  88. package/dist/memory/UpstashKnowledgeBase.js +152 -0
  89. package/dist/memory/UpstashKnowledgeBase.js.map +1 -0
  90. package/dist/memory/historyUtils.d.ts +58 -0
  91. package/dist/memory/historyUtils.d.ts.map +1 -0
  92. package/dist/memory/historyUtils.js +190 -0
  93. package/dist/memory/historyUtils.js.map +1 -0
  94. package/dist/memory/index.d.ts +7 -0
  95. package/dist/memory/index.d.ts.map +1 -0
  96. package/dist/memory/index.js +12 -0
  97. package/dist/memory/index.js.map +1 -0
  98. package/dist/memory/ingestKnowledgeBase.d.ts +17 -0
  99. package/dist/memory/ingestKnowledgeBase.d.ts.map +1 -0
  100. package/dist/memory/ingestKnowledgeBase.js +35 -0
  101. package/dist/memory/ingestKnowledgeBase.js.map +1 -0
  102. package/dist/services/MoralisService.d.ts +1350 -0
  103. package/dist/services/MoralisService.d.ts.map +1 -0
  104. package/dist/services/MoralisService.js +1364 -0
  105. package/dist/services/MoralisService.js.map +1 -0
  106. package/dist/services/PantographService.d.ts +38 -0
  107. package/dist/services/PantographService.d.ts.map +1 -0
  108. package/dist/services/PantographService.js +199 -0
  109. package/dist/services/PantographService.js.map +1 -0
  110. package/dist/services/PoolService.d.ts +241 -0
  111. package/dist/services/PoolService.d.ts.map +1 -0
  112. package/dist/services/PoolService.js +507 -0
  113. package/dist/services/PoolService.js.map +1 -0
  114. package/dist/services/UniswapService.d.ts +289 -0
  115. package/dist/services/UniswapService.d.ts.map +1 -0
  116. package/dist/services/UniswapService.js +585 -0
  117. package/dist/services/UniswapService.js.map +1 -0
  118. package/dist/services/swap/BaseSwapService.d.ts +17 -0
  119. package/dist/services/swap/BaseSwapService.d.ts.map +1 -0
  120. package/dist/services/swap/BaseSwapService.js +19 -0
  121. package/dist/services/swap/BaseSwapService.js.map +1 -0
  122. package/dist/services/swap/DebridgeAdapter.d.ts +20 -0
  123. package/dist/services/swap/DebridgeAdapter.d.ts.map +1 -0
  124. package/dist/services/swap/DebridgeAdapter.js +175 -0
  125. package/dist/services/swap/DebridgeAdapter.js.map +1 -0
  126. package/dist/services/swap/RelayAdapter.d.ts +19 -0
  127. package/dist/services/swap/RelayAdapter.d.ts.map +1 -0
  128. package/dist/services/swap/RelayAdapter.js +189 -0
  129. package/dist/services/swap/RelayAdapter.js.map +1 -0
  130. package/dist/services/swap/SwapServiceFactory.d.ts +24 -0
  131. package/dist/services/swap/SwapServiceFactory.d.ts.map +1 -0
  132. package/dist/services/swap/SwapServiceFactory.js +74 -0
  133. package/dist/services/swap/SwapServiceFactory.js.map +1 -0
  134. package/dist/services/swap/addresses.d.ts +3 -0
  135. package/dist/services/swap/addresses.d.ts.map +1 -0
  136. package/dist/services/swap/addresses.js +68 -0
  137. package/dist/services/swap/addresses.js.map +1 -0
  138. package/dist/services/swap/affiliate.d.ts +17 -0
  139. package/dist/services/swap/affiliate.d.ts.map +1 -0
  140. package/dist/services/swap/affiliate.js +126 -0
  141. package/dist/services/swap/affiliate.js.map +1 -0
  142. package/dist/services/swap/config.d.ts +9 -0
  143. package/dist/services/swap/config.d.ts.map +1 -0
  144. package/dist/services/swap/config.js +19 -0
  145. package/dist/services/swap/config.js.map +1 -0
  146. package/dist/services/swap/index.d.ts +10 -0
  147. package/dist/services/swap/index.d.ts.map +1 -0
  148. package/dist/services/swap/index.js +22 -0
  149. package/dist/services/swap/index.js.map +1 -0
  150. package/dist/services/swap/types.d.ts +89 -0
  151. package/dist/services/swap/types.d.ts.map +1 -0
  152. package/dist/services/swap/types.js +6 -0
  153. package/dist/services/swap/types.js.map +1 -0
  154. package/dist/tools/BaseTool.d.ts +15 -0
  155. package/dist/tools/BaseTool.d.ts.map +1 -0
  156. package/dist/tools/BaseTool.js +35 -0
  157. package/dist/tools/BaseTool.js.map +1 -0
  158. package/dist/tools/ToolRegistry.d.ts +27 -0
  159. package/dist/tools/ToolRegistry.d.ts.map +1 -0
  160. package/dist/tools/ToolRegistry.js +80 -0
  161. package/dist/tools/ToolRegistry.js.map +1 -0
  162. package/dist/tools/builtin/ai/MoralisCortexTool.d.ts +33 -0
  163. package/dist/tools/builtin/ai/MoralisCortexTool.d.ts.map +1 -0
  164. package/dist/tools/builtin/ai/MoralisCortexTool.js +76 -0
  165. package/dist/tools/builtin/ai/MoralisCortexTool.js.map +1 -0
  166. package/dist/tools/builtin/ai/SolanaCortexTool.d.ts +22 -0
  167. package/dist/tools/builtin/ai/SolanaCortexTool.d.ts.map +1 -0
  168. package/dist/tools/builtin/ai/SolanaCortexTool.js +80 -0
  169. package/dist/tools/builtin/ai/SolanaCortexTool.js.map +1 -0
  170. package/dist/tools/builtin/ai/index.d.ts +5 -0
  171. package/dist/tools/builtin/ai/index.d.ts.map +1 -0
  172. package/dist/tools/builtin/ai/index.js +8 -0
  173. package/dist/tools/builtin/ai/index.js.map +1 -0
  174. package/dist/tools/builtin/index.d.ts +6 -0
  175. package/dist/tools/builtin/index.d.ts.map +1 -0
  176. package/dist/tools/builtin/index.js +22 -0
  177. package/dist/tools/builtin/index.js.map +1 -0
  178. package/dist/tools/builtin/nft/NFTContractInfoTool.d.ts +21 -0
  179. package/dist/tools/builtin/nft/NFTContractInfoTool.d.ts.map +1 -0
  180. package/dist/tools/builtin/nft/NFTContractInfoTool.js +54 -0
  181. package/dist/tools/builtin/nft/NFTContractInfoTool.js.map +1 -0
  182. package/dist/tools/builtin/nft/NFTMetadataTool.d.ts +121 -0
  183. package/dist/tools/builtin/nft/NFTMetadataTool.d.ts.map +1 -0
  184. package/dist/tools/builtin/nft/NFTMetadataTool.js +159 -0
  185. package/dist/tools/builtin/nft/NFTMetadataTool.js.map +1 -0
  186. package/dist/tools/builtin/nft/WalletNFTsTool.d.ts +82 -0
  187. package/dist/tools/builtin/nft/WalletNFTsTool.d.ts.map +1 -0
  188. package/dist/tools/builtin/nft/WalletNFTsTool.js +172 -0
  189. package/dist/tools/builtin/nft/WalletNFTsTool.js.map +1 -0
  190. package/dist/tools/builtin/nft/index.d.ts +7 -0
  191. package/dist/tools/builtin/nft/index.d.ts.map +1 -0
  192. package/dist/tools/builtin/nft/index.js +10 -0
  193. package/dist/tools/builtin/nft/index.js.map +1 -0
  194. package/dist/tools/builtin/pool/EstimatePoolYieldTool.d.ts +124 -0
  195. package/dist/tools/builtin/pool/EstimatePoolYieldTool.d.ts.map +1 -0
  196. package/dist/tools/builtin/pool/EstimatePoolYieldTool.js +235 -0
  197. package/dist/tools/builtin/pool/EstimatePoolYieldTool.js.map +1 -0
  198. package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.d.ts +127 -0
  199. package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.d.ts.map +1 -0
  200. package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.js +517 -0
  201. package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.js.map +1 -0
  202. package/dist/tools/builtin/pool/PoolByAddressTool.d.ts +127 -0
  203. package/dist/tools/builtin/pool/PoolByAddressTool.d.ts.map +1 -0
  204. package/dist/tools/builtin/pool/PoolByAddressTool.js +237 -0
  205. package/dist/tools/builtin/pool/PoolByAddressTool.js.map +1 -0
  206. package/dist/tools/builtin/pool/PoolDetailTool.d.ts +127 -0
  207. package/dist/tools/builtin/pool/PoolDetailTool.d.ts.map +1 -0
  208. package/dist/tools/builtin/pool/PoolDetailTool.js +272 -0
  209. package/dist/tools/builtin/pool/PoolDetailTool.js.map +1 -0
  210. package/dist/tools/builtin/pool/PoolSearchTool.d.ts +50 -0
  211. package/dist/tools/builtin/pool/PoolSearchTool.d.ts.map +1 -0
  212. package/dist/tools/builtin/pool/PoolSearchTool.js +159 -0
  213. package/dist/tools/builtin/pool/PoolSearchTool.js.map +1 -0
  214. package/dist/tools/builtin/pool/PreviewAddLiquidityTool.d.ts +123 -0
  215. package/dist/tools/builtin/pool/PreviewAddLiquidityTool.d.ts.map +1 -0
  216. package/dist/tools/builtin/pool/PreviewAddLiquidityTool.js +380 -0
  217. package/dist/tools/builtin/pool/PreviewAddLiquidityTool.js.map +1 -0
  218. package/dist/tools/builtin/pool/TopPoolsTool.d.ts +68 -0
  219. package/dist/tools/builtin/pool/TopPoolsTool.d.ts.map +1 -0
  220. package/dist/tools/builtin/pool/TopPoolsTool.js +158 -0
  221. package/dist/tools/builtin/pool/TopPoolsTool.js.map +1 -0
  222. package/dist/tools/builtin/pool/index.d.ts +15 -0
  223. package/dist/tools/builtin/pool/index.d.ts.map +1 -0
  224. package/dist/tools/builtin/pool/index.js +18 -0
  225. package/dist/tools/builtin/pool/index.js.map +1 -0
  226. package/dist/tools/builtin/token/TokenAnalyticsTool.d.ts +71 -0
  227. package/dist/tools/builtin/token/TokenAnalyticsTool.d.ts.map +1 -0
  228. package/dist/tools/builtin/token/TokenAnalyticsTool.js +146 -0
  229. package/dist/tools/builtin/token/TokenAnalyticsTool.js.map +1 -0
  230. package/dist/tools/builtin/token/TokenHoldersTool.d.ts +81 -0
  231. package/dist/tools/builtin/token/TokenHoldersTool.d.ts.map +1 -0
  232. package/dist/tools/builtin/token/TokenHoldersTool.js +138 -0
  233. package/dist/tools/builtin/token/TokenHoldersTool.js.map +1 -0
  234. package/dist/tools/builtin/token/TokenInfoTool.d.ts +36 -0
  235. package/dist/tools/builtin/token/TokenInfoTool.d.ts.map +1 -0
  236. package/dist/tools/builtin/token/TokenInfoTool.js +163 -0
  237. package/dist/tools/builtin/token/TokenInfoTool.js.map +1 -0
  238. package/dist/tools/builtin/token/TokenScoreTool.d.ts +63 -0
  239. package/dist/tools/builtin/token/TokenScoreTool.d.ts.map +1 -0
  240. package/dist/tools/builtin/token/TokenScoreTool.js +147 -0
  241. package/dist/tools/builtin/token/TokenScoreTool.js.map +1 -0
  242. package/dist/tools/builtin/token/TopGainersTool.d.ts +46 -0
  243. package/dist/tools/builtin/token/TopGainersTool.d.ts.map +1 -0
  244. package/dist/tools/builtin/token/TopGainersTool.js +110 -0
  245. package/dist/tools/builtin/token/TopGainersTool.js.map +1 -0
  246. package/dist/tools/builtin/token/TopLosersTool.d.ts +66 -0
  247. package/dist/tools/builtin/token/TopLosersTool.d.ts.map +1 -0
  248. package/dist/tools/builtin/token/TopLosersTool.js +128 -0
  249. package/dist/tools/builtin/token/TopLosersTool.js.map +1 -0
  250. package/dist/tools/builtin/token/TrendingTokensTool.d.ts +39 -0
  251. package/dist/tools/builtin/token/TrendingTokensTool.d.ts.map +1 -0
  252. package/dist/tools/builtin/token/TrendingTokensTool.js +75 -0
  253. package/dist/tools/builtin/token/TrendingTokensTool.js.map +1 -0
  254. package/dist/tools/builtin/token/index.d.ts +15 -0
  255. package/dist/tools/builtin/token/index.d.ts.map +1 -0
  256. package/dist/tools/builtin/token/index.js +18 -0
  257. package/dist/tools/builtin/token/index.js.map +1 -0
  258. package/dist/tools/builtin/wallet/TransactionByHashTool.d.ts +70 -0
  259. package/dist/tools/builtin/wallet/TransactionByHashTool.d.ts.map +1 -0
  260. package/dist/tools/builtin/wallet/TransactionByHashTool.js +110 -0
  261. package/dist/tools/builtin/wallet/TransactionByHashTool.js.map +1 -0
  262. package/dist/tools/builtin/wallet/WalletApprovalsTool.d.ts +107 -0
  263. package/dist/tools/builtin/wallet/WalletApprovalsTool.d.ts.map +1 -0
  264. package/dist/tools/builtin/wallet/WalletApprovalsTool.js +163 -0
  265. package/dist/tools/builtin/wallet/WalletApprovalsTool.js.map +1 -0
  266. package/dist/tools/builtin/wallet/WalletDefiPositionsTool.d.ts +61 -0
  267. package/dist/tools/builtin/wallet/WalletDefiPositionsTool.d.ts.map +1 -0
  268. package/dist/tools/builtin/wallet/WalletDefiPositionsTool.js +99 -0
  269. package/dist/tools/builtin/wallet/WalletDefiPositionsTool.js.map +1 -0
  270. package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.d.ts +68 -0
  271. package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.d.ts.map +1 -0
  272. package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.js +114 -0
  273. package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.js.map +1 -0
  274. package/dist/tools/builtin/wallet/WalletDefiSummaryTool.d.ts +50 -0
  275. package/dist/tools/builtin/wallet/WalletDefiSummaryTool.d.ts.map +1 -0
  276. package/dist/tools/builtin/wallet/WalletDefiSummaryTool.js +79 -0
  277. package/dist/tools/builtin/wallet/WalletDefiSummaryTool.js.map +1 -0
  278. package/dist/tools/builtin/wallet/WalletHistoryTool.d.ts +31 -0
  279. package/dist/tools/builtin/wallet/WalletHistoryTool.d.ts.map +1 -0
  280. package/dist/tools/builtin/wallet/WalletHistoryTool.js +153 -0
  281. package/dist/tools/builtin/wallet/WalletHistoryTool.js.map +1 -0
  282. package/dist/tools/builtin/wallet/WalletNetWorthTool.d.ts +44 -0
  283. package/dist/tools/builtin/wallet/WalletNetWorthTool.d.ts.map +1 -0
  284. package/dist/tools/builtin/wallet/WalletNetWorthTool.js +122 -0
  285. package/dist/tools/builtin/wallet/WalletNetWorthTool.js.map +1 -0
  286. package/dist/tools/builtin/wallet/WalletNftTransfersTool.d.ts +86 -0
  287. package/dist/tools/builtin/wallet/WalletNftTransfersTool.d.ts.map +1 -0
  288. package/dist/tools/builtin/wallet/WalletNftTransfersTool.js +264 -0
  289. package/dist/tools/builtin/wallet/WalletNftTransfersTool.js.map +1 -0
  290. package/dist/tools/builtin/wallet/WalletPnlSummaryTool.d.ts +43 -0
  291. package/dist/tools/builtin/wallet/WalletPnlSummaryTool.d.ts.map +1 -0
  292. package/dist/tools/builtin/wallet/WalletPnlSummaryTool.js +88 -0
  293. package/dist/tools/builtin/wallet/WalletPnlSummaryTool.js.map +1 -0
  294. package/dist/tools/builtin/wallet/WalletPnlTool.d.ts +43 -0
  295. package/dist/tools/builtin/wallet/WalletPnlTool.d.ts.map +1 -0
  296. package/dist/tools/builtin/wallet/WalletPnlTool.js +174 -0
  297. package/dist/tools/builtin/wallet/WalletPnlTool.js.map +1 -0
  298. package/dist/tools/builtin/wallet/WalletTokenBalancesTool.d.ts +35 -0
  299. package/dist/tools/builtin/wallet/WalletTokenBalancesTool.d.ts.map +1 -0
  300. package/dist/tools/builtin/wallet/WalletTokenBalancesTool.js +67 -0
  301. package/dist/tools/builtin/wallet/WalletTokenBalancesTool.js.map +1 -0
  302. package/dist/tools/builtin/wallet/WalletTokenTransfersTool.d.ts +109 -0
  303. package/dist/tools/builtin/wallet/WalletTokenTransfersTool.d.ts.map +1 -0
  304. package/dist/tools/builtin/wallet/WalletTokenTransfersTool.js +353 -0
  305. package/dist/tools/builtin/wallet/WalletTokenTransfersTool.js.map +1 -0
  306. package/dist/tools/builtin/wallet/index.d.ts +25 -0
  307. package/dist/tools/builtin/wallet/index.d.ts.map +1 -0
  308. package/dist/tools/builtin/wallet/index.js +28 -0
  309. package/dist/tools/builtin/wallet/index.js.map +1 -0
  310. package/dist/tools/index.d.ts +4 -0
  311. package/dist/tools/index.d.ts.map +1 -0
  312. package/dist/tools/index.js +23 -0
  313. package/dist/tools/index.js.map +1 -0
  314. package/dist/types/index.d.ts +566 -0
  315. package/dist/types/index.d.ts.map +1 -0
  316. package/dist/types/index.js +6 -0
  317. package/dist/types/index.js.map +1 -0
  318. package/package.json +52 -0
@@ -0,0 +1,264 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WalletNftTransfersTool = void 0;
4
+ const BaseTool_1 = require("../../BaseTool");
5
+ const MoralisService_1 = require("../../../services/MoralisService");
6
+ /**
7
+ * Tool: get-wallet-nft-transfers
8
+ *
9
+ * Queries the dedicated Moralis NFT transfer endpoint
10
+ * `GET /{address}/nft/transfers`, which returns every NFT transfer involving
11
+ * the wallet — optionally scoped to specific NFT contract addresses.
12
+ *
13
+ * Each item is enriched with:
14
+ * - `direction`: "send" or "receive" (from from_address vs wallet)
15
+ * - `counterparty`: the other address with optional label/entity
16
+ * - `last_sale`: purchase price data if `includePrices=true`
17
+ *
18
+ * The response includes a `counterparties` aggregation with token IDs,
19
+ * collections, and timestamps for each unique sender/recipient.
20
+ */
21
+ class WalletNftTransfersTool extends BaseTool_1.BaseTool {
22
+ name = 'get-wallet-nft-transfers';
23
+ description = 'Get all NFT transfers for a wallet from the dedicated Moralis NFT transfers endpoint. ' +
24
+ 'Each transfer includes direction (send/receive), the exact counterparty address, token ID, collection, contract type (ERC721/ERC1155), and optional last sale price. ' +
25
+ "The response includes a 'counterparties' section aggregating unique senders/recipients with token IDs and collections. " +
26
+ 'Use this tool for questions like: ' +
27
+ '"Which NFTs did I sell and to whom?" (direction=send), ' +
28
+ '"Who sent me NFTs from collection 0x…?" (contractAddresses=[0x…], direction=receive), ' +
29
+ '"Show all transfers for my NFT collection 0x…" (contractAddresses=[0x…]), ' +
30
+ '"What NFTs did I mint?" (direction=receive), ' +
31
+ '"Show NFT sales with prices" (direction=send, includePrices=true). ' +
32
+ 'Supports: Ethereum, Optimism, BSC, Polygon, Base, Arbitrum, Avalanche, Linea, Solana. ' +
33
+ 'Returns paginated results — pass cursor to get the next page.';
34
+ category = 'blockchain-data';
35
+ parameters = [
36
+ {
37
+ name: 'address',
38
+ type: 'string',
39
+ description: 'EVM wallet address (0x…). If omitted, uses the connected wallet from user context.',
40
+ required: false,
41
+ },
42
+ {
43
+ name: 'chain',
44
+ type: 'string',
45
+ description: 'Hex chain ID: "0x1" Ethereum, "0xa" Optimism, "0x38" BSC, "0x89" Polygon, "0x2105" Base, ' +
46
+ '"0xa4b1" Arbitrum, "0xa86a" Avalanche, "0xe708" Linea . Defaults to connected chain.',
47
+ required: true,
48
+ },
49
+ {
50
+ name: 'contractAddresses',
51
+ type: 'array',
52
+ description: 'Filter by one or more NFT contract addresses (0x…). ' +
53
+ 'Use this to scope queries to a specific collection. Omit to return all NFT transfers.',
54
+ required: false,
55
+ items: { type: 'string' },
56
+ },
57
+ {
58
+ name: 'direction',
59
+ type: 'string',
60
+ description: 'Client-side direction filter: "send" (wallet sent the NFT), "receive" (wallet received it), "all" (default).',
61
+ required: false,
62
+ default: 'all',
63
+ },
64
+ {
65
+ name: 'limit',
66
+ type: 'number',
67
+ description: 'Page size (1-100, default 25).',
68
+ required: false,
69
+ default: 25,
70
+ },
71
+ {
72
+ name: 'fromDate',
73
+ type: 'string',
74
+ description: 'Inclusive start date (ISO-8601 or "YYYY-MM-DD").',
75
+ required: false,
76
+ },
77
+ {
78
+ name: 'toDate',
79
+ type: 'string',
80
+ description: 'Inclusive end date (ISO-8601 or "YYYY-MM-DD").',
81
+ required: false,
82
+ },
83
+ {
84
+ name: 'fromBlock',
85
+ type: 'number',
86
+ description: 'Minimum block number.',
87
+ required: false,
88
+ },
89
+ {
90
+ name: 'toBlock',
91
+ type: 'number',
92
+ description: 'Maximum block number.',
93
+ required: false,
94
+ },
95
+ {
96
+ name: 'cursor',
97
+ type: 'string',
98
+ description: 'Pagination cursor from a previous response.',
99
+ required: false,
100
+ },
101
+ {
102
+ name: 'order',
103
+ type: 'string',
104
+ description: '"DESC" newest first (default) or "ASC" oldest first.',
105
+ required: false,
106
+ default: 'DESC',
107
+ },
108
+ {
109
+ name: 'includePrices',
110
+ type: 'boolean',
111
+ description: 'If true, include last_sale price data (buyer, seller, price, USD value, payment token) on each transfer. ' +
112
+ 'Useful for questions about NFT sale prices.',
113
+ required: false,
114
+ },
115
+ ];
116
+ service;
117
+ constructor(config) {
118
+ super();
119
+ this.service = new MoralisService_1.MoralisService(config);
120
+ }
121
+ async run(args, userContext) {
122
+ const address = args.address || userContext?.walletAddress || undefined;
123
+ const chain = args.chain || userContext?.chain || undefined;
124
+ if (!address) {
125
+ return { error: 'No wallet address available. Please connect a wallet or pass "address".' };
126
+ }
127
+ const rawLimit = typeof args.limit === 'number' ? args.limit : Number(args.limit);
128
+ const limit = Number.isFinite(rawLimit) && rawLimit > 0 ? Math.min(100, Math.floor(rawLimit)) : 25;
129
+ const fromDate = typeof args.fromDate === 'string' && args.fromDate ? args.fromDate : undefined;
130
+ const toDate = typeof args.toDate === 'string' && args.toDate ? args.toDate : undefined;
131
+ const fromBlock = this.parseBlock(args.fromBlock);
132
+ const toBlock = this.parseBlock(args.toBlock);
133
+ const cursor = typeof args.cursor === 'string' && args.cursor ? args.cursor : undefined;
134
+ const rawOrder = typeof args.order === 'string' ? args.order.toUpperCase() : '';
135
+ const order = rawOrder === 'ASC' ? 'ASC' : 'DESC';
136
+ const includePrices = typeof args.includePrices === 'boolean' ? args.includePrices : undefined;
137
+ const rawDir = typeof args.direction === 'string' ? args.direction.trim().toLowerCase() : 'all';
138
+ const direction = rawDir === 'send' ? 'send' : rawDir === 'receive' ? 'receive' : 'all';
139
+ const contractAddresses = Array.isArray(args.contractAddresses)
140
+ ? args.contractAddresses
141
+ .filter((c) => typeof c === 'string' && !!c)
142
+ .map((c) => c.trim())
143
+ : undefined;
144
+ const result = await this.service.getWalletNftTransfers({
145
+ address,
146
+ chain,
147
+ contractAddresses,
148
+ limit,
149
+ fromDate,
150
+ toDate,
151
+ fromBlock,
152
+ toBlock,
153
+ cursor,
154
+ order,
155
+ includePrices,
156
+ });
157
+ if (!result.success) {
158
+ return { error: result.error || 'Failed to fetch NFT transfers' };
159
+ }
160
+ const walletLower = address.toLowerCase();
161
+ const rawItems = result.data?.result || [];
162
+ // Enrich with direction and counterparty
163
+ const allEnriched = rawItems.map((nft) => {
164
+ const isSend = nft.from_address.toLowerCase() === walletLower;
165
+ const dir = isSend ? 'send' : 'receive';
166
+ const counterparty = isSend ? nft.to_address : nft.from_address;
167
+ const counterpartyLabel = isSend ? (nft.to_address_label ?? undefined) : (nft.from_address_label ?? undefined);
168
+ const counterpartyEntity = isSend ? (nft.to_address_entity ?? undefined) : (nft.from_address_entity ?? undefined);
169
+ return {
170
+ ...nft,
171
+ direction: dir,
172
+ counterparty,
173
+ counterparty_label: counterpartyLabel,
174
+ counterparty_entity: counterpartyEntity,
175
+ };
176
+ });
177
+ // Apply client-side direction filter
178
+ const enriched = direction === 'all' ? allEnriched : allEnriched.filter((t) => t.direction === direction);
179
+ // Build counterparty aggregation
180
+ const counterparties = this.buildCounterparties(enriched);
181
+ return {
182
+ walletAddress: address,
183
+ chain: chain || 'default',
184
+ filters: {
185
+ contractAddresses: contractAddresses || null,
186
+ direction,
187
+ limit,
188
+ order,
189
+ fromDate: fromDate || null,
190
+ toDate: toDate || null,
191
+ fromBlock: fromBlock ?? null,
192
+ toBlock: toBlock ?? null,
193
+ includePrices: includePrices ?? null,
194
+ },
195
+ pagination: {
196
+ cursor: result.data?.cursor ?? null,
197
+ pageSize: result.data?.page_size ?? limit,
198
+ page: result.data?.page ?? null,
199
+ hasMore: !!result.data?.cursor,
200
+ },
201
+ transferCount: enriched.length,
202
+ transfers: enriched,
203
+ counterparties,
204
+ };
205
+ }
206
+ buildCounterparties(transfers) {
207
+ const sentMap = new Map();
208
+ const receivedMap = new Map();
209
+ for (const t of transfers) {
210
+ const map = t.direction === 'send' ? sentMap : receivedMap;
211
+ const key = t.counterparty.toLowerCase();
212
+ const collection = t.token_name ?? t.token_address;
213
+ const existing = map.get(key);
214
+ if (existing) {
215
+ existing.tokenIds.add(t.token_id);
216
+ existing.collections.add(collection);
217
+ existing.count += 1;
218
+ if (!existing.label && t.counterparty_label)
219
+ existing.label = t.counterparty_label;
220
+ if (!existing.entity && t.counterparty_entity)
221
+ existing.entity = t.counterparty_entity;
222
+ if (t.block_timestamp < existing.first)
223
+ existing.first = t.block_timestamp;
224
+ if (t.block_timestamp > existing.last)
225
+ existing.last = t.block_timestamp;
226
+ }
227
+ else {
228
+ map.set(key, {
229
+ label: t.counterparty_label,
230
+ entity: t.counterparty_entity,
231
+ tokenIds: new Set([t.token_id]),
232
+ collections: new Set([collection]),
233
+ count: 1,
234
+ first: t.block_timestamp,
235
+ last: t.block_timestamp,
236
+ });
237
+ }
238
+ }
239
+ const toArray = (map) => Array.from(map.entries())
240
+ .sort((a, b) => b[1].count - a[1].count)
241
+ .map(([addr, info]) => ({
242
+ address: addr,
243
+ label: info.label,
244
+ entity: info.entity,
245
+ token_ids: Array.from(info.tokenIds),
246
+ collections: Array.from(info.collections),
247
+ tx_count: info.count,
248
+ first_seen: info.first,
249
+ last_seen: info.last,
250
+ }));
251
+ return { sent: toArray(sentMap), received: toArray(receivedMap) };
252
+ }
253
+ parseBlock(raw) {
254
+ if (typeof raw === 'number')
255
+ return Number.isFinite(raw) ? raw : undefined;
256
+ if (typeof raw === 'string' && raw) {
257
+ const n = Number(raw);
258
+ return Number.isFinite(n) ? n : undefined;
259
+ }
260
+ return undefined;
261
+ }
262
+ }
263
+ exports.WalletNftTransfersTool = WalletNftTransfersTool;
264
+ //# sourceMappingURL=WalletNftTransfersTool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WalletNftTransfersTool.js","sourceRoot":"","sources":["../../../../src/tools/builtin/wallet/WalletNftTransfersTool.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAE1C,qEAI0C;AAwB1C;;;;;;;;;;;;;;GAcG;AACH,MAAa,sBAAuB,SAAQ,mBAAQ;IAClD,IAAI,GAAG,0BAA0B,CAAC;IAClC,WAAW,GACT,wFAAwF;QACxF,uKAAuK;QACvK,yHAAyH;QACzH,oCAAoC;QACpC,yDAAyD;QACzD,wFAAwF;QACxF,4EAA4E;QAC5E,+CAA+C;QAC/C,qEAAqE;QACrE,wFAAwF;QACxF,+DAA+D,CAAC;IAClE,QAAQ,GAAG,iBAAiB,CAAC;IAC7B,UAAU,GAAoB;QAC5B;YACE,IAAI,EAAE,SAAS;YACf,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OAAO,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;IACpE,CAAC;IAEO,UAAU,CAAC,GAAY;QAC7B,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;QAC3E,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,EAAE,CAAC;YACnC,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YACtB,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5C,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAnRD,wDAmRC"}
@@ -0,0 +1,43 @@
1
+ import { BaseTool } from '../../BaseTool';
2
+ import type { ToolParameter, UserContext } from '../../../types';
3
+ import { type MoralisServiceConfig, type WalletPnlDaysWindow } from '../../../services/MoralisService';
4
+ export type WalletPnlSummaryToolConfig = MoralisServiceConfig;
5
+ /**
6
+ * Tool: get-wallet-pnl-summary
7
+ *
8
+ * Queries `GET /wallets/{address}/profitability/summary` for an aggregate
9
+ * profit-and-loss view across all tokens the wallet has traded.
10
+ *
11
+ * Mainnet only — supported chains: Ethereum (0x1), Base (0x2105), Polygon (0x89).
12
+ */
13
+ export declare class WalletPnlSummaryTool extends BaseTool {
14
+ name: string;
15
+ description: string;
16
+ category: string;
17
+ parameters: ToolParameter[];
18
+ private service;
19
+ constructor(config?: WalletPnlSummaryToolConfig);
20
+ protected run(args: Record<string, unknown>, userContext?: UserContext): Promise<{
21
+ error: string;
22
+ walletAddress?: undefined;
23
+ chain?: undefined;
24
+ days?: undefined;
25
+ summary?: undefined;
26
+ } | {
27
+ walletAddress: string;
28
+ chain: string;
29
+ days: WalletPnlDaysWindow;
30
+ summary: {
31
+ totalCountOfTrades: number;
32
+ totalTradeVolume: string;
33
+ totalRealizedProfitUsd: string;
34
+ totalRealizedProfitPercentage: number;
35
+ totalBuys: number;
36
+ totalSells: number;
37
+ totalBoughtVolumeUsd: string;
38
+ totalSoldVolumeUsd: string;
39
+ };
40
+ error?: undefined;
41
+ }>;
42
+ }
43
+ //# sourceMappingURL=WalletPnlSummaryTool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WalletPnlSummaryTool.d.ts","sourceRoot":"","sources":["../../../../src/tools/builtin/wallet/WalletPnlSummaryTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAkB,KAAK,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvH,MAAM,MAAM,0BAA0B,GAAG,oBAAoB,CAAC;AAI9D;;;;;;;GAOG;AACH,qBAAa,oBAAqB,SAAQ,QAAQ;IAChD,IAAI,SAA4B;IAChC,WAAW,SAWgC;IAC3C,QAAQ,SAAqB;IAC7B,UAAU,EAAE,aAAa,EAAE,CAwBzB;IAEF,OAAO,CAAC,OAAO,CAAiB;gBAEpB,MAAM,CAAC,EAAE,0BAA0B;cAK/B,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,CAAC,EAAE,WAAW;;;;;;;;;;;;;;;;;;;;;;CAmC7E"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WalletPnlSummaryTool = void 0;
4
+ const BaseTool_1 = require("../../BaseTool");
5
+ const MoralisService_1 = require("../../../services/MoralisService");
6
+ const VALID_DAYS = ['all', '7', '30', '60', '90'];
7
+ /**
8
+ * Tool: get-wallet-pnl-summary
9
+ *
10
+ * Queries `GET /wallets/{address}/profitability/summary` for an aggregate
11
+ * profit-and-loss view across all tokens the wallet has traded.
12
+ *
13
+ * Mainnet only — supported chains: Ethereum (0x1), Base (0x2105), Polygon (0x89).
14
+ */
15
+ class WalletPnlSummaryTool extends BaseTool_1.BaseTool {
16
+ name = 'get-wallet-pnl-summary';
17
+ description = "Get a wallet's aggregate realized profit-and-loss summary across all tokens it has traded. " +
18
+ 'Returns: total_count_of_trades, total_trade_volume (USD), total_realized_profit_usd, ' +
19
+ 'total_realized_profit_percentage, total_buys, total_sells, total_sold_volume_usd, total_bought_volume_usd. ' +
20
+ 'Use this tool for questions like: ' +
21
+ '"How much profit have I made trading?", "What is my realized PnL?", ' +
22
+ '"How many trades have I done this month?" (days=30), "Am I up or down overall?". ' +
23
+ 'IMPORTANT — this endpoint only supports mainnet: Ethereum ("0x1"), Base ("0x2105"), Polygon ("0x89"). ' +
24
+ 'Use days="all" (default), "7", "30", "60", or "90" to scope the time window. ' +
25
+ 'Do NOT use for: per-token breakdown → get-wallet-pnl; ' +
26
+ 'current portfolio value → get-wallet-token-balance; ' +
27
+ 'transfer history → get-wallet-history.';
28
+ category = 'blockchain-data';
29
+ parameters = [
30
+ {
31
+ name: 'address',
32
+ type: 'string',
33
+ description: 'EVM wallet address (0x…). If omitted, uses the connected wallet from user context.',
34
+ required: false,
35
+ },
36
+ {
37
+ name: 'chain',
38
+ type: 'string',
39
+ description: 'Hex chain ID: "0x1" Ethereum, "0xa" Optimism, "0x38" BSC, "0x89" Polygon, "0x2105" Base, ' +
40
+ '"0xa4b1" Arbitrum, "0xa86a" Avalanche, "0xe708" Linea . Defaults to connected chain.',
41
+ required: true,
42
+ },
43
+ {
44
+ name: 'days',
45
+ type: 'string',
46
+ description: 'Time window for the summary. Values: "all" (default, lifetime), "7", "30", "60", "90". ' +
47
+ 'Pass "30" when the user asks about the last month, "7" for the last week, etc.',
48
+ required: false,
49
+ default: 'all',
50
+ },
51
+ ];
52
+ service;
53
+ constructor(config) {
54
+ super();
55
+ this.service = new MoralisService_1.MoralisService(config);
56
+ }
57
+ async run(args, userContext) {
58
+ const address = args.address || userContext?.walletAddress || undefined;
59
+ const chain = args.chain || userContext?.chain || undefined;
60
+ if (!address) {
61
+ return { error: 'No wallet address available. Please connect a wallet or pass "address".' };
62
+ }
63
+ const rawDays = typeof args.days === 'string' ? args.days.trim().toLowerCase() : '';
64
+ const days = VALID_DAYS.includes(rawDays) ? rawDays : undefined;
65
+ const result = await this.service.getWalletPnlSummary({ address, chain, days });
66
+ if (!result.success) {
67
+ return { error: result.error || 'Failed to fetch wallet PnL summary' };
68
+ }
69
+ const data = result.data;
70
+ return {
71
+ walletAddress: address,
72
+ chain: chain || 'default',
73
+ days: days ?? 'all',
74
+ summary: {
75
+ totalCountOfTrades: data.total_count_of_trades,
76
+ totalTradeVolume: data.total_trade_volume,
77
+ totalRealizedProfitUsd: data.total_realized_profit_usd,
78
+ totalRealizedProfitPercentage: data.total_realized_profit_percentage,
79
+ totalBuys: data.total_buys,
80
+ totalSells: data.total_sells,
81
+ totalBoughtVolumeUsd: data.total_bought_volume_usd,
82
+ totalSoldVolumeUsd: data.total_sold_volume_usd,
83
+ },
84
+ };
85
+ }
86
+ }
87
+ exports.WalletPnlSummaryTool = WalletPnlSummaryTool;
88
+ //# sourceMappingURL=WalletPnlSummaryTool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WalletPnlSummaryTool.js","sourceRoot":"","sources":["../../../../src/tools/builtin/wallet/WalletPnlSummaryTool.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAE1C,qEAAuH;AAIvH,MAAM,UAAU,GAA0B,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAEzE;;;;;;;GAOG;AACH,MAAa,oBAAqB,SAAQ,mBAAQ;IAChD,IAAI,GAAG,wBAAwB,CAAC;IAChC,WAAW,GACT,6FAA6F;QAC7F,uFAAuF;QACvF,6GAA6G;QAC7G,oCAAoC;QACpC,sEA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,CAAC,CAAC,CAAE,OAA+B,CAAC,CAAC,CAAC,SAAS,CAAC;QAEvG,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAEhF,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,oCAAoC,EAAE,CAAC;QACzE,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,CAAC,IAAK,CAAC;QAE1B,OAAO;YACL,aAAa,EAAE,OAAO;YACtB,KAAK,EAAE,KAAK,IAAI,SAAS;YACzB,IAAI,EAAE,IAAI,IAAI,KAAK;YACnB,OAAO,EAAE;gBACP,kBAAkB,EAAE,IAAI,CAAC,qBAAqB;gBAC9C,gBAAgB,EAAE,IAAI,CAAC,kBAAkB;gBACzC,sBAAsB,EAAE,IAAI,CAAC,yBAAyB;gBACtD,6BAA6B,EAAE,IAAI,CAAC,gCAAgC;gBACpE,SAAS,EAAE,IAAI,CAAC,UAAU;gBAC1B,UAAU,EAAE,IAAI,CAAC,WAAW;gBAC5B,oBAAoB,EAAE,IAAI,CAAC,uBAAuB;gBAClD,kBAAkB,EAAE,IAAI,CAAC,qBAAqB;aAC/C;SACF,CAAC;IACJ,CAAC;CACF;AAnFD,oDAmFC"}
@@ -0,0 +1,43 @@
1
+ import { BaseTool } from '../../BaseTool';
2
+ import type { ToolParameter, UserContext } from '../../../types';
3
+ import { type MoralisServiceConfig, type WalletPnlDaysWindow } from '../../../services/MoralisService';
4
+ export type WalletPnlToolConfig = MoralisServiceConfig;
5
+ export declare class WalletPnlTool extends BaseTool {
6
+ name: string;
7
+ description: string;
8
+ category: string;
9
+ parameters: ToolParameter[];
10
+ private service;
11
+ constructor(config?: WalletPnlToolConfig);
12
+ protected run(args: Record<string, unknown>, userContext?: UserContext): Promise<{
13
+ error: string;
14
+ walletAddress?: undefined;
15
+ chain?: undefined;
16
+ days?: undefined;
17
+ filters?: undefined;
18
+ tokenCount?: undefined;
19
+ tokens?: undefined;
20
+ } | {
21
+ walletAddress: string;
22
+ chain: string;
23
+ days: WalletPnlDaysWindow;
24
+ filters: {
25
+ tokenAddresses: string[] | null;
26
+ resolvedSymbols: {
27
+ symbol: string;
28
+ address: string;
29
+ }[] | null;
30
+ unresolvedSymbols: string[] | null;
31
+ };
32
+ tokenCount: number;
33
+ tokens: import("../../../services/MoralisService").WalletPnlTokenItem[];
34
+ error?: undefined;
35
+ }>;
36
+ /**
37
+ * Resolve a contract address from a token symbol.
38
+ * 1. Wallet balances (if wallet address available — most reliable)
39
+ * 2. Pantograph token search (fallback)
40
+ */
41
+ private resolveContractAddress;
42
+ }
43
+ //# sourceMappingURL=WalletPnlTool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WalletPnlTool.d.ts","sourceRoot":"","sources":["../../../../src/tools/builtin/wallet/WalletPnlTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAkB,KAAK,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvH,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAevD,qBAAa,aAAc,SAAQ,QAAQ;IACzC,IAAI,SAAoB;IACxB,WAAW,SAgBwC;IACnD,QAAQ,SAAqB;IAC7B,UAAU,EAAE,aAAa,EAAE,CAyCzB;IAEF,OAAO,CAAC,OAAO,CAAiB;gBAEpB,MAAM,CAAC,EAAE,mBAAmB;cAKxB,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,CAAC,EAAE,WAAW;;;;;;;;;;;;;;;wBAuB/B,MAAM;yBAAW,MAAM;;;;;;;;IA+CpE;;;;OAIG;YACW,sBAAsB;CA4BrC"}
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WalletPnlTool = void 0;
4
+ const BaseTool_1 = require("../../BaseTool");
5
+ const MoralisService_1 = require("../../../services/MoralisService");
6
+ const VALID_DAYS = ['all', '7', '30', '60', '90'];
7
+ /**
8
+ * Tool: get-wallet-pnl
9
+ *
10
+ * Queries `GET /wallets/{address}/profitability` for a per-token realized-PnL
11
+ * breakdown. Each entry covers average buy/sell price, invested amount,
12
+ * quantities traded, realized profit USD + percentage, and counts.
13
+ *
14
+ * Mainnet only — supported chains: Ethereum (0x1), Base (0x2105), Polygon (0x89).
15
+ */
16
+ const MAX_TOKEN_FILTERS = 25;
17
+ class WalletPnlTool extends BaseTool_1.BaseTool {
18
+ name = 'get-wallet-pnl';
19
+ description = "Get a wallet's realized profit-and-loss broken down per ERC-20 token. " +
20
+ 'Each entry includes: token_address, name, symbol, decimals, logo, avg_buy_price_usd, avg_sell_price_usd, ' +
21
+ 'total_usd_invested, total_tokens_bought, total_tokens_sold, total_sold_usd, avg_cost_of_quantity_sold, ' +
22
+ 'count_of_trades, realized_profit_usd, realized_profit_percentage, total_buys, total_sells, possible_spam. ' +
23
+ 'Use this tool for questions like: ' +
24
+ '"Which tokens made me the most money?", "What are my best/worst trades?", ' +
25
+ '"How much profit did I make on USDC?" (tokenSymbols=["USDC"]), ' +
26
+ '"PnL for PEPE and DEGEN this month" (tokenSymbols=["PEPE","DEGEN"], days=30), ' +
27
+ '"PnL breakdown for each token I traded this month" (days=30). ' +
28
+ 'IMPORTANT — this endpoint ONLY supports mainnet: Ethereum ("0x1"), Polygon ("0x89"), Base ("0x2105"). ' +
29
+ 'Use days="all" (default), "7", "30", "60", or "90" for the time window. ' +
30
+ 'Pass tokenSymbols (by ticker, auto-resolved) and/or tokenAddresses (raw 0x…) to restrict to specific tokens ' +
31
+ `— combined total capped at ${MAX_TOKEN_FILTERS}. ` +
32
+ 'Do NOT use for: aggregate summary → get-wallet-pnl-summary; ' +
33
+ 'current balances → get-wallet-token-balances; ' +
34
+ 'transfer history → get-wallet-token-transfers.';
35
+ category = 'blockchain-data';
36
+ parameters = [
37
+ {
38
+ name: 'address',
39
+ type: 'string',
40
+ description: 'EVM wallet address (0x…). If omitted, uses the connected wallet from user context.',
41
+ required: false,
42
+ },
43
+ {
44
+ name: 'chain',
45
+ type: 'string',
46
+ description: 'Hex chain ID: "0x1" Ethereum, "0xa" Optimism, "0x38" BSC, "0x89" Polygon, "0x2105" Base, ' +
47
+ '"0xa4b1" Arbitrum, "0xa86a" Avalanche, "0xe708" Linea. Defaults to connected chain.',
48
+ required: true,
49
+ },
50
+ {
51
+ name: 'days',
52
+ type: 'string',
53
+ description: 'Time window for the breakdown. Values: "all" (default, lifetime), "7", "30", "60", "90".',
54
+ required: false,
55
+ default: 'all',
56
+ },
57
+ {
58
+ name: 'tokenSymbols',
59
+ type: 'array',
60
+ description: 'Optional list of token symbols (e.g. ["USDC", "PEPE"]). Auto-resolved to contract addresses via ' +
61
+ "the connected wallet's balances first, then Pantograph search. Symbols that can't be resolved are skipped. " +
62
+ `Merged with tokenAddresses; combined total capped at ${MAX_TOKEN_FILTERS}.`,
63
+ required: false,
64
+ items: { type: 'string' },
65
+ },
66
+ {
67
+ name: 'tokenAddresses',
68
+ type: 'array',
69
+ description: `Optional list of raw ERC-20 contract addresses (0x…). Use when the exact addresses are already known. ` +
70
+ `Merged with tokenSymbols; combined total capped at ${MAX_TOKEN_FILTERS}.`,
71
+ required: false,
72
+ items: { type: 'string' },
73
+ },
74
+ ];
75
+ service;
76
+ constructor(config) {
77
+ super();
78
+ this.service = new MoralisService_1.MoralisService(config);
79
+ }
80
+ async run(args, userContext) {
81
+ const address = args.address || userContext?.walletAddress || undefined;
82
+ const chain = args.chain || userContext?.chain || undefined;
83
+ if (!address) {
84
+ return { error: 'No wallet address available. Please connect a wallet or pass "address".' };
85
+ }
86
+ const rawDays = typeof args.days === 'string' ? args.days.trim().toLowerCase() : '';
87
+ const days = VALID_DAYS.includes(rawDays) ? rawDays : undefined;
88
+ const rawTokenSymbols = Array.isArray(args.tokenSymbols)
89
+ ? args.tokenSymbols
90
+ .filter((s) => typeof s === 'string' && !!s.trim())
91
+ .map((s) => s.trim())
92
+ : [];
93
+ const rawTokenAddresses = Array.isArray(args.tokenAddresses)
94
+ ? args.tokenAddresses
95
+ .filter((a) => typeof a === 'string' && !!a.trim())
96
+ .map((a) => a.trim())
97
+ : [];
98
+ const resolvedFromSymbols = [];
99
+ const unresolvedSymbols = [];
100
+ if (rawTokenSymbols.length > 0) {
101
+ const resolutions = await Promise.all(rawTokenSymbols.map((sym) => this.resolveContractAddress(sym, chain, address)));
102
+ resolutions.forEach((resolved, i) => {
103
+ if (resolved)
104
+ resolvedFromSymbols.push({ symbol: rawTokenSymbols[i], address: resolved.address });
105
+ else
106
+ unresolvedSymbols.push(rawTokenSymbols[i]);
107
+ });
108
+ }
109
+ const mergedAddresses = dedupe([...resolvedFromSymbols.map((r) => r.address), ...rawTokenAddresses]).slice(0, MAX_TOKEN_FILTERS);
110
+ const tokenAddresses = mergedAddresses.length > 0 ? mergedAddresses : undefined;
111
+ const result = await this.service.getWalletPnl({
112
+ address,
113
+ chain,
114
+ days,
115
+ tokenAddresses,
116
+ });
117
+ if (!result.success) {
118
+ return { error: result.error || 'Failed to fetch wallet PnL' };
119
+ }
120
+ const tokens = result.data?.result ?? [];
121
+ return {
122
+ walletAddress: address,
123
+ chain: chain || 'default',
124
+ days: days ?? 'all',
125
+ filters: {
126
+ tokenAddresses: tokenAddresses ?? null,
127
+ resolvedSymbols: resolvedFromSymbols.length > 0 ? resolvedFromSymbols : null,
128
+ unresolvedSymbols: unresolvedSymbols.length > 0 ? unresolvedSymbols : null,
129
+ },
130
+ tokenCount: tokens.length,
131
+ tokens,
132
+ };
133
+ }
134
+ /**
135
+ * Resolve a contract address from a token symbol.
136
+ * 1. Wallet balances (if wallet address available — most reliable)
137
+ * 2. Pantograph token search (fallback)
138
+ */
139
+ async resolveContractAddress(symbol, chain, walletAddress) {
140
+ const symLower = symbol.toLowerCase();
141
+ if (walletAddress) {
142
+ const balRes = await this.service.getWalletTokenBalances({ address: walletAddress, chain });
143
+ if (balRes.success && balRes.data?.result?.length) {
144
+ const match = balRes.data.result.find((t) => (t.symbol ?? '').toLowerCase() === symLower);
145
+ if (match) {
146
+ return { address: match.token_address, symbol: match.symbol, name: match.name };
147
+ }
148
+ }
149
+ }
150
+ const searchRes = await this.service.searchTokensByKey({ key: symbol, chain });
151
+ if (searchRes.success && searchRes.data?.length) {
152
+ const exact = searchRes.data.find((t) => (t.symbol ?? '').toLowerCase() === symLower);
153
+ const candidate = exact ?? searchRes.data[0];
154
+ if (candidate?.token_address) {
155
+ return { address: candidate.token_address, symbol: candidate.symbol, name: candidate.name };
156
+ }
157
+ }
158
+ return undefined;
159
+ }
160
+ }
161
+ exports.WalletPnlTool = WalletPnlTool;
162
+ function dedupe(addresses) {
163
+ const seen = new Set();
164
+ const out = [];
165
+ for (const addr of addresses) {
166
+ const key = addr.toLowerCase();
167
+ if (seen.has(key))
168
+ continue;
169
+ seen.add(key);
170
+ out.push(addr);
171
+ }
172
+ return out;
173
+ }
174
+ //# sourceMappingURL=WalletPnlTool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WalletPnlTool.js","sourceRoot":"","sources":["../../../../src/tools/builtin/wallet/WalletPnlTool.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAE1C,qEAAuH;AAIvH,MAAM,UAAU,GAA0B,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAEzE;;;;;;;;GAQG;AACH,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,MAAa,aAAc,SAAQ,mBAAQ;IACzC,IAAI,GAAG,gBAAgB,CAAC;IACxB,WAAW,GACT,wEAAwE;QACxE,2GAA2G;QAC3G,y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