@coinbase/agentkit 0.10.2 → 0.10.4

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 (107) hide show
  1. package/README.md +89 -10
  2. package/dist/action-providers/across/acrossActionProvider.js +2 -4
  3. package/dist/action-providers/across/acrossActionProvider.test.js +10 -5
  4. package/dist/action-providers/baseAccount/baseAccountActionProvider.js +5 -7
  5. package/dist/action-providers/cdp/cdpApiActionProvider.js +7 -30
  6. package/dist/action-providers/cdp/cdpApiActionProvider.test.js +2 -8
  7. package/dist/action-providers/cdp/faucetUtils.d.ts +38 -0
  8. package/dist/action-providers/cdp/faucetUtils.js +81 -0
  9. package/dist/action-providers/clanker/schemas.d.ts +4 -4
  10. package/dist/action-providers/clanker/utils.d.ts +2 -1
  11. package/dist/action-providers/clanker/utils.js +2 -2
  12. package/dist/action-providers/enso/constants.d.ts +4 -0
  13. package/dist/action-providers/enso/constants.js +10 -0
  14. package/dist/action-providers/enso/ensoActionProvider.d.ts +34 -0
  15. package/dist/action-providers/enso/ensoActionProvider.js +125 -0
  16. package/dist/action-providers/enso/ensoActionProvider.test.d.ts +1 -0
  17. package/dist/action-providers/enso/ensoActionProvider.test.js +141 -0
  18. package/dist/action-providers/enso/index.d.ts +1 -0
  19. package/dist/action-providers/enso/index.js +17 -0
  20. package/dist/action-providers/enso/schemas.d.ts +23 -0
  21. package/dist/action-providers/enso/schemas.js +22 -0
  22. package/dist/action-providers/erc20/constants.d.ts +2 -0
  23. package/dist/action-providers/erc20/constants.js +2 -0
  24. package/dist/action-providers/erc20/erc20ActionProvider.d.ts +17 -1
  25. package/dist/action-providers/erc20/erc20ActionProvider.js +103 -1
  26. package/dist/action-providers/erc20/erc20ActionProvider.test.js +201 -0
  27. package/dist/action-providers/erc20/schemas.d.ts +29 -0
  28. package/dist/action-providers/erc20/schemas.js +34 -1
  29. package/dist/action-providers/index.d.ts +4 -1
  30. package/dist/action-providers/index.js +4 -1
  31. package/dist/action-providers/jupiter/jupiterActionProvider.js +2 -2
  32. package/dist/action-providers/spl/splActionProvider.js +12 -13
  33. package/dist/action-providers/superfluid/graphQueries/superfluidGraphQueries.js +2 -2
  34. package/dist/action-providers/sushi/constants.d.ts +35 -0
  35. package/dist/action-providers/sushi/constants.js +7 -0
  36. package/dist/action-providers/sushi/index.d.ts +4 -0
  37. package/dist/action-providers/sushi/index.js +20 -0
  38. package/dist/action-providers/sushi/sushiDataActionProvider.d.ts +32 -0
  39. package/dist/action-providers/sushi/sushiDataActionProvider.js +113 -0
  40. package/dist/action-providers/sushi/sushiDataSchemas.d.ts +11 -0
  41. package/dist/action-providers/sushi/sushiDataSchemas.js +16 -0
  42. package/dist/action-providers/sushi/sushiRouterActionProvider.d.ts +40 -0
  43. package/dist/action-providers/sushi/sushiRouterActionProvider.js +386 -0
  44. package/dist/action-providers/sushi/sushiRouterActionProvider.test.d.ts +1 -0
  45. package/dist/action-providers/sushi/sushiRouterActionProvider.test.js +392 -0
  46. package/dist/action-providers/sushi/sushiRouterSchemas.d.ts +36 -0
  47. package/dist/action-providers/sushi/sushiRouterSchemas.js +55 -0
  48. package/dist/action-providers/vaultsfyi/constants.d.ts +8 -12
  49. package/dist/action-providers/vaultsfyi/constants.js +47 -13
  50. package/dist/action-providers/vaultsfyi/schemas.d.ts +120 -65
  51. package/dist/action-providers/vaultsfyi/schemas.js +72 -38
  52. package/dist/action-providers/vaultsfyi/sdk.d.ts +8 -0
  53. package/dist/action-providers/vaultsfyi/sdk.js +15 -0
  54. package/dist/action-providers/vaultsfyi/utils.d.ts +151 -55
  55. package/dist/action-providers/vaultsfyi/utils.js +29 -75
  56. package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.d.ts +55 -16
  57. package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.js +413 -217
  58. package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.test.js +509 -316
  59. package/dist/action-providers/wallet/walletActionProvider.js +1 -1
  60. package/dist/action-providers/weth/constants.d.ts +0 -1
  61. package/dist/action-providers/weth/constants.js +1 -2
  62. package/dist/action-providers/weth/schemas.js +6 -2
  63. package/dist/action-providers/weth/wethActionProvider.d.ts +7 -0
  64. package/dist/action-providers/weth/wethActionProvider.js +57 -32
  65. package/dist/action-providers/weth/wethActionProvider.test.js +60 -11
  66. package/dist/action-providers/x402/constants.d.ts +67 -0
  67. package/dist/action-providers/x402/constants.js +37 -0
  68. package/dist/action-providers/x402/schemas.d.ts +45 -5
  69. package/dist/action-providers/x402/schemas.js +81 -11
  70. package/dist/action-providers/x402/utils.d.ts +89 -14
  71. package/dist/action-providers/x402/utils.js +335 -31
  72. package/dist/action-providers/x402/x402ActionProvider.d.ts +21 -7
  73. package/dist/action-providers/x402/x402ActionProvider.js +250 -184
  74. package/dist/action-providers/x402/x402ActionProvider.test.js +240 -236
  75. package/dist/action-providers/yelay/constants.d.ts +64 -0
  76. package/dist/action-providers/yelay/constants.js +137 -0
  77. package/dist/action-providers/yelay/index.d.ts +2 -0
  78. package/dist/action-providers/yelay/index.js +18 -0
  79. package/dist/action-providers/yelay/schemas.d.ts +47 -0
  80. package/dist/action-providers/yelay/schemas.js +59 -0
  81. package/dist/action-providers/yelay/types.d.ts +24 -0
  82. package/dist/action-providers/yelay/yelayActionProvider.d.ts +70 -0
  83. package/dist/action-providers/yelay/yelayActionProvider.js +329 -0
  84. package/dist/action-providers/yelay/yelayActionProvider.test.d.ts +1 -0
  85. package/dist/action-providers/yelay/yelayActionProvider.test.js +302 -0
  86. package/dist/action-providers/zora/zoraActionProvider.js +4 -5
  87. package/dist/wallet-providers/cdpSmartWalletProvider.js +1 -3
  88. package/dist/wallet-providers/cdpSolanaWalletProvider.d.ts +14 -0
  89. package/dist/wallet-providers/cdpSolanaWalletProvider.js +39 -3
  90. package/dist/wallet-providers/cdpSolanaWalletProvider.test.js +16 -0
  91. package/dist/wallet-providers/privySvmWalletProvider.d.ts +14 -0
  92. package/dist/wallet-providers/privySvmWalletProvider.js +17 -0
  93. package/dist/wallet-providers/privySvmWalletProvider.test.js +10 -0
  94. package/dist/wallet-providers/solanaKeypairWalletProvider.d.ts +14 -0
  95. package/dist/wallet-providers/solanaKeypairWalletProvider.js +17 -0
  96. package/dist/wallet-providers/svmWalletProvider.d.ts +34 -0
  97. package/dist/wallet-providers/svmWalletProvider.js +43 -0
  98. package/dist/wallet-providers/svmWalletProvider.test.js +10 -0
  99. package/package.json +11 -6
  100. package/dist/action-providers/vaultsfyi/api/actions.d.ts +0 -41
  101. package/dist/action-providers/vaultsfyi/api/actions.js +0 -28
  102. package/dist/action-providers/vaultsfyi/api/historicalData.d.ts +0 -31
  103. package/dist/action-providers/vaultsfyi/api/historicalData.js +0 -44
  104. package/dist/action-providers/vaultsfyi/api/types.d.ts +0 -34
  105. package/dist/action-providers/vaultsfyi/api/vaults.d.ts +0 -66
  106. package/dist/action-providers/vaultsfyi/api/vaults.js +0 -57
  107. /package/dist/action-providers/{vaultsfyi/api → yelay}/types.js +0 -0
package/README.md CHANGED
@@ -313,6 +313,15 @@ const agent = createReactAgent({
313
313
  </table>
314
314
  </details>
315
315
  <details>
316
+ <summary><strong>Enso</strong></summary>
317
+ <table width="100%">
318
+ <tr>
319
+ <td width="200"><code>route</code></td>
320
+ <td width="768">Find and execute a route for entering or exiting any DeFi position or swapping any ERC20 tokens.</td>
321
+ </tr>
322
+ </table>
323
+ </details>
324
+ <details>
316
325
  <summary><strong>ERC20</strong></summary>
317
326
  <table width="100%">
318
327
  <tr>
@@ -323,6 +332,14 @@ const agent = createReactAgent({
323
332
  <td width="200"><code>transfer</code></td>
324
333
  <td width="768">Transfers a specified amount of ERC-20 tokens to a destination address.</td>
325
334
  </tr>
335
+ <tr>
336
+ <td width="200"><code>approve</code></td>
337
+ <td width="768">Approves a spender to transfer ERC-20 tokens on behalf of the wallet.</td>
338
+ </tr>
339
+ <tr>
340
+ <td width="200"><code>get_allowance</code></td>
341
+ <td width="768">Checks the allowance amount for a spender of an ERC-20 token.</td>
342
+ </tr>
326
343
  <tr>
327
344
  <td width="200"><code>get_erc20_token_address</code></td>
328
345
  <td width="768">Gets the contract address for frequently used ERC20 tokens on different networks by token symbol.</td>
@@ -488,6 +505,23 @@ const agent = createReactAgent({
488
505
  </table>
489
506
  </details>
490
507
  <details>
508
+ <summary><strong>Sushi</strong></summary>
509
+ <table width="100%">
510
+ <tr>
511
+ <td width="200"><code>find-token</code></td>
512
+ <td width="768">Searches the Sushi Data API for up to 10 matching tokens by symbol or address.</td>
513
+ </tr>
514
+ <tr>
515
+ <td width="200"><code>quote</code></td>
516
+ <td width="768">Fetches an off-chain swap quote between ERC20 or native assets using the Sushi Swap API.</td>
517
+ </tr>
518
+ <tr>
519
+ <td width="200"><code>swap</code></td>
520
+ <td width="768">Executes a Sushi-routed swap after validating balances and approvals, returning the transaction hash.</td>
521
+ </tr>
522
+ </table>
523
+ </details>
524
+ <details>
491
525
  <summary><strong>Twitter</strong></summary>
492
526
  <table width="100%">
493
527
  <tr>
@@ -541,25 +575,45 @@ const agent = createReactAgent({
541
575
  <td width="768">Gets historical APY and TVL data for a specific vault over time.</td>
542
576
  </tr>
543
577
  <tr>
544
- <td width="200"><code>deposit</code></td>
545
- <td width="768">Deposits assets into a selected vault to start earning yield.</td>
578
+ <td width="200"><code>transaction_context</code></td>
579
+ <td width="768">Gets the available balances and operations for a given vault.</td>
546
580
  </tr>
547
581
  <tr>
548
- <td width="200"><code>redeem</code></td>
549
- <td width="768">Redeems assets from a vault to withdraw principal and earned yield.</td>
582
+ <td width="200"><code>execute_step</code></td>
583
+ <td width="768">Executes an operation on a given vault.</td>
550
584
  </tr>
551
585
  <tr>
552
- <td width="200"><code>claim</code></td>
553
- <td width="768">Claims rewards from a vault without withdrawing the principal deposit.</td>
554
- </tr>
555
- <tr>
556
- <td width="200"><code>balances</code></td>
557
- <td width="768">Retrieves user's native token and ERC20 token balances across supported networks.</td>
586
+ <td width="200"><code>user_idle_assets</code></td>
587
+ <td width="768">Gets the user's idle assets.</td>
558
588
  </tr>
559
589
  <tr>
560
590
  <td width="200"><code>positions</code></td>
561
591
  <td width="768">Gets user's current positions in vaults including balances and unclaimed rewards.</td>
562
592
  </tr>
593
+ <tr>
594
+ <td width="200"><code>rewards_context</code></td>
595
+ <td width="768">Gets the available rewards for a given user.</td>
596
+ </tr>
597
+ <tr>
598
+ <td width="200"><code>claim_rewards</code></td>
599
+ <td width="768">Claims requested rewards for a given user.</td>
600
+ </tr>
601
+ <tr>
602
+ <td width="200"><code>benchmark_apy</code></td>
603
+ <td width="768">Gets the benchmark APY.</td>
604
+ </tr>
605
+ <tr>
606
+ <td width="200"><code>historical_benchmark_apy</code></td>
607
+ <td width="768">Gets the historical benchmark APY.</td>
608
+ </tr>
609
+ <tr>
610
+ <td width="200"><code>total_vault_returns</code></td>
611
+ <td width="768">Gets the total returns for a given vault.</td>
612
+ </tr>
613
+ <tr>
614
+ <td width="200"><code>user_events</code></td>
615
+ <td width="768">Gets the user's events for a given vault.</td>
616
+ </tr>
563
617
  </table>
564
618
  </details>
565
619
  <details>
@@ -650,6 +704,31 @@ it will return payment details that can be used on retry.</td>
650
704
  </table>
651
705
  </details>
652
706
  <details>
707
+ <summary><strong>Yelay</strong></summary>
708
+ <table width="100%">
709
+ <tr>
710
+ <td width="200"><code>get_vaults</code></td>
711
+ <td width="768">Fetches a list of available Yelay Vaults with their current APYs and contract addresses.</td>
712
+ </tr>
713
+ <tr>
714
+ <td width="200"><code>deposit</code></td>
715
+ <td width="768">Deposits assets into a specified Yelay Vault.</td>
716
+ </tr>
717
+ <tr>
718
+ <td width="200"><code>redeem</code></td>
719
+ <td width="768">Withdraws assets from a Yelay Vault.</td>
720
+ </tr>
721
+ <tr>
722
+ <td width="200"><code>claim</code></td>
723
+ <td width="768">Claims accumulated yield from a Yelay Vault.</td>
724
+ </tr>
725
+ <tr>
726
+ <td width="200"><code>get_balance</code></td>
727
+ <td width="768">Gets the user's balance and yield information for a specific vault.</td>
728
+ </tr>
729
+ </table>
730
+ </details>
731
+ <details>
653
732
  <summary><strong>ZeroX</strong></summary>
654
733
  <table width="100%">
655
734
  <tr>
@@ -32,6 +32,7 @@ const wallet_providers_1 = require("../../wallet-providers");
32
32
  const utils_1 = require("./utils");
33
33
  const accounts_1 = require("viem/accounts");
34
34
  const viem_2 = require("viem");
35
+ const app_sdk_1 = require("@across-protocol/app-sdk");
35
36
  /**
36
37
  * AcrossActionProvider provides actions for cross-chain bridging via Across Protocol.
37
38
  */
@@ -68,9 +69,6 @@ class AcrossActionProvider extends actionProvider_1.ActionProvider {
68
69
  */
69
70
  async bridgeToken(walletProvider, args) {
70
71
  try {
71
- // Use dynamic import to get the Across SDK
72
- const acrossModule = await import("@across-protocol/app-sdk");
73
- const createAcrossClient = acrossModule.createAcrossClient;
74
72
  // Get recipient address if provided, otherwise use sender
75
73
  const address = walletProvider.getAddress();
76
74
  const recipient = (args.recipient || address);
@@ -105,7 +103,7 @@ class AcrossActionProvider extends actionProvider_1.ActionProvider {
105
103
  transport: (0, viem_1.http)(),
106
104
  });
107
105
  // Create Across client
108
- const acrossClient = createAcrossClient({
106
+ const acrossClient = (0, app_sdk_1.createAcrossClient)({
109
107
  chains: [originChain, destinationChain],
110
108
  useTestnet,
111
109
  });
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const acrossActionProvider_1 = require("./acrossActionProvider");
4
4
  const viem_1 = require("viem");
5
+ const app_sdk_1 = require("@across-protocol/app-sdk");
5
6
  // Mock the necessary imports and modules
6
7
  jest.mock("viem", () => {
7
8
  return {
@@ -63,10 +64,11 @@ jest.mock("../../network", () => {
63
64
  };
64
65
  });
65
66
  // Mock the Across SDK
66
- const mockCreateAcrossClient = jest.fn();
67
67
  jest.mock("@across-protocol/app-sdk", () => ({
68
- createAcrossClient: mockCreateAcrossClient,
68
+ createAcrossClient: jest.fn(),
69
69
  }));
70
+ // Cast the imported mock to a Jest mock function
71
+ const mockedCreateAcrossClient = app_sdk_1.createAcrossClient;
70
72
  // Default implementation for the createAcrossClient mock
71
73
  const defaultClientImplementation = () => ({
72
74
  getSupportedChains: jest.fn().mockResolvedValue([
@@ -134,7 +136,7 @@ const defaultClientImplementation = () => ({
134
136
  }),
135
137
  });
136
138
  // Set the default implementation
137
- mockCreateAcrossClient.mockImplementation(() => {
139
+ mockedCreateAcrossClient.mockImplementation(() => {
138
140
  const client = defaultClientImplementation();
139
141
  // Add the chains property to match what the code expects
140
142
  return {
@@ -151,6 +153,7 @@ mockCreateAcrossClient.mockImplementation(() => {
151
153
  network: "optimism",
152
154
  },
153
155
  ],
156
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
154
157
  };
155
158
  });
156
159
  // Mock the isTestnet function
@@ -170,7 +173,7 @@ describe("Across Action Provider", () => {
170
173
  beforeEach(() => {
171
174
  jest.clearAllMocks();
172
175
  // Reset to default implementation
173
- mockCreateAcrossClient.mockImplementation(() => {
176
+ mockedCreateAcrossClient.mockImplementation(() => {
174
177
  const client = defaultClientImplementation();
175
178
  // Add the chains property to match what the code expects
176
179
  return {
@@ -187,6 +190,7 @@ describe("Across Action Provider", () => {
187
190
  network: "optimism",
188
191
  },
189
192
  ],
193
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
190
194
  };
191
195
  });
192
196
  mockPublicClient = {
@@ -247,7 +251,7 @@ describe("Across Action Provider", () => {
247
251
  });
248
252
  it("should fail when slippage is too high", async () => {
249
253
  // Override the default mock with high slippage for this test only
250
- mockCreateAcrossClient.mockImplementationOnce(() => ({
254
+ mockedCreateAcrossClient.mockImplementationOnce(() => ({
251
255
  getSupportedChains: jest.fn().mockResolvedValue([
252
256
  {
253
257
  chainId: 1,
@@ -288,6 +292,7 @@ describe("Across Action Provider", () => {
288
292
  waitForDepositTx: jest.fn().mockResolvedValue({
289
293
  depositId: "123456",
290
294
  }),
295
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
291
296
  }));
292
297
  // Set a low max slippage
293
298
  const args = {
@@ -19,6 +19,7 @@ const utils_1 = require("../erc20/utils");
19
19
  const schemas_1 = require("./schemas");
20
20
  const utils_2 = require("./utils");
21
21
  const utils_3 = require("../../utils");
22
+ const spend_permission_1 = require("@base-org/account/spend-permission");
22
23
  /**
23
24
  * Fetch spend permissions for a user account from a spender address
24
25
  *
@@ -29,8 +30,7 @@ const utils_3 = require("../../utils");
29
30
  */
30
31
  async function fetchUserSpendPermissions(userAccount, spenderAccount, tokenAddress) {
31
32
  try {
32
- const { fetchPermissions } = await import("@base-org/account/spend-permission");
33
- const permissions = await fetchPermissions({
33
+ const permissions = await (0, spend_permission_1.fetchPermissions)({
34
34
  account: userAccount,
35
35
  chainId: 8453,
36
36
  spender: spenderAccount,
@@ -200,10 +200,9 @@ class BaseAccountActionProvider extends actionProvider_1.ActionProvider {
200
200
  });
201
201
  }
202
202
  // Check permission status and prepare spend call data
203
- const { getPermissionStatus, prepareSpendCallData } = await import("@base-org/account/spend-permission");
204
203
  const status = await (0, utils_3.retryWithExponentialBackoff)(
205
204
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
206
- () => getPermissionStatus(_permission), 3, // Max 3 retries
205
+ () => (0, spend_permission_1.getPermissionStatus)(_permission), 3, // Max 3 retries
207
206
  1000, // 1s base delay
208
207
  2000);
209
208
  // Determine amount to spend - use provided amount or full remaining allowance
@@ -226,7 +225,7 @@ class BaseAccountActionProvider extends actionProvider_1.ActionProvider {
226
225
  // Prepare the spend transaction - returns an array of calls
227
226
  const spendCalls = await (0, utils_3.retryWithExponentialBackoff)(
228
227
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
229
- () => prepareSpendCallData(_permission, amountInAtomicUnits), 3, // Max 3 retries
228
+ () => (0, spend_permission_1.prepareSpendCallData)(_permission, amountInAtomicUnits), 3, // Max 3 retries
230
229
  1000, // 1s base delay
231
230
  2000);
232
231
  // Take the first call from the array (there should be one for spend operations)
@@ -303,9 +302,8 @@ class BaseAccountActionProvider extends actionProvider_1.ActionProvider {
303
302
  // Use the specified permission (convert to 0-based index)
304
303
  const _permission = permissions[permissionIndex - 1];
305
304
  // Prepare the revoke transaction
306
- const { prepareRevokeCallData } = await import("@base-org/account/spend-permission");
307
305
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
308
- const revokeCall = await prepareRevokeCallData(_permission);
306
+ const revokeCall = await (0, spend_permission_1.prepareRevokeCallData)(_permission);
309
307
  // Execute the revoke transaction
310
308
  const txHash = await walletProvider.sendTransaction({
311
309
  to: revokeCall.to,
@@ -12,10 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.cdpApiActionProvider = exports.CdpApiActionProvider = void 0;
13
13
  const zod_1 = require("zod");
14
14
  const wallet_providers_1 = require("../../wallet-providers");
15
- const cdpShared_1 = require("../../wallet-providers/cdpShared");
16
15
  const actionDecorator_1 = require("../actionDecorator");
17
16
  const actionProvider_1 = require("../actionProvider");
18
17
  const schemas_1 = require("./schemas");
18
+ const faucetUtils_1 = require("./faucetUtils");
19
19
  /**
20
20
  * CdpApiActionProvider is an action provider for CDP API.
21
21
  *
@@ -47,35 +47,12 @@ class CdpApiActionProvider extends actionProvider_1.ActionProvider {
47
47
  async faucet(walletProvider, args) {
48
48
  const network = walletProvider.getNetwork();
49
49
  const networkId = network.networkId;
50
- if ((0, cdpShared_1.isWalletProviderWithClient)(walletProvider)) {
51
- if (network.protocolFamily === "evm") {
52
- if (networkId !== "base-sepolia" && networkId !== "ethereum-sepolia") {
53
- throw new Error("Faucet is only supported on 'base-sepolia' or 'ethereum-sepolia' evm networks.");
54
- }
55
- const faucetTx = await walletProvider.getClient().evm.requestFaucet({
56
- address: walletProvider.getAddress(),
57
- token: (args.assetId || "eth"),
58
- network: networkId,
59
- });
60
- return `Received ${args.assetId || "ETH"} from the faucet. Transaction hash: ${faucetTx.transactionHash}`;
61
- }
62
- else if (network.protocolFamily === "svm") {
63
- if (networkId !== "solana-devnet") {
64
- throw new Error("Faucet is only supported on 'solana-devnet' solana networks.");
65
- }
66
- const faucetTx = await walletProvider.getClient().solana.requestFaucet({
67
- address: walletProvider.getAddress(),
68
- token: (args.assetId || "sol"),
69
- });
70
- return `Received ${args.assetId || "SOL"} from the faucet. Transaction signature hash: ${faucetTx.signature}`;
71
- }
72
- else {
73
- throw new Error("Faucet is only supported on Ethereum and Solana protocol families.");
74
- }
75
- }
76
- else {
77
- throw new Error("Wallet provider is not a CDP Wallet Provider.");
78
- }
50
+ const address = walletProvider.getAddress();
51
+ const cdpClient = (0, faucetUtils_1.getCdpClient)(walletProvider);
52
+ (0, faucetUtils_1.validateNetworkSupport)(network, networkId);
53
+ return network.protocolFamily === "evm"
54
+ ? (0, faucetUtils_1.handleEvmFaucet)(cdpClient, address, networkId, args)
55
+ : (0, faucetUtils_1.handleSvmFaucet)(cdpClient, address, args);
79
56
  }
80
57
  }
81
58
  exports.CdpApiActionProvider = CdpApiActionProvider;
@@ -72,19 +72,13 @@ describe("CDP API Action Provider", () => {
72
72
  const mockNetwork = { protocolFamily: "evm", networkId: "ethereum-mainnet" };
73
73
  mockWalletProvider.getNetwork.mockReturnValue(mockNetwork);
74
74
  mockWalletProvider.getClient.mockReturnValue(mockCdpClient);
75
- await expect(actionProvider.faucet(mockWalletProvider, { assetId: "eth" })).rejects.toThrow("Faucet is only supported on 'base-sepolia' or 'ethereum-sepolia' evm networks");
75
+ await expect(actionProvider.faucet(mockWalletProvider, { assetId: "eth" })).rejects.toThrow("Faucet is only supported on base-sepolia or ethereum-sepolia evm networks");
76
76
  });
77
77
  it("should throw error for unsupported Solana network", async () => {
78
78
  const mockNetwork = { protocolFamily: "svm", networkId: "solana-mainnet" };
79
79
  mockWalletProvider.getNetwork.mockReturnValue(mockNetwork);
80
80
  mockWalletProvider.getClient.mockReturnValue(mockCdpClient);
81
- await expect(actionProvider.faucet(mockWalletProvider, { assetId: "sol" })).rejects.toThrow("Faucet is only supported on 'solana-devnet' solana networks");
82
- });
83
- it("should throw error for wallet provider without client", async () => {
84
- const mockWalletWithoutClient = {
85
- getNetwork: jest.fn().mockReturnValue({ protocolFamily: "evm", networkId: "base-sepolia" }),
86
- };
87
- await expect(actionProvider.faucet(mockWalletWithoutClient, { assetId: "eth" })).rejects.toThrow("Wallet provider is not a CDP Wallet Provider");
81
+ await expect(actionProvider.faucet(mockWalletProvider, { assetId: "sol" })).rejects.toThrow("Faucet is only supported on solana-devnet svm networks");
88
82
  });
89
83
  });
90
84
  describe("RequestFaucetFundsV2Schema", () => {
@@ -0,0 +1,38 @@
1
+ import { z } from "zod";
2
+ import { CdpClient } from "@coinbase/cdp-sdk";
3
+ import { Network } from "../../network";
4
+ import { WalletProvider } from "../../wallet-providers";
5
+ import { RequestFaucetFundsV2Schema } from "./schemas";
6
+ /**
7
+ * Gets or creates a CDP client from the wallet provider or environment variables.
8
+ *
9
+ * @param walletProvider - The wallet provider to get the client from.
10
+ * @returns The CDP client.
11
+ */
12
+ export declare function getCdpClient(walletProvider: WalletProvider): CdpClient;
13
+ /**
14
+ * Validates that the network and protocol family are supported for faucet operations.
15
+ *
16
+ * @param network - The network to validate.
17
+ * @param networkId - The network ID to validate.
18
+ */
19
+ export declare function validateNetworkSupport(network: Network, networkId: string): void;
20
+ /**
21
+ * Handles faucet requests for EVM networks.
22
+ *
23
+ * @param cdpClient - The CDP client to use.
24
+ * @param address - The address to request funds from.
25
+ * @param networkId - The network ID to request funds from.
26
+ * @param args - The arguments to request funds from.
27
+ * @returns The transaction hash.
28
+ */
29
+ export declare function handleEvmFaucet(cdpClient: CdpClient, address: string, networkId: string, args: z.infer<typeof RequestFaucetFundsV2Schema>): Promise<string>;
30
+ /**
31
+ * Handles faucet requests for Solana networks.
32
+ *
33
+ * @param cdpClient - The CDP client to use.
34
+ * @param address - The address to request funds from.
35
+ * @param args - The arguments to request funds from.
36
+ * @returns The transaction hash.
37
+ */
38
+ export declare function handleSvmFaucet(cdpClient: CdpClient, address: string, args: z.infer<typeof RequestFaucetFundsV2Schema>): Promise<string>;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCdpClient = getCdpClient;
4
+ exports.validateNetworkSupport = validateNetworkSupport;
5
+ exports.handleEvmFaucet = handleEvmFaucet;
6
+ exports.handleSvmFaucet = handleSvmFaucet;
7
+ const cdp_sdk_1 = require("@coinbase/cdp-sdk");
8
+ const cdpShared_1 = require("../../wallet-providers/cdpShared");
9
+ /**
10
+ * Gets or creates a CDP client from the wallet provider or environment variables.
11
+ *
12
+ * @param walletProvider - The wallet provider to get the client from.
13
+ * @returns The CDP client.
14
+ */
15
+ function getCdpClient(walletProvider) {
16
+ if ((0, cdpShared_1.isWalletProviderWithClient)(walletProvider)) {
17
+ return walletProvider.getClient();
18
+ }
19
+ const apiKeyId = process.env.CDP_API_KEY_ID;
20
+ const apiKeySecret = process.env.CDP_API_KEY_SECRET;
21
+ if (!apiKeyId || !apiKeySecret) {
22
+ throw new Error("Faucet requires CDP_API_KEY_ID and CDP_API_KEY_SECRET environment variables to be set.");
23
+ }
24
+ return new cdp_sdk_1.CdpClient({ apiKeyId, apiKeySecret });
25
+ }
26
+ /**
27
+ * Validates that the network and protocol family are supported for faucet operations.
28
+ *
29
+ * @param network - The network to validate.
30
+ * @param networkId - The network ID to validate.
31
+ */
32
+ function validateNetworkSupport(network, networkId) {
33
+ const supportedProtocols = ["evm", "svm"];
34
+ if (!supportedProtocols.includes(network.protocolFamily)) {
35
+ throw new Error("Faucet is only supported on Ethereum and Solana protocol families.");
36
+ }
37
+ const supportedEvmNetworks = ["base-sepolia", "ethereum-sepolia"];
38
+ const supportedSvmNetworks = ["solana-devnet"];
39
+ const isEvmSupported = network.protocolFamily === "evm" && supportedEvmNetworks.includes(networkId);
40
+ const isSvmSupported = network.protocolFamily === "svm" && supportedSvmNetworks.includes(networkId);
41
+ if (!isEvmSupported && !isSvmSupported) {
42
+ const supportedNetworks = network.protocolFamily === "evm"
43
+ ? supportedEvmNetworks.join(" or ")
44
+ : supportedSvmNetworks.join(" or ");
45
+ throw new Error(`Faucet is only supported on ${supportedNetworks} ${network.protocolFamily} networks.`);
46
+ }
47
+ }
48
+ /**
49
+ * Handles faucet requests for EVM networks.
50
+ *
51
+ * @param cdpClient - The CDP client to use.
52
+ * @param address - The address to request funds from.
53
+ * @param networkId - The network ID to request funds from.
54
+ * @param args - The arguments to request funds from.
55
+ * @returns The transaction hash.
56
+ */
57
+ async function handleEvmFaucet(cdpClient, address, networkId, args) {
58
+ const token = (args.assetId || "eth");
59
+ const faucetTx = await cdpClient.evm.requestFaucet({
60
+ address,
61
+ token,
62
+ network: networkId,
63
+ });
64
+ return `Received ${args.assetId || "ETH"} from the faucet. Transaction hash: ${faucetTx.transactionHash}`;
65
+ }
66
+ /**
67
+ * Handles faucet requests for Solana networks.
68
+ *
69
+ * @param cdpClient - The CDP client to use.
70
+ * @param address - The address to request funds from.
71
+ * @param args - The arguments to request funds from.
72
+ * @returns The transaction hash.
73
+ */
74
+ async function handleSvmFaucet(cdpClient, address, args) {
75
+ const token = (args.assetId || "sol");
76
+ const faucetTx = await cdpClient.solana.requestFaucet({
77
+ address,
78
+ token,
79
+ });
80
+ return `Received ${args.assetId || "SOL"} from the faucet. Transaction signature hash: ${faucetTx.signature}`;
81
+ }
@@ -17,11 +17,11 @@ export declare const ClankTokenSchema: z.ZodObject<{
17
17
  platform: z.ZodString;
18
18
  url: z.ZodString;
19
19
  }, "strip", z.ZodTypeAny, {
20
- url: string;
21
20
  platform: string;
22
- }, {
23
21
  url: string;
22
+ }, {
24
23
  platform: string;
24
+ url: string;
25
25
  }>, "many">>;
26
26
  interface: z.ZodDefault<z.ZodString>;
27
27
  id: z.ZodDefault<z.ZodString>;
@@ -36,8 +36,8 @@ export declare const ClankTokenSchema: z.ZodObject<{
36
36
  interface: string;
37
37
  description?: string | undefined;
38
38
  socialMediaUrls?: {
39
- url: string;
40
39
  platform: string;
40
+ url: string;
41
41
  }[] | undefined;
42
42
  }, {
43
43
  tokenName: string;
@@ -49,8 +49,8 @@ export declare const ClankTokenSchema: z.ZodObject<{
49
49
  id?: string | undefined;
50
50
  description?: string | undefined;
51
51
  socialMediaUrls?: {
52
- url: string;
53
52
  platform: string;
53
+ url: string;
54
54
  }[] | undefined;
55
55
  interface?: string | undefined;
56
56
  }>;
@@ -1,4 +1,5 @@
1
1
  import { EvmWalletProvider } from "../../wallet-providers";
2
+ import { Clanker } from "clanker-sdk/v4";
2
3
  /**
3
4
  * Creates the client Clanker expects from the EvmWalletProvider
4
5
  *
@@ -6,4 +7,4 @@ import { EvmWalletProvider } from "../../wallet-providers";
6
7
  * @param networkId - The network to Clank on
7
8
  * @returns The Clanker implementation
8
9
  */
9
- export declare function createClankerClient(walletProvider: EvmWalletProvider, networkId: string): Promise<import("clanker-sdk/v4", { with: { "resolution-mode": "import" } }).Clanker>;
10
+ export declare function createClankerClient(walletProvider: EvmWalletProvider, networkId: string): Promise<Clanker>;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createClankerClient = createClankerClient;
4
4
  const viem_1 = require("viem");
5
5
  const network_1 = require("../../network");
6
+ const v4_1 = require("clanker-sdk/v4");
6
7
  /**
7
8
  * Creates the client Clanker expects from the EvmWalletProvider
8
9
  *
@@ -11,7 +12,6 @@ const network_1 = require("../../network");
11
12
  * @returns The Clanker implementation
12
13
  */
13
14
  async function createClankerClient(walletProvider, networkId) {
14
- const { Clanker } = await import("clanker-sdk/v4");
15
15
  const account = walletProvider.toSigner();
16
16
  const publicClient = walletProvider.getPublicClient();
17
17
  const wallet = (0, viem_1.createWalletClient)({
@@ -19,5 +19,5 @@ async function createClankerClient(walletProvider, networkId) {
19
19
  chain: network_1.NETWORK_ID_TO_VIEM_CHAIN[networkId],
20
20
  transport: (0, viem_1.http)(publicClient.transport.url),
21
21
  });
22
- return new Clanker({ wallet, publicClient });
22
+ return new v4_1.Clanker({ wallet, publicClient });
23
23
  }
@@ -0,0 +1,4 @@
1
+ export declare const ENSO_API_KEY: "1e02632d-6feb-4a75-a157-documentation";
2
+ export declare const ENSO_ETH: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
3
+ export declare const ENSO_ROUTE_SINGLE_SIG: "0xb94c3609";
4
+ export declare const ENSO_SUPPORTED_NETWORKS: Set<number>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ENSO_SUPPORTED_NETWORKS = exports.ENSO_ROUTE_SINGLE_SIG = exports.ENSO_ETH = exports.ENSO_API_KEY = void 0;
4
+ exports.ENSO_API_KEY = "1e02632d-6feb-4a75-a157-documentation";
5
+ exports.ENSO_ETH = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
6
+ exports.ENSO_ROUTE_SINGLE_SIG = "0xb94c3609";
7
+ exports.ENSO_SUPPORTED_NETWORKS = new Set([
8
+ 1, 10, 56, 100, 130, 137, 146, 480, 999, 1868, 8453, 42161, 43114, 57073, 59144, 80094, 98866,
9
+ 747474,
10
+ ]);
@@ -0,0 +1,34 @@
1
+ import { z } from "zod";
2
+ import { ActionProvider } from "../actionProvider";
3
+ import { Network } from "../../network";
4
+ import { EnsoActionProviderParams, EnsoRouteSchema } from "./schemas";
5
+ import { EvmWalletProvider } from "../../wallet-providers";
6
+ import { EnsoClient } from "@ensofinance/sdk";
7
+ /**
8
+ * EnsoActionProvider is an action provider for Enso.
9
+ */
10
+ export declare class EnsoActionProvider extends ActionProvider<EvmWalletProvider> {
11
+ readonly ensoClient: EnsoClient;
12
+ /**
13
+ * Constructor for the EnsoActionProvider
14
+ *
15
+ * @param params - The initialization parameters for the Enso action provider
16
+ */
17
+ constructor(params?: EnsoActionProviderParams);
18
+ /**
19
+ * Finds the optimal route from a token to a token and executes it.
20
+ *
21
+ * @param walletProvider - The wallet to execute the transaction from.
22
+ * @param args - The input arguments for the action.
23
+ * @returns A message containing the token route details.
24
+ */
25
+ route(walletProvider: EvmWalletProvider, args: z.infer<typeof EnsoRouteSchema>): Promise<string>;
26
+ /**
27
+ * Checks if the Enso action provider supports the given network.
28
+ *
29
+ * @param network - The network to check.
30
+ * @returns True if the Enso action provider supports the network, false otherwise.
31
+ */
32
+ supportsNetwork: (network: Network) => boolean;
33
+ }
34
+ export declare const ensoActionProvider: () => EnsoActionProvider;