keyring-agent-core 0.2.1 → 0.2.2

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 (417) hide show
  1. package/dist/index.d.ts +6692 -27
  2. package/dist/index.js +877 -70
  3. package/package.json +4 -3
  4. package/dist/agent/AgentCore.d.ts +0 -256
  5. package/dist/agent/AgentCore.d.ts.map +0 -1
  6. package/dist/agent/AgentCore.js +0 -1093
  7. package/dist/agent/AgentCore.js.map +0 -1
  8. package/dist/agent/QueryRewriter.d.ts +0 -84
  9. package/dist/agent/QueryRewriter.d.ts.map +0 -1
  10. package/dist/agent/QueryRewriter.js +0 -306
  11. package/dist/agent/QueryRewriter.js.map +0 -1
  12. package/dist/agent/Router.d.ts +0 -33
  13. package/dist/agent/Router.d.ts.map +0 -1
  14. package/dist/agent/Router.js +0 -229
  15. package/dist/agent/Router.js.map +0 -1
  16. package/dist/agent/Subagent.d.ts +0 -80
  17. package/dist/agent/Subagent.d.ts.map +0 -1
  18. package/dist/agent/Subagent.js +0 -272
  19. package/dist/agent/Subagent.js.map +0 -1
  20. package/dist/agent/Synthesizer.d.ts +0 -11
  21. package/dist/agent/Synthesizer.d.ts.map +0 -1
  22. package/dist/agent/Synthesizer.js +0 -86
  23. package/dist/agent/Synthesizer.js.map +0 -1
  24. package/dist/agent/chatGraph.d.ts +0 -364
  25. package/dist/agent/chatGraph.d.ts.map +0 -1
  26. package/dist/agent/chatGraph.js +0 -184
  27. package/dist/agent/chatGraph.js.map +0 -1
  28. package/dist/agent/index.d.ts +0 -10
  29. package/dist/agent/index.d.ts.map +0 -1
  30. package/dist/agent/index.js +0 -24
  31. package/dist/agent/index.js.map +0 -1
  32. package/dist/agent/subagents/AiAgent.d.ts +0 -6
  33. package/dist/agent/subagents/AiAgent.d.ts.map +0 -1
  34. package/dist/agent/subagents/AiAgent.js +0 -52
  35. package/dist/agent/subagents/AiAgent.js.map +0 -1
  36. package/dist/agent/subagents/NftAgent.d.ts +0 -6
  37. package/dist/agent/subagents/NftAgent.d.ts.map +0 -1
  38. package/dist/agent/subagents/NftAgent.js +0 -79
  39. package/dist/agent/subagents/NftAgent.js.map +0 -1
  40. package/dist/agent/subagents/PoolAgent.d.ts +0 -6
  41. package/dist/agent/subagents/PoolAgent.d.ts.map +0 -1
  42. package/dist/agent/subagents/PoolAgent.js +0 -184
  43. package/dist/agent/subagents/PoolAgent.js.map +0 -1
  44. package/dist/agent/subagents/PoolSubgraphAgent.d.ts +0 -6
  45. package/dist/agent/subagents/PoolSubgraphAgent.d.ts.map +0 -1
  46. package/dist/agent/subagents/PoolSubgraphAgent.js +0 -117
  47. package/dist/agent/subagents/PoolSubgraphAgent.js.map +0 -1
  48. package/dist/agent/subagents/TokenAgent.d.ts +0 -6
  49. package/dist/agent/subagents/TokenAgent.d.ts.map +0 -1
  50. package/dist/agent/subagents/TokenAgent.js +0 -76
  51. package/dist/agent/subagents/TokenAgent.js.map +0 -1
  52. package/dist/agent/subagents/WalletActionAgent.d.ts +0 -6
  53. package/dist/agent/subagents/WalletActionAgent.d.ts.map +0 -1
  54. package/dist/agent/subagents/WalletActionAgent.js +0 -55
  55. package/dist/agent/subagents/WalletActionAgent.js.map +0 -1
  56. package/dist/agent/subagents/WalletAgent.d.ts +0 -6
  57. package/dist/agent/subagents/WalletAgent.d.ts.map +0 -1
  58. package/dist/agent/subagents/WalletAgent.js +0 -93
  59. package/dist/agent/subagents/WalletAgent.js.map +0 -1
  60. package/dist/agent/subagents/index.d.ts +0 -34
  61. package/dist/agent/subagents/index.d.ts.map +0 -1
  62. package/dist/agent/subagents/index.js +0 -69
  63. package/dist/agent/subagents/index.js.map +0 -1
  64. package/dist/constants/abi.d.ts +0 -551
  65. package/dist/constants/abi.d.ts.map +0 -1
  66. package/dist/constants/abi.js +0 -690
  67. package/dist/constants/abi.js.map +0 -1
  68. package/dist/functions/pool.d.ts +0 -25
  69. package/dist/functions/pool.d.ts.map +0 -1
  70. package/dist/functions/pool.js +0 -151
  71. package/dist/functions/pool.js.map +0 -1
  72. package/dist/functions/web3.d.ts +0 -31
  73. package/dist/functions/web3.d.ts.map +0 -1
  74. package/dist/functions/web3.js +0 -232
  75. package/dist/functions/web3.js.map +0 -1
  76. package/dist/index.d.ts.map +0 -1
  77. package/dist/index.js.map +0 -1
  78. package/dist/llm/GeminiProvider.d.ts +0 -16
  79. package/dist/llm/GeminiProvider.d.ts.map +0 -1
  80. package/dist/llm/GeminiProvider.js +0 -329
  81. package/dist/llm/GeminiProvider.js.map +0 -1
  82. package/dist/llm/index.d.ts +0 -2
  83. package/dist/llm/index.d.ts.map +0 -1
  84. package/dist/llm/index.js +0 -6
  85. package/dist/llm/index.js.map +0 -1
  86. package/dist/memory/ChatHistory.d.ts +0 -83
  87. package/dist/memory/ChatHistory.d.ts.map +0 -1
  88. package/dist/memory/ChatHistory.js +0 -143
  89. package/dist/memory/ChatHistory.js.map +0 -1
  90. package/dist/memory/KnowledgeBase.d.ts +0 -38
  91. package/dist/memory/KnowledgeBase.d.ts.map +0 -1
  92. package/dist/memory/KnowledgeBase.js +0 -139
  93. package/dist/memory/KnowledgeBase.js.map +0 -1
  94. package/dist/memory/Summarizer.d.ts +0 -12
  95. package/dist/memory/Summarizer.d.ts.map +0 -1
  96. package/dist/memory/Summarizer.js +0 -39
  97. package/dist/memory/Summarizer.js.map +0 -1
  98. package/dist/memory/UpstashKnowledgeBase.d.ts +0 -124
  99. package/dist/memory/UpstashKnowledgeBase.d.ts.map +0 -1
  100. package/dist/memory/UpstashKnowledgeBase.js +0 -152
  101. package/dist/memory/UpstashKnowledgeBase.js.map +0 -1
  102. package/dist/memory/historyUtils.d.ts +0 -58
  103. package/dist/memory/historyUtils.d.ts.map +0 -1
  104. package/dist/memory/historyUtils.js +0 -190
  105. package/dist/memory/historyUtils.js.map +0 -1
  106. package/dist/memory/index.d.ts +0 -7
  107. package/dist/memory/index.d.ts.map +0 -1
  108. package/dist/memory/index.js +0 -12
  109. package/dist/memory/index.js.map +0 -1
  110. package/dist/memory/ingestKnowledgeBase.d.ts +0 -17
  111. package/dist/memory/ingestKnowledgeBase.d.ts.map +0 -1
  112. package/dist/memory/ingestKnowledgeBase.js +0 -35
  113. package/dist/memory/ingestKnowledgeBase.js.map +0 -1
  114. package/dist/services/MoralisService.d.ts +0 -1328
  115. package/dist/services/MoralisService.d.ts.map +0 -1
  116. package/dist/services/MoralisService.js +0 -1239
  117. package/dist/services/MoralisService.js.map +0 -1
  118. package/dist/services/PantographService.d.ts +0 -98
  119. package/dist/services/PantographService.d.ts.map +0 -1
  120. package/dist/services/PantographService.js +0 -451
  121. package/dist/services/PantographService.js.map +0 -1
  122. package/dist/services/PoolService.d.ts +0 -238
  123. package/dist/services/PoolService.d.ts.map +0 -1
  124. package/dist/services/PoolService.js +0 -485
  125. package/dist/services/PoolService.js.map +0 -1
  126. package/dist/services/UniswapService.d.ts +0 -289
  127. package/dist/services/UniswapService.d.ts.map +0 -1
  128. package/dist/services/UniswapService.js +0 -585
  129. package/dist/services/UniswapService.js.map +0 -1
  130. package/dist/services/UniswapSubgraphService.d.ts +0 -144
  131. package/dist/services/UniswapSubgraphService.d.ts.map +0 -1
  132. package/dist/services/UniswapSubgraphService.js +0 -606
  133. package/dist/services/UniswapSubgraphService.js.map +0 -1
  134. package/dist/services/rpc.d.ts +0 -35
  135. package/dist/services/rpc.d.ts.map +0 -1
  136. package/dist/services/rpc.js +0 -110
  137. package/dist/services/rpc.js.map +0 -1
  138. package/dist/services/swap/BaseSwapService.d.ts +0 -17
  139. package/dist/services/swap/BaseSwapService.d.ts.map +0 -1
  140. package/dist/services/swap/BaseSwapService.js +0 -19
  141. package/dist/services/swap/BaseSwapService.js.map +0 -1
  142. package/dist/services/swap/DebridgeAdapter.d.ts +0 -37
  143. package/dist/services/swap/DebridgeAdapter.d.ts.map +0 -1
  144. package/dist/services/swap/DebridgeAdapter.js +0 -243
  145. package/dist/services/swap/DebridgeAdapter.js.map +0 -1
  146. package/dist/services/swap/RelayAdapter.d.ts +0 -19
  147. package/dist/services/swap/RelayAdapter.d.ts.map +0 -1
  148. package/dist/services/swap/RelayAdapter.js +0 -189
  149. package/dist/services/swap/RelayAdapter.js.map +0 -1
  150. package/dist/services/swap/SwapServiceFactory.d.ts +0 -25
  151. package/dist/services/swap/SwapServiceFactory.d.ts.map +0 -1
  152. package/dist/services/swap/SwapServiceFactory.js +0 -79
  153. package/dist/services/swap/SwapServiceFactory.js.map +0 -1
  154. package/dist/services/swap/addresses.d.ts +0 -3
  155. package/dist/services/swap/addresses.d.ts.map +0 -1
  156. package/dist/services/swap/addresses.js +0 -68
  157. package/dist/services/swap/addresses.js.map +0 -1
  158. package/dist/services/swap/affiliate.d.ts +0 -17
  159. package/dist/services/swap/affiliate.d.ts.map +0 -1
  160. package/dist/services/swap/affiliate.js +0 -126
  161. package/dist/services/swap/affiliate.js.map +0 -1
  162. package/dist/services/swap/config.d.ts +0 -9
  163. package/dist/services/swap/config.d.ts.map +0 -1
  164. package/dist/services/swap/config.js +0 -19
  165. package/dist/services/swap/config.js.map +0 -1
  166. package/dist/services/swap/index.d.ts +0 -10
  167. package/dist/services/swap/index.d.ts.map +0 -1
  168. package/dist/services/swap/index.js +0 -22
  169. package/dist/services/swap/index.js.map +0 -1
  170. package/dist/services/swap/types.d.ts +0 -89
  171. package/dist/services/swap/types.d.ts.map +0 -1
  172. package/dist/services/swap/types.js +0 -6
  173. package/dist/services/swap/types.js.map +0 -1
  174. package/dist/tools/BaseTool.d.ts +0 -15
  175. package/dist/tools/BaseTool.d.ts.map +0 -1
  176. package/dist/tools/BaseTool.js +0 -35
  177. package/dist/tools/BaseTool.js.map +0 -1
  178. package/dist/tools/ToolRegistry.d.ts +0 -27
  179. package/dist/tools/ToolRegistry.d.ts.map +0 -1
  180. package/dist/tools/ToolRegistry.js +0 -80
  181. package/dist/tools/ToolRegistry.js.map +0 -1
  182. package/dist/tools/builtin/ai/GeminiSearchAiTool.d.ts +0 -36
  183. package/dist/tools/builtin/ai/GeminiSearchAiTool.d.ts.map +0 -1
  184. package/dist/tools/builtin/ai/GeminiSearchAiTool.js +0 -91
  185. package/dist/tools/builtin/ai/GeminiSearchAiTool.js.map +0 -1
  186. package/dist/tools/builtin/ai/index.d.ts +0 -3
  187. package/dist/tools/builtin/ai/index.d.ts.map +0 -1
  188. package/dist/tools/builtin/ai/index.js +0 -6
  189. package/dist/tools/builtin/ai/index.js.map +0 -1
  190. package/dist/tools/builtin/index.d.ts +0 -8
  191. package/dist/tools/builtin/index.d.ts.map +0 -1
  192. package/dist/tools/builtin/index.js +0 -24
  193. package/dist/tools/builtin/index.js.map +0 -1
  194. package/dist/tools/builtin/nft/BaseNftMessageTool.d.ts +0 -35
  195. package/dist/tools/builtin/nft/BaseNftMessageTool.d.ts.map +0 -1
  196. package/dist/tools/builtin/nft/BaseNftMessageTool.js +0 -45
  197. package/dist/tools/builtin/nft/BaseNftMessageTool.js.map +0 -1
  198. package/dist/tools/builtin/nft/NFTContractInfoTool.d.ts +0 -15
  199. package/dist/tools/builtin/nft/NFTContractInfoTool.d.ts.map +0 -1
  200. package/dist/tools/builtin/nft/NFTContractInfoTool.js +0 -19
  201. package/dist/tools/builtin/nft/NFTContractInfoTool.js.map +0 -1
  202. package/dist/tools/builtin/nft/NFTMetadataTool.d.ts +0 -15
  203. package/dist/tools/builtin/nft/NFTMetadataTool.d.ts.map +0 -1
  204. package/dist/tools/builtin/nft/NFTMetadataTool.js +0 -20
  205. package/dist/tools/builtin/nft/NFTMetadataTool.js.map +0 -1
  206. package/dist/tools/builtin/nft/SendNftTool.d.ts +0 -14
  207. package/dist/tools/builtin/nft/SendNftTool.d.ts.map +0 -1
  208. package/dist/tools/builtin/nft/SendNftTool.js +0 -20
  209. package/dist/tools/builtin/nft/SendNftTool.js.map +0 -1
  210. package/dist/tools/builtin/nft/WalletNFTsTool.d.ts +0 -15
  211. package/dist/tools/builtin/nft/WalletNFTsTool.d.ts.map +0 -1
  212. package/dist/tools/builtin/nft/WalletNFTsTool.js +0 -20
  213. package/dist/tools/builtin/nft/WalletNFTsTool.js.map +0 -1
  214. package/dist/tools/builtin/nft/index.d.ts +0 -7
  215. package/dist/tools/builtin/nft/index.d.ts.map +0 -1
  216. package/dist/tools/builtin/nft/index.js +0 -10
  217. package/dist/tools/builtin/nft/index.js.map +0 -1
  218. package/dist/tools/builtin/pool/EstimatePoolYieldTool.d.ts +0 -124
  219. package/dist/tools/builtin/pool/EstimatePoolYieldTool.d.ts.map +0 -1
  220. package/dist/tools/builtin/pool/EstimatePoolYieldTool.js +0 -236
  221. package/dist/tools/builtin/pool/EstimatePoolYieldTool.js.map +0 -1
  222. package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.d.ts +0 -128
  223. package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.d.ts.map +0 -1
  224. package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.js +0 -520
  225. package/dist/tools/builtin/pool/OpenAddLiquidityFormTool.js.map +0 -1
  226. package/dist/tools/builtin/pool/PoolByAddressTool.d.ts +0 -127
  227. package/dist/tools/builtin/pool/PoolByAddressTool.d.ts.map +0 -1
  228. package/dist/tools/builtin/pool/PoolByAddressTool.js +0 -238
  229. package/dist/tools/builtin/pool/PoolByAddressTool.js.map +0 -1
  230. package/dist/tools/builtin/pool/PoolDetailTool.d.ts +0 -127
  231. package/dist/tools/builtin/pool/PoolDetailTool.d.ts.map +0 -1
  232. package/dist/tools/builtin/pool/PoolDetailTool.js +0 -273
  233. package/dist/tools/builtin/pool/PoolDetailTool.js.map +0 -1
  234. package/dist/tools/builtin/pool/PoolSearchTool.d.ts +0 -50
  235. package/dist/tools/builtin/pool/PoolSearchTool.d.ts.map +0 -1
  236. package/dist/tools/builtin/pool/PoolSearchTool.js +0 -160
  237. package/dist/tools/builtin/pool/PoolSearchTool.js.map +0 -1
  238. package/dist/tools/builtin/pool/PreviewAddLiquidityTool.d.ts +0 -124
  239. package/dist/tools/builtin/pool/PreviewAddLiquidityTool.d.ts.map +0 -1
  240. package/dist/tools/builtin/pool/PreviewAddLiquidityTool.js +0 -382
  241. package/dist/tools/builtin/pool/PreviewAddLiquidityTool.js.map +0 -1
  242. package/dist/tools/builtin/pool/TopPoolsTool.d.ts +0 -68
  243. package/dist/tools/builtin/pool/TopPoolsTool.d.ts.map +0 -1
  244. package/dist/tools/builtin/pool/TopPoolsTool.js +0 -159
  245. package/dist/tools/builtin/pool/TopPoolsTool.js.map +0 -1
  246. package/dist/tools/builtin/pool/index.d.ts +0 -15
  247. package/dist/tools/builtin/pool/index.d.ts.map +0 -1
  248. package/dist/tools/builtin/pool/index.js +0 -18
  249. package/dist/tools/builtin/pool/index.js.map +0 -1
  250. package/dist/tools/builtin/pool-subgraph/SubgraphCoinPoolPairsTool.d.ts +0 -54
  251. package/dist/tools/builtin/pool-subgraph/SubgraphCoinPoolPairsTool.d.ts.map +0 -1
  252. package/dist/tools/builtin/pool-subgraph/SubgraphCoinPoolPairsTool.js +0 -98
  253. package/dist/tools/builtin/pool-subgraph/SubgraphCoinPoolPairsTool.js.map +0 -1
  254. package/dist/tools/builtin/pool-subgraph/SubgraphPoolByAddressTool.d.ts +0 -63
  255. package/dist/tools/builtin/pool-subgraph/SubgraphPoolByAddressTool.d.ts.map +0 -1
  256. package/dist/tools/builtin/pool-subgraph/SubgraphPoolByAddressTool.js +0 -82
  257. package/dist/tools/builtin/pool-subgraph/SubgraphPoolByAddressTool.js.map +0 -1
  258. package/dist/tools/builtin/pool-subgraph/SubgraphPoolByPositionIdTool.d.ts +0 -79
  259. package/dist/tools/builtin/pool-subgraph/SubgraphPoolByPositionIdTool.d.ts.map +0 -1
  260. package/dist/tools/builtin/pool-subgraph/SubgraphPoolByPositionIdTool.js +0 -97
  261. package/dist/tools/builtin/pool-subgraph/SubgraphPoolByPositionIdTool.js.map +0 -1
  262. package/dist/tools/builtin/pool-subgraph/SubgraphPoolSearchTool.d.ts +0 -77
  263. package/dist/tools/builtin/pool-subgraph/SubgraphPoolSearchTool.d.ts.map +0 -1
  264. package/dist/tools/builtin/pool-subgraph/SubgraphPoolSearchTool.js +0 -190
  265. package/dist/tools/builtin/pool-subgraph/SubgraphPoolSearchTool.js.map +0 -1
  266. package/dist/tools/builtin/pool-subgraph/SubgraphPositionDetailTool.d.ts +0 -107
  267. package/dist/tools/builtin/pool-subgraph/SubgraphPositionDetailTool.d.ts.map +0 -1
  268. package/dist/tools/builtin/pool-subgraph/SubgraphPositionDetailTool.js +0 -92
  269. package/dist/tools/builtin/pool-subgraph/SubgraphPositionDetailTool.js.map +0 -1
  270. package/dist/tools/builtin/pool-subgraph/SubgraphTrendingPoolsTool.d.ts +0 -56
  271. package/dist/tools/builtin/pool-subgraph/SubgraphTrendingPoolsTool.d.ts.map +0 -1
  272. package/dist/tools/builtin/pool-subgraph/SubgraphTrendingPoolsTool.js +0 -94
  273. package/dist/tools/builtin/pool-subgraph/SubgraphTrendingPoolsTool.js.map +0 -1
  274. package/dist/tools/builtin/pool-subgraph/index.d.ts +0 -13
  275. package/dist/tools/builtin/pool-subgraph/index.d.ts.map +0 -1
  276. package/dist/tools/builtin/pool-subgraph/index.js +0 -18
  277. package/dist/tools/builtin/pool-subgraph/index.js.map +0 -1
  278. package/dist/tools/builtin/token/TokenAnalyticsTool.d.ts +0 -71
  279. package/dist/tools/builtin/token/TokenAnalyticsTool.d.ts.map +0 -1
  280. package/dist/tools/builtin/token/TokenAnalyticsTool.js +0 -147
  281. package/dist/tools/builtin/token/TokenAnalyticsTool.js.map +0 -1
  282. package/dist/tools/builtin/token/TokenHoldersTool.d.ts +0 -81
  283. package/dist/tools/builtin/token/TokenHoldersTool.d.ts.map +0 -1
  284. package/dist/tools/builtin/token/TokenHoldersTool.js +0 -139
  285. package/dist/tools/builtin/token/TokenHoldersTool.js.map +0 -1
  286. package/dist/tools/builtin/token/TokenInfoTool.d.ts +0 -40
  287. package/dist/tools/builtin/token/TokenInfoTool.d.ts.map +0 -1
  288. package/dist/tools/builtin/token/TokenInfoTool.js +0 -221
  289. package/dist/tools/builtin/token/TokenInfoTool.js.map +0 -1
  290. package/dist/tools/builtin/token/TokenScoreTool.d.ts +0 -63
  291. package/dist/tools/builtin/token/TokenScoreTool.d.ts.map +0 -1
  292. package/dist/tools/builtin/token/TokenScoreTool.js +0 -148
  293. package/dist/tools/builtin/token/TokenScoreTool.js.map +0 -1
  294. package/dist/tools/builtin/token/TopGainersTool.d.ts +0 -37
  295. package/dist/tools/builtin/token/TopGainersTool.d.ts.map +0 -1
  296. package/dist/tools/builtin/token/TopGainersTool.js +0 -100
  297. package/dist/tools/builtin/token/TopGainersTool.js.map +0 -1
  298. package/dist/tools/builtin/token/TopLosersTool.d.ts +0 -66
  299. package/dist/tools/builtin/token/TopLosersTool.d.ts.map +0 -1
  300. package/dist/tools/builtin/token/TopLosersTool.js +0 -129
  301. package/dist/tools/builtin/token/TopLosersTool.js.map +0 -1
  302. package/dist/tools/builtin/token/TrendingTokensTool.d.ts +0 -39
  303. package/dist/tools/builtin/token/TrendingTokensTool.d.ts.map +0 -1
  304. package/dist/tools/builtin/token/TrendingTokensTool.js +0 -83
  305. package/dist/tools/builtin/token/TrendingTokensTool.js.map +0 -1
  306. package/dist/tools/builtin/token/index.d.ts +0 -13
  307. package/dist/tools/builtin/token/index.d.ts.map +0 -1
  308. package/dist/tools/builtin/token/index.js +0 -16
  309. package/dist/tools/builtin/token/index.js.map +0 -1
  310. package/dist/tools/builtin/wallet/TransactionByHashTool.d.ts +0 -70
  311. package/dist/tools/builtin/wallet/TransactionByHashTool.d.ts.map +0 -1
  312. package/dist/tools/builtin/wallet/TransactionByHashTool.js +0 -111
  313. package/dist/tools/builtin/wallet/TransactionByHashTool.js.map +0 -1
  314. package/dist/tools/builtin/wallet/WalletApprovalsTool.d.ts +0 -107
  315. package/dist/tools/builtin/wallet/WalletApprovalsTool.d.ts.map +0 -1
  316. package/dist/tools/builtin/wallet/WalletApprovalsTool.js +0 -164
  317. package/dist/tools/builtin/wallet/WalletApprovalsTool.js.map +0 -1
  318. package/dist/tools/builtin/wallet/WalletDefiPositionsTool.d.ts +0 -61
  319. package/dist/tools/builtin/wallet/WalletDefiPositionsTool.d.ts.map +0 -1
  320. package/dist/tools/builtin/wallet/WalletDefiPositionsTool.js +0 -100
  321. package/dist/tools/builtin/wallet/WalletDefiPositionsTool.js.map +0 -1
  322. package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.d.ts +0 -68
  323. package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.d.ts.map +0 -1
  324. package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.js +0 -115
  325. package/dist/tools/builtin/wallet/WalletDefiProtocolPositionsTool.js.map +0 -1
  326. package/dist/tools/builtin/wallet/WalletDefiSummaryTool.d.ts +0 -50
  327. package/dist/tools/builtin/wallet/WalletDefiSummaryTool.d.ts.map +0 -1
  328. package/dist/tools/builtin/wallet/WalletDefiSummaryTool.js +0 -80
  329. package/dist/tools/builtin/wallet/WalletDefiSummaryTool.js.map +0 -1
  330. package/dist/tools/builtin/wallet/WalletHistoryTool.d.ts +0 -31
  331. package/dist/tools/builtin/wallet/WalletHistoryTool.d.ts.map +0 -1
  332. package/dist/tools/builtin/wallet/WalletHistoryTool.js +0 -154
  333. package/dist/tools/builtin/wallet/WalletHistoryTool.js.map +0 -1
  334. package/dist/tools/builtin/wallet/WalletNetWorthTool.d.ts +0 -44
  335. package/dist/tools/builtin/wallet/WalletNetWorthTool.d.ts.map +0 -1
  336. package/dist/tools/builtin/wallet/WalletNetWorthTool.js +0 -122
  337. package/dist/tools/builtin/wallet/WalletNetWorthTool.js.map +0 -1
  338. package/dist/tools/builtin/wallet/WalletNftTransfersTool.d.ts +0 -86
  339. package/dist/tools/builtin/wallet/WalletNftTransfersTool.d.ts.map +0 -1
  340. package/dist/tools/builtin/wallet/WalletNftTransfersTool.js +0 -265
  341. package/dist/tools/builtin/wallet/WalletNftTransfersTool.js.map +0 -1
  342. package/dist/tools/builtin/wallet/WalletPnlSummaryTool.d.ts +0 -43
  343. package/dist/tools/builtin/wallet/WalletPnlSummaryTool.d.ts.map +0 -1
  344. package/dist/tools/builtin/wallet/WalletPnlSummaryTool.js +0 -89
  345. package/dist/tools/builtin/wallet/WalletPnlSummaryTool.js.map +0 -1
  346. package/dist/tools/builtin/wallet/WalletPnlTool.d.ts +0 -43
  347. package/dist/tools/builtin/wallet/WalletPnlTool.d.ts.map +0 -1
  348. package/dist/tools/builtin/wallet/WalletPnlTool.js +0 -175
  349. package/dist/tools/builtin/wallet/WalletPnlTool.js.map +0 -1
  350. package/dist/tools/builtin/wallet/WalletTokenBalancesTool.d.ts +0 -35
  351. package/dist/tools/builtin/wallet/WalletTokenBalancesTool.d.ts.map +0 -1
  352. package/dist/tools/builtin/wallet/WalletTokenBalancesTool.js +0 -68
  353. package/dist/tools/builtin/wallet/WalletTokenBalancesTool.js.map +0 -1
  354. package/dist/tools/builtin/wallet/WalletTokenTransfersTool.d.ts +0 -109
  355. package/dist/tools/builtin/wallet/WalletTokenTransfersTool.d.ts.map +0 -1
  356. package/dist/tools/builtin/wallet/WalletTokenTransfersTool.js +0 -354
  357. package/dist/tools/builtin/wallet/WalletTokenTransfersTool.js.map +0 -1
  358. package/dist/tools/builtin/wallet/index.d.ts +0 -28
  359. package/dist/tools/builtin/wallet/index.d.ts.map +0 -1
  360. package/dist/tools/builtin/wallet/index.js +0 -32
  361. package/dist/tools/builtin/wallet/index.js.map +0 -1
  362. package/dist/tools/builtin/wallet-action/ApproveTokenTool.d.ts +0 -25
  363. package/dist/tools/builtin/wallet-action/ApproveTokenTool.d.ts.map +0 -1
  364. package/dist/tools/builtin/wallet-action/ApproveTokenTool.js +0 -98
  365. package/dist/tools/builtin/wallet-action/ApproveTokenTool.js.map +0 -1
  366. package/dist/tools/builtin/wallet-action/BaseWalletActionTool.d.ts +0 -211
  367. package/dist/tools/builtin/wallet-action/BaseWalletActionTool.d.ts.map +0 -1
  368. package/dist/tools/builtin/wallet-action/BaseWalletActionTool.js +0 -499
  369. package/dist/tools/builtin/wallet-action/BaseWalletActionTool.js.map +0 -1
  370. package/dist/tools/builtin/wallet-action/BuyTokenTool.d.ts +0 -240
  371. package/dist/tools/builtin/wallet-action/BuyTokenTool.d.ts.map +0 -1
  372. package/dist/tools/builtin/wallet-action/BuyTokenTool.js +0 -1257
  373. package/dist/tools/builtin/wallet-action/BuyTokenTool.js.map +0 -1
  374. package/dist/tools/builtin/wallet-action/SendNativeTool.d.ts +0 -41
  375. package/dist/tools/builtin/wallet-action/SendNativeTool.d.ts.map +0 -1
  376. package/dist/tools/builtin/wallet-action/SendNativeTool.js +0 -127
  377. package/dist/tools/builtin/wallet-action/SendNativeTool.js.map +0 -1
  378. package/dist/tools/builtin/wallet-action/SendTokenTool.d.ts +0 -63
  379. package/dist/tools/builtin/wallet-action/SendTokenTool.d.ts.map +0 -1
  380. package/dist/tools/builtin/wallet-action/SendTokenTool.js +0 -294
  381. package/dist/tools/builtin/wallet-action/SendTokenTool.js.map +0 -1
  382. package/dist/tools/builtin/wallet-action/SwapTokenTool.d.ts +0 -247
  383. package/dist/tools/builtin/wallet-action/SwapTokenTool.d.ts.map +0 -1
  384. package/dist/tools/builtin/wallet-action/SwapTokenTool.js +0 -1258
  385. package/dist/tools/builtin/wallet-action/SwapTokenTool.js.map +0 -1
  386. package/dist/tools/builtin/wallet-action/UnwrapNativeTool.d.ts +0 -20
  387. package/dist/tools/builtin/wallet-action/UnwrapNativeTool.d.ts.map +0 -1
  388. package/dist/tools/builtin/wallet-action/UnwrapNativeTool.js +0 -36
  389. package/dist/tools/builtin/wallet-action/UnwrapNativeTool.js.map +0 -1
  390. package/dist/tools/builtin/wallet-action/WrapNativeTool.d.ts +0 -23
  391. package/dist/tools/builtin/wallet-action/WrapNativeTool.d.ts.map +0 -1
  392. package/dist/tools/builtin/wallet-action/WrapNativeTool.js +0 -54
  393. package/dist/tools/builtin/wallet-action/WrapNativeTool.js.map +0 -1
  394. package/dist/tools/builtin/wallet-action/amountSpec.d.ts +0 -62
  395. package/dist/tools/builtin/wallet-action/amountSpec.d.ts.map +0 -1
  396. package/dist/tools/builtin/wallet-action/amountSpec.js +0 -93
  397. package/dist/tools/builtin/wallet-action/amountSpec.js.map +0 -1
  398. package/dist/tools/builtin/wallet-action/gasReserve.d.ts +0 -42
  399. package/dist/tools/builtin/wallet-action/gasReserve.d.ts.map +0 -1
  400. package/dist/tools/builtin/wallet-action/gasReserve.js +0 -103
  401. package/dist/tools/builtin/wallet-action/gasReserve.js.map +0 -1
  402. package/dist/tools/builtin/wallet-action/index.d.ts +0 -9
  403. package/dist/tools/builtin/wallet-action/index.d.ts.map +0 -1
  404. package/dist/tools/builtin/wallet-action/index.js +0 -20
  405. package/dist/tools/builtin/wallet-action/index.js.map +0 -1
  406. package/dist/tools/chainResolver.d.ts +0 -98
  407. package/dist/tools/chainResolver.d.ts.map +0 -1
  408. package/dist/tools/chainResolver.js +0 -302
  409. package/dist/tools/chainResolver.js.map +0 -1
  410. package/dist/tools/index.d.ts +0 -4
  411. package/dist/tools/index.d.ts.map +0 -1
  412. package/dist/tools/index.js +0 -23
  413. package/dist/tools/index.js.map +0 -1
  414. package/dist/types/index.d.ts +0 -777
  415. package/dist/types/index.d.ts.map +0 -1
  416. package/dist/types/index.js +0 -6
  417. package/dist/types/index.js.map +0 -1
