@coinbase/agentkit 0.0.0-nightly-20250904210426 → 0.0.0-nightly-20250906210355

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 (73) hide show
  1. package/README.md +29 -0
  2. package/dist/action-providers/across/acrossActionProvider.js +3 -3
  3. package/dist/action-providers/cdp/cdpApiActionProvider.d.ts +0 -1
  4. package/dist/action-providers/cdp/cdpApiActionProvider.js +0 -16
  5. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.d.ts +1 -2
  6. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.js +7 -26
  7. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.test.js +8 -0
  8. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.d.ts +0 -1
  9. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.js +7 -22
  10. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.test.js +11 -1
  11. package/dist/action-providers/clanker/clankerActionProvider.d.ts +43 -0
  12. package/dist/action-providers/clanker/clankerActionProvider.js +130 -0
  13. package/dist/action-providers/clanker/clankerActionProvider.test.d.ts +4 -0
  14. package/dist/action-providers/clanker/clankerActionProvider.test.js +119 -0
  15. package/dist/action-providers/clanker/index.d.ts +2 -0
  16. package/dist/action-providers/clanker/index.js +18 -0
  17. package/dist/action-providers/clanker/schemas.d.ts +56 -0
  18. package/dist/action-providers/clanker/schemas.js +47 -0
  19. package/dist/action-providers/clanker/utils.d.ts +9 -0
  20. package/dist/action-providers/clanker/utils.js +23 -0
  21. package/dist/action-providers/compound/constants.d.ts +1 -1
  22. package/dist/action-providers/compound/constants.js +2 -2
  23. package/dist/action-providers/erc20/constants.d.ts +35 -135
  24. package/dist/action-providers/erc20/constants.js +37 -189
  25. package/dist/action-providers/erc20/erc20ActionProvider.d.ts +9 -1
  26. package/dist/action-providers/erc20/erc20ActionProvider.js +87 -35
  27. package/dist/action-providers/erc20/erc20ActionProvider.test.js +115 -52
  28. package/dist/action-providers/erc20/schemas.d.ts +25 -12
  29. package/dist/action-providers/erc20/schemas.js +34 -6
  30. package/dist/action-providers/erc20/utils.d.ts +19 -0
  31. package/dist/action-providers/erc20/utils.js +54 -0
  32. package/dist/action-providers/flaunch/constants.d.ts +1 -1
  33. package/dist/action-providers/flaunch/constants.js +2 -2
  34. package/dist/action-providers/index.d.ts +1 -0
  35. package/dist/action-providers/index.js +1 -0
  36. package/dist/action-providers/moonwell/schemas.d.ts +2 -2
  37. package/dist/action-providers/morpho/morphoActionProvider.js +5 -5
  38. package/dist/action-providers/morpho/schemas.d.ts +2 -2
  39. package/dist/action-providers/pyth/pythActionProvider.js +5 -0
  40. package/dist/action-providers/pyth/pythActionProvider.test.js +5 -1
  41. package/dist/action-providers/superfluid/superfluidSuperTokenCreatorActionProvider.js +4 -4
  42. package/dist/action-providers/superfluid/superfluidWrapperActionProvider.js +3 -3
  43. package/dist/action-providers/superfluid/superfluidWrapperActionProvider.test.js +2 -2
  44. package/dist/action-providers/truemarkets/truemarketsActionProvider.js +10 -10
  45. package/dist/action-providers/wallet/walletActionProvider.js +21 -10
  46. package/dist/action-providers/wallet/walletActionProvider.test.js +6 -2
  47. package/dist/action-providers/zeroX/zeroXActionProvider.js +2 -0
  48. package/dist/wallet-providers/cdpEvmWalletProvider.d.ts +13 -1
  49. package/dist/wallet-providers/cdpEvmWalletProvider.js +30 -24
  50. package/dist/wallet-providers/cdpSmartWalletProvider.d.ts +13 -1
  51. package/dist/wallet-providers/cdpSmartWalletProvider.js +31 -25
  52. package/dist/wallet-providers/cdpSolanaWalletProvider.d.ts +1 -1
  53. package/dist/wallet-providers/cdpSolanaWalletProvider.js +7 -7
  54. package/dist/wallet-providers/cdpSolanaWalletProvider.test.js +15 -12
  55. package/dist/wallet-providers/legacyCdpSmartWalletProvider.d.ts +1 -1
  56. package/dist/wallet-providers/legacyCdpSmartWalletProvider.js +1 -1
  57. package/dist/wallet-providers/legacyCdpWalletProvider.d.ts +1 -1
  58. package/dist/wallet-providers/legacyCdpWalletProvider.js +1 -1
  59. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.d.ts +1 -1
  60. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.js +2 -2
  61. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.test.js +1 -1
  62. package/dist/wallet-providers/privyEvmWalletProvider.test.js +1 -1
  63. package/dist/wallet-providers/solanaKeypairWalletProvider.d.ts +1 -1
  64. package/dist/wallet-providers/solanaKeypairWalletProvider.js +3 -4
  65. package/dist/wallet-providers/solanaKeypairWalletProvider.test.js +4 -2
  66. package/dist/wallet-providers/viemWalletProvider.d.ts +1 -1
  67. package/dist/wallet-providers/viemWalletProvider.js +2 -2
  68. package/dist/wallet-providers/viemWalletProvider.test.js +6 -5
  69. package/dist/wallet-providers/walletProvider.d.ts +1 -1
  70. package/dist/wallet-providers/zeroDevWalletProvider.d.ts +1 -1
  71. package/dist/wallet-providers/zeroDevWalletProvider.js +4 -4
  72. package/dist/wallet-providers/zeroDevWalletProvider.test.js +2 -2
  73. package/package.json +3 -2
