@coinbase/agentkit 0.0.0-nightly-20250328174338

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 (292) hide show
  1. package/README.md +827 -0
  2. package/dist/action-providers/across/acrossActionProvider.d.ts +50 -0
  3. package/dist/action-providers/across/acrossActionProvider.js +333 -0
  4. package/dist/action-providers/across/acrossActionProvider.test.d.ts +1 -0
  5. package/dist/action-providers/across/acrossActionProvider.test.js +391 -0
  6. package/dist/action-providers/across/constants.d.ts +1 -0
  7. package/dist/action-providers/across/constants.js +2 -0
  8. package/dist/action-providers/across/index.d.ts +1 -0
  9. package/dist/action-providers/across/index.js +17 -0
  10. package/dist/action-providers/across/schemas.d.ts +36 -0
  11. package/dist/action-providers/across/schemas.js +46 -0
  12. package/dist/action-providers/across/utils.d.ts +7 -0
  13. package/dist/action-providers/across/utils.js +25 -0
  14. package/dist/action-providers/actionDecorator.d.ts +69 -0
  15. package/dist/action-providers/actionDecorator.js +96 -0
  16. package/dist/action-providers/actionProvider.d.ts +48 -0
  17. package/dist/action-providers/actionProvider.js +62 -0
  18. package/dist/action-providers/alchemy/alchemyTokenPricesActionProvider.d.ts +55 -0
  19. package/dist/action-providers/alchemy/alchemyTokenPricesActionProvider.js +173 -0
  20. package/dist/action-providers/alchemy/alchemyTokenPricesActionProvider.test.d.ts +1 -0
  21. package/dist/action-providers/alchemy/alchemyTokenPricesActionProvider.test.js +131 -0
  22. package/dist/action-providers/alchemy/index.d.ts +2 -0
  23. package/dist/action-providers/alchemy/index.js +18 -0
  24. package/dist/action-providers/alchemy/schemas.d.ts +41 -0
  25. package/dist/action-providers/alchemy/schemas.js +34 -0
  26. package/dist/action-providers/allora/alloraActionProvider.d.ts +44 -0
  27. package/dist/action-providers/allora/alloraActionProvider.js +195 -0
  28. package/dist/action-providers/allora/alloraActionProvider.test.d.ts +1 -0
  29. package/dist/action-providers/allora/alloraActionProvider.test.js +109 -0
  30. package/dist/action-providers/allora/index.d.ts +2 -0
  31. package/dist/action-providers/allora/index.js +18 -0
  32. package/dist/action-providers/allora/schemas.d.ts +28 -0
  33. package/dist/action-providers/allora/schemas.js +30 -0
  34. package/dist/action-providers/basename/basenameActionProvider.d.ts +30 -0
  35. package/dist/action-providers/basename/basenameActionProvider.js +109 -0
  36. package/dist/action-providers/basename/basenameActionProvider.test.d.ts +1 -0
  37. package/dist/action-providers/basename/basenameActionProvider.test.js +146 -0
  38. package/dist/action-providers/basename/constants.d.ts +52 -0
  39. package/dist/action-providers/basename/constants.js +81 -0
  40. package/dist/action-providers/basename/index.d.ts +2 -0
  41. package/dist/action-providers/basename/index.js +18 -0
  42. package/dist/action-providers/basename/schemas.d.ts +14 -0
  43. package/dist/action-providers/basename/schemas.js +14 -0
  44. package/dist/action-providers/cdp/cdpApiActionProvider.d.ts +43 -0
  45. package/dist/action-providers/cdp/cdpApiActionProvider.js +128 -0
  46. package/dist/action-providers/cdp/cdpApiActionProvider.test.d.ts +1 -0
  47. package/dist/action-providers/cdp/cdpApiActionProvider.test.js +146 -0
  48. package/dist/action-providers/cdp/cdpWalletActionProvider.d.ts +58 -0
  49. package/dist/action-providers/cdp/cdpWalletActionProvider.js +224 -0
  50. package/dist/action-providers/cdp/cdpWalletActionProvider.test.d.ts +1 -0
  51. package/dist/action-providers/cdp/cdpWalletActionProvider.test.js +267 -0
  52. package/dist/action-providers/cdp/constants.d.ts +31 -0
  53. package/dist/action-providers/cdp/constants.js +34 -0
  54. package/dist/action-providers/cdp/index.d.ts +3 -0
  55. package/dist/action-providers/cdp/index.js +19 -0
  56. package/dist/action-providers/cdp/schemas.d.ts +91 -0
  57. package/dist/action-providers/cdp/schemas.js +77 -0
  58. package/dist/action-providers/compound/compoundActionProvider.d.ts +67 -0
  59. package/dist/action-providers/compound/compoundActionProvider.js +365 -0
  60. package/dist/action-providers/compound/compoundActionProvider.test.d.ts +1 -0
  61. package/dist/action-providers/compound/compoundActionProvider.test.js +353 -0
  62. package/dist/action-providers/compound/constants.d.ts +180 -0
  63. package/dist/action-providers/compound/constants.js +129 -0
  64. package/dist/action-providers/compound/index.d.ts +1 -0
  65. package/dist/action-providers/compound/index.js +17 -0
  66. package/dist/action-providers/compound/schemas.d.ts +57 -0
  67. package/dist/action-providers/compound/schemas.js +58 -0
  68. package/dist/action-providers/compound/utils.d.ts +95 -0
  69. package/dist/action-providers/compound/utils.js +353 -0
  70. package/dist/action-providers/customActionProvider.d.ts +30 -0
  71. package/dist/action-providers/customActionProvider.js +66 -0
  72. package/dist/action-providers/defillama/constants.d.ts +8 -0
  73. package/dist/action-providers/defillama/constants.js +11 -0
  74. package/dist/action-providers/defillama/defillamaActionProvider.d.ts +54 -0
  75. package/dist/action-providers/defillama/defillamaActionProvider.js +180 -0
  76. package/dist/action-providers/defillama/defillamaActionProvider.test.d.ts +1 -0
  77. package/dist/action-providers/defillama/defillamaActionProvider.test.js +114 -0
  78. package/dist/action-providers/defillama/index.d.ts +1 -0
  79. package/dist/action-providers/defillama/index.js +17 -0
  80. package/dist/action-providers/defillama/schemas.d.ts +34 -0
  81. package/dist/action-providers/defillama/schemas.js +34 -0
  82. package/dist/action-providers/defillama/types.d.ts +73 -0
  83. package/dist/action-providers/defillama/types.js +2 -0
  84. package/dist/action-providers/defillama/utils.d.ts +10 -0
  85. package/dist/action-providers/defillama/utils.js +87 -0
  86. package/dist/action-providers/defillama/utils.test.d.ts +1 -0
  87. package/dist/action-providers/defillama/utils.test.js +124 -0
  88. package/dist/action-providers/erc20/constants.d.ts +137 -0
  89. package/dist/action-providers/erc20/constants.js +202 -0
  90. package/dist/action-providers/erc20/erc20ActionProvider.d.ts +38 -0
  91. package/dist/action-providers/erc20/erc20ActionProvider.js +142 -0
  92. package/dist/action-providers/erc20/erc20ActionProvider.test.d.ts +1 -0
  93. package/dist/action-providers/erc20/erc20ActionProvider.test.js +131 -0
  94. package/dist/action-providers/erc20/index.d.ts +1 -0
  95. package/dist/action-providers/erc20/index.js +17 -0
  96. package/dist/action-providers/erc20/schemas.d.ts +27 -0
  97. package/dist/action-providers/erc20/schemas.js +26 -0
  98. package/dist/action-providers/erc721/constants.d.ts +232 -0
  99. package/dist/action-providers/erc721/constants.js +298 -0
  100. package/dist/action-providers/erc721/erc721ActionProvider.d.ts +46 -0
  101. package/dist/action-providers/erc721/erc721ActionProvider.js +164 -0
  102. package/dist/action-providers/erc721/erc721ActionProvider.test.d.ts +1 -0
  103. package/dist/action-providers/erc721/erc721ActionProvider.test.js +137 -0
  104. package/dist/action-providers/erc721/index.d.ts +1 -0
  105. package/dist/action-providers/erc721/index.js +17 -0
  106. package/dist/action-providers/erc721/schemas.d.ts +46 -0
  107. package/dist/action-providers/erc721/schemas.js +44 -0
  108. package/dist/action-providers/farcaster/farcasterActionProvider.d.ts +57 -0
  109. package/dist/action-providers/farcaster/farcasterActionProvider.js +142 -0
  110. package/dist/action-providers/farcaster/farcasterActionProvider.test.d.ts +1 -0
  111. package/dist/action-providers/farcaster/farcasterActionProvider.test.js +151 -0
  112. package/dist/action-providers/farcaster/index.d.ts +2 -0
  113. package/dist/action-providers/farcaster/index.js +18 -0
  114. package/dist/action-providers/farcaster/schemas.d.ts +15 -0
  115. package/dist/action-providers/farcaster/schemas.js +20 -0
  116. package/dist/action-providers/index.d.ts +24 -0
  117. package/dist/action-providers/index.js +40 -0
  118. package/dist/action-providers/jupiter/index.d.ts +1 -0
  119. package/dist/action-providers/jupiter/index.js +17 -0
  120. package/dist/action-providers/jupiter/jupiterActionProvider.d.ts +36 -0
  121. package/dist/action-providers/jupiter/jupiterActionProvider.js +115 -0
  122. package/dist/action-providers/jupiter/jupiterActionProvider.test.d.ts +1 -0
  123. package/dist/action-providers/jupiter/jupiterActionProvider.test.js +146 -0
  124. package/dist/action-providers/jupiter/schemas.d.ts +20 -0
  125. package/dist/action-providers/jupiter/schemas.js +20 -0
  126. package/dist/action-providers/messari/constants.d.ts +17 -0
  127. package/dist/action-providers/messari/constants.js +20 -0
  128. package/dist/action-providers/messari/index.d.ts +5 -0
  129. package/dist/action-providers/messari/index.js +21 -0
  130. package/dist/action-providers/messari/messariActionProvider.d.ts +42 -0
  131. package/dist/action-providers/messari/messariActionProvider.js +128 -0
  132. package/dist/action-providers/messari/messariActionProvider.test.d.ts +1 -0
  133. package/dist/action-providers/messari/messariActionProvider.test.js +152 -0
  134. package/dist/action-providers/messari/schemas.d.ts +11 -0
  135. package/dist/action-providers/messari/schemas.js +16 -0
  136. package/dist/action-providers/messari/types.d.ts +40 -0
  137. package/dist/action-providers/messari/types.js +2 -0
  138. package/dist/action-providers/messari/utils.d.ts +22 -0
  139. package/dist/action-providers/messari/utils.js +65 -0
  140. package/dist/action-providers/moonwell/constants.d.ts +78 -0
  141. package/dist/action-providers/moonwell/constants.js +111 -0
  142. package/dist/action-providers/moonwell/index.d.ts +1 -0
  143. package/dist/action-providers/moonwell/index.js +5 -0
  144. package/dist/action-providers/moonwell/moonwellActionProvider.d.ts +39 -0
  145. package/dist/action-providers/moonwell/moonwellActionProvider.js +249 -0
  146. package/dist/action-providers/moonwell/moonwellActionProvider.test.d.ts +1 -0
  147. package/dist/action-providers/moonwell/moonwellActionProvider.test.js +455 -0
  148. package/dist/action-providers/moonwell/schemas.d.ts +30 -0
  149. package/dist/action-providers/moonwell/schemas.js +39 -0
  150. package/dist/action-providers/morpho/constants.d.ts +16 -0
  151. package/dist/action-providers/morpho/constants.js +27 -0
  152. package/dist/action-providers/morpho/index.d.ts +2 -0
  153. package/dist/action-providers/morpho/index.js +18 -0
  154. package/dist/action-providers/morpho/morphoActionProvider.d.ts +39 -0
  155. package/dist/action-providers/morpho/morphoActionProvider.js +154 -0
  156. package/dist/action-providers/morpho/morphoActionProvider.test.d.ts +1 -0
  157. package/dist/action-providers/morpho/morphoActionProvider.test.js +128 -0
  158. package/dist/action-providers/morpho/schemas.d.ts +36 -0
  159. package/dist/action-providers/morpho/schemas.js +47 -0
  160. package/dist/action-providers/opensea/index.d.ts +1 -0
  161. package/dist/action-providers/opensea/index.js +17 -0
  162. package/dist/action-providers/opensea/openseaActionProvider.d.ts +59 -0
  163. package/dist/action-providers/opensea/openseaActionProvider.js +146 -0
  164. package/dist/action-providers/opensea/openseaActionProvider.test.d.ts +1 -0
  165. package/dist/action-providers/opensea/openseaActionProvider.test.js +201 -0
  166. package/dist/action-providers/opensea/schemas.d.ts +30 -0
  167. package/dist/action-providers/opensea/schemas.js +33 -0
  168. package/dist/action-providers/opensea/utils.d.ts +12 -0
  169. package/dist/action-providers/opensea/utils.js +47 -0
  170. package/dist/action-providers/pyth/index.d.ts +2 -0
  171. package/dist/action-providers/pyth/index.js +18 -0
  172. package/dist/action-providers/pyth/pythActionProvider.d.ts +33 -0
  173. package/dist/action-providers/pyth/pythActionProvider.js +121 -0
  174. package/dist/action-providers/pyth/pythActionProvider.test.d.ts +1 -0
  175. package/dist/action-providers/pyth/pythActionProvider.test.js +113 -0
  176. package/dist/action-providers/pyth/schemas.d.ts +21 -0
  177. package/dist/action-providers/pyth/schemas.js +20 -0
  178. package/dist/action-providers/spl/index.d.ts +1 -0
  179. package/dist/action-providers/spl/index.js +17 -0
  180. package/dist/action-providers/spl/schemas.d.ts +30 -0
  181. package/dist/action-providers/spl/schemas.js +26 -0
  182. package/dist/action-providers/spl/splActionProvider.d.ts +45 -0
  183. package/dist/action-providers/spl/splActionProvider.js +173 -0
  184. package/dist/action-providers/spl/splActionProvider.test.d.ts +1 -0
  185. package/dist/action-providers/spl/splActionProvider.test.js +300 -0
  186. package/dist/action-providers/twitter/index.d.ts +2 -0
  187. package/dist/action-providers/twitter/index.js +18 -0
  188. package/dist/action-providers/twitter/schemas.d.ts +38 -0
  189. package/dist/action-providers/twitter/schemas.js +44 -0
  190. package/dist/action-providers/twitter/twitterActionProvider.d.ts +82 -0
  191. package/dist/action-providers/twitter/twitterActionProvider.js +204 -0
  192. package/dist/action-providers/twitter/twitterActionProvider.test.d.ts +1 -0
  193. package/dist/action-providers/twitter/twitterActionProvider.test.js +185 -0
  194. package/dist/action-providers/wallet/index.d.ts +1 -0
  195. package/dist/action-providers/wallet/index.js +17 -0
  196. package/dist/action-providers/wallet/schemas.d.ts +19 -0
  197. package/dist/action-providers/wallet/schemas.js +19 -0
  198. package/dist/action-providers/wallet/walletActionProvider.d.ts +44 -0
  199. package/dist/action-providers/wallet/walletActionProvider.js +140 -0
  200. package/dist/action-providers/wallet/walletActionProvider.test.d.ts +1 -0
  201. package/dist/action-providers/wallet/walletActionProvider.test.js +194 -0
  202. package/dist/action-providers/weth/constants.d.ts +19 -0
  203. package/dist/action-providers/weth/constants.js +29 -0
  204. package/dist/action-providers/weth/index.d.ts +1 -0
  205. package/dist/action-providers/weth/index.js +17 -0
  206. package/dist/action-providers/weth/schemas.d.ts +8 -0
  207. package/dist/action-providers/weth/schemas.js +10 -0
  208. package/dist/action-providers/weth/wethActionProvider.d.ts +30 -0
  209. package/dist/action-providers/weth/wethActionProvider.js +89 -0
  210. package/dist/action-providers/weth/wethActionProvider.test.d.ts +1 -0
  211. package/dist/action-providers/weth/wethActionProvider.test.js +92 -0
  212. package/dist/action-providers/wow/constants.d.ts +15 -0
  213. package/dist/action-providers/wow/constants.js +844 -0
  214. package/dist/action-providers/wow/index.d.ts +2 -0
  215. package/dist/action-providers/wow/index.js +18 -0
  216. package/dist/action-providers/wow/schemas.d.ts +43 -0
  217. package/dist/action-providers/wow/schemas.js +47 -0
  218. package/dist/action-providers/wow/uniswap/constants.d.ts +3 -0
  219. package/dist/action-providers/wow/uniswap/constants.js +100 -0
  220. package/dist/action-providers/wow/uniswap/utils.d.ts +82 -0
  221. package/dist/action-providers/wow/uniswap/utils.js +226 -0
  222. package/dist/action-providers/wow/utils.d.ts +27 -0
  223. package/dist/action-providers/wow/utils.js +63 -0
  224. package/dist/action-providers/wow/wowActionProvider.d.ts +46 -0
  225. package/dist/action-providers/wow/wowActionProvider.js +223 -0
  226. package/dist/action-providers/wow/wowActionProvider.test.d.ts +1 -0
  227. package/dist/action-providers/wow/wowActionProvider.test.js +291 -0
  228. package/dist/agentkit.d.ts +44 -0
  229. package/dist/agentkit.js +68 -0
  230. package/dist/analytics/index.d.ts +1 -0
  231. package/dist/analytics/index.js +17 -0
  232. package/dist/analytics/sendAnalyticsEvent.d.ts +31 -0
  233. package/dist/analytics/sendAnalyticsEvent.js +52 -0
  234. package/dist/index.d.ts +4 -0
  235. package/dist/index.js +20 -0
  236. package/dist/network/index.d.ts +3 -0
  237. package/dist/network/index.js +19 -0
  238. package/dist/network/network.d.ts +20 -0
  239. package/dist/network/network.js +86 -0
  240. package/dist/network/svm.d.ts +15 -0
  241. package/dist/network/svm.js +38 -0
  242. package/dist/network/types.d.ts +17 -0
  243. package/dist/network/types.js +2 -0
  244. package/dist/utils.d.ts +22 -0
  245. package/dist/utils.js +57 -0
  246. package/dist/utils.test.d.ts +1 -0
  247. package/dist/utils.test.js +50 -0
  248. package/dist/wallet-providers/cdpWalletProvider.d.ts +246 -0
  249. package/dist/wallet-providers/cdpWalletProvider.js +421 -0
  250. package/dist/wallet-providers/cdpWalletProvider.test.d.ts +1 -0
  251. package/dist/wallet-providers/cdpWalletProvider.test.js +701 -0
  252. package/dist/wallet-providers/evmWalletProvider.d.ts +51 -0
  253. package/dist/wallet-providers/evmWalletProvider.js +14 -0
  254. package/dist/wallet-providers/evmWalletProvider.test.d.ts +1 -0
  255. package/dist/wallet-providers/evmWalletProvider.test.js +56 -0
  256. package/dist/wallet-providers/index.d.ts +10 -0
  257. package/dist/wallet-providers/index.js +26 -0
  258. package/dist/wallet-providers/privyEvmWalletProvider.d.ts +55 -0
  259. package/dist/wallet-providers/privyEvmWalletProvider.js +140 -0
  260. package/dist/wallet-providers/privyEvmWalletProvider.test.d.ts +1 -0
  261. package/dist/wallet-providers/privyEvmWalletProvider.test.js +331 -0
  262. package/dist/wallet-providers/privyShared.d.ts +40 -0
  263. package/dist/wallet-providers/privyShared.js +49 -0
  264. package/dist/wallet-providers/privySvmWalletProvider.d.ts +128 -0
  265. package/dist/wallet-providers/privySvmWalletProvider.js +212 -0
  266. package/dist/wallet-providers/privySvmWalletProvider.test.d.ts +1 -0
  267. package/dist/wallet-providers/privySvmWalletProvider.test.js +310 -0
  268. package/dist/wallet-providers/privyWalletProvider.d.ts +35 -0
  269. package/dist/wallet-providers/privyWalletProvider.js +39 -0
  270. package/dist/wallet-providers/privyWalletProvider.test.d.ts +1 -0
  271. package/dist/wallet-providers/privyWalletProvider.test.js +124 -0
  272. package/dist/wallet-providers/smartWalletProvider.d.ts +177 -0
  273. package/dist/wallet-providers/smartWalletProvider.js +303 -0
  274. package/dist/wallet-providers/smartWalletProvider.test.d.ts +1 -0
  275. package/dist/wallet-providers/smartWalletProvider.test.js +388 -0
  276. package/dist/wallet-providers/solanaKeypairWalletProvider.d.ts +143 -0
  277. package/dist/wallet-providers/solanaKeypairWalletProvider.js +280 -0
  278. package/dist/wallet-providers/solanaKeypairWalletProvider.test.d.ts +1 -0
  279. package/dist/wallet-providers/solanaKeypairWalletProvider.test.js +218 -0
  280. package/dist/wallet-providers/svmWalletProvider.d.ts +56 -0
  281. package/dist/wallet-providers/svmWalletProvider.js +13 -0
  282. package/dist/wallet-providers/svmWalletProvider.test.d.ts +1 -0
  283. package/dist/wallet-providers/svmWalletProvider.test.js +55 -0
  284. package/dist/wallet-providers/viemWalletProvider.d.ts +103 -0
  285. package/dist/wallet-providers/viemWalletProvider.js +206 -0
  286. package/dist/wallet-providers/viemWalletProvider.test.d.ts +1 -0
  287. package/dist/wallet-providers/viemWalletProvider.test.js +338 -0
  288. package/dist/wallet-providers/walletProvider.d.ts +48 -0
  289. package/dist/wallet-providers/walletProvider.js +41 -0
  290. package/dist/wallet-providers/walletProvider.test.d.ts +1 -0
  291. package/dist/wallet-providers/walletProvider.test.js +103 -0
  292. package/package.json +83 -0
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./compoundActionProvider"), exports);
@@ -0,0 +1,57 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Input schema for Compound supply action.
4
+ */
5
+ export declare const CompoundSupplySchema: z.ZodObject<{
6
+ assetId: z.ZodEnum<["weth", "cbeth", "cbbtc", "wsteth", "usdc"]>;
7
+ amount: z.ZodString;
8
+ }, "strip", z.ZodTypeAny, {
9
+ amount: string;
10
+ assetId: "weth" | "cbeth" | "cbbtc" | "wsteth" | "usdc";
11
+ }, {
12
+ amount: string;
13
+ assetId: "weth" | "cbeth" | "cbbtc" | "wsteth" | "usdc";
14
+ }>;
15
+ /**
16
+ * Input schema for Compound withdraw action.
17
+ */
18
+ export declare const CompoundWithdrawSchema: z.ZodObject<{
19
+ assetId: z.ZodEnum<["weth", "cbeth", "cbbtc", "wsteth", "usdc"]>;
20
+ amount: z.ZodString;
21
+ }, "strip", z.ZodTypeAny, {
22
+ amount: string;
23
+ assetId: "weth" | "cbeth" | "cbbtc" | "wsteth" | "usdc";
24
+ }, {
25
+ amount: string;
26
+ assetId: "weth" | "cbeth" | "cbbtc" | "wsteth" | "usdc";
27
+ }>;
28
+ /**
29
+ * Input schema for Compound borrow action.
30
+ */
31
+ export declare const CompoundBorrowSchema: z.ZodObject<{
32
+ assetId: z.ZodEnum<["weth", "usdc"]>;
33
+ amount: z.ZodString;
34
+ }, "strip", z.ZodTypeAny, {
35
+ amount: string;
36
+ assetId: "weth" | "usdc";
37
+ }, {
38
+ amount: string;
39
+ assetId: "weth" | "usdc";
40
+ }>;
41
+ /**
42
+ * Input schema for Compound repay action.
43
+ */
44
+ export declare const CompoundRepaySchema: z.ZodObject<{
45
+ assetId: z.ZodEnum<["weth", "usdc"]>;
46
+ amount: z.ZodString;
47
+ }, "strip", z.ZodTypeAny, {
48
+ amount: string;
49
+ assetId: "weth" | "usdc";
50
+ }, {
51
+ amount: string;
52
+ assetId: "weth" | "usdc";
53
+ }>;
54
+ /**
55
+ * Input schema for Compound get portfolio action.
56
+ */
57
+ export declare const CompoundPortfolioSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CompoundPortfolioSchema = exports.CompoundRepaySchema = exports.CompoundBorrowSchema = exports.CompoundWithdrawSchema = exports.CompoundSupplySchema = void 0;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * Input schema for Compound supply action.
7
+ */
8
+ exports.CompoundSupplySchema = zod_1.z
9
+ .object({
10
+ assetId: zod_1.z.enum(["weth", "cbeth", "cbbtc", "wsteth", "usdc"]).describe("The asset to supply"),
11
+ amount: zod_1.z
12
+ .string()
13
+ .regex(/^\d+(\.\d+)?$/, "Must be a valid integer or decimal value")
14
+ .describe("The amount of tokens to supply in human-readable format"),
15
+ })
16
+ .describe("Input schema for Compound supply action");
17
+ /**
18
+ * Input schema for Compound withdraw action.
19
+ */
20
+ exports.CompoundWithdrawSchema = zod_1.z
21
+ .object({
22
+ assetId: zod_1.z.enum(["weth", "cbeth", "cbbtc", "wsteth", "usdc"]).describe("The asset to withdraw"),
23
+ amount: zod_1.z
24
+ .string()
25
+ .regex(/^\d+(\.\d+)?$/, "Must be a valid integer or decimal value")
26
+ .describe("The amount of tokens to withdraw in human-readable format"),
27
+ })
28
+ .describe("Input schema for Compound withdraw action");
29
+ /**
30
+ * Input schema for Compound borrow action.
31
+ */
32
+ exports.CompoundBorrowSchema = zod_1.z
33
+ .object({
34
+ assetId: zod_1.z.enum(["weth", "usdc"]).describe("The asset to borrow"),
35
+ amount: zod_1.z
36
+ .string()
37
+ .regex(/^\d+(\.\d+)?$/, "Must be a valid integer or decimal value")
38
+ .describe("The amount of base tokens to borrow in human-readable format"),
39
+ })
40
+ .describe("Input schema for Compound borrow action");
41
+ /**
42
+ * Input schema for Compound repay action.
43
+ */
44
+ exports.CompoundRepaySchema = zod_1.z
45
+ .object({
46
+ assetId: zod_1.z.enum(["weth", "usdc"]).describe("The asset to repay"),
47
+ amount: zod_1.z
48
+ .string()
49
+ .regex(/^\d+(\.\d+)?$/, "Must be a valid integer or decimal value")
50
+ .describe("The amount of tokens to repay in human-readable format"),
51
+ })
52
+ .describe("Input schema for Compound repay action");
53
+ /**
54
+ * Input schema for Compound get portfolio action.
55
+ */
56
+ exports.CompoundPortfolioSchema = zod_1.z
57
+ .object({})
58
+ .describe("Input schema for Compound get portfolio action");
@@ -0,0 +1,95 @@
1
+ import { Decimal } from "decimal.js";
2
+ import { Address } from "viem";
3
+ import { EvmWalletProvider } from "../../wallet-providers";
4
+ import { Network } from "../../network";
5
+ /**
6
+ * Get token decimals from contract
7
+ *
8
+ * @param wallet - The wallet provider instance
9
+ * @param tokenAddress - The address of the token contract
10
+ * @returns The number of decimals for the token
11
+ */
12
+ export declare const getTokenDecimals: (wallet: EvmWalletProvider, tokenAddress: Address) => Promise<number>;
13
+ /**
14
+ * Get token symbol from contract
15
+ *
16
+ * @param wallet - The wallet provider instance
17
+ * @param tokenAddress - The address of the token contract
18
+ * @returns The symbol of the token
19
+ */
20
+ export declare const getTokenSymbol: (wallet: EvmWalletProvider, tokenAddress: Address) => Promise<string>;
21
+ /**
22
+ * Get token balance for an address
23
+ *
24
+ * @param wallet - The wallet provider instance
25
+ * @param tokenAddress - The address of the token contract
26
+ * @returns The token balance as a bigint
27
+ */
28
+ export declare const getTokenBalance: (wallet: EvmWalletProvider, tokenAddress: Address) => Promise<bigint>;
29
+ /**
30
+ * Get collateral balance for an address
31
+ *
32
+ * @param wallet - The wallet provider instance
33
+ * @param cometAddress - The address of the Comet contract
34
+ * @param tokenAddress - The address of the token contract
35
+ * @returns The collateral balance as a bigint
36
+ */
37
+ export declare const getCollateralBalance: (wallet: EvmWalletProvider, cometAddress: Address, tokenAddress: Address) => Promise<bigint>;
38
+ /**
39
+ * Get health ratio for an account
40
+ *
41
+ * @param wallet - The wallet provider instance
42
+ * @param cometAddress - The address of the Comet contract
43
+ * @returns The health ratio as a Decimal
44
+ */
45
+ export declare const getHealthRatio: (wallet: EvmWalletProvider, cometAddress: Address) => Promise<Decimal>;
46
+ /**
47
+ * Get health ratio after a hypothetical withdraw
48
+ *
49
+ * @param wallet - The wallet provider instance
50
+ * @param cometAddress - The address of the Comet contract
51
+ * @param tokenAddress - The address of the token contract
52
+ * @param amount - The amount to withdraw
53
+ * @returns The health ratio after withdraw as a Decimal
54
+ */
55
+ export declare const getHealthRatioAfterWithdraw: (wallet: EvmWalletProvider, cometAddress: Address, tokenAddress: Address, amount: bigint) => Promise<Decimal>;
56
+ /**
57
+ * Get health ratio after a hypothetical borrow
58
+ *
59
+ * @param wallet - The wallet provider instance
60
+ * @param cometAddress - The address of the Comet contract
61
+ * @param amount - The amount to borrow
62
+ * @returns The health ratio after borrow as a Decimal
63
+ */
64
+ export declare const getHealthRatioAfterBorrow: (wallet: EvmWalletProvider, cometAddress: Address, amount: bigint) => Promise<Decimal>;
65
+ /**
66
+ * Get portfolio details in markdown format
67
+ *
68
+ * @param wallet - The wallet provider instance
69
+ * @param cometAddress - The address of the Comet contract
70
+ * @returns A markdown formatted string with portfolio details
71
+ */
72
+ export declare const getPortfolioDetailsMarkdown: (wallet: EvmWalletProvider, cometAddress: Address) => Promise<string>;
73
+ /**
74
+ * Gets the Comet address for the current network.
75
+ *
76
+ * @param network - The network instance
77
+ * @returns The Comet contract address
78
+ */
79
+ export declare const getCometAddress: (network: Network) => Address;
80
+ /**
81
+ * Gets the asset address for a given assetId on the current network.
82
+ *
83
+ * @param network - The network instance
84
+ * @param assetId - The identifier of the asset
85
+ * @returns The asset contract address
86
+ */
87
+ export declare const getAssetAddress: (network: Network, assetId: string) => Address;
88
+ /**
89
+ * Get the base token address for a Compound market
90
+ *
91
+ * @param wallet - The wallet provider instance
92
+ * @param cometAddress - The address of the Comet contract
93
+ * @returns The base token address
94
+ */
95
+ export declare const getBaseTokenAddress: (wallet: EvmWalletProvider, cometAddress: Address) => Promise<Address>;
@@ -0,0 +1,353 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBaseTokenAddress = exports.getAssetAddress = exports.getCometAddress = exports.getPortfolioDetailsMarkdown = exports.getHealthRatioAfterBorrow = exports.getHealthRatioAfterWithdraw = exports.getHealthRatio = exports.getCollateralBalance = exports.getTokenBalance = exports.getTokenSymbol = exports.getTokenDecimals = void 0;
4
+ const decimal_js_1 = require("decimal.js");
5
+ const viem_1 = require("viem");
6
+ const constants_1 = require("./constants");
7
+ const constants_2 = require("./constants");
8
+ /**
9
+ * Get token decimals from contract
10
+ *
11
+ * @param wallet - The wallet provider instance
12
+ * @param tokenAddress - The address of the token contract
13
+ * @returns The number of decimals for the token
14
+ */
15
+ const getTokenDecimals = async (wallet, tokenAddress) => {
16
+ const decimals = await wallet.readContract({
17
+ address: tokenAddress,
18
+ abi: constants_1.ERC20_ABI,
19
+ functionName: "decimals",
20
+ });
21
+ return Number(decimals);
22
+ };
23
+ exports.getTokenDecimals = getTokenDecimals;
24
+ /**
25
+ * Get token symbol from contract
26
+ *
27
+ * @param wallet - The wallet provider instance
28
+ * @param tokenAddress - The address of the token contract
29
+ * @returns The symbol of the token
30
+ */
31
+ const getTokenSymbol = async (wallet, tokenAddress) => {
32
+ const symbol = await wallet.readContract({
33
+ address: tokenAddress,
34
+ abi: constants_1.ERC20_ABI,
35
+ functionName: "symbol",
36
+ });
37
+ return symbol;
38
+ };
39
+ exports.getTokenSymbol = getTokenSymbol;
40
+ /**
41
+ * Get token balance for an address
42
+ *
43
+ * @param wallet - The wallet provider instance
44
+ * @param tokenAddress - The address of the token contract
45
+ * @returns The token balance as a bigint
46
+ */
47
+ const getTokenBalance = async (wallet, tokenAddress) => {
48
+ const balance = await wallet.readContract({
49
+ address: tokenAddress,
50
+ abi: constants_1.ERC20_ABI,
51
+ functionName: "balanceOf",
52
+ args: [wallet.getAddress()],
53
+ });
54
+ return balance;
55
+ };
56
+ exports.getTokenBalance = getTokenBalance;
57
+ /**
58
+ * Get collateral balance for an address
59
+ *
60
+ * @param wallet - The wallet provider instance
61
+ * @param cometAddress - The address of the Comet contract
62
+ * @param tokenAddress - The address of the token contract
63
+ * @returns The collateral balance as a bigint
64
+ */
65
+ const getCollateralBalance = async (wallet, cometAddress, tokenAddress) => {
66
+ const balance = await wallet.readContract({
67
+ address: cometAddress,
68
+ abi: constants_1.COMET_ABI,
69
+ functionName: "collateralBalanceOf",
70
+ args: [(await wallet.getAddress()), tokenAddress],
71
+ });
72
+ return balance;
73
+ };
74
+ exports.getCollateralBalance = getCollateralBalance;
75
+ /**
76
+ * Get health ratio for an account
77
+ *
78
+ * @param wallet - The wallet provider instance
79
+ * @param cometAddress - The address of the Comet contract
80
+ * @returns The health ratio as a Decimal
81
+ */
82
+ const getHealthRatio = async (wallet, cometAddress) => {
83
+ const borrowDetails = await getBorrowDetails(wallet, cometAddress);
84
+ const supplyDetails = await getSupplyDetails(wallet, cometAddress);
85
+ const borrowValue = borrowDetails.borrowAmount.mul(borrowDetails.price);
86
+ let totalAdjustedCollateral = new decimal_js_1.Decimal(0);
87
+ for (const supply of supplyDetails) {
88
+ const collateralValue = supply.supplyAmount.mul(supply.price);
89
+ const adjustedValue = collateralValue.mul(supply.collateralFactor);
90
+ totalAdjustedCollateral = totalAdjustedCollateral.add(adjustedValue);
91
+ }
92
+ return borrowValue.eq(0) ? new decimal_js_1.Decimal(Infinity) : totalAdjustedCollateral.div(borrowValue);
93
+ };
94
+ exports.getHealthRatio = getHealthRatio;
95
+ /**
96
+ * Get health ratio after a hypothetical withdraw
97
+ *
98
+ * @param wallet - The wallet provider instance
99
+ * @param cometAddress - The address of the Comet contract
100
+ * @param tokenAddress - The address of the token contract
101
+ * @param amount - The amount to withdraw
102
+ * @returns The health ratio after withdraw as a Decimal
103
+ */
104
+ const getHealthRatioAfterWithdraw = async (wallet, cometAddress, tokenAddress, amount) => {
105
+ const borrowDetails = await getBorrowDetails(wallet, cometAddress);
106
+ const supplyDetails = await getSupplyDetails(wallet, cometAddress);
107
+ const borrowValue = borrowDetails.borrowAmount.mul(borrowDetails.price);
108
+ let totalAdjustedCollateral = new decimal_js_1.Decimal(0);
109
+ for (const supply of supplyDetails) {
110
+ const supplyTokenSymbol = supply.tokenSymbol;
111
+ const withdrawTokenSymbol = await (0, exports.getTokenSymbol)(wallet, tokenAddress);
112
+ if (supplyTokenSymbol === withdrawTokenSymbol) {
113
+ const decimals = await (0, exports.getTokenDecimals)(wallet, tokenAddress);
114
+ const withdrawAmountHuman = new decimal_js_1.Decimal((0, viem_1.formatUnits)(amount, decimals));
115
+ const newSupplyAmount = supply.supplyAmount.sub(withdrawAmountHuman);
116
+ const assetValue = newSupplyAmount.mul(supply.price);
117
+ totalAdjustedCollateral = totalAdjustedCollateral.add(assetValue.mul(supply.collateralFactor));
118
+ }
119
+ else {
120
+ totalAdjustedCollateral = totalAdjustedCollateral.add(supply.supplyAmount.mul(supply.price).mul(supply.collateralFactor));
121
+ }
122
+ }
123
+ return borrowValue.eq(0) ? new decimal_js_1.Decimal(Infinity) : totalAdjustedCollateral.div(borrowValue);
124
+ };
125
+ exports.getHealthRatioAfterWithdraw = getHealthRatioAfterWithdraw;
126
+ /**
127
+ * Get health ratio after a hypothetical borrow
128
+ *
129
+ * @param wallet - The wallet provider instance
130
+ * @param cometAddress - The address of the Comet contract
131
+ * @param amount - The amount to borrow
132
+ * @returns The health ratio after borrow as a Decimal
133
+ */
134
+ const getHealthRatioAfterBorrow = async (wallet, cometAddress, amount) => {
135
+ const borrowDetails = await getBorrowDetails(wallet, cometAddress);
136
+ const supplyDetails = await getSupplyDetails(wallet, cometAddress);
137
+ const baseToken = await (0, exports.getBaseTokenAddress)(wallet, cometAddress);
138
+ const baseDecimals = await (0, exports.getTokenDecimals)(wallet, baseToken);
139
+ const additionalBorrow = new decimal_js_1.Decimal((0, viem_1.formatUnits)(amount, baseDecimals));
140
+ const newBorrow = borrowDetails.borrowAmount.add(additionalBorrow);
141
+ const newBorrowValue = newBorrow.mul(borrowDetails.price);
142
+ let totalAdjustedCollateral = new decimal_js_1.Decimal(0);
143
+ for (const supply of supplyDetails) {
144
+ totalAdjustedCollateral = totalAdjustedCollateral.add(supply.supplyAmount.mul(supply.price).mul(supply.collateralFactor));
145
+ }
146
+ return newBorrowValue.eq(0) ? new decimal_js_1.Decimal(Infinity) : totalAdjustedCollateral.div(newBorrowValue);
147
+ };
148
+ exports.getHealthRatioAfterBorrow = getHealthRatioAfterBorrow;
149
+ /**
150
+ * Get portfolio details in markdown format
151
+ *
152
+ * @param wallet - The wallet provider instance
153
+ * @param cometAddress - The address of the Comet contract
154
+ * @returns A markdown formatted string with portfolio details
155
+ */
156
+ const getPortfolioDetailsMarkdown = async (wallet, cometAddress) => {
157
+ let markdownOutput = "# Portfolio Details\n\n";
158
+ markdownOutput += "## Supply Details\n\n";
159
+ let totalSupplyValue = new decimal_js_1.Decimal(0);
160
+ const supplyDetails = await getSupplyDetails(wallet, cometAddress);
161
+ if (supplyDetails.length > 0) {
162
+ for (const supply of supplyDetails) {
163
+ const token = supply.tokenSymbol;
164
+ const supplyAmount = supply.supplyAmount;
165
+ const price = supply.price;
166
+ const decimals = supply.decimals;
167
+ const collateralFactor = supply.collateralFactor;
168
+ const assetValue = supplyAmount.mul(price);
169
+ markdownOutput += `### ${token}\n`;
170
+ markdownOutput += `- **Supply Amount:** ${supplyAmount.toFixed(decimals)}\n`;
171
+ markdownOutput += `- **Price:** $${price.toFixed(2)}\n`;
172
+ markdownOutput += `- **Collateral Factor:** ${collateralFactor.toFixed(2)}\n`;
173
+ markdownOutput += `- **Asset Value:** $${assetValue.toFixed(2)}\n\n`;
174
+ totalSupplyValue = totalSupplyValue.add(assetValue);
175
+ }
176
+ }
177
+ else {
178
+ markdownOutput += "No supplied assets found in your Compound position.\n\n";
179
+ }
180
+ markdownOutput += `### Total Supply Value: $${totalSupplyValue.toFixed(2)}\n\n`;
181
+ markdownOutput += "## Borrow Details\n\n";
182
+ const borrowDetails = await getBorrowDetails(wallet, cometAddress);
183
+ if (borrowDetails.borrowAmount.gt(0)) {
184
+ const token = borrowDetails.tokenSymbol;
185
+ const price = borrowDetails.price;
186
+ const borrowValue = borrowDetails.borrowAmount.mul(price);
187
+ markdownOutput += `### ${token}\n`;
188
+ markdownOutput += `- **Borrow Amount:** ${borrowDetails.borrowAmount.toFixed(6)}\n`;
189
+ markdownOutput += `- **Price:** $${price.toFixed(2)}\n`;
190
+ markdownOutput += `- **Borrow Value:** $${borrowValue.toFixed(2)}\n\n`;
191
+ }
192
+ else {
193
+ markdownOutput += "No borrowed assets found in your Compound position.\n\n";
194
+ }
195
+ markdownOutput += "## Overall Health\n\n";
196
+ const healthRatio = await (0, exports.getHealthRatio)(wallet, cometAddress);
197
+ markdownOutput += `- **Health Ratio:** ${healthRatio.toFixed(2)}\n`;
198
+ return markdownOutput;
199
+ };
200
+ exports.getPortfolioDetailsMarkdown = getPortfolioDetailsMarkdown;
201
+ /**
202
+ * Fetch the latest price feed data.
203
+ *
204
+ * @param wallet - The wallet provider instance
205
+ * @param priceFeedAddress - The address of the price feed contract
206
+ * @returns A tuple containing the price and timestamp
207
+ */
208
+ const getPriceFeedData = async (wallet, priceFeedAddress) => {
209
+ const latestData = await wallet.readContract({
210
+ address: priceFeedAddress,
211
+ abi: constants_1.PRICE_FEED_ABI,
212
+ functionName: "latestRoundData",
213
+ args: [],
214
+ });
215
+ const answer = latestData[1].toString();
216
+ const updatedAt = Number(latestData[3]);
217
+ return [answer, updatedAt];
218
+ };
219
+ /**
220
+ * Retrieve borrow details: amount, base token symbol, and price.
221
+ *
222
+ * @param wallet - The wallet provider instance
223
+ * @param cometAddress - The address of the Comet contract
224
+ * @returns An object containing borrow details
225
+ */
226
+ const getBorrowDetails = async (wallet, cometAddress) => {
227
+ const borrowAmountRaw = await wallet.readContract({
228
+ address: cometAddress,
229
+ abi: constants_1.COMET_ABI,
230
+ functionName: "borrowBalanceOf",
231
+ args: [(await wallet.getAddress())],
232
+ });
233
+ const baseToken = await (0, exports.getBaseTokenAddress)(wallet, cometAddress);
234
+ const baseDecimals = await (0, exports.getTokenDecimals)(wallet, baseToken);
235
+ const baseTokenSymbol = await (0, exports.getTokenSymbol)(wallet, baseToken);
236
+ const basePriceFeed = await wallet.readContract({
237
+ address: cometAddress,
238
+ abi: constants_1.COMET_ABI,
239
+ functionName: "baseTokenPriceFeed",
240
+ args: [],
241
+ });
242
+ const [basePriceRaw] = await getPriceFeedData(wallet, basePriceFeed);
243
+ const humanBorrowAmount = new decimal_js_1.Decimal((0, viem_1.formatUnits)(borrowAmountRaw, baseDecimals));
244
+ const price = new decimal_js_1.Decimal(basePriceRaw).div(new decimal_js_1.Decimal(10).pow(8));
245
+ return { tokenSymbol: baseTokenSymbol, borrowAmount: humanBorrowAmount, price };
246
+ };
247
+ /**
248
+ * Retrieve supply details across all collateral assets.
249
+ *
250
+ * @param wallet - The wallet provider instance
251
+ * @param cometAddress - The address of the Comet contract
252
+ * @returns An array of supply details for each asset
253
+ */
254
+ const getSupplyDetails = async (wallet, cometAddress) => {
255
+ const numAssets = await wallet.readContract({
256
+ address: cometAddress,
257
+ abi: constants_1.COMET_ABI,
258
+ functionName: "numAssets",
259
+ args: [],
260
+ });
261
+ const supplyDetails = [];
262
+ for (let i = 0; i < numAssets; i++) {
263
+ const assetInfo = await wallet.readContract({
264
+ address: cometAddress,
265
+ abi: constants_1.COMET_ABI,
266
+ functionName: "getAssetInfo",
267
+ args: [i],
268
+ });
269
+ const assetAddress = assetInfo.asset;
270
+ const collateralBalance = await (0, exports.getCollateralBalance)(wallet, cometAddress, assetAddress);
271
+ if (collateralBalance > 0n) {
272
+ const tokenSymbol = await (0, exports.getTokenSymbol)(wallet, assetAddress);
273
+ const decimals = await (0, exports.getTokenDecimals)(wallet, assetAddress);
274
+ const [priceRaw] = await getPriceFeedData(wallet, assetInfo.priceFeed);
275
+ const humanSupplyAmount = new decimal_js_1.Decimal((0, viem_1.formatUnits)(collateralBalance, decimals));
276
+ const price = new decimal_js_1.Decimal(priceRaw).div(new decimal_js_1.Decimal(10).pow(8));
277
+ const collateralFactor = new decimal_js_1.Decimal(assetInfo.borrowCollateralFactor.toString()).div(new decimal_js_1.Decimal(10).pow(18));
278
+ supplyDetails.push({
279
+ tokenSymbol,
280
+ supplyAmount: humanSupplyAmount,
281
+ price,
282
+ collateralFactor,
283
+ decimals,
284
+ });
285
+ }
286
+ }
287
+ return supplyDetails;
288
+ };
289
+ /**
290
+ * Gets the Comet address for the current network.
291
+ *
292
+ * @param network - The network instance
293
+ * @returns The Comet contract address
294
+ */
295
+ const getCometAddress = (network) => {
296
+ if (!network.networkId) {
297
+ throw new Error("Network ID is required");
298
+ }
299
+ if (network.networkId === "base-mainnet") {
300
+ return constants_2.COMET_ADDRESSES["base-mainnet"];
301
+ }
302
+ else if (network.networkId === "base-sepolia") {
303
+ return constants_2.COMET_ADDRESSES["base-sepolia"];
304
+ }
305
+ throw new Error(`Network ${network.networkId} not supported`);
306
+ };
307
+ exports.getCometAddress = getCometAddress;
308
+ /**
309
+ * Gets the asset address for a given assetId on the current network.
310
+ *
311
+ * @param network - The network instance
312
+ * @param assetId - The identifier of the asset
313
+ * @returns The asset contract address
314
+ */
315
+ const getAssetAddress = (network, assetId) => {
316
+ if (!network.networkId) {
317
+ throw new Error("Network ID is required");
318
+ }
319
+ const normalizedAssetId = assetId.toLowerCase();
320
+ if (network.networkId === "base-mainnet") {
321
+ const address = constants_2.ASSET_ADDRESSES["base-mainnet"][normalizedAssetId];
322
+ if (!address) {
323
+ throw new Error(`Asset ${assetId} not supported on Base Mainnet`);
324
+ }
325
+ return address;
326
+ }
327
+ else if (network.networkId === "base-sepolia") {
328
+ const address = constants_2.ASSET_ADDRESSES["base-sepolia"][normalizedAssetId];
329
+ if (!address) {
330
+ throw new Error(`Asset ${assetId} not supported on Base Sepolia`);
331
+ }
332
+ return address;
333
+ }
334
+ throw new Error(`Network ${network.networkId} not supported`);
335
+ };
336
+ exports.getAssetAddress = getAssetAddress;
337
+ /**
338
+ * Get the base token address for a Compound market
339
+ *
340
+ * @param wallet - The wallet provider instance
341
+ * @param cometAddress - The address of the Comet contract
342
+ * @returns The base token address
343
+ */
344
+ const getBaseTokenAddress = async (wallet, cometAddress) => {
345
+ const baseToken = await wallet.readContract({
346
+ address: cometAddress,
347
+ abi: constants_1.COMET_ABI,
348
+ functionName: "baseToken",
349
+ args: [],
350
+ });
351
+ return baseToken;
352
+ };
353
+ exports.getBaseTokenAddress = getBaseTokenAddress;
@@ -0,0 +1,30 @@
1
+ import { z } from "zod";
2
+ import { ActionProvider } from "./actionProvider";
3
+ import { Network } from "../network";
4
+ import { WalletProvider } from "../wallet-providers";
5
+ interface CustomActionProviderOptions<TWalletProvider extends WalletProvider> {
6
+ name: string;
7
+ description: string;
8
+ schema: z.ZodSchema;
9
+ invoke: ((args: any) => Promise<any>) | ((walletProvider: TWalletProvider, args: any) => Promise<any>);
10
+ }
11
+ /**
12
+ * CustomActionProvider is a custom action provider that allows for custom action registration
13
+ */
14
+ export declare class CustomActionProvider<TWalletProvider extends WalletProvider> extends ActionProvider {
15
+ /**
16
+ * Creates a new CustomActionProvider that dynamically adds decorated action methods
17
+ *
18
+ * @param actions - Array of custom actions to be added to the provider
19
+ */
20
+ constructor(actions: CustomActionProviderOptions<TWalletProvider>[]);
21
+ /**
22
+ * Custom action providers are supported on all networks
23
+ *
24
+ * @param _ - The network to checkpointSaver
25
+ * @returns true
26
+ */
27
+ supportsNetwork(_: Network): boolean;
28
+ }
29
+ export declare const customActionProvider: <TWalletProvider extends WalletProvider>(actions: CustomActionProviderOptions<TWalletProvider> | CustomActionProviderOptions<TWalletProvider>[]) => CustomActionProvider<TWalletProvider>;
30
+ export {};
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.customActionProvider = exports.CustomActionProvider = void 0;
5
+ const actionDecorator_1 = require("./actionDecorator");
6
+ const actionProvider_1 = require("./actionProvider");
7
+ const wallet_providers_1 = require("../wallet-providers");
8
+ /**
9
+ * CustomActionProvider is a custom action provider that allows for custom action registration
10
+ */
11
+ class CustomActionProvider extends actionProvider_1.ActionProvider {
12
+ /**
13
+ * Creates a new CustomActionProvider that dynamically adds decorated action methods
14
+ *
15
+ * @param actions - Array of custom actions to be added to the provider
16
+ */
17
+ constructor(actions) {
18
+ super("custom", []);
19
+ actions.forEach(({ name, description, schema, invoke }) => {
20
+ // Check if the invoke function expects a wallet provider
21
+ const takesWalletProvider = invoke.length === 2;
22
+ // Define the method on the prototype with the correct signature
23
+ Object.defineProperty(CustomActionProvider.prototype, name, {
24
+ value: takesWalletProvider
25
+ ? async function (walletProvider, args) {
26
+ const parsedArgs = schema.parse(args);
27
+ return await invoke(walletProvider, parsedArgs);
28
+ }
29
+ : async function (args) {
30
+ const parsedArgs = schema.parse(args);
31
+ return await invoke(parsedArgs);
32
+ },
33
+ configurable: true,
34
+ writable: true,
35
+ enumerable: true,
36
+ });
37
+ // Manually set the parameter metadata
38
+ const paramTypes = takesWalletProvider ? [wallet_providers_1.WalletProvider, Object] : [Object];
39
+ Reflect.defineMetadata("design:paramtypes", paramTypes, CustomActionProvider.prototype, name);
40
+ // Apply the decorator using original name
41
+ const decoratedMethod = (0, actionDecorator_1.CreateAction)({
42
+ name,
43
+ description,
44
+ schema,
45
+ })(CustomActionProvider.prototype, name, Object.getOwnPropertyDescriptor(CustomActionProvider.prototype, name));
46
+ // Add the decorated method to the instance
47
+ Object.defineProperty(this, name, {
48
+ value: decoratedMethod,
49
+ configurable: true,
50
+ writable: true,
51
+ });
52
+ });
53
+ }
54
+ /**
55
+ * Custom action providers are supported on all networks
56
+ *
57
+ * @param _ - The network to checkpointSaver
58
+ * @returns true
59
+ */
60
+ supportsNetwork(_) {
61
+ return true;
62
+ }
63
+ }
64
+ exports.CustomActionProvider = CustomActionProvider;
65
+ const customActionProvider = (actions) => new CustomActionProvider(Array.isArray(actions) ? actions : [actions]);
66
+ exports.customActionProvider = customActionProvider;