@@ -1,485 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tickToPrice = exports.roundTickToSpacing = exports.priceToTick = exports.clampTick = exports.PoolService = exports.TRANSFER_TOPIC = exports.ZERO_ADDRESS = void 0;
4
- exports.getChainMeta = getChainMeta;
5
- exports.getNativeTokenInfo = getNativeTokenInfo;
6
- exports.buildRangePresets = buildRangePresets;
7
- const pool_1 = require("../functions/pool");
8
- Object.defineProperty(exports, "clampTick", { enumerable: true, get: function () { return pool_1.clampTick; } });
9
- Object.defineProperty(exports, "priceToTick", { enumerable: true, get: function () { return pool_1.priceToTick; } });
10
- Object.defineProperty(exports, "roundTickToSpacing", { enumerable: true, get: function () { return pool_1.roundTickToSpacing; } });
11
- Object.defineProperty(exports, "tickToPrice", { enumerable: true, get: function () { return pool_1.tickToPrice; } });
12
- const swap_1 = require("./swap");
13
- const rpc_1 = require("./rpc");
14
- // ============================================================
15
- // PoolService — on-chain reads + add-liquidity tx builders
16
- // ============================================================
17
- //
18
- // Self-contained: uses raw JSON-RPC (`eth_call`, `eth_getBalance`,
19
- // `eth_gasPrice`) and minimal ABI encode/decode helpers — no viem dependency.
20
- // Mirrors the behaviour of coinpool-v2's ProvideLiquidity flow, restricted
21
- // to native-coin input (the only mode supported by the gateway today).
22
- // ---- Chain registry ----
23
- exports.ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
24
- const CHAIN_REGISTRY = {
25
- '0x1': {
26
- hexId: '0x1',
27
- name: 'Ethereum',
28
- defaultRpc: rpc_1.DEFAULT_RPC_BY_CHAIN['0x1'],
29
- native: { symbol: 'ETH', name: 'Ether', decimals: 18, coingeckoId: 'ethereum' },
30
- defaultMintGasLimit: 1_200_000,
31
- },
32
- '0xa': {
33
- hexId: '0xa',
34
- name: 'Optimism',
35
- defaultRpc: rpc_1.DEFAULT_RPC_BY_CHAIN['0xa'],
36
- native: { symbol: 'ETH', name: 'Ether', decimals: 18, coingeckoId: 'ethereum' },
37
- defaultMintGasLimit: 1_200_000,
38
- },
39
- '0x38': {
40
- hexId: '0x38',
41
- name: 'BNB Smart Chain',
42
- defaultRpc: rpc_1.DEFAULT_RPC_BY_CHAIN['0x38'],
43
- native: { symbol: 'BNB', name: 'BNB', decimals: 18, coingeckoId: 'binancecoin' },
44
- defaultMintGasLimit: 1_200_000,
45
- },
46
- '0x89': {
47
- hexId: '0x89',
48
- name: 'Polygon',
49
- defaultRpc: rpc_1.DEFAULT_RPC_BY_CHAIN['0x89'],
50
- native: { symbol: 'MATIC', name: 'Polygon', decimals: 18, coingeckoId: 'matic-network' },
51
- defaultMintGasLimit: 1_200_000,
52
- },
53
- '0x2105': {
54
- hexId: '0x2105',
55
- name: 'Base',
56
- defaultRpc: rpc_1.DEFAULT_RPC_BY_CHAIN['0x2105'],
57
- native: { symbol: 'ETH', name: 'Ether', decimals: 18, coingeckoId: 'ethereum' },
58
- defaultMintGasLimit: 1_200_000,
59
- },
60
- '0xa4b1': {
61
- hexId: '0xa4b1',
62
- name: 'Arbitrum One',
63
- defaultRpc: rpc_1.DEFAULT_RPC_BY_CHAIN['0xa4b1'],
64
- native: { symbol: 'ETH', name: 'Ether', decimals: 18, coingeckoId: 'ethereum' },
65
- defaultMintGasLimit: 2_200_000,
66
- },
67
- '0xa86a': {
68
- hexId: '0xa86a',
69
- name: 'Avalanche',
70
- defaultRpc: rpc_1.DEFAULT_RPC_BY_CHAIN['0xa86a'],
71
- native: { symbol: 'AVAX', name: 'Avalanche', decimals: 18, coingeckoId: 'avalanche-2' },
72
- defaultMintGasLimit: 1_200_000,
73
- },
74
- '0xe708': {
75
- hexId: '0xe708',
76
- name: 'Linea',
77
- defaultRpc: rpc_1.DEFAULT_RPC_BY_CHAIN['0xe708'],
78
- native: { symbol: 'ETH', name: 'Ether', decimals: 18, coingeckoId: 'ethereum' },
79
- defaultMintGasLimit: 1_200_000,
80
- },
81
- };
82
- function getChainMeta(chainId) {
83
- return CHAIN_REGISTRY[chainId.toLowerCase()];
84
- }
85
- function getNativeTokenInfo(chainId) {
86
- return getChainMeta(chainId)?.native;
87
- }
88
- /** keccak256("Transfer(address,address,uint256)") — ERC-20 / ERC-721 transfer */
89
- exports.TRANSFER_TOPIC = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef';
90
- function buildRangePresets(input) {
91
- const stableTicks = input.stableTicks ?? 3;
92
- const widePercent = input.widePercent ?? { down: 50, up: 100 };
93
- const currentPrice = (0, pool_1.tickToPrice)(input.currentTick, input.token0Decimals, input.token1Decimals);
94
- // Stable: ±N tickSpacing units around current
95
- const stableLower = (0, pool_1.clampTick)((0, pool_1.roundTickToSpacing)(input.currentTick - stableTicks * input.tickSpacing, input.tickSpacing, 'down'));
96
- const stableUpper = (0, pool_1.clampTick)((0, pool_1.roundTickToSpacing)(input.currentTick + stableTicks * input.tickSpacing, input.tickSpacing, 'up'));
97
- // Wide: -down% / +up% around current price → convert to ticks → round to spacing
98
- const wideMinPrice = currentPrice * (1 - widePercent.down / 100);
99
- const wideMaxPrice = currentPrice * (1 + widePercent.up / 100);
100
- const wideLowerRaw = (0, pool_1.priceToTick)(wideMinPrice, input.token0Decimals, input.token1Decimals);
101
- const wideUpperRaw = (0, pool_1.priceToTick)(wideMaxPrice, input.token0Decimals, input.token1Decimals);
102
- const wideLower = (0, pool_1.clampTick)((0, pool_1.roundTickToSpacing)(wideLowerRaw, input.tickSpacing, 'down'));
103
- const wideUpper = (0, pool_1.clampTick)((0, pool_1.roundTickToSpacing)(wideUpperRaw, input.tickSpacing, 'up'));
104
- const toPreset = (id, label, description, tickLower, tickUpper) => {
105
- const minPrice = (0, pool_1.tickToPrice)(tickLower, input.token0Decimals, input.token1Decimals);
106
- const maxPrice = (0, pool_1.tickToPrice)(tickUpper, input.token0Decimals, input.token1Decimals);
107
- return {
108
- id,
109
- label,
110
- description,
111
- tickLower,
112
- tickUpper,
113
- minPrice,
114
- maxPrice,
115
- minPercentChange: ((minPrice - currentPrice) / currentPrice) * 100,
116
- maxPercentChange: ((maxPrice - currentPrice) / currentPrice) * 100,
117
- };
118
- };
119
- return [
120
- toPreset('stable', 'Stable', 'Good for stablecoins or low volatility pairs', stableLower, stableUpper),
121
- toPreset('wide', 'Wide', 'Good for volatile pairs', wideLower, wideUpper),
122
- ];
123
- }
124
- const SLOT0_SELECTOR = (0, pool_1.functionSelector)('slot0()');
125
- const LIQUIDITY_SELECTOR = (0, pool_1.functionSelector)('liquidity()');
126
- const TICK_SPACING_SELECTOR = (0, pool_1.functionSelector)('tickSpacing()');
127
- const FEE_SELECTOR = (0, pool_1.functionSelector)('fee()');
128
- const TOKEN0_SELECTOR = (0, pool_1.functionSelector)('token0()');
129
- const TOKEN1_SELECTOR = (0, pool_1.functionSelector)('token1()');
130
- const DECIMALS_SELECTOR = (0, pool_1.functionSelector)('decimals()');
131
- class PoolService {
132
- swapFactory;
133
- isProduction;
134
- constructor(config) {
135
- this.isProduction = config?.isProduction ?? true;
136
- this.swapFactory =
137
- config?.swapFactory ?? (this.isProduction ? swap_1.swapServiceFactory : new swap_1.SwapServiceFactory(undefined, false));
138
- }
139
- getRpcUrl(chainId) {
140
- // RPC comes from the core-wide shared overrides (AgentConfig.rpcUrls,
141
- // installed via setRpcOverrides), falling back to the chain default.
142
- const shared = (0, rpc_1.resolveRpcUrl)(chainId);
143
- if (shared)
144
- return shared;
145
- const meta = getChainMeta(chainId);
146
- if (!meta)
147
- throw new Error(`Unsupported chain: ${chainId}`);
148
- return meta.defaultRpc;
149
- }
150
- async getGatewayAddress(chainId) {
151
- return (0, swap_1.getGatewayAddress)(chainId, this.isProduction);
152
- }
153
- async getPositionManagerAddress(chainId) {
154
- return (0, swap_1.getPositionManagerAddress)(chainId, this.isProduction);
155
- }
156
- /** Generic eth_call helper. `data` is the encoded calldata (with selector). */
157
- async ethCall(chainId, to, data) {
158
- return (0, rpc_1.rpcCall)(this.getRpcUrl(chainId), 'eth_call', [{ to, data }, 'latest']);
159
- }
160
- /** Read native balance (wei) */
161
- async getNativeBalance(chainId, userAddress) {
162
- const hex = await (0, rpc_1.rpcCall)(this.getRpcUrl(chainId), 'eth_getBalance', [userAddress, 'latest']);
163
- return BigInt(hex);
164
- }
165
- /** Read current gas price (wei) */
166
- async getGasPrice(chainId) {
167
- const hex = await (0, rpc_1.rpcCall)(this.getRpcUrl(chainId), 'eth_gasPrice', []);
168
- return BigInt(hex);
169
- }
170
- /**
171
- * Fetch the receipt for a transaction. Returns null while the tx is still
172
- * pending. Throws on RPC errors.
173
- */
174
- async getTransactionReceipt(chainId, txHash) {
175
- const res = await (0, rpc_1.rpcCall)(this.getRpcUrl(chainId), 'eth_getTransactionReceipt', [
176
- txHash,
177
- ]);
178
- return res;
179
- }
180
- /**
181
- * Pull the minted NFT id out of a Uniswap V3 mint receipt. Looks for an
182
- * ERC-721 Transfer event from the zero address emitted by the position
183
- * manager contract. Returns null when no such log is present (pending tx,
184
- * failed tx, or wrong contract).
185
- */
186
- async extractMintedNftId(chainId, receipt) {
187
- const positionManager = await this.getPositionManagerAddress(chainId);
188
- if (!positionManager)
189
- return null;
190
- const pmLower = positionManager.toLowerCase();
191
- for (const log of receipt.logs ?? []) {
192
- if ((log.address ?? '').toLowerCase() !== pmLower)
193
- continue;
194
- const topics = log.topics ?? [];
195
- if (topics.length < 4)
196
- continue;
197
- if (topics[0]?.toLowerCase() !== exports.TRANSFER_TOPIC)
198
- continue;
199
- // Mint = transfer FROM zero address (topic[1] is the indexed `from`).
200
- const from = '0x' + topics[1].slice(-40).toLowerCase();
201
- if (from !== exports.ZERO_ADDRESS)
202
- continue;
203
- try {
204
- return BigInt(topics[3]).toString();
205
- }
206
- catch {
207
- return null;
208
- }
209
- }
210
- return null;
211
- }
212
- /**
213
- * Estimate the gas reserve we should subtract from the user's native balance
214
- * before quoting "spendable". Mirrors coinpool-v2: gasLimit × gasPrice × 1.8.
215
- */
216
- async estimateGasReserveWei(chainId) {
217
- const meta = getChainMeta(chainId);
218
- if (!meta)
219
- throw new Error(`Unsupported chain: ${chainId}`);
220
- const gasPrice = await this.getGasPrice(chainId);
221
- // ×18/10 for the 1.8× safety multiplier without floating point.
222
- return (BigInt(meta.defaultMintGasLimit) * gasPrice * 18n) / 10n;
223
- }
224
- /** Read full pool state in one batch of eth_calls */
225
- async readPoolOnchain(chainId, poolAddress) {
226
- const [slot0Hex, liquidityHex, tickSpacingHex, feeHex, token0Hex, token1Hex] = await Promise.all([
227
- this.ethCall(chainId, poolAddress, SLOT0_SELECTOR),
228
- this.ethCall(chainId, poolAddress, LIQUIDITY_SELECTOR),
229
- this.ethCall(chainId, poolAddress, TICK_SPACING_SELECTOR),
230
- this.ethCall(chainId, poolAddress, FEE_SELECTOR),
231
- this.ethCall(chainId, poolAddress, TOKEN0_SELECTOR),
232
- this.ethCall(chainId, poolAddress, TOKEN1_SELECTOR),
233
- ]);
234
- // slot0 returns: (sqrtPriceX96 uint160, tick int24, observationIndex uint16,
235
- // observationCardinality uint16, observationCardinalityNext uint16,
236
- // feeProtocol uint8, unlocked bool)
237
- const slot0Body = (0, pool_1.strip0x)(slot0Hex);
238
- const sqrtPriceX96 = (0, pool_1.decodeUint256)(slot0Body, 0);
239
- const tick = (0, pool_1.decodeInt24)(slot0Body, 64);
240
- const liquidity = (0, pool_1.decodeUint256)((0, pool_1.strip0x)(liquidityHex), 0);
241
- const tickSpacing = Number((0, pool_1.decodeInt24)((0, pool_1.strip0x)(tickSpacingHex), 0));
242
- const fee = Number((0, pool_1.decodeUint256)((0, pool_1.strip0x)(feeHex), 0));
243
- const token0 = (0, pool_1.decodeAddress)((0, pool_1.strip0x)(token0Hex), 0);
244
- const token1 = (0, pool_1.decodeAddress)((0, pool_1.strip0x)(token1Hex), 0);
245
- const [token0Decimals, token1Decimals] = await Promise.all([
246
- this.readErc20Decimals(chainId, token0),
247
- this.readErc20Decimals(chainId, token1),
248
- ]);
249
- const currentPrice = (0, pool_1.sqrtPriceX96ToPrice)(sqrtPriceX96, token0Decimals, token1Decimals);
250
- return {
251
- poolAddress,
252
- chainId,
253
- fee,
254
- tickSpacing,
255
- liquidity,
256
- sqrtPriceX96,
257
- currentTick: tick,
258
- token0,
259
- token1,
260
- currentPrice,
261
- };
262
- }
263
- async readErc20Decimals(chainId, tokenAddress) {
264
- if (tokenAddress.toLowerCase() === exports.ZERO_ADDRESS)
265
- return 18;
266
- const hex = await this.ethCall(chainId, tokenAddress, DECIMALS_SELECTOR);
267
- return Number((0, pool_1.decodeUint256)((0, pool_1.strip0x)(hex), 0));
268
- }
269
- // ---- Native price (USD) ----
270
- /**
271
- * Best-effort USD price for a chain's native coin. Tries Coingecko's free
272
- * simple-price endpoint; returns null on failure (caller can degrade
273
- * gracefully — show form without the USD warning).
274
- */
275
- async getNativePriceUsd(chainId) {
276
- const meta = getChainMeta(chainId);
277
- if (!meta)
278
- return null;
279
- try {
280
- const url = `https://api.coingecko.com/api/v3/simple/price?ids=${meta.native.coingeckoId}&vs_currencies=usd`;
281
- const res = await fetch(url);
282
- if (!res.ok)
283
- return null;
284
- const json = (await res.json());
285
- const price = json[meta.native.coingeckoId]?.usd;
286
- return typeof price === 'number' ? price : null;
287
- }
288
- catch {
289
- return null;
290
- }
291
- }
292
- // ---- Add-liquidity amount split ----
293
- /**
294
- * Given a native deposit and a tick range, split it across token0/token1
295
- * legs. Pure pool math — no swap quote calls.
296
- *
297
- * Uniswap V3 (in-range), using RAW √P (no decimal adjustment):
298
- * amount0_raw = L · (1/√P - 1/√Pmax) // token0 base units
299
- * amount1_raw = L · (√P - √Pmin) // token1 base units
300
- *
301
- * Critical: the V3 formula only works on raw sqrt price. Using a
302
- * decimal-adjusted √P silently breaks the amount0:amount1 ratio whenever
303
- * token0/token1 have different decimals (e.g. WETH/USDC: 18 vs 6).
304
- *
305
- * To split a single tokenIn (native) across both legs we need both legs
306
- * in the same unit. Convert amount0 → token1 human-space via the
307
- * decimal-adjusted pool price (`P_human = token1_human / token0_human`):
308
- * value0_in_t1 = (amount0_raw / 10^d0) · P_human
309
- * value1_in_t1 = amount1_raw / 10^d1
310
- * ratio0 = value0_in_t1 / (value0 + value1)
311
- *
312
- * Note: this assumes 1 native ↔ 1 token0 / 1 token1 in *value* — fine when
313
- * native is one of the pool tokens. When neither is native, swap
314
- * fees/spreads pull the deposit slightly off ratio and the gateway's
315
- * refund leg picks up the dust.
316
- */
317
- splitNativeAmountForRange(args) {
318
- const { nativeAmountWei, pool, tickLower, tickUpper, token0Decimals, token1Decimals } = args;
319
- // Raw sqrt prices (no decimal adjustment). sqrtPriceX96 / 2^96 = √(t1_raw/t0_raw).
320
- const Q96_NUM = 2 ** 96;
321
- const sqrtPRaw = Number(pool.sqrtPriceX96) / Q96_NUM;
322
- const sqrtPminRaw = Math.pow(1.0001, tickLower / 2);
323
- const sqrtPmaxRaw = Math.pow(1.0001, tickUpper / 2);
324
- // Below range → all token0; above range → all token1.
325
- if (sqrtPRaw <= sqrtPminRaw) {
326
- return { ratio0: 1, ratio1: 0, amountInFor0Wei: nativeAmountWei, amountInFor1Wei: 0n };
327
- }
328
- if (sqrtPRaw >= sqrtPmaxRaw) {
329
- return { ratio0: 0, ratio1: 1, amountInFor0Wei: 0n, amountInFor1Wei: nativeAmountWei };
330
- }
331
- // Per-unit-L raw amounts (token0/token1 base units, modulo L). L cancels.
332
- const amount0PerL = 1 / sqrtPRaw - 1 / sqrtPmaxRaw;
333
- const amount1PerL = sqrtPRaw - sqrtPminRaw;
334
- // Both legs in token1 raw units: value0 = amount0_t0_wei * (t1/t0)_raw.
335
- // (t1/t0)_raw = sqrtPRaw². The 10^d1 denominator is identical in both legs
336
- // and cancels in the ratio, so we don't apply decimals here at all.
337
- const priceRaw = sqrtPRaw * sqrtPRaw;
338
- const value0 = amount0PerL * priceRaw;
339
- const value1 = amount1PerL;
340
- const total = value0 + value1;
341
- if (!Number.isFinite(total) || total <= 0) {
342
- throw new Error('splitNativeAmountForRange: invalid total value');
343
- }
344
- const ratio0 = value0 / total;
345
- const ratio1 = 1 - ratio0;
346
- void token0Decimals;
347
- void token1Decimals;
348
- // SCALE=1e15: stays under Number.MAX_SAFE_INTEGER (~9.007e15) and ratio0
349
- // is in [0,1] so ratio0*SCALE never overflows. leg1 = total - leg0 keeps
350
- // the wei sum exact (no rounding loss).
351
- const SCALE = 1000000000000000n;
352
- const ratio0Scaled = BigInt(Math.floor(ratio0 * Number(SCALE)));
353
- const amountInFor0Wei = (nativeAmountWei * ratio0Scaled) / SCALE;
354
- const amountInFor1Wei = nativeAmountWei - amountInFor0Wei;
355
- return { ratio0, ratio1, amountInFor0Wei, amountInFor1Wei };
356
- }
357
- // ---- Swap quote (single-leg, same-chain) ----
358
- /**
359
- * Fetches a single-leg same-chain swap quote (native → token) used to mix
360
- * the user's native input into pool token0 / token1 before minting.
361
- *
362
- * Provider is picked by `SwapServiceFactory` from the (numeric) chain id —
363
- * deBridge for chains it supports, Relay otherwise. The return shape is
364
- * normalised: `{ to, data, value, minAmountOut }`, regardless of provider.
365
- *
366
- * Throws on failure; caller decides whether to surface or skip.
367
- */
368
- async fetchSwapLeg(args) {
369
- const numericChainId = Number.parseInt(args.chainId, 16);
370
- if (!Number.isFinite(numericChainId)) {
371
- throw new Error(`Invalid hex chain id: ${args.chainId}`);
372
- }
373
- const service = await this.swapFactory.getService(numericChainId);
374
- const quote = await service.getQuote({
375
- srcChainId: numericChainId,
376
- srcTokenAddress: args.tokenIn,
377
- srcTokenAmount: args.tokenInAmount,
378
- dstChainId: numericChainId,
379
- dstTokenAddress: args.tokenOut,
380
- recipientAddress: args.tokenOutRecipient,
381
- senderAddress: args.senderAddress ?? args.tokenOutRecipient,
382
- slippage: args.slippage,
383
- isCrossChain: false,
384
- });
385
- if (!quote.success || !quote.tx) {
386
- throw new Error(quote.errorMessage ?? 'Swap quote failed');
387
- }
388
- const tx = quote.tx;
389
- if (!tx.to || typeof tx.data !== 'string') {
390
- throw new Error('Swap quote returned an unsupported tx shape (non-EVM payload?)');
391
- }
392
- // minAmountOut shape differs per provider: deBridge returns raw.tokenOut.minAmount;
393
- // Relay surfaces it via raw.details.currencyOut.minimumAmount (string).
394
- const raw = (quote.raw ?? {});
395
- const minAmountOut = raw.tokenOut?.minAmount ?? raw.details?.currencyOut?.minimumAmount ?? '0';
396
- return {
397
- to: tx.to,
398
- data: tx.data,
399
- value: tx.value ?? '0',
400
- minAmountOut,
401
- };
402
- }
403
- // ---- Mint tx encoding ----
404
- /**
405
- * Encode a call to the CoinPool gateway's `mint(paymentInfo, exchanges, params)`
406
- * function. Layout matches coinpool-v2's GatewayAbi.
407
- *
408
- * Function signature:
409
- * mint(
410
- * PaymentInfo[2] paymentInfo,
411
- * Exchange[2] exchanges,
412
- * MintParams params
413
- * )
414
- *
415
- * Where:
416
- * PaymentInfo = (address tokenIn, uint256 tokenInAmount, address tokenOut, uint256 tokenOutAmount)
417
- * Exchange = (address to, bytes data, uint256 value)
418
- * MintParams = (uint24 fee, uint256 amount0Min, uint256 amount1Min, int24 tickLower, int24 tickUpper)
419
- */
420
- encodeMintCalldata(args) {
421
- if (args.paymentInfo.length !== 2 || args.exchanges.length !== 2) {
422
- throw new Error('encodeMintCalldata: paymentInfo and exchanges must each have length 2');
423
- }
424
- const selector = (0, pool_1.functionSelector)('mint((address,uint256,address,uint256)[2],(address,bytes,uint256)[2],(uint24,uint256,uint256,int24,int24))');
425
- // PaymentInfo[2] is a fixed-size array of static structs (4 × 32 bytes each)
426
- // → encoded inline (no offset).
427
- const paymentInfoEnc = args.paymentInfo
428
- .map((p) => (0, pool_1.encodeAddress)(p.tokenIn) +
429
- (0, pool_1.encodeUint)(p.tokenInAmount) +
430
- (0, pool_1.encodeAddress)(p.tokenOut) +
431
- (0, pool_1.encodeUint)(p.tokenOutAmount))
432
- .join('');
433
- // Exchange[2] contains a dynamic field (bytes), so it's a fixed array of dynamic
434
- // structs → encoded with offsets relative to the start of the array.
435
- const exchangeBodies = args.exchanges.map((e) => {
436
- const dataClean = (0, pool_1.strip0x)(e.data || '0x');
437
- const dataLen = dataClean.length / 2;
438
- const dataLenEnc = (0, pool_1.encodeUint)(dataLen);
439
- // Pad data to 32-byte boundary
440
- const padding = (64 - (dataClean.length % 64)) % 64;
441
- const dataPadded = dataClean + '0'.repeat(padding);
442
- // Inside one Exchange struct: head = (to, dataOffset, value); offsets are
443
- // relative to the struct start. dataOffset = 3*32 = 96.
444
- const head = (0, pool_1.encodeAddress)(e.to) + (0, pool_1.encodeUint)(96) + (0, pool_1.encodeUint)(e.value);
445
- return { head, body: dataLenEnc + dataPadded };
446
- });
447
- // For Exchange[2]: each element is itself a dynamic tuple. Encode each as a
448
- // standalone tuple (head + body), then prefix with offsets relative to the
449
- // start of the array (the array itself has no length prefix because it's fixed-size).
450
- const elementEncodings = exchangeBodies.map((e) => e.head + e.body);
451
- let cursor = elementEncodings.length * 32; // 2 offsets, each 32 bytes
452
- const offsets = [];
453
- for (const enc of elementEncodings) {
454
- offsets.push((0, pool_1.encodeUint)(cursor));
455
- cursor += enc.length / 2;
456
- }
457
- const exchangesEnc = offsets.join('') + elementEncodings.join('');
458
- // MintParams (static struct: uint24, uint256, uint256, int24, int24 → 5 slots)
459
- const mintParamsEnc = (0, pool_1.encodeUint)(args.fee, 24) +
460
- (0, pool_1.encodeUint)(args.amount0Min) +
461
- (0, pool_1.encodeUint)(args.amount1Min) +
462
- (0, pool_1.encodeInt24)(args.tickLower) +
463
- (0, pool_1.encodeInt24)(args.tickUpper);
464
- // Top-level args:
465
- // - paymentInfo: static (4*32*2 = 256 bytes inline)
466
- // - exchanges: dynamic → offset
467
- // - mintParams: static → inline
468
- const paymentInfoSize = 256; // 8 slots
469
- const mintParamsSize = 160; // 5 slots
470
- // Layout in calldata (after selector):
471
- // [paymentInfo inline (8 slots)]
472
- // [exchanges offset (1 slot)]
473
- // [mintParams inline (5 slots)]
474
- // [exchanges body]
475
- const exchangesOffset = paymentInfoSize + 32 + mintParamsSize;
476
- const body = paymentInfoEnc + (0, pool_1.encodeUint)(exchangesOffset) + mintParamsEnc + exchangesEnc;
477
- return selector + body;
478
- }
479
- // suppress ts unused warning for keccakHex (kept exported for future address-derive needs)
480
- _keccak(hex) {
481
- return (0, pool_1.keccakHex)(hex);
482
- }
483
- }
484
- exports.PoolService = PoolService;
485
- //# sourceMappingURL=PoolService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PoolService.js","sourceRoot":"","sources":["../../src/services/PoolService.ts"],"names":[],"mappings":";;;AA6GA,oCAEC;AAED,gDAEC;AAyED,8CA+CC;AA3OD,4CAe2B;AAkqBlB,0FAhrBP,gBAAS,OAgrBO;AAAE,4FAvqBlB,kBAAW,OAuqBkB;AAAE,mGAtqB/B,yBAAkB,OAsqB+B;AAAE,4FAnqBnD,kBAAW,OAmqBmD;AAjqBhE,iCAA8G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