@@ -3,25 +3,38 @@ import { z } from "zod";
3
3
  * Input schema for transfer action.
4
4
  */
5
5
  export declare const TransferSchema: z.ZodObject<{
6
- amount: z.ZodType<bigint, z.ZodTypeDef, bigint>;
7
- contractAddress: z.ZodString;
8
- destination: z.ZodString;
6
+ amount: z.ZodString;
7
+ tokenAddress: z.ZodString;
8
+ destinationAddress: z.ZodString;
9
9
  }, "strip", z.ZodTypeAny, {
10
- contractAddress: string;
11
- amount: bigint;
12
- destination: string;
10
+ amount: string;
11
+ tokenAddress: string;
12
+ destinationAddress: string;
13
13
  }, {
14
- contractAddress: string;
15
- amount: bigint;
16
- destination: string;
14
+ amount: string;
15
+ tokenAddress: string;
16
+ destinationAddress: string;
17
17
  }>;
18
18
  /**
19
19
  * Input schema for get balance action.
20
20
  */
21
21
  export declare const GetBalanceSchema: z.ZodObject<{
22
- contractAddress: z.ZodString;
22
+ tokenAddress: z.ZodString;
23
+ address: z.ZodOptional<z.ZodString>;
23
24
  }, "strip", z.ZodTypeAny, {
24
- contractAddress: string;
25
+ tokenAddress: string;
26
+ address?: string | undefined;
25
27
  }, {
26
- contractAddress: string;
28
+ tokenAddress: string;
29
+ address?: string | undefined;
30
+ }>;
31
+ /**
32
+ * Input schema for get token address action.
33
+ */
34
+ export declare const GetTokenAddressSchema: z.ZodObject<{
35
+ symbol: z.ZodString;
36
+ }, "strip", z.ZodTypeAny, {
37
+ symbol: string;
38
+ }, {
39
+ symbol: string;
27
40
  }>;
@@ -1,15 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetBalanceSchema = exports.TransferSchema = void 0;
3
+ exports.GetTokenAddressSchema = exports.GetBalanceSchema = exports.TransferSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  /**
6
6
  * Input schema for transfer action.
7
7
  */
8
8
  exports.TransferSchema = zod_1.z
9
9
  .object({
10
- amount: zod_1.z.custom().describe("The amount of the asset to transfer"),
11
- contractAddress: zod_1.z.string().describe("The contract address of the token to transfer"),
12
- destination: zod_1.z.string().describe("The destination to transfer the funds"),
10
+ amount: zod_1.z
11
+ .string()
12
+ .describe("The amount of the asset to transfer in whole units (e.g. 1.5 USDC)"),
13
+ tokenAddress: zod_1.z
14
+ .string()
15
+ .regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
16
+ .describe("The contract address of the token to transfer"),
17
+ destinationAddress: zod_1.z
18
+ .string()
19
+ .regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
20
+ .describe("The destination to transfer the funds"),
13
21
  })
14
22
  .strip()
15
23
  .describe("Instructions for transferring assets");
@@ -18,9 +26,29 @@ exports.TransferSchema = zod_1.z
18
26
  */
19
27
  exports.GetBalanceSchema = zod_1.z
20
28
  .object({
21
- contractAddress: zod_1.z
29
+ tokenAddress: zod_1.z
22
30
  .string()
23
- .describe("The contract address of the token to get the balance for"),
31
+ .regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
32
+ .describe("The contract address of the ERC20 token to get the balance for"),
33
+ address: zod_1.z
34
+ .string()
35
+ .regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
36
+ .optional()
37
+ .describe("The address to check the balance for. If not provided, uses the wallet's address"),
24
38
  })
25
39
  .strip()
26
40
  .describe("Instructions for getting wallet balance");
41
+ /**
42
+ * Input schema for get token address action.
43
+ */
44
+ exports.GetTokenAddressSchema = zod_1.z
45
+ .object({
46
+ symbol: zod_1.z
47
+ .string()
48
+ .min(1)
49
+ .max(10)
50
+ .toUpperCase()
51
+ .describe("The token symbol (e.g., USDC, WETH, DEGEN)"),
52
+ })
53
+ .strip()
54
+ .describe("Instructions for getting a token's contract address by symbol");
@@ -0,0 +1,19 @@
1
+ import { EvmWalletProvider } from "../../wallet-providers";
2
+ /**
3
+ * Interface for token details
4
+ */
5
+ export interface TokenDetails {
6
+ name: string;
7
+ decimals: number;
8
+ balance: bigint;
9
+ formattedBalance: string;
10
+ }
11
+ /**
12
+ * Gets the details of an ERC20 token including name, decimals, and balance.
13
+ *
14
+ * @param walletProvider - The wallet provider to use for the multicall.
15
+ * @param contractAddress - The contract address of the ERC20 token.
16
+ * @param address - The address to check the balance for. If not provided, uses the wallet's address.
17
+ * @returns A promise that resolves to TokenDetails or null if there's an error.
18
+ */
19
+ export declare function getTokenDetails(walletProvider: EvmWalletProvider, contractAddress: string, address?: string): Promise<TokenDetails | null>;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTokenDetails = getTokenDetails;
4
+ const viem_1 = require("viem");
5
+ /**
6
+ * Gets the details of an ERC20 token including name, decimals, and balance.
7
+ *
8
+ * @param walletProvider - The wallet provider to use for the multicall.
9
+ * @param contractAddress - The contract address of the ERC20 token.
10
+ * @param address - The address to check the balance for. If not provided, uses the wallet's address.
11
+ * @returns A promise that resolves to TokenDetails or null if there's an error.
12
+ */
13
+ async function getTokenDetails(walletProvider, contractAddress, address) {
14
+ try {
15
+ const results = await walletProvider.getPublicClient().multicall({
16
+ contracts: [
17
+ {
18
+ address: contractAddress,
19
+ abi: viem_1.erc20Abi,
20
+ functionName: "name",
21
+ args: [],
22
+ },
23
+ {
24
+ address: contractAddress,
25
+ abi: viem_1.erc20Abi,
26
+ functionName: "decimals",
27
+ args: [],
28
+ },
29
+ {
30
+ address: contractAddress,
31
+ abi: viem_1.erc20Abi,
32
+ functionName: "balanceOf",
33
+ args: [(address || walletProvider.getAddress())],
34
+ },
35
+ ],
36
+ });
37
+ const name = results[0].result;
38
+ const decimals = results[1]?.result;
39
+ const balance = results[2]?.result;
40
+ if (balance === undefined || decimals === undefined || name === undefined) {
41
+ return null;
42
+ }
43
+ const formattedBalance = (0, viem_1.formatUnits)(BigInt(balance), decimals);
44
+ return {
45
+ name,
46
+ decimals,
47
+ balance: BigInt(balance),
48
+ formattedBalance,
49
+ };
50
+ }
51
+ catch {
52
+ return null;
53
+ }
54
+ }
@@ -1,5 +1,5 @@
1
1
  import { Addresses } from "./types";
2
- import { abi as ERC20_ABI } from "../erc20/constants";
2
+ import { erc20Abi as ERC20_ABI } from "viem";
3
3
  export { ERC20_ABI };
4
4
  export declare const FastFlaunchZapAddress: Addresses;
5
5
  export declare const FlaunchPositionManagerAddress: Addresses;
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PERMIT_TYPES = exports.PERMIT_DETAILS = exports.PERMIT2_ABI = exports.UNIVERSAL_ROUTER_ABI = exports.URCommands = exports.V4Actions = exports.IV4RouterAbiExactOutput = exports.IV4RouterAbiExactInput = exports.QUOTER_ABI = exports.POSITION_MANAGER_ABI = exports.FAST_FLAUNCH_ZAP_ABI = exports.Permit2Address = exports.UniversalRouterAddress = exports.QuoterAddress = exports.FLETHHooksAddress = exports.FLETHAddress = exports.FlaunchPositionManagerAddress = exports.FastFlaunchZapAddress = exports.ERC20_ABI = void 0;
4
4
  const viem_1 = require("viem");
5
5
  const chains_1 = require("viem/chains");
6
- const constants_1 = require("../erc20/constants");
7
- Object.defineProperty(exports, "ERC20_ABI", { enumerable: true, get: function () { return constants_1.abi; } });
6
+ const viem_2 = require("viem");
7
+ Object.defineProperty(exports, "ERC20_ABI", { enumerable: true, get: function () { return viem_2.erc20Abi; } });
8
8
  exports.FastFlaunchZapAddress = {
9
9
  [chains_1.base.id]: "0xd79e27f51ddf9df5ee76106ee192530f474b02f6",
10
10
  [chains_1.baseSepolia.id]: "0x251e97446a7019E5DA4860d4CF47291321C693D0",
@@ -33,3 +33,4 @@ export * from "./zerion";
33
33
  export * from "./zerodev";
34
34
  export * from "./zeroX";
35
35
  export * from "./zora";
36
+ export * from "./clanker";
@@ -49,3 +49,4 @@ __exportStar(require("./zerion"), exports);
49
49
  __exportStar(require("./zerodev"), exports);
50
50
  __exportStar(require("./zeroX"), exports);
51
51
  __exportStar(require("./zora"), exports);
52
+ __exportStar(require("./clanker"), exports);
@@ -7,12 +7,12 @@ export declare const MintSchema: z.ZodObject<{
7
7
  tokenAddress: z.ZodString;
8
8
  mTokenAddress: z.ZodString;
9
9
  }, "strip", z.ZodTypeAny, {
10
- assets: string;
11
10
  tokenAddress: string;
11
+ assets: string;
12
12
  mTokenAddress: string;
13
13
  }, {
14
- assets: string;
15
14
  tokenAddress: string;
15
+ assets: string;
16
16
  mTokenAddress: string;
17
17
  }>;
18
18
  /**
@@ -13,12 +13,12 @@ exports.morphoActionProvider = exports.MorphoActionProvider = exports.SUPPORTED_
13
13
  const zod_1 = require("zod");
14
14
  const decimal_js_1 = require("decimal.js");
15
15
  const viem_1 = require("viem");
16
- const constants_1 = require("../erc20/constants");
16
+ const viem_2 = require("viem");
17
17
  const actionProvider_1 = require("../actionProvider");
18
18
  const wallet_providers_1 = require("../../wallet-providers");
19
19
  const actionDecorator_1 = require("../actionDecorator");
20
20
  const utils_1 = require("../../utils");
21
- const constants_2 = require("./constants");
21
+ const constants_1 = require("./constants");
22
22
  const schemas_1 = require("./schemas");
23
23
  exports.SUPPORTED_NETWORKS = ["base-mainnet", "base-sepolia"];
24
24
  /**
@@ -53,7 +53,7 @@ class MorphoActionProvider extends actionProvider_1.ActionProvider {
53
53
  try {
54
54
  const decimals = await wallet.readContract({
55
55
  address: args.tokenAddress,
56
- abi: constants_1.abi,
56
+ abi: viem_2.erc20Abi,
57
57
  functionName: "decimals",
58
58
  args: [],
59
59
  });
@@ -63,7 +63,7 @@ class MorphoActionProvider extends actionProvider_1.ActionProvider {
63
63
  return `Error approving Morpho Vault as spender: ${approvalResult}`;
64
64
  }
65
65
  const data = (0, viem_1.encodeFunctionData)({
66
- abi: constants_2.METAMORPHO_ABI,
66
+ abi: constants_1.METAMORPHO_ABI,
67
67
  functionName: "deposit",
68
68
  args: [atomicAssets, args.receiver],
69
69
  });
@@ -91,7 +91,7 @@ class MorphoActionProvider extends actionProvider_1.ActionProvider {
91
91
  }
92
92
  try {
93
93
  const data = (0, viem_1.encodeFunctionData)({
94
- abi: constants_2.METAMORPHO_ABI,
94
+ abi: constants_1.METAMORPHO_ABI,
95
95
  functionName: "withdraw",
96
96
  args: [BigInt(args.assets), args.receiver, args.receiver],
97
97
  });
@@ -8,14 +8,14 @@ export declare const DepositSchema: z.ZodObject<{
8
8
  tokenAddress: z.ZodString;
9
9
  vaultAddress: z.ZodString;
10
10
  }, "strip", z.ZodTypeAny, {
11
+ tokenAddress: string;
11
12
  receiver: string;
12
13
  assets: string;
13
- tokenAddress: string;
14
14
  vaultAddress: string;
15
15
  }, {
16
+ tokenAddress: string;
16
17
  receiver: string;
17
18
  assets: string;
18
- tokenAddress: string;
19
19
  vaultAddress: string;
20
20
  }>;
21
21
  /**
@@ -37,6 +37,11 @@ class PythActionProvider extends actionProvider_1.ActionProvider {
37
37
  * @returns The price feed ID as a string.
38
38
  */
39
39
  async fetchPriceFeed(args) {
40
+ // Stop-gap solution: Return hardcoded price feed ID for ETH
41
+ // This is temporary until proper new API link is provided after talking to the Pyth team
42
+ if (args.tokenSymbol.toUpperCase() === "ETH") {
43
+ return "0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace";
44
+ }
40
45
  const url = `https://hermes.pyth.network/v2/price_feeds?query=${args.tokenSymbol}&asset_type=crypto`;
41
46
  const response = await fetch(url);
42
47
  if (!response.ok) {
@@ -22,7 +22,11 @@ describe("PythActionProvider", () => {
22
22
  ok: true,
23
23
  json: async () => [{ id: "some-price-feed-id", attributes: { base: "BTC" } }],
24
24
  });
25
- await expect(provider.fetchPriceFeed({ tokenSymbol: "ETH" })).rejects.toThrow("No price feed found for ETH");
25
+ await expect(provider.fetchPriceFeed({ tokenSymbol: "SOL" })).rejects.toThrow("No price feed found for SOL");
26
+ });
27
+ it("should return hardcoded price feed ID for ETH", async () => {
28
+ const priceFeedId = await provider.fetchPriceFeed({ tokenSymbol: "ETH" });
29
+ expect(priceFeedId).toEqual("0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace");
26
30
  });
27
31
  it("should throw an error if the response is not ok", async () => {
28
32
  fetchMock.mockResolvedValueOnce({
@@ -17,7 +17,7 @@ const viem_1 = require("viem");
17
17
  const actionProvider_1 = require("../actionProvider");
18
18
  const wallet_providers_1 = require("../../wallet-providers");
19
19
  const actionDecorator_1 = require("../actionDecorator");
20
- const constants_2 = require("../erc20/constants");
20
+ const viem_2 = require("viem");
21
21
  const parseLogs_1 = require("./utils/parseLogs");
22
22
  /**
23
23
  * SuperfluidSuperTokenCreatorActionProvider is an action provider for Superfluid interactions.
@@ -47,19 +47,19 @@ class SuperfluidSuperTokenCreatorActionProvider extends actionProvider_1.ActionP
47
47
  try {
48
48
  const decimals = await walletProvider.readContract({
49
49
  address: args.erc20TokenAddress,
50
- abi: constants_2.abi,
50
+ abi: viem_2.erc20Abi,
51
51
  functionName: "decimals",
52
52
  args: [],
53
53
  });
54
54
  const name = await walletProvider.readContract({
55
55
  address: args.erc20TokenAddress,
56
- abi: constants_2.abi,
56
+ abi: viem_2.erc20Abi,
57
57
  functionName: "name",
58
58
  args: [],
59
59
  });
60
60
  const symbol = await walletProvider.readContract({
61
61
  address: args.erc20TokenAddress,
62
- abi: constants_2.abi,
62
+ abi: viem_2.erc20Abi,
63
63
  functionName: "symbol",
64
64
  args: [],
65
65
  });
@@ -17,7 +17,7 @@ const viem_1 = require("viem");
17
17
  const actionProvider_1 = require("../actionProvider");
18
18
  const wallet_providers_1 = require("../../wallet-providers");
19
19
  const actionDecorator_1 = require("../actionDecorator");
20
- const constants_2 = require("../erc20/constants");
20
+ const viem_2 = require("viem");
21
21
  /**
22
22
  * SuperfluidStreamActionProvider is an action provider for wrapping superfluid token.
23
23
  */
@@ -48,13 +48,13 @@ class SuperfluidWrapperActionProvider extends actionProvider_1.ActionProvider {
48
48
  try {
49
49
  const decimals = await walletProvider.readContract({
50
50
  address: args.erc20TokenAddress,
51
- abi: constants_2.abi,
51
+ abi: viem_2.erc20Abi,
52
52
  functionName: "decimals",
53
53
  args: [],
54
54
  });
55
55
  const amount = (0, viem_1.parseUnits)(String(args.wrapAmount), Number(decimals));
56
56
  const approveData = (0, viem_1.encodeFunctionData)({
57
- abi: constants_2.abi,
57
+ abi: viem_2.erc20Abi,
58
58
  functionName: "approve",
59
59
  args: [args.superTokenAddress, amount],
60
60
  });
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const viem_1 = require("viem");
4
4
  const constants_1 = require("./constants");
5
5
  const superfluidWrapperActionProvider_1 = require("./superfluidWrapperActionProvider");
6
- const constants_2 = require("../erc20/constants");
6
+ const viem_2 = require("viem");
7
7
  describe("SuperfluidWrapperActionProvider", () => {
8
8
  const MOCK_ADDRESS = "0xe6b2af36b3bb8d47206a129ff11d5a2de2a63c83";
9
9
  const MOCK_ERC20_CONTRACT = "0x1234567890123456789012345678901234567890";
@@ -45,7 +45,7 @@ describe("SuperfluidWrapperActionProvider", () => {
45
45
  await actionProvider.wrapToken(mockWallet, args);
46
46
  const amount = (0, viem_1.parseUnits)(String(args.wrapAmount), Number(MOCK_DECIMALS));
47
47
  const approveData = (0, viem_1.encodeFunctionData)({
48
- abi: constants_2.abi,
48
+ abi: viem_2.erc20Abi,
49
49
  functionName: "approve",
50
50
  args: [MOCK_SUPERTOKEN_CONTRACT, amount],
51
51
  });
@@ -15,9 +15,9 @@ const actionProvider_1 = require("../actionProvider");
15
15
  const actionDecorator_1 = require("../actionDecorator");
16
16
  const schemas_1 = require("./schemas");
17
17
  const constants_1 = require("./constants");
18
- const constants_2 = require("../erc20/constants");
19
- const wallet_providers_1 = require("../../wallet-providers");
20
18
  const viem_1 = require("viem");
19
+ const wallet_providers_1 = require("../../wallet-providers");
20
+ const viem_2 = require("viem");
21
21
  /**
22
22
  * Action provider for TrueMarkets interactions.
23
23
  */
@@ -288,25 +288,25 @@ class TrueMarketsActionProvider extends actionProvider_1.ActionProvider {
288
288
  const balanceCalls = [
289
289
  {
290
290
  address: payToken,
291
- abi: constants_2.abi,
291
+ abi: viem_1.erc20Abi,
292
292
  functionName: "balanceOf",
293
293
  args: [yesPool],
294
294
  },
295
295
  {
296
296
  address: yesToken,
297
- abi: constants_2.abi,
297
+ abi: viem_1.erc20Abi,
298
298
  functionName: "balanceOf",
299
299
  args: [yesPool],
300
300
  },
301
301
  {
302
302
  address: payToken,
303
- abi: constants_2.abi,
303
+ abi: viem_1.erc20Abi,
304
304
  functionName: "balanceOf",
305
305
  args: [noPool],
306
306
  },
307
307
  {
308
308
  address: noToken,
309
- abi: constants_2.abi,
309
+ abi: viem_1.erc20Abi,
310
310
  functionName: "balanceOf",
311
311
  args: [noPool],
312
312
  },
@@ -346,10 +346,10 @@ class TrueMarketsActionProvider extends actionProvider_1.ActionProvider {
346
346
  const yesPrice = calculatePrice(yesSqrtPriceX96, isYesToken0, payDecimals, yesNoTokenDecimals_);
347
347
  const noPrice = calculatePrice(noSqrtPriceX96, isNoToken0, payDecimals, yesNoTokenDecimals_);
348
348
  // Calculate TVL using token balances
349
- const yesPoolStableValue = Number((0, viem_1.formatUnits)(yesPoolStableBalance || 0n, payDecimals));
350
- const yesPoolTokenValue = Number((0, viem_1.formatUnits)(yesPoolTokenBalance || 0n, yesNoTokenDecimals_)) * yesPrice;
351
- const noPoolStableValue = Number((0, viem_1.formatUnits)(noPoolStableBalance || 0n, payDecimals));
352
- const noPoolTokenValue = Number((0, viem_1.formatUnits)(noPoolTokenBalance || 0n, yesNoTokenDecimals_)) * noPrice;
349
+ const yesPoolStableValue = Number((0, viem_2.formatUnits)(yesPoolStableBalance || 0n, payDecimals));
350
+ const yesPoolTokenValue = Number((0, viem_2.formatUnits)(yesPoolTokenBalance || 0n, yesNoTokenDecimals_)) * yesPrice;
351
+ const noPoolStableValue = Number((0, viem_2.formatUnits)(noPoolStableBalance || 0n, payDecimals));
352
+ const noPoolTokenValue = Number((0, viem_2.formatUnits)(noPoolTokenBalance || 0n, yesNoTokenDecimals_)) * noPrice;
353
353
  const yesTVL = yesPoolStableValue + yesPoolTokenValue;
354
354
  const noTVL = noPoolStableValue + noPoolTokenValue;
355
355
  const totalTVL = yesTVL + noTVL;
@@ -14,12 +14,25 @@ const zod_1 = require("zod");
14
14
  const actionDecorator_1 = require("../actionDecorator");
15
15
  const actionProvider_1 = require("../actionProvider");
16
16
  const wallet_providers_1 = require("../../wallet-providers");
17
+ const viem_1 = require("viem");
17
18
  const schemas_1 = require("./schemas");
18
19
  const PROTOCOL_FAMILY_TO_TERMINOLOGY = {
19
- evm: { unit: "WEI", displayUnit: "ETH", type: "Transaction hash", verb: "transaction" },
20
- svm: { unit: "LAMPORTS", displayUnit: "SOL", type: "Signature", verb: "transfer" },
20
+ evm: {
21
+ unit: "WEI",
22
+ displayUnit: "ETH",
23
+ decimals: 18,
24
+ type: "Transaction hash",
25
+ verb: "transaction",
26
+ },
27
+ svm: { unit: "LAMPORTS", displayUnit: "SOL", decimals: 9, type: "Signature", verb: "transfer" },
28
+ };
29
+ const DEFAULT_TERMINOLOGY = {
30
+ unit: "",
31
+ displayUnit: "",
32
+ decimals: 0,
33
+ type: "Hash",
34
+ verb: "transfer",
21
35
  };
22
- const DEFAULT_TERMINOLOGY = { unit: "", displayUnit: "", type: "Hash", verb: "transfer" };
23
36
  /**
24
37
  * WalletActionProvider provides actions for getting basic wallet information.
25
38
  */
@@ -61,6 +74,7 @@ class WalletActionProvider extends actionProvider_1.ActionProvider {
61
74
  ` * Network ID: ${network.networkId || "N/A"}`,
62
75
  ` * Chain ID: ${network.chainId || "N/A"}`,
63
76
  `- Native Balance: ${balance.toString()} ${terminology.unit}`,
77
+ `- Native Balance: ${(0, viem_1.formatUnits)(balance, terminology.decimals)} ${terminology.displayUnit}`,
64
78
  ].join("\n");
65
79
  }
66
80
  catch (error) {
@@ -81,7 +95,8 @@ class WalletActionProvider extends actionProvider_1.ActionProvider {
81
95
  if (protocolFamily === "evm" && !args.to.startsWith("0x")) {
82
96
  args.to = `0x${args.to}`;
83
97
  }
84
- const result = await walletProvider.nativeTransfer(args.to, args.value);
98
+ const amountInAtomicUnits = (0, viem_1.parseUnits)(args.value, terminology.decimals);
99
+ const result = await walletProvider.nativeTransfer(args.to, amountInAtomicUnits.toString());
85
100
  return [
86
101
  `Transferred ${args.value} ${terminology.displayUnit} to ${args.to}`,
87
102
  `${terminology.type}: ${result}`,
@@ -115,15 +130,11 @@ __decorate([
115
130
  (0, actionDecorator_1.CreateAction)({
116
131
  name: "native_transfer",
117
132
  description: `
118
- This tool will transfer native tokens from the wallet to another onchain address.
133
+ This tool will transfer (send) native tokens from the wallet to another onchain address.
119
134
 
120
135
  It takes the following inputs:
121
- - amount: The amount to transfer in whole units (e.g. 1 ETH, 0.1 SOL)
136
+ - amount: The amount to transfer in whole units (e.g. 4.2 ETH, 0.1 SOL)
122
137
  - destination: The address to receive the funds
123
-
124
- Important notes:
125
- - Ensure sufficient balance of the input asset before transferring
126
- - Ensure there is sufficient native token balance for gas fees
127
138
  `,
128
139
  schema: schemas_1.NativeTransferSchema,
129
140
  }),
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const walletActionProvider_1 = require("./walletActionProvider");
4
4
  const schemas_1 = require("./schemas");
5
+ const viem_1 = require("viem");
5
6
  describe("Wallet Action Provider", () => {
6
7
  const MOCK_ADDRESS = "0xe6b2af36b3bb8d47206a129ff11d5a2de2a63c83";
7
8
  const MOCK_ETH_BALANCE = 1000000000000000000n;
@@ -47,6 +48,7 @@ describe("Wallet Action Provider", () => {
47
48
  ` * Network ID: ${MOCK_EVM_NETWORK.networkId}`,
48
49
  ` * Chain ID: ${MOCK_EVM_NETWORK.chainId}`,
49
50
  `- Native Balance: ${MOCK_ETH_BALANCE.toString()} WEI`,
51
+ `- Native Balance: ${(0, viem_1.formatUnits)(MOCK_ETH_BALANCE, 18)} ETH`,
50
52
  ].join("\n");
51
53
  expect(response).toBe(expectedResponse);
52
54
  });
@@ -63,6 +65,7 @@ describe("Wallet Action Provider", () => {
63
65
  ` * Network ID: ${MOCK_SOLANA_NETWORK.networkId}`,
64
66
  ` * Chain ID: N/A`,
65
67
  `- Native Balance: ${MOCK_SOL_BALANCE.toString()} LAMPORTS`,
68
+ `- Native Balance: ${(0, viem_1.formatUnits)(MOCK_SOL_BALANCE, 9)} SOL`,
66
69
  ].join("\n");
67
70
  expect(response).toBe(expectedResponse);
68
71
  });
@@ -79,6 +82,7 @@ describe("Wallet Action Provider", () => {
79
82
  ` * Network ID: ${MOCK_UNKNOWN_NETWORK.networkId}`,
80
83
  ` * Chain ID: N/A`,
81
84
  `- Native Balance: ${MOCK_ETH_BALANCE.toString()} `,
85
+ `- Native Balance: ${MOCK_ETH_BALANCE.toString()} `,
82
86
  ].join("\n");
83
87
  expect(response).toBe(expectedResponse);
84
88
  });
@@ -125,7 +129,7 @@ describe("Wallet Action Provider", () => {
125
129
  value: MOCK_AMOUNT,
126
130
  };
127
131
  const response = await actionProvider.nativeTransfer(mockWallet, args);
128
- expect(mockWallet.nativeTransfer).toHaveBeenCalledWith(MOCK_DESTINATION, MOCK_AMOUNT);
132
+ expect(mockWallet.nativeTransfer).toHaveBeenCalledWith(MOCK_DESTINATION, (0, viem_1.parseUnits)(MOCK_AMOUNT, 18).toString());
129
133
  expect(response).toBe(`Transferred ${MOCK_AMOUNT} ETH to ${MOCK_DESTINATION}\nTransaction hash: ${MOCK_TRANSACTION_HASH}`);
130
134
  });
131
135
  it("should successfully transfer SOL", async () => {
@@ -136,7 +140,7 @@ describe("Wallet Action Provider", () => {
136
140
  value: MOCK_AMOUNT,
137
141
  };
138
142
  const response = await actionProvider.nativeTransfer(mockWallet, args);
139
- expect(mockWallet.nativeTransfer).toHaveBeenCalledWith(MOCK_DESTINATION, MOCK_AMOUNT);
143
+ expect(mockWallet.nativeTransfer).toHaveBeenCalledWith(MOCK_DESTINATION, (0, viem_1.parseUnits)(MOCK_AMOUNT, 9).toString());
140
144
  expect(response).toBe(`Transferred ${MOCK_AMOUNT} SOL to ${MOCK_DESTINATION}\nSignature: ${MOCK_SIGNATURE}`);
141
145
  });
142
146
  it("should handle ETH transfer errors", async () => {
@@ -357,6 +357,7 @@ Important notes:
357
357
  - This only fetches a price quote and does not execute a swap
358
358
  - Supported on all EVM networks compatible with 0x API
359
359
  - Use sellToken units exactly as provided, do not convert to wei or any other units
360
+ - Never assume token or address, they have to be provided as inputs. If only token symbol is provided, use the get_token_address tool if available to get the token address first
360
361
  `,
361
362
  schema: schemas_1.GetSwapPriceSchema,
362
363
  }),
@@ -388,6 +389,7 @@ Important notes:
388
389
  - First fetch a price quote and only execute swap if you are happy with the indicated price
389
390
  - Supported on all EVM networks compatible with 0x API
390
391
  - Use sellToken units exactly as provided, do not convert to wei or any other units
392
+ - Never assume token or address, they have to be provided as inputs. If only token symbol is provided, use the get_token_address tool if available to get the token address first
391
393
  `,
392
394
  schema: schemas_1.ExecuteSwapSchema,
393
395
  }),
@@ -3,6 +3,10 @@ import { Abi, Address, ContractFunctionArgs, ContractFunctionName, Hex, PublicCl
3
3
  import { Network } from "../network";
4
4
  import { EvmWalletProvider } from "./evmWalletProvider";
5
5
  import { WalletProviderWithClient, CdpWalletProviderConfig } from "./cdpShared";
6
+ /**
7
+ * Supported network types for CDP SDK EVM transactions
8
+ */
9
+ type CdpEvmNetwork = "base" | "base-sepolia" | "ethereum" | "ethereum-sepolia" | "polygon" | "arbitrum" | "optimism";
6
10
  /**
7
11
  * A wallet provider that uses the Coinbase SDK.
8
12
  */
@@ -113,8 +117,16 @@ export declare class CdpEvmWalletProvider extends EvmWalletProvider implements W
113
117
  * Transfer the native asset of the network.
114
118
  *
115
119
  * @param to - The destination address.
116
- * @param value - The amount to transfer in Wei.
120
+ * @param value - The amount to transfer in atomic units (Wei).
117
121
  * @returns The transaction hash.
118
122
  */
119
123
  nativeTransfer(to: Address, value: string): Promise<Hex>;
124
+ /**
125
+ * Converts the internal network ID to the format expected by the CDP SDK.
126
+ *
127
+ * @returns The network ID in CDP SDK format
128
+ * @throws Error if the network is not supported
129
+ */
130
+ getCdpSdkNetwork(): CdpEvmNetwork;
120
131
  }
132
+ export {};