@coinbase/agentkit 0.9.1 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/README.md +181 -54
  2. package/dist/action-providers/across/acrossActionProvider.js +3 -3
  3. package/dist/action-providers/cdp/cdpApiActionProvider.d.ts +3 -12
  4. package/dist/action-providers/cdp/cdpApiActionProvider.js +2 -79
  5. package/dist/action-providers/cdp/cdpApiActionProvider.test.js +0 -125
  6. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.d.ts +58 -0
  7. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.js +351 -0
  8. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.test.d.ts +1 -0
  9. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.test.js +520 -0
  10. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.d.ts +57 -0
  11. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.js +337 -0
  12. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.test.d.ts +1 -0
  13. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.test.js +463 -0
  14. package/dist/action-providers/cdp/index.d.ts +3 -0
  15. package/dist/action-providers/cdp/index.js +3 -0
  16. package/dist/action-providers/cdp/schemas.d.ts +38 -9
  17. package/dist/action-providers/cdp/schemas.js +49 -6
  18. package/dist/action-providers/cdp/spendPermissionUtils.d.ts +24 -0
  19. package/dist/action-providers/cdp/spendPermissionUtils.js +66 -0
  20. package/dist/action-providers/cdp/swapUtils.d.ts +32 -0
  21. package/dist/action-providers/cdp/swapUtils.js +142 -0
  22. package/dist/action-providers/clanker/clankerActionProvider.d.ts +43 -0
  23. package/dist/action-providers/clanker/clankerActionProvider.js +130 -0
  24. package/dist/action-providers/clanker/clankerActionProvider.test.d.ts +4 -0
  25. package/dist/action-providers/clanker/clankerActionProvider.test.js +119 -0
  26. package/dist/action-providers/clanker/index.d.ts +2 -0
  27. package/dist/action-providers/clanker/index.js +18 -0
  28. package/dist/action-providers/clanker/schemas.d.ts +56 -0
  29. package/dist/action-providers/clanker/schemas.js +47 -0
  30. package/dist/action-providers/clanker/utils.d.ts +9 -0
  31. package/dist/action-providers/clanker/utils.js +23 -0
  32. package/dist/action-providers/compound/constants.d.ts +1 -1
  33. package/dist/action-providers/compound/constants.js +2 -2
  34. package/dist/action-providers/erc20/constants.d.ts +35 -135
  35. package/dist/action-providers/erc20/constants.js +37 -189
  36. package/dist/action-providers/erc20/erc20ActionProvider.d.ts +9 -1
  37. package/dist/action-providers/erc20/erc20ActionProvider.js +87 -35
  38. package/dist/action-providers/erc20/erc20ActionProvider.test.js +115 -52
  39. package/dist/action-providers/erc20/schemas.d.ts +25 -12
  40. package/dist/action-providers/erc20/schemas.js +34 -6
  41. package/dist/action-providers/erc20/utils.d.ts +19 -0
  42. package/dist/action-providers/erc20/utils.js +54 -0
  43. package/dist/action-providers/flaunch/constants.d.ts +1 -1
  44. package/dist/action-providers/flaunch/constants.js +2 -2
  45. package/dist/action-providers/flaunch/flaunchActionProvider.js +3 -11
  46. package/dist/action-providers/flaunch/flaunchActionProvider.test.js +5 -0
  47. package/dist/action-providers/index.d.ts +4 -0
  48. package/dist/action-providers/index.js +4 -0
  49. package/dist/action-providers/jupiter/schemas.d.ts +1 -1
  50. package/dist/action-providers/moonwell/schemas.d.ts +2 -2
  51. package/dist/action-providers/morpho/morphoActionProvider.js +5 -5
  52. package/dist/action-providers/morpho/schemas.d.ts +2 -2
  53. package/dist/action-providers/pyth/pythActionProvider.js +5 -0
  54. package/dist/action-providers/pyth/pythActionProvider.test.js +5 -1
  55. package/dist/action-providers/superfluid/constants.d.ts +814 -0
  56. package/dist/action-providers/superfluid/constants.js +2826 -0
  57. package/dist/action-providers/superfluid/graphQueries/endpoints.d.ts +2 -0
  58. package/dist/action-providers/superfluid/graphQueries/endpoints.js +5 -0
  59. package/dist/action-providers/superfluid/graphQueries/queries.d.ts +1 -0
  60. package/dist/action-providers/superfluid/graphQueries/queries.js +35 -0
  61. package/dist/action-providers/superfluid/graphQueries/superfluidGraphQueries.d.ts +8 -0
  62. package/dist/action-providers/superfluid/graphQueries/superfluidGraphQueries.js +24 -0
  63. package/dist/action-providers/superfluid/graphQueries/types.d.ts +27 -0
  64. package/dist/action-providers/superfluid/graphQueries/types.js +2 -0
  65. package/dist/action-providers/superfluid/index.d.ts +7 -0
  66. package/dist/action-providers/superfluid/index.js +23 -0
  67. package/dist/action-providers/superfluid/schemas.d.ts +86 -0
  68. package/dist/action-providers/superfluid/schemas.js +103 -0
  69. package/dist/action-providers/superfluid/superfluidActionProvider.d.ts +20 -0
  70. package/dist/action-providers/superfluid/superfluidActionProvider.js +36 -0
  71. package/dist/action-providers/superfluid/superfluidPoolActionProvider.d.ts +46 -0
  72. package/dist/action-providers/superfluid/superfluidPoolActionProvider.js +143 -0
  73. package/dist/action-providers/superfluid/superfluidPoolActionProvider.test.d.ts +1 -0
  74. package/dist/action-providers/superfluid/superfluidPoolActionProvider.test.js +92 -0
  75. package/dist/action-providers/superfluid/superfluidQueryActionProvider.d.ts +27 -0
  76. package/dist/action-providers/superfluid/superfluidQueryActionProvider.js +71 -0
  77. package/dist/action-providers/superfluid/superfluidQueryActionProvider.test.d.ts +1 -0
  78. package/dist/action-providers/superfluid/superfluidQueryActionProvider.test.js +57 -0
  79. package/dist/action-providers/superfluid/superfluidStreamActionProvider.d.ts +56 -0
  80. package/dist/action-providers/superfluid/superfluidStreamActionProvider.js +191 -0
  81. package/dist/action-providers/superfluid/superfluidStreamActionProvider.test.d.ts +1 -0
  82. package/dist/action-providers/superfluid/superfluidStreamActionProvider.test.js +80 -0
  83. package/dist/action-providers/superfluid/superfluidSuperTokenCreatorActionProvider.d.ts +30 -0
  84. package/dist/action-providers/superfluid/superfluidSuperTokenCreatorActionProvider.js +108 -0
  85. package/dist/action-providers/superfluid/superfluidSuperTokenCreatorActionProvider.test.d.ts +1 -0
  86. package/dist/action-providers/superfluid/superfluidSuperTokenCreatorActionProvider.test.js +75 -0
  87. package/dist/action-providers/superfluid/superfluidWrapperActionProvider.d.ts +32 -0
  88. package/dist/action-providers/superfluid/superfluidWrapperActionProvider.js +101 -0
  89. package/dist/action-providers/superfluid/superfluidWrapperActionProvider.test.d.ts +1 -0
  90. package/dist/action-providers/superfluid/superfluidWrapperActionProvider.test.js +85 -0
  91. package/dist/action-providers/superfluid/utils/parseLogs.d.ts +18 -0
  92. package/dist/action-providers/superfluid/utils/parseLogs.js +78 -0
  93. package/dist/action-providers/truemarkets/truemarketsActionProvider.d.ts +4 -16
  94. package/dist/action-providers/truemarkets/truemarketsActionProvider.js +20 -41
  95. package/dist/action-providers/truemarkets/truemarketsActionProvider.test.js +11 -33
  96. package/dist/action-providers/wallet/walletActionProvider.js +21 -10
  97. package/dist/action-providers/wallet/walletActionProvider.test.js +6 -2
  98. package/dist/action-providers/zerion/constants.d.ts +1 -0
  99. package/dist/action-providers/zerion/constants.js +4 -0
  100. package/dist/action-providers/zerion/index.d.ts +2 -0
  101. package/dist/action-providers/zerion/index.js +18 -0
  102. package/dist/action-providers/zerion/schemas.d.ts +11 -0
  103. package/dist/action-providers/zerion/schemas.js +15 -0
  104. package/dist/action-providers/zerion/types.d.ts +125 -0
  105. package/dist/action-providers/zerion/types.js +16 -0
  106. package/dist/action-providers/zerion/utils.d.ts +3 -0
  107. package/dist/action-providers/zerion/utils.js +45 -0
  108. package/dist/action-providers/zerion/zerionActionProvider.d.ts +57 -0
  109. package/dist/action-providers/zerion/zerionActionProvider.js +159 -0
  110. package/dist/action-providers/zerion/zerionActionProvider.test.d.ts +1 -0
  111. package/dist/action-providers/zerion/zerionActionProvider.test.js +213 -0
  112. package/dist/action-providers/zeroX/index.d.ts +1 -0
  113. package/dist/action-providers/zeroX/index.js +17 -0
  114. package/dist/action-providers/zeroX/schemas.d.ts +51 -0
  115. package/dist/action-providers/zeroX/schemas.js +82 -0
  116. package/dist/action-providers/zeroX/utils.d.ts +23 -0
  117. package/dist/action-providers/zeroX/utils.js +106 -0
  118. package/dist/action-providers/zeroX/zeroXActionProvider.d.ts +57 -0
  119. package/dist/action-providers/zeroX/zeroXActionProvider.js +407 -0
  120. package/dist/action-providers/zeroX/zeroXActionProvider.test.d.ts +1 -0
  121. package/dist/action-providers/zeroX/zeroXActionProvider.test.js +445 -0
  122. package/dist/wallet-providers/cdpEvmWalletProvider.d.ts +20 -2
  123. package/dist/wallet-providers/cdpEvmWalletProvider.js +40 -15
  124. package/dist/wallet-providers/cdpShared.d.ts +9 -0
  125. package/dist/wallet-providers/cdpSmartWalletProvider.d.ts +29 -3
  126. package/dist/wallet-providers/cdpSmartWalletProvider.js +64 -28
  127. package/dist/wallet-providers/cdpSolanaWalletProvider.d.ts +1 -1
  128. package/dist/wallet-providers/cdpSolanaWalletProvider.js +7 -7
  129. package/dist/wallet-providers/cdpSolanaWalletProvider.test.js +15 -12
  130. package/dist/wallet-providers/evmWalletProvider.d.ts +5 -1
  131. package/dist/wallet-providers/legacyCdpSmartWalletProvider.d.ts +9 -2
  132. package/dist/wallet-providers/legacyCdpSmartWalletProvider.js +12 -2
  133. package/dist/wallet-providers/legacyCdpWalletProvider.d.ts +12 -2
  134. package/dist/wallet-providers/legacyCdpWalletProvider.js +11 -2
  135. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.d.ts +10 -2
  136. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.js +12 -3
  137. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.test.js +1 -1
  138. package/dist/wallet-providers/privyEvmWalletProvider.d.ts +2 -0
  139. package/dist/wallet-providers/privyEvmWalletProvider.js +2 -1
  140. package/dist/wallet-providers/privyEvmWalletProvider.test.js +1 -1
  141. package/dist/wallet-providers/solanaKeypairWalletProvider.d.ts +1 -1
  142. package/dist/wallet-providers/solanaKeypairWalletProvider.js +3 -4
  143. package/dist/wallet-providers/solanaKeypairWalletProvider.test.js +4 -2
  144. package/dist/wallet-providers/viemWalletProvider.d.ts +12 -2
  145. package/dist/wallet-providers/viemWalletProvider.js +12 -3
  146. package/dist/wallet-providers/viemWalletProvider.test.js +6 -5
  147. package/dist/wallet-providers/walletProvider.d.ts +1 -1
  148. package/dist/wallet-providers/zeroDevWalletProvider.d.ts +10 -2
  149. package/dist/wallet-providers/zeroDevWalletProvider.js +14 -5
  150. package/dist/wallet-providers/zeroDevWalletProvider.test.js +2 -2
  151. package/package.json +4 -2
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const viem_1 = require("viem");
4
+ const constants_1 = require("./constants");
5
+ const superfluidPoolActionProvider_1 = require("./superfluidPoolActionProvider");
6
+ describe("SuperfluidPoolActionProvider", () => {
7
+ const MOCK_ADDRESS = "0xe6b2af36b3bb8d47206a129ff11d5a2de2a63c83";
8
+ const MOCK_ERC20_CONTRACT = "0x1234567890123456789012345678901234567890";
9
+ const MOCK_CHAIN_ID = "8453";
10
+ let mockWallet;
11
+ const actionProvider = (0, superfluidPoolActionProvider_1.superfluidPoolActionProvider)();
12
+ // We'll assert on this directly (easier typing than asserting through the PublicClient type)
13
+ let simulateContractMock;
14
+ let mockPublicClient;
15
+ beforeEach(() => {
16
+ simulateContractMock = jest.fn().mockResolvedValue({
17
+ request: {},
18
+ result: [true, "0xDeCc403f23881285E05Df2BbC7Ebb9a88Dd8A554"],
19
+ });
20
+ // Minimal PublicClient stub with just the method we use
21
+ mockPublicClient = { simulateContract: simulateContractMock };
22
+ mockWallet = {
23
+ getAddress: jest.fn().mockReturnValue(MOCK_ADDRESS),
24
+ getNetwork: jest.fn().mockReturnValue({ protocolFamily: "evm" }),
25
+ getPublicClient: jest.fn().mockReturnValue(mockPublicClient),
26
+ sendTransaction: jest.fn().mockResolvedValue("0xmockhash"),
27
+ waitForTransactionReceipt: jest.fn().mockResolvedValue({}),
28
+ readContract: jest.fn(),
29
+ call: jest.fn(),
30
+ };
31
+ });
32
+ describe("create pool", () => {
33
+ it("should successfully create a superfluid pool", async () => {
34
+ const args = {
35
+ superTokenAddress: MOCK_ERC20_CONTRACT,
36
+ chainId: MOCK_CHAIN_ID,
37
+ };
38
+ const config = {
39
+ transferabilityForUnitsOwner: false,
40
+ distributionFromAnyAddress: false,
41
+ };
42
+ const createArgs = [
43
+ MOCK_ERC20_CONTRACT,
44
+ mockWallet.getAddress(),
45
+ config,
46
+ ];
47
+ const data = (0, viem_1.encodeFunctionData)({
48
+ abi: constants_1.GDAv1ForwarderABI,
49
+ functionName: "createPool",
50
+ args: createArgs,
51
+ });
52
+ await actionProvider.createPool(mockWallet, args);
53
+ expect(simulateContractMock).toHaveBeenCalledWith({
54
+ address: constants_1.GDAv1ForwarderAddress,
55
+ abi: constants_1.GDAv1ForwarderABI,
56
+ functionName: "createPool",
57
+ args: createArgs,
58
+ account: MOCK_ADDRESS,
59
+ });
60
+ expect(mockWallet.sendTransaction).toHaveBeenCalledWith({
61
+ to: constants_1.GDAv1ForwarderAddress,
62
+ data,
63
+ });
64
+ expect(mockWallet.waitForTransactionReceipt).toHaveBeenCalledWith("0xmockhash");
65
+ });
66
+ it("should handle pool creation errors", async () => {
67
+ simulateContractMock.mockRejectedValueOnce(new Error("sim failed"));
68
+ const args = {
69
+ superTokenAddress: MOCK_ERC20_CONTRACT,
70
+ chainId: MOCK_CHAIN_ID,
71
+ };
72
+ const response = await actionProvider.createPool(mockWallet, args);
73
+ expect(response).toContain("Error creating Superfluid pool:");
74
+ });
75
+ });
76
+ describe("supportsNetwork", () => {
77
+ it("should return true for Base", () => {
78
+ const result = actionProvider.supportsNetwork({
79
+ protocolFamily: "evm",
80
+ networkId: "base-mainnet",
81
+ });
82
+ expect(result).toBe(true);
83
+ });
84
+ it("should return false for non-base networks", () => {
85
+ const result = actionProvider.supportsNetwork({
86
+ protocolFamily: "bitcoin",
87
+ networkId: "any",
88
+ });
89
+ expect(result).toBe(false);
90
+ });
91
+ });
92
+ });
@@ -0,0 +1,27 @@
1
+ import { ActionProvider } from "../actionProvider";
2
+ import { EvmWalletProvider } from "../../wallet-providers";
3
+ import { Network } from "../../network";
4
+ /**
5
+ * SuperfluidQueryActionProvider is an action provider for Superfluid interactions.
6
+ */
7
+ export declare class SuperfluidQueryActionProvider extends ActionProvider {
8
+ /**
9
+ * Constructor for the SuperfluidQueryActionProvider class.
10
+ */
11
+ constructor();
12
+ /**
13
+ * Gets a list of addresses to which a stream is open
14
+ *
15
+ * @param walletProvider - The wallet of the agent.
16
+ * @returns A JSON string containing the account details or error message
17
+ */
18
+ queryStreams(walletProvider: EvmWalletProvider): Promise<string>;
19
+ /**
20
+ * Checks if the Superfluid action provider supports the given network.
21
+ *
22
+ * @param network - The network to check.
23
+ * @returns True if the Superfluid action provider supports the network, false otherwise.
24
+ */
25
+ supportsNetwork: (network: Network) => boolean;
26
+ }
27
+ export declare const superfluidQueryActionProvider: () => SuperfluidQueryActionProvider;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.superfluidQueryActionProvider = exports.SuperfluidQueryActionProvider = void 0;
13
+ const actionProvider_1 = require("../actionProvider");
14
+ const wallet_providers_1 = require("../../wallet-providers");
15
+ const actionDecorator_1 = require("../actionDecorator");
16
+ const schemas_1 = require("./schemas");
17
+ const superfluidGraphQueries_1 = require("./graphQueries/superfluidGraphQueries");
18
+ /**
19
+ * SuperfluidQueryActionProvider is an action provider for Superfluid interactions.
20
+ */
21
+ class SuperfluidQueryActionProvider extends actionProvider_1.ActionProvider {
22
+ /**
23
+ * Constructor for the SuperfluidQueryActionProvider class.
24
+ */
25
+ constructor() {
26
+ super("superfluid-query", []);
27
+ /**
28
+ * Checks if the Superfluid action provider supports the given network.
29
+ *
30
+ * @param network - The network to check.
31
+ * @returns True if the Superfluid action provider supports the network, false otherwise.
32
+ */
33
+ this.supportsNetwork = (network) => network.networkId === "base-mainnet" || network.networkId === "base-sepolia";
34
+ }
35
+ /**
36
+ * Gets a list of addresses to which a stream is open
37
+ *
38
+ * @param walletProvider - The wallet of the agent.
39
+ * @returns A JSON string containing the account details or error message
40
+ */
41
+ async queryStreams(walletProvider) {
42
+ try {
43
+ const accountData = await (0, superfluidGraphQueries_1.getAccountOutflow)(walletProvider.getAddress());
44
+ const outflows = accountData?.accounts?.length ? accountData?.accounts[0].outflows : [];
45
+ const activeOutflows = outflows.filter(o => {
46
+ return parseInt(o.currentFlowRate) > 0;
47
+ });
48
+ return `Current outflows are ${JSON.stringify(activeOutflows)}`;
49
+ }
50
+ catch (error) {
51
+ return `Error querying Superfluid streams: ${error}`;
52
+ }
53
+ }
54
+ }
55
+ exports.SuperfluidQueryActionProvider = SuperfluidQueryActionProvider;
56
+ __decorate([
57
+ (0, actionDecorator_1.CreateAction)({
58
+ name: "query_streams",
59
+ description: `
60
+ This tool will query the Superfluid subgraph to find a list of addresses to which you are streaming a token.
61
+ It takes nothing as input; you will be checking against your own wallet.
62
+ It returns an array of account outflows, each with a receiver (wallet address), a token, and a flow rate. If the flow rate is greater than zero, there is a current flow.
63
+ `,
64
+ schema: schemas_1.EmptySchema,
65
+ }),
66
+ __metadata("design:type", Function),
67
+ __metadata("design:paramtypes", [wallet_providers_1.EvmWalletProvider]),
68
+ __metadata("design:returntype", Promise)
69
+ ], SuperfluidQueryActionProvider.prototype, "queryStreams", null);
70
+ const superfluidQueryActionProvider = () => new SuperfluidQueryActionProvider();
71
+ exports.superfluidQueryActionProvider = superfluidQueryActionProvider;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const superfluidQueryActionProvider_1 = require("./superfluidQueryActionProvider");
4
+ const superfluidGraphQueries_1 = require("./graphQueries/superfluidGraphQueries");
5
+ jest.mock("./graphQueries/superfluidGraphQueries", () => ({
6
+ getAccountOutflow: jest.fn(async () => ({
7
+ accounts: [{ outflows: [{ receiver: "0x123", token: "0xABC", currentFlowRate: "100" }] }],
8
+ })),
9
+ }));
10
+ describe("SuperfluidQueryActionProvider", () => {
11
+ const MOCK_ADDRESS = "0xe6b2af36b3bb8d47206a129ff11d5a2de2a63c83";
12
+ let mockWallet;
13
+ const actionProvider = (0, superfluidQueryActionProvider_1.superfluidQueryActionProvider)();
14
+ beforeEach(() => {
15
+ mockWallet = {
16
+ getAddress: jest.fn().mockReturnValue(MOCK_ADDRESS),
17
+ getNetwork: jest.fn().mockReturnValue({ protocolFamily: "evm" }),
18
+ };
19
+ });
20
+ describe("queryStreams", () => {
21
+ it("should return active outflows when streams exist", async () => {
22
+ const response = await actionProvider.queryStreams(mockWallet);
23
+ expect(response).toContain("Current outflows are");
24
+ expect(response).toContain("0x123");
25
+ });
26
+ it("should return an empty array when no active streams exist", async () => {
27
+ superfluidGraphQueries_1.getAccountOutflow.mockImplementation(async () => ({
28
+ accounts: [{ outflows: [] }],
29
+ }));
30
+ const response = await actionProvider.queryStreams(mockWallet);
31
+ expect(response).toBe("Current outflows are []");
32
+ });
33
+ it("should handle query errors gracefully", async () => {
34
+ superfluidGraphQueries_1.getAccountOutflow.mockImplementation(async () => {
35
+ throw new Error("Query failed");
36
+ });
37
+ const response = await actionProvider.queryStreams(mockWallet);
38
+ expect(response).toBe("Error querying Superfluid streams: Error: Query failed");
39
+ });
40
+ });
41
+ describe("supportsNetwork", () => {
42
+ it("should return true for Base", () => {
43
+ const result = actionProvider.supportsNetwork({
44
+ protocolFamily: "evm",
45
+ networkId: "base-mainnet",
46
+ });
47
+ expect(result).toBe(true);
48
+ });
49
+ it("should return false for non-base networks", () => {
50
+ const result = actionProvider.supportsNetwork({
51
+ protocolFamily: "bitcoin",
52
+ networkId: "any",
53
+ });
54
+ expect(result).toBe(false);
55
+ });
56
+ });
57
+ });
@@ -0,0 +1,56 @@
1
+ import { z } from "zod";
2
+ import { SuperfluidCreateStreamSchema, SuperfluidDeleteStreamSchema } from "./schemas";
3
+ import { ActionProvider } from "../actionProvider";
4
+ import { Network } from "../../network";
5
+ import { EvmWalletProvider } from "../../wallet-providers";
6
+ /**
7
+ * SuperfluidStreamActionProvider is an action provider for Superfluid interactions.
8
+ */
9
+ export declare class SuperfluidStreamActionProvider extends ActionProvider<EvmWalletProvider> {
10
+ /**
11
+ * Constructor for the SuperfluidStreamActionProvider class.
12
+ */
13
+ constructor();
14
+ /**
15
+ * Creates a stream from the agent wallet to the recipient
16
+ *
17
+ * @param walletProvider - The wallet provider to start the stream from.
18
+ * @param args - The input arguments for the action.
19
+ * @returns A JSON string containing the account details or error message
20
+ */
21
+ createStream(walletProvider: EvmWalletProvider, args: z.infer<typeof SuperfluidCreateStreamSchema>): Promise<string>;
22
+ /**
23
+ * Updates a stream from the agent wallet to the recipient
24
+ *
25
+ * @param walletProvider - The wallet provider to start the stream from.
26
+ * @param args - The input arguments for the action.
27
+ * @returns A JSON string containing the account details or error message
28
+ */
29
+ updateStream(walletProvider: EvmWalletProvider, args: z.infer<typeof SuperfluidCreateStreamSchema>): Promise<string>;
30
+ /**
31
+ * Deletes a stream from the agent wallet to the recipient
32
+ *
33
+ * @param walletProvider - The wallet provider to start the stream from.
34
+ * @param args - The input arguments for the action.
35
+ * @returns A JSON string containing the account details or error message
36
+ */
37
+ deleteStream(walletProvider: EvmWalletProvider, args: z.infer<typeof SuperfluidDeleteStreamSchema>): Promise<string>;
38
+ /**
39
+ * Checks if the Superfluid action provider supports the given network.
40
+ *
41
+ * @param network - The network to check.
42
+ * @returns True if the Superfluid action provider supports the network, false otherwise.
43
+ */
44
+ supportsNetwork: (network: Network) => boolean;
45
+ /**
46
+ * Gets the link to the Superfluid dashboard pertaining to the stream
47
+ *
48
+ * @param network - The current network
49
+ * @param tokenAddress - The ERC20 token address of the underlying stream
50
+ * @param senderAddress - The sender of the stream (the agent)
51
+ * @param recipientAddress - The recipient of the stream
52
+ * @returns The view link to the new stream on Superfluid
53
+ */
54
+ getStreamLink: (network: Network, tokenAddress: string, senderAddress: string, recipientAddress: string) => string;
55
+ }
56
+ export declare const superfluidStreamActionProvider: () => SuperfluidStreamActionProvider;
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.superfluidStreamActionProvider = exports.SuperfluidStreamActionProvider = void 0;
13
+ const zod_1 = require("zod");
14
+ const schemas_1 = require("./schemas");
15
+ const constants_1 = require("./constants");
16
+ const viem_1 = require("viem");
17
+ const actionProvider_1 = require("../actionProvider");
18
+ const wallet_providers_1 = require("../../wallet-providers");
19
+ const actionDecorator_1 = require("../actionDecorator");
20
+ /**
21
+ * SuperfluidStreamActionProvider is an action provider for Superfluid interactions.
22
+ */
23
+ class SuperfluidStreamActionProvider extends actionProvider_1.ActionProvider {
24
+ /**
25
+ * Constructor for the SuperfluidStreamActionProvider class.
26
+ */
27
+ constructor() {
28
+ super("superfluid-stream", []);
29
+ /**
30
+ * Checks if the Superfluid action provider supports the given network.
31
+ *
32
+ * @param network - The network to check.
33
+ * @returns True if the Superfluid action provider supports the network, false otherwise.
34
+ */
35
+ this.supportsNetwork = (network) => network.networkId === "base-mainnet" || network.networkId === "base-sepolia";
36
+ /**
37
+ * Gets the link to the Superfluid dashboard pertaining to the stream
38
+ *
39
+ * @param network - The current network
40
+ * @param tokenAddress - The ERC20 token address of the underlying stream
41
+ * @param senderAddress - The sender of the stream (the agent)
42
+ * @param recipientAddress - The recipient of the stream
43
+ * @returns The view link to the new stream on Superfluid
44
+ */
45
+ this.getStreamLink = (network, tokenAddress, senderAddress, recipientAddress) => {
46
+ return `https://app.superfluid.finance/stream/${network.networkId}/${senderAddress}-${recipientAddress}-${tokenAddress}`;
47
+ };
48
+ }
49
+ /**
50
+ * Creates a stream from the agent wallet to the recipient
51
+ *
52
+ * @param walletProvider - The wallet provider to start the stream from.
53
+ * @param args - The input arguments for the action.
54
+ * @returns A JSON string containing the account details or error message
55
+ */
56
+ async createStream(walletProvider, args) {
57
+ try {
58
+ const streamData = (0, viem_1.encodeFunctionData)({
59
+ abi: constants_1.CFAv1ForwarderABI,
60
+ functionName: "createFlow",
61
+ args: [
62
+ args.superTokenAddress,
63
+ walletProvider.getAddress(),
64
+ args.recipientAddress,
65
+ BigInt(args.flowRate),
66
+ "0x",
67
+ ],
68
+ });
69
+ const streamHash = await walletProvider.sendTransaction({
70
+ to: constants_1.CFAv1ForwarderAddress,
71
+ data: streamData,
72
+ });
73
+ await walletProvider.waitForTransactionReceipt(streamHash);
74
+ return `Created stream of token ${args.superTokenAddress} to ${args.recipientAddress} at a rate of ${args.flowRate}. The link to the stream is ${this.getStreamLink(walletProvider.getNetwork(), args.superTokenAddress, walletProvider.getAddress(), args.recipientAddress)}. Transaction hash: ${streamHash}`;
75
+ }
76
+ catch (error) {
77
+ return `Error creating Superfluid stream: ${error}`;
78
+ }
79
+ }
80
+ /**
81
+ * Updates a stream from the agent wallet to the recipient
82
+ *
83
+ * @param walletProvider - The wallet provider to start the stream from.
84
+ * @param args - The input arguments for the action.
85
+ * @returns A JSON string containing the account details or error message
86
+ */
87
+ async updateStream(walletProvider, args) {
88
+ try {
89
+ const data = (0, viem_1.encodeFunctionData)({
90
+ abi: constants_1.CFAv1ForwarderABI,
91
+ functionName: "updateFlow",
92
+ args: [
93
+ args.superTokenAddress,
94
+ walletProvider.getAddress(),
95
+ args.recipientAddress,
96
+ BigInt(args.flowRate),
97
+ "0x",
98
+ ],
99
+ });
100
+ const hash = await walletProvider.sendTransaction({
101
+ to: constants_1.CFAv1ForwarderAddress,
102
+ data,
103
+ });
104
+ await walletProvider.waitForTransactionReceipt(hash);
105
+ return `Updated stream of token ${args.superTokenAddress} to ${args.recipientAddress} at a rate of ${args.flowRate}. Transaction hash: ${hash}`;
106
+ }
107
+ catch (error) {
108
+ return `Error updating Superfluid stream: ${error}`;
109
+ }
110
+ }
111
+ /**
112
+ * Deletes a stream from the agent wallet to the recipient
113
+ *
114
+ * @param walletProvider - The wallet provider to start the stream from.
115
+ * @param args - The input arguments for the action.
116
+ * @returns A JSON string containing the account details or error message
117
+ */
118
+ async deleteStream(walletProvider, args) {
119
+ try {
120
+ const data = (0, viem_1.encodeFunctionData)({
121
+ abi: constants_1.CFAv1ForwarderABI,
122
+ functionName: "deleteFlow",
123
+ args: [
124
+ args.superTokenAddress,
125
+ walletProvider.getAddress(),
126
+ args.recipientAddress,
127
+ "0x",
128
+ ],
129
+ });
130
+ const hash = await walletProvider.sendTransaction({
131
+ to: constants_1.CFAv1ForwarderAddress,
132
+ data,
133
+ });
134
+ await walletProvider.waitForTransactionReceipt(hash);
135
+ return `Stopped stream of token ${args.superTokenAddress} to ${args.recipientAddress}. Transaction hash: ${hash}`;
136
+ }
137
+ catch (error) {
138
+ return `Error deleting Superfluid stream: ${error}`;
139
+ }
140
+ }
141
+ }
142
+ exports.SuperfluidStreamActionProvider = SuperfluidStreamActionProvider;
143
+ __decorate([
144
+ (0, actionDecorator_1.CreateAction)({
145
+ name: "create_stream",
146
+ description: `
147
+ This tool will create a Superfluid stream for a desired token on an EVM network.
148
+ It takes the Super token address, a recipient address, and a stream rate to create a Superfluid stream.
149
+ Assume the Super token already exists; if the action fails, tell the user to ensure the Super token exists.
150
+ Superfluid will then start streaming the token to the recipient at the specified rate (wei per second).
151
+ Do not use the ERC20 address as the destination address. If you are unsure of the destination address, please ask the user before proceeding.
152
+ `,
153
+ schema: schemas_1.SuperfluidCreateStreamSchema,
154
+ }),
155
+ __metadata("design:type", Function),
156
+ __metadata("design:paramtypes", [wallet_providers_1.EvmWalletProvider, void 0]),
157
+ __metadata("design:returntype", Promise)
158
+ ], SuperfluidStreamActionProvider.prototype, "createStream", null);
159
+ __decorate([
160
+ (0, actionDecorator_1.CreateAction)({
161
+ name: "update_stream",
162
+ description: `
163
+ This tool will update a Superfluid stream for a desired token on an EVM network.
164
+ It takes the ERC20 token address, a recipient address, and a stream rate to update a Superfluid stream.
165
+ Superfluid will then start streaming the token with the updated flow rate to the recipient.
166
+ Do not use the ERC20 address as the destination address. If you are unsure of the destination address, please ask the user before proceeding.
167
+ `,
168
+ // schema same as create schema
169
+ schema: schemas_1.SuperfluidCreateStreamSchema,
170
+ }),
171
+ __metadata("design:type", Function),
172
+ __metadata("design:paramtypes", [wallet_providers_1.EvmWalletProvider, void 0]),
173
+ __metadata("design:returntype", Promise)
174
+ ], SuperfluidStreamActionProvider.prototype, "updateStream", null);
175
+ __decorate([
176
+ (0, actionDecorator_1.CreateAction)({
177
+ name: "delete_stream",
178
+ description: `
179
+ This tool will stop the streaming of a Superfluid ERC20 token.
180
+ It takes the ERC20 token address and a recipient address to delete a Superfluid stream, if one is present.
181
+ Superfluid will then stop streaming the token to the recipient.
182
+ Do not use the ERC20 address as the destination address. If you are unsure of the destination address, please ask the user before proceeding.
183
+ `,
184
+ schema: schemas_1.SuperfluidDeleteStreamSchema,
185
+ }),
186
+ __metadata("design:type", Function),
187
+ __metadata("design:paramtypes", [wallet_providers_1.EvmWalletProvider, void 0]),
188
+ __metadata("design:returntype", Promise)
189
+ ], SuperfluidStreamActionProvider.prototype, "deleteStream", null);
190
+ const superfluidStreamActionProvider = () => new SuperfluidStreamActionProvider();
191
+ exports.superfluidStreamActionProvider = superfluidStreamActionProvider;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const viem_1 = require("viem");
4
+ const superfluidStreamActionProvider_1 = require("./superfluidStreamActionProvider");
5
+ const constants_1 = require("./constants");
6
+ describe("SuperfluidStreamActionProvider", () => {
7
+ const MOCK_ADDRESS = "0xe6b2af36b3bb8d47206a129ff11d5a2de2a63c83";
8
+ const MOCK_ERC20_CONTRACT = "0x1234567890123456789012345678901234567890";
9
+ const MOCK_RECIPIENT_ADDRESS = "0x9876543210987654321098765432109876543210";
10
+ const MOCK_FLOW_RATE = "123";
11
+ const MOCK_CHAIN_ID = "8453";
12
+ let mockWallet;
13
+ const actionProvider = (0, superfluidStreamActionProvider_1.superfluidStreamActionProvider)();
14
+ beforeEach(() => {
15
+ mockWallet = {
16
+ getAddress: jest.fn().mockReturnValue(MOCK_ADDRESS),
17
+ getNetwork: jest.fn().mockReturnValue({ protocolFamily: "evm" }),
18
+ sendTransaction: jest.fn(),
19
+ waitForTransactionReceipt: jest.fn(),
20
+ readContract: jest.fn(),
21
+ call: jest.fn(),
22
+ };
23
+ mockWallet.sendTransaction.mockResolvedValue("0xmockhash");
24
+ mockWallet.waitForTransactionReceipt.mockResolvedValue({});
25
+ });
26
+ describe("create stream", () => {
27
+ it("should successfully create a superfluid stream", async () => {
28
+ const args = {
29
+ superTokenAddress: MOCK_ERC20_CONTRACT,
30
+ chainId: MOCK_CHAIN_ID,
31
+ recipientAddress: MOCK_RECIPIENT_ADDRESS,
32
+ flowRate: MOCK_FLOW_RATE,
33
+ };
34
+ await actionProvider.createStream(mockWallet, args);
35
+ expect(mockWallet.sendTransaction).toHaveBeenCalledWith({
36
+ to: constants_1.CFAv1ForwarderAddress,
37
+ data: (0, viem_1.encodeFunctionData)({
38
+ abi: constants_1.CFAv1ForwarderABI,
39
+ functionName: "createFlow",
40
+ args: [
41
+ MOCK_ERC20_CONTRACT,
42
+ MOCK_ADDRESS,
43
+ MOCK_RECIPIENT_ADDRESS,
44
+ BigInt(MOCK_FLOW_RATE),
45
+ "0x",
46
+ ],
47
+ }),
48
+ });
49
+ expect(mockWallet.waitForTransactionReceipt).toHaveBeenCalledWith("0xmockhash");
50
+ });
51
+ it("should handle stream creation errors", async () => {
52
+ const error = new Error("Stream creation failed");
53
+ mockWallet.sendTransaction.mockRejectedValue(error);
54
+ const args = {
55
+ superTokenAddress: MOCK_ERC20_CONTRACT,
56
+ chainId: MOCK_CHAIN_ID,
57
+ recipientAddress: MOCK_RECIPIENT_ADDRESS,
58
+ flowRate: MOCK_FLOW_RATE,
59
+ };
60
+ const response = await actionProvider.createStream(mockWallet, args);
61
+ expect(response).toBe(`Error creating Superfluid stream: ${error}`);
62
+ });
63
+ });
64
+ describe("supportsNetwork", () => {
65
+ it("should return true for Base", () => {
66
+ const result = actionProvider.supportsNetwork({
67
+ protocolFamily: "evm",
68
+ networkId: "base-mainnet",
69
+ });
70
+ expect(result).toBe(true);
71
+ });
72
+ it("should return false for non-base networks", () => {
73
+ const result = actionProvider.supportsNetwork({
74
+ protocolFamily: "bitcoin",
75
+ networkId: "any",
76
+ });
77
+ expect(result).toBe(false);
78
+ });
79
+ });
80
+ });
@@ -0,0 +1,30 @@
1
+ import { z } from "zod";
2
+ import { SuperfluidCreateSuperTokenSchema } from "./schemas";
3
+ import { ActionProvider } from "../actionProvider";
4
+ import { Network } from "../../network";
5
+ import { EvmWalletProvider } from "../../wallet-providers";
6
+ /**
7
+ * SuperfluidSuperTokenCreatorActionProvider is an action provider for Superfluid interactions.
8
+ */
9
+ export declare class SuperfluidSuperTokenCreatorActionProvider extends ActionProvider<EvmWalletProvider> {
10
+ /**
11
+ * Constructor for the SuperfluidSuperTokenCreatorActionProvider class.
12
+ */
13
+ constructor();
14
+ /**
15
+ * Creates a new Super token
16
+ *
17
+ * @param walletProvider - The wallet provider to start the stream from.
18
+ * @param args - The input arguments for the action.
19
+ * @returns A JSON string containing the account details or error message
20
+ */
21
+ createSuperToken(walletProvider: EvmWalletProvider, args: z.infer<typeof SuperfluidCreateSuperTokenSchema>): Promise<string>;
22
+ /**
23
+ * Checks if the Superfluid action provider supports the given network.
24
+ *
25
+ * @param network - The network to check.
26
+ * @returns True if the Superfluid action provider supports the network, false otherwise.
27
+ */
28
+ supportsNetwork: (network: Network) => boolean;
29
+ }
30
+ export declare const superfluidSuperTokenCreatorActionProvider: () => SuperfluidSuperTokenCreatorActionProvider;