@elizaos/plugin-wallet 2.0.0-beta.1

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 (200) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +64 -0
  3. package/auto-enable.ts +76 -0
  4. package/dist/LpManagementService-BWrQ5-cO.mjs +353 -0
  5. package/dist/MockLpService-D_Apn4Fd.mjs +99 -0
  6. package/dist/aerodrome-CfnESC32.mjs +890 -0
  7. package/dist/chunk-hT5z_Zn9.mjs +35 -0
  8. package/dist/index.d.mts +34727 -0
  9. package/dist/index.mjs +21590 -0
  10. package/dist/lib/server-wallet-trade.d.mts +34 -0
  11. package/dist/lib/server-wallet-trade.mjs +306 -0
  12. package/dist/meteora-BPX39hZo.mjs +22640 -0
  13. package/dist/orca-Bybp1HXO.mjs +249 -0
  14. package/dist/pancakeswp-CkEXlXti.mjs +604 -0
  15. package/dist/plugin-ZO_MTyd0.mjs +529 -0
  16. package/dist/raydium-rfaM9yEf.mjs +539 -0
  17. package/dist/sdk/index.d.mts +32492 -0
  18. package/dist/sdk/index.mjs +6415 -0
  19. package/dist/types-D5252NZk.mjs +487 -0
  20. package/dist/uniswap-CReXgXVN.mjs +573 -0
  21. package/dist/wallet-action.d.mts +6 -0
  22. package/dist/wallet-action.mjs +820 -0
  23. package/package.json +152 -0
  24. package/src/actions/failure-codes.ts +79 -0
  25. package/src/actions/index.ts +1 -0
  26. package/src/analytics/birdeye/actions/wallet-search-address.ts +9 -0
  27. package/src/analytics/birdeye/birdeye-task.ts +175 -0
  28. package/src/analytics/birdeye/birdeye.ts +813 -0
  29. package/src/analytics/birdeye/constants.ts +74 -0
  30. package/src/analytics/birdeye/providers/agent-portfolio-provider.ts +18 -0
  31. package/src/analytics/birdeye/providers/market.ts +227 -0
  32. package/src/analytics/birdeye/providers/portfolio-factory.test.ts +138 -0
  33. package/src/analytics/birdeye/providers/portfolio-factory.ts +252 -0
  34. package/src/analytics/birdeye/providers/trending.ts +365 -0
  35. package/src/analytics/birdeye/providers/wallet.ts +14 -0
  36. package/src/analytics/birdeye/search-category.test.ts +207 -0
  37. package/src/analytics/birdeye/search-category.ts +506 -0
  38. package/src/analytics/birdeye/service.ts +992 -0
  39. package/src/analytics/birdeye/tasks/birdeye.ts +232 -0
  40. package/src/analytics/birdeye/types/api/common.ts +305 -0
  41. package/src/analytics/birdeye/types/api/defi.ts +220 -0
  42. package/src/analytics/birdeye/types/api/pair.ts +200 -0
  43. package/src/analytics/birdeye/types/api/search.ts +86 -0
  44. package/src/analytics/birdeye/types/api/token.ts +635 -0
  45. package/src/analytics/birdeye/types/api/trader.ts +76 -0
  46. package/src/analytics/birdeye/types/api/wallet.ts +181 -0
  47. package/src/analytics/birdeye/types/shared.ts +106 -0
  48. package/src/analytics/birdeye/utils.ts +700 -0
  49. package/src/analytics/dexscreener/errors.ts +28 -0
  50. package/src/analytics/dexscreener/index.ts +3 -0
  51. package/src/analytics/dexscreener/search-category.test.ts +49 -0
  52. package/src/analytics/dexscreener/search-category.ts +42 -0
  53. package/src/analytics/dexscreener/service.ts +595 -0
  54. package/src/analytics/dexscreener/types.ts +128 -0
  55. package/src/analytics/lpinfo/index.d.ts +7 -0
  56. package/src/analytics/lpinfo/index.ts +52 -0
  57. package/src/analytics/lpinfo/kamino/README.md +102 -0
  58. package/src/analytics/lpinfo/kamino/index.ts +24 -0
  59. package/src/analytics/lpinfo/kamino/providers/kaminoLiquidityProvider.ts +422 -0
  60. package/src/analytics/lpinfo/kamino/providers/kaminoPoolProvider.ts +365 -0
  61. package/src/analytics/lpinfo/kamino/providers/kaminoProvider.ts +496 -0
  62. package/src/analytics/lpinfo/kamino/services/kaminoLiquidityService.ts +1123 -0
  63. package/src/analytics/lpinfo/kamino/services/kaminoService.ts +758 -0
  64. package/src/analytics/lpinfo/steer/README.md +169 -0
  65. package/src/analytics/lpinfo/steer/index.ts +23 -0
  66. package/src/analytics/lpinfo/steer/providers/steerLiquidityProvider.ts +544 -0
  67. package/src/analytics/lpinfo/steer/services/steerLiquidityService.ts +1690 -0
  68. package/src/analytics/lpinfo/steer/steer-display-types.ts +99 -0
  69. package/src/analytics/news/index.ts +52 -0
  70. package/src/analytics/news/interfaces/types.ts +222 -0
  71. package/src/analytics/news/providers/defiNewsProvider.ts +734 -0
  72. package/src/analytics/news/services/newsDataService.ts +332 -0
  73. package/src/analytics/news/utils/formatters.ts +151 -0
  74. package/src/analytics/token-info/action.ts +240 -0
  75. package/src/analytics/token-info/index.ts +3 -0
  76. package/src/analytics/token-info/params.ts +215 -0
  77. package/src/analytics/token-info/providers.ts +681 -0
  78. package/src/analytics/token-info/service.ts +168 -0
  79. package/src/analytics/token-info/types.ts +74 -0
  80. package/src/audit/audit-log.ts +45 -0
  81. package/src/browser-shim/build-shim.ts +123 -0
  82. package/src/browser-shim/index.ts +5 -0
  83. package/src/browser-shim/shim.template.js +563 -0
  84. package/src/chains/evm/.github/workflows/npm-deploy.yml +112 -0
  85. package/src/chains/evm/LICENSE +21 -0
  86. package/src/chains/evm/README.md +106 -0
  87. package/src/chains/evm/actions/helpers.ts +147 -0
  88. package/src/chains/evm/actions/swap.ts +839 -0
  89. package/src/chains/evm/actions/transfer.ts +254 -0
  90. package/src/chains/evm/biome.json +61 -0
  91. package/src/chains/evm/bridge-router.ts +660 -0
  92. package/src/chains/evm/build.ts +89 -0
  93. package/src/chains/evm/chain-handler.ts +416 -0
  94. package/src/chains/evm/constants.ts +23 -0
  95. package/src/chains/evm/contracts/artifacts/OZGovernor.json +1707 -0
  96. package/src/chains/evm/contracts/artifacts/TimelockController.json +1007 -0
  97. package/src/chains/evm/contracts/artifacts/VoteToken.json +895 -0
  98. package/src/chains/evm/dex/aerodrome/index.ts +34 -0
  99. package/src/chains/evm/dex/aerodrome/services/AerodromeLpService.ts +558 -0
  100. package/src/chains/evm/dex/aerodrome/types.ts +318 -0
  101. package/src/chains/evm/dex/pancakeswp/index.ts +35 -0
  102. package/src/chains/evm/dex/pancakeswp/services/PancakeSwapV3LpService.ts +743 -0
  103. package/src/chains/evm/dex/pancakeswp/types.ts +65 -0
  104. package/src/chains/evm/dex/uniswap/index.ts +35 -0
  105. package/src/chains/evm/dex/uniswap/services/UniswapV3LpService.ts +759 -0
  106. package/src/chains/evm/dex/uniswap/types.ts +390 -0
  107. package/src/chains/evm/generated/specs/spec-helpers.ts +73 -0
  108. package/src/chains/evm/generated/specs/specs.ts +151 -0
  109. package/src/chains/evm/gov-router.ts +250 -0
  110. package/src/chains/evm/index.browser.ts +16 -0
  111. package/src/chains/evm/index.ts +31 -0
  112. package/src/chains/evm/prompts.ts +193 -0
  113. package/src/chains/evm/providers/get-balance.ts +123 -0
  114. package/src/chains/evm/providers/wallet.ts +715 -0
  115. package/src/chains/evm/routes/sign.ts +333 -0
  116. package/src/chains/evm/rpc-providers.ts +410 -0
  117. package/src/chains/evm/service.ts +140 -0
  118. package/src/chains/evm/templates/index.ts +10 -0
  119. package/src/chains/evm/types/index.ts +432 -0
  120. package/src/chains/evm/vitest.config.ts +18 -0
  121. package/src/chains/registry.ts +668 -0
  122. package/src/chains/solana/README.md +367 -0
  123. package/src/chains/wallet-action.ts +533 -0
  124. package/src/chains/wallet-router.test.ts +296 -0
  125. package/src/contracts.ts +65 -0
  126. package/src/core-augmentation.ts +10 -0
  127. package/src/index.ts +71 -0
  128. package/src/lib/server-wallet-trade.ts +192 -0
  129. package/src/lib/wallet-export-guard.ts +330 -0
  130. package/src/lp/actions/liquidity.ts +827 -0
  131. package/src/lp/e2e/real-token-tests.ts +428 -0
  132. package/src/lp/e2e/scenarios.ts +470 -0
  133. package/src/lp/e2e/test-utils.ts +145 -0
  134. package/src/lp/lp-manager-entry.ts +303 -0
  135. package/src/lp/services/ConcentratedLiquidityService.ts +120 -0
  136. package/src/lp/services/DexInteractionService.ts +226 -0
  137. package/src/lp/services/LpManagementService.test.ts +148 -0
  138. package/src/lp/services/LpManagementService.ts +632 -0
  139. package/src/lp/services/UserLpProfileService.ts +163 -0
  140. package/src/lp/services/VaultService.ts +153 -0
  141. package/src/lp/services/YieldOptimizationService.ts +344 -0
  142. package/src/lp/services/__tests__/MockLpService.ts +146 -0
  143. package/src/lp/tasks/LpAutoRebalanceTask.ts +117 -0
  144. package/src/lp/tasks/__tests__/LpAutoRebalanceTask.test.ts +370 -0
  145. package/src/lp/types.ts +582 -0
  146. package/src/lp/utils/solanaClient.ts +143 -0
  147. package/src/plugin.ts +125 -0
  148. package/src/policy/policy.ts +19 -0
  149. package/src/providers/canonical-provider.ts +27 -0
  150. package/src/providers/unified-wallet-provider.ts +79 -0
  151. package/src/register-routes.ts +11 -0
  152. package/src/routes/plugin.ts +47 -0
  153. package/src/routes/wallet-market-overview-route.ts +869 -0
  154. package/src/sdk/abi.ts +258 -0
  155. package/src/sdk/bridge/abis.ts +126 -0
  156. package/src/sdk/bridge/client.ts +518 -0
  157. package/src/sdk/bridge/index.ts +56 -0
  158. package/src/sdk/bridge/solana.ts +604 -0
  159. package/src/sdk/bridge/types.ts +202 -0
  160. package/src/sdk/convenience.ts +347 -0
  161. package/src/sdk/escrow/MutualStakeEscrow.ts +480 -0
  162. package/src/sdk/escrow/types.ts +64 -0
  163. package/src/sdk/escrow/verifiers.ts +73 -0
  164. package/src/sdk/identity/erc8004.ts +692 -0
  165. package/src/sdk/identity/reputation.ts +449 -0
  166. package/src/sdk/identity/uaid.ts +497 -0
  167. package/src/sdk/identity/validation.ts +372 -0
  168. package/src/sdk/index.ts +763 -0
  169. package/src/sdk/policy/SpendingPolicy.ts +260 -0
  170. package/src/sdk/policy/UptoBillingPolicy.ts +320 -0
  171. package/src/sdk/router/PaymentRouter.ts +215 -0
  172. package/src/sdk/router/index.ts +8 -0
  173. package/src/sdk/swap/SwapModule.ts +310 -0
  174. package/src/sdk/swap/abi.ts +117 -0
  175. package/src/sdk/swap/index.ts +34 -0
  176. package/src/sdk/swap/types.ts +135 -0
  177. package/src/sdk/tokens/decimals.ts +140 -0
  178. package/src/sdk/tokens/registry.ts +911 -0
  179. package/src/sdk/tokens/solana.ts +419 -0
  180. package/src/sdk/tokens/transfers.ts +327 -0
  181. package/src/sdk/types.ts +158 -0
  182. package/src/sdk/wallet-core.ts +115 -0
  183. package/src/sdk/x402/budget.ts +168 -0
  184. package/src/sdk/x402/chains/abstract/index.ts +280 -0
  185. package/src/sdk/x402/client.ts +320 -0
  186. package/src/sdk/x402/index.ts +46 -0
  187. package/src/sdk/x402/middleware.ts +92 -0
  188. package/src/sdk/x402/multi-asset.ts +144 -0
  189. package/src/sdk/x402/types.ts +156 -0
  190. package/src/services/wallet-backend-service.ts +328 -0
  191. package/src/types/wallet-router.ts +227 -0
  192. package/src/utils/intent-trajectory.ts +106 -0
  193. package/src/wallet/backend.ts +62 -0
  194. package/src/wallet/errors.ts +49 -0
  195. package/src/wallet/index.ts +27 -0
  196. package/src/wallet/local-eoa-backend.ts +201 -0
  197. package/src/wallet/pending.ts +60 -0
  198. package/src/wallet/select-backend.ts +47 -0
  199. package/src/wallet/steward-backend.ts +161 -0
  200. package/src/wallet-action.ts +1 -0
@@ -0,0 +1,365 @@
1
+ // @ts-nocheck — legacy code from absorbed plugins (lp-manager, lpinfo, dexscreener, defi-news, birdeye); strict types pending cleanup
2
+ import type { IAgentRuntime, Memory, Provider, State } from "@elizaos/core";
3
+ import { ModelType } from "@elizaos/core";
4
+ import type { KaminoLiquidityService } from "../services/kaminoLiquidityService";
5
+
6
+ const KAMINO_POOL_TEXT_LIMIT = 4000;
7
+
8
+ /**
9
+ * Kamino Pool-Specific Provider
10
+ * Provides detailed information about specific Kamino pools by their address
11
+ */
12
+ export const kaminoPoolProvider: Provider = {
13
+ name: "KAMINO_POOL",
14
+ description:
15
+ "Provides detailed information about specific Kamino liquidity pools by pool address",
16
+ descriptionCompressed:
17
+ "provide detail information specific Kamino liquidity pool pool address",
18
+ dynamic: true,
19
+ contexts: ["finance", "crypto", "wallet"],
20
+ contextGate: { anyOf: ["finance", "crypto", "wallet"] },
21
+ cacheStable: false,
22
+ cacheScope: "turn",
23
+ roleGate: { minRole: "USER" },
24
+ get: async (runtime: IAgentRuntime, message: Memory, _state: State) => {
25
+ console.log("KAMINO_POOL provider called");
26
+
27
+ let poolInfo = "";
28
+
29
+ try {
30
+ // Extract pool address from message content
31
+ const content = message.content.text || "";
32
+ const poolMatch = content.match(/([A-Za-z0-9]{32,44})/);
33
+
34
+ let poolAddress = "";
35
+ if (poolMatch) {
36
+ poolAddress = poolMatch[1];
37
+ }
38
+
39
+ // Get Kamino liquidity service
40
+ const kaminoLiquidityService = runtime.getService(
41
+ "KAMINO_LIQUIDITY_SERVICE",
42
+ ) as KaminoLiquidityService;
43
+ if (!kaminoLiquidityService) {
44
+ poolInfo += "❌ Kamino liquidity service not available.\n";
45
+ } else {
46
+ if (poolAddress) {
47
+ console.log(`Pool address found: ${poolAddress}`);
48
+
49
+ poolInfo += `=== KAMINO POOL ANALYSIS ===\n\n`;
50
+ poolInfo += `🔍 Pool Address: ${poolAddress}\n\n`;
51
+
52
+ // Get detailed pool information
53
+ const poolData =
54
+ await kaminoLiquidityService.getPoolByAddress(poolAddress);
55
+
56
+ if (poolData) {
57
+ poolInfo += await generatePoolReport(
58
+ runtime,
59
+ poolData,
60
+ kaminoLiquidityService,
61
+ );
62
+ } else {
63
+ poolInfo += `❌ No Kamino pool found for address: ${poolAddress}\n\n`;
64
+ poolInfo += `🔍 Analysis Results:\n`;
65
+ poolInfo += ` • Address: ${poolAddress}\n`;
66
+ poolInfo += ` • Searched through Kamino liquidity program\n`;
67
+ poolInfo += ` • No active pool or strategy found for this address\n\n`;
68
+ poolInfo += `💡 Possible reasons:\n`;
69
+ poolInfo += ` • Address may not be a valid Kamino pool address\n`;
70
+ poolInfo += ` • Pool may have been closed or migrated\n`;
71
+ poolInfo += ` • Address might be a token address rather than a pool address\n`;
72
+ poolInfo += ` • Pool might be in a different protocol\n\n`;
73
+ poolInfo += `🔗 Check available pools at: https://app.kamino.finance/liquidity\n`;
74
+ }
75
+ } else {
76
+ // No specific pool address provided, show usage instructions
77
+ poolInfo += `=== KAMINO POOL PROVIDER ===\n\n`;
78
+ poolInfo += `🔍 Kamino Pool-Specific Information\n\n`;
79
+
80
+ // Use testConnection to get basic info
81
+ const testResults = await kaminoLiquidityService.testConnection();
82
+
83
+ poolInfo += `📊 Service Status:\n`;
84
+ poolInfo += ` ✅ Connection: ${testResults.connectionTest ? "Connected" : "Failed"}\n`;
85
+ poolInfo += ` 📋 Program ID: ${testResults.programId}\n`;
86
+ poolInfo += ` 🔗 RPC Endpoint: ${testResults.rpcEndpoint}\n`;
87
+ poolInfo += ` 📈 Available Strategies: ${testResults.strategyCount}\n\n`;
88
+
89
+ // Add usage instructions
90
+ poolInfo += `💡 How to use:\n`;
91
+ poolInfo += ` • Provide a pool address to get detailed information\n`;
92
+ poolInfo += ` • Example: "Kamino stats on pool cccsdfsdsdsxcxcxcsdsdsd"\n`;
93
+ poolInfo += ` • Example: "Tell me about Kamino pool HeLp6NuQkmYB4pYWo2zYs22mESHXPQYzXbB8n4V98jwC"\n`;
94
+ poolInfo += ` • Visit https://app.kamino.finance/liquidity to find pool addresses\n\n`;
95
+ }
96
+ }
97
+ } catch (error) {
98
+ console.error("Error in Kamino pool provider:", error);
99
+ poolInfo = `Error generating Kamino pool report: ${error instanceof Error ? error.message : "Unknown error"}`;
100
+ }
101
+
102
+ const data = {
103
+ kaminoPool: poolInfo,
104
+ };
105
+
106
+ const text = `${poolInfo}\n`.slice(0, KAMINO_POOL_TEXT_LIMIT);
107
+
108
+ return {
109
+ data,
110
+ values: {} as Record<string, unknown>,
111
+ text,
112
+ };
113
+ },
114
+ };
115
+
116
+ function asPromptRecord(value: unknown): Record<string, unknown> {
117
+ return value && typeof value === "object"
118
+ ? (value as Record<string, unknown>)
119
+ : {};
120
+ }
121
+
122
+ function formatPoolDataForPrompt(poolData: unknown): string {
123
+ if (!poolData) {
124
+ return "pool_status: not found";
125
+ }
126
+
127
+ const pool = asPromptRecord(poolData);
128
+ const lines = [
129
+ "pool_status: found",
130
+ `address: ${formatPromptValue(pool.address)}`,
131
+ `last_updated: ${formatPromptValue(pool.timestamp)}`,
132
+ ];
133
+
134
+ if (pool.note) {
135
+ lines.push(`note: ${formatPromptValue(pool.note)}`);
136
+ }
137
+
138
+ if (pool.strategy) {
139
+ const strategy = asPromptRecord(pool.strategy);
140
+ const positions = Array.isArray(strategy.positions)
141
+ ? strategy.positions
142
+ : [];
143
+ lines.push(
144
+ "strategy:",
145
+ ` address: ${formatPromptValue(strategy.address)}`,
146
+ ` type: ${formatPromptValue(strategy.strategyType)}`,
147
+ ` tvl_usd: ${formatPromptValue(strategy.estimatedTvl)}`,
148
+ ` volume_24h_usd: ${formatPromptValue(strategy.volume24h)}`,
149
+ ` apy_percent: ${formatPromptValue(strategy.apy)}`,
150
+ ` fee_tier: ${formatPromptValue(strategy.feeTier)}`,
151
+ ` rebalancing: ${formatPromptValue(strategy.rebalancing)}`,
152
+ ` last_rebalance: ${formatPromptValue(strategy.lastRebalance)}`,
153
+ ` token_a: ${formatPromptValue(strategy.tokenA)}`,
154
+ ` token_b: ${formatPromptValue(strategy.tokenB)}`,
155
+ ` position_count: ${positions.length}`,
156
+ );
157
+
158
+ positions.forEach((positionData, index) => {
159
+ const position = asPromptRecord(positionData);
160
+ lines.push(
161
+ `positions[${index}]: type=${formatPromptValue(position.type)}, range=${formatPromptValue(position.range)}, liquidity_usd=${formatPromptValue(position.liquidity)}, fees_earned_usd=${formatPromptValue(position.feesEarned)}`,
162
+ );
163
+ });
164
+ }
165
+
166
+ if (pool.tokenInfo) {
167
+ const tokenInfo = asPromptRecord(pool.tokenInfo);
168
+ lines.push(
169
+ "token_info:",
170
+ ` name: ${formatPromptValue(tokenInfo.name)}`,
171
+ ` symbol: ${formatPromptValue(tokenInfo.symbol)}`,
172
+ ` address: ${formatPromptValue(tokenInfo.address)}`,
173
+ ` price_usd: ${formatPromptValue(tokenInfo.price)}`,
174
+ ` liquidity_usd: ${formatPromptValue(tokenInfo.liquidity)}`,
175
+ ` market_cap_usd: ${formatPromptValue(tokenInfo.marketCap)}`,
176
+ ` volume_24h_usd: ${formatPromptValue(tokenInfo.volume24h)}`,
177
+ ` price_change_24h_percent: ${formatPromptValue(tokenInfo.priceChange24h)}`,
178
+ ` decimals: ${formatPromptValue(tokenInfo.decimals)}`,
179
+ );
180
+ }
181
+
182
+ if (pool.metrics) {
183
+ const metrics = asPromptRecord(pool.metrics);
184
+ lines.push(
185
+ "metrics:",
186
+ ` total_value_locked_usd: ${formatPromptValue(metrics.totalValueLocked)}`,
187
+ ` volume_24h_usd: ${formatPromptValue(metrics.volume24h)}`,
188
+ ` apy_percent: ${formatPromptValue(metrics.apy)}`,
189
+ ` fee_tier: ${formatPromptValue(metrics.feeTier)}`,
190
+ ` rebalancing: ${formatPromptValue(metrics.rebalancing)}`,
191
+ ` position_count: ${formatPromptValue(metrics.positionCount)}`,
192
+ ` last_rebalance: ${formatPromptValue(metrics.lastRebalance)}`,
193
+ );
194
+ }
195
+
196
+ return lines.join("\n");
197
+ }
198
+
199
+ function formatPromptValue(value: unknown): string {
200
+ if (value === null || value === undefined) {
201
+ return "N/A";
202
+ }
203
+
204
+ if (typeof value === "number") {
205
+ return Number.isFinite(value) ? String(value) : "N/A";
206
+ }
207
+
208
+ if (typeof value === "string") {
209
+ return value;
210
+ }
211
+
212
+ if (typeof value === "boolean") {
213
+ return String(value);
214
+ }
215
+
216
+ return String(value);
217
+ }
218
+
219
+ /**
220
+ * Generate detailed pool report
221
+ */
222
+ async function generatePoolReport(
223
+ runtime: IAgentRuntime,
224
+ poolData: unknown,
225
+ _kaminoLiquidityService: KaminoLiquidityService,
226
+ ): Promise<string> {
227
+ let report = "";
228
+
229
+ try {
230
+ // Pool basic information
231
+ report += `🏊‍♂️ POOL OVERVIEW:\n`;
232
+ report += ` 📍 Address: ${poolData.address}\n`;
233
+ report += ` 📅 Last Updated: ${new Date(poolData.timestamp).toLocaleString()}\n\n`;
234
+
235
+ if (poolData.strategy) {
236
+ const strategy = poolData.strategy;
237
+
238
+ report += `📊 STRATEGY DETAILS:\n`;
239
+ report += ` 🏷️ Type: ${strategy.strategyType}\n`;
240
+ report += ` 💰 TVL: $${strategy.estimatedTvl.toLocaleString()}\n`;
241
+ report += ` 📈 24h Volume: $${strategy.volume24h.toLocaleString()}\n`;
242
+ report += ` 🎯 APY: ${strategy.apy.toFixed(2)}%\n`;
243
+ report += ` 💸 Fee Tier: ${strategy.feeTier}\n`;
244
+ report += ` 🔄 Rebalancing: ${strategy.rebalancing}\n`;
245
+ report += ` 🕒 Last Rebalance: ${new Date(strategy.lastRebalance).toLocaleDateString()}\n\n`;
246
+
247
+ // Token information
248
+ report += `🪙 TOKEN PAIR:\n`;
249
+ report += ` Token A: ${strategy.tokenA}\n`;
250
+ report += ` Token B: ${strategy.tokenB}\n\n`;
251
+
252
+ // Position details
253
+ if (strategy.positions && strategy.positions.length > 0) {
254
+ report += `📍 POSITIONS:\n`;
255
+ for (const position of strategy.positions) {
256
+ report += ` • ${position.type}: ${position.range}\n`;
257
+ report += ` 💧 Liquidity: $${position.liquidity.toLocaleString()}\n`;
258
+ report += ` 💰 Fees Earned: $${position.feesEarned.toLocaleString()}\n`;
259
+ }
260
+ report += `\n`;
261
+ }
262
+ }
263
+
264
+ // Token information if available
265
+ if (poolData.tokenInfo) {
266
+ const tokenInfo = poolData.tokenInfo;
267
+ report += `🔍 TOKEN INFORMATION:\n`;
268
+ report += ` 📝 Name: ${tokenInfo.name}\n`;
269
+ report += ` 🔖 Symbol: ${tokenInfo.symbol}\n`;
270
+ report += ` 🔗 Address: ${tokenInfo.address}\n`;
271
+ if (tokenInfo.price) {
272
+ report += ` 💵 Price: $${tokenInfo.price.toFixed(6)}\n`;
273
+ }
274
+ if (tokenInfo.liquidity) {
275
+ report += ` 💧 Liquidity: $${tokenInfo.liquidity.toLocaleString()}\n`;
276
+ }
277
+ if (tokenInfo.marketCap) {
278
+ report += ` 📊 Market Cap: $${tokenInfo.marketCap.toLocaleString()}\n`;
279
+ }
280
+ if (tokenInfo.priceChange24h) {
281
+ report += ` 📈 24h Change: ${tokenInfo.priceChange24h.toFixed(2)}%\n`;
282
+ }
283
+ report += `\n`;
284
+ }
285
+
286
+ // Metrics summary
287
+ if (poolData.metrics) {
288
+ const metrics = poolData.metrics;
289
+ report += `📈 PERFORMANCE METRICS:\n`;
290
+ report += ` 💰 Total Value Locked: $${metrics.totalValueLocked.toLocaleString()}\n`;
291
+ report += ` 📊 24h Volume: $${metrics.volume24h.toLocaleString()}\n`;
292
+ report += ` 🎯 Current APY: ${metrics.apy.toFixed(2)}%\n`;
293
+ report += ` 💸 Fee Structure: ${metrics.feeTier}\n`;
294
+ report += ` 🔄 Rebalancing Strategy: ${metrics.rebalancing}\n`;
295
+ report += ` 📍 Active Positions: ${metrics.positionCount}\n`;
296
+ report += ` 🕒 Last Activity: ${new Date(metrics.lastRebalance).toLocaleString()}\n\n`;
297
+ }
298
+
299
+ // Generate enhanced analysis using LLM
300
+ const enhancedAnalysis = await generateEnhancedPoolAnalysis(
301
+ runtime,
302
+ poolData,
303
+ );
304
+ if (enhancedAnalysis) {
305
+ report += enhancedAnalysis;
306
+ }
307
+
308
+ // Add action links
309
+ report += `🔗 ACTIONS:\n`;
310
+ report += ` • View on Kamino: https://app.kamino.finance/liquidity\n`;
311
+ report += ` • Add Liquidity: https://app.kamino.finance/liquidity/deposit\n`;
312
+ report += ` • Monitor Performance: https://app.kamino.finance/liquidity/strategies\n\n`;
313
+ } catch (error) {
314
+ console.error("Error generating pool report:", error);
315
+ report += `❌ Error generating detailed pool report: ${error instanceof Error ? error.message : "Unknown error"}\n`;
316
+ }
317
+
318
+ return report;
319
+ }
320
+
321
+ /**
322
+ * Generate enhanced pool analysis using LLM
323
+ */
324
+ async function generateEnhancedPoolAnalysis(
325
+ runtime: IAgentRuntime,
326
+ poolData: unknown,
327
+ ): Promise<string> {
328
+ try {
329
+ // Create a focused prompt for the LLM
330
+ const analysisPrompt = `You are a professional DeFi analyst specializing in Kamino Finance liquidity pools. Generate a concise, insightful analysis for the pool with address ${poolData.address}.
331
+
332
+ POOL DATA:
333
+ ${formatPoolDataForPrompt(poolData)}
334
+
335
+ Please provide a brief but comprehensive analysis that includes:
336
+
337
+ 1. **Pool Health Assessment** - Is this pool performing well? What are the key indicators?
338
+ 2. **Risk Analysis** - What are the main risks for liquidity providers in this pool?
339
+ 3. **Opportunity Assessment** - What opportunities does this pool present?
340
+ 4. **Market Context** - How does this pool compare to similar strategies?
341
+ 5. **Recommendations** - Should someone consider providing liquidity to this pool?
342
+
343
+ Keep the analysis:
344
+ - Professional but accessible
345
+ - Focused on actionable insights
346
+ - Based on the provided data
347
+ - Under 200 words total
348
+
349
+ Generate a concise Kamino pool analysis:`;
350
+
351
+ // Use LLM to generate the enhanced analysis
352
+ const enhancedAnalysis = await runtime.useModel(ModelType.TEXT_LARGE, {
353
+ prompt: analysisPrompt,
354
+ });
355
+
356
+ if (enhancedAnalysis) {
357
+ return `🧠 AI ANALYSIS:\n${enhancedAnalysis}\n\n`;
358
+ }
359
+
360
+ return "";
361
+ } catch (error) {
362
+ console.error("Error generating enhanced pool analysis:", error);
363
+ return ""; // Return empty string if LLM analysis fails
364
+ }
365
+ }