@coinbase/agentkit 0.5.0 → 0.6.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 (42) hide show
  1. package/README.md +30 -0
  2. package/dist/action-providers/flaunch/constants.d.ts +1078 -0
  3. package/dist/action-providers/flaunch/constants.js +709 -0
  4. package/dist/action-providers/flaunch/flaunchActionProvider.d.ts +102 -0
  5. package/dist/action-providers/flaunch/flaunchActionProvider.js +519 -0
  6. package/dist/action-providers/flaunch/flaunchActionProvider.test.d.ts +1 -0
  7. package/dist/action-providers/flaunch/flaunchActionProvider.test.js +307 -0
  8. package/dist/action-providers/flaunch/index.d.ts +7 -0
  9. package/dist/action-providers/flaunch/index.js +23 -0
  10. package/dist/action-providers/flaunch/schemas.d.ts +77 -0
  11. package/dist/action-providers/flaunch/schemas.js +71 -0
  12. package/dist/action-providers/flaunch/types.d.ts +64 -0
  13. package/dist/action-providers/flaunch/types.js +2 -0
  14. package/dist/action-providers/flaunch/utils.d.ts +60 -0
  15. package/dist/action-providers/flaunch/utils.js +507 -0
  16. package/dist/action-providers/index.d.ts +2 -0
  17. package/dist/action-providers/index.js +2 -0
  18. package/dist/action-providers/onramp/index.d.ts +7 -0
  19. package/dist/action-providers/onramp/index.js +23 -0
  20. package/dist/action-providers/onramp/onrampActionProvider.d.ts +56 -0
  21. package/dist/action-providers/onramp/onrampActionProvider.js +109 -0
  22. package/dist/action-providers/onramp/onrampActionProvider.test.d.ts +1 -0
  23. package/dist/action-providers/onramp/onrampActionProvider.test.js +97 -0
  24. package/dist/action-providers/onramp/schemas.d.ts +12 -0
  25. package/dist/action-providers/onramp/schemas.js +15 -0
  26. package/dist/action-providers/onramp/types.d.ts +107 -0
  27. package/dist/action-providers/onramp/types.js +2 -0
  28. package/dist/action-providers/onramp/utils.d.ts +16 -0
  29. package/dist/action-providers/onramp/utils.js +56 -0
  30. package/dist/action-providers/onramp/version.d.ts +2 -0
  31. package/dist/action-providers/onramp/version.js +5 -0
  32. package/dist/wallet-providers/cdpWalletProvider.js +20 -10
  33. package/dist/wallet-providers/cdpWalletProvider.test.js +37 -3
  34. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.d.ts +2 -0
  35. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.test.js +1 -0
  36. package/dist/wallet-providers/privyShared.d.ts +3 -5
  37. package/dist/wallet-providers/privySvmWalletProvider.d.ts +2 -0
  38. package/dist/wallet-providers/privySvmWalletProvider.js +4 -1
  39. package/dist/wallet-providers/privySvmWalletProvider.test.js +1 -0
  40. package/dist/wallet-providers/privyWalletProvider.d.ts +6 -5
  41. package/dist/wallet-providers/privyWalletProvider.test.js +30 -0
  42. package/package.json +4 -2
@@ -0,0 +1,307 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const flaunchActionProvider_1 = require("./flaunchActionProvider");
4
+ const schemas_1 = require("./schemas");
5
+ const viem_1 = require("viem");
6
+ // Mock the actual contract calls with Jest
7
+ jest.mock("viem", () => {
8
+ const originalModule = jest.requireActual("viem");
9
+ return {
10
+ ...originalModule,
11
+ createPublicClient: jest.fn().mockReturnValue({
12
+ simulateContract: jest.fn().mockResolvedValue({
13
+ result: [BigInt(1000000000000000000)],
14
+ }),
15
+ }),
16
+ decodeEventLog: jest.fn().mockImplementation(() => {
17
+ return {
18
+ eventName: "PoolCreated",
19
+ args: {
20
+ _memecoin: "0x1234567890123456789012345678901234567890",
21
+ },
22
+ };
23
+ }),
24
+ parseEther: jest.fn().mockReturnValue(BigInt(100000000000000000)),
25
+ zeroAddress: "0x0000000000000000000000000000000000000000",
26
+ };
27
+ });
28
+ // Mock the utils module
29
+ jest.mock("./utils", () => ({
30
+ generateTokenUri: jest.fn().mockResolvedValue("ipfs://test-uri"),
31
+ ethToMemecoin: jest.fn().mockReturnValue({
32
+ commands: "0x01",
33
+ inputs: ["0x1234"],
34
+ }),
35
+ memecoinToEthWithPermit2: jest.fn().mockReturnValue({
36
+ commands: "0x02",
37
+ inputs: ["0x5678"],
38
+ }),
39
+ getAmountWithSlippage: jest.fn().mockImplementation(amount => amount),
40
+ getSwapAmountsFromReceipt: jest.fn().mockImplementation(() => ({
41
+ coinsBought: BigInt(1000000000000000000),
42
+ ethSold: BigInt(100000000000000000),
43
+ coinsSold: BigInt(1000000000000000000),
44
+ ethBought: BigInt(100000000000000000),
45
+ })),
46
+ }));
47
+ // Mock the constants used in the test
48
+ jest.mock("./constants", () => {
49
+ const actualConstants = jest.requireActual("./constants");
50
+ const baseSepolia = 84532; // Base Sepolia chain ID
51
+ const baseMainnet = 8453; // Base Mainnet chain ID
52
+ return {
53
+ ...actualConstants,
54
+ // Only override the address mappings
55
+ FlaunchPositionManagerAddress: {
56
+ "0x14a34": "0x9A7059cA00dA92843906Cb4bCa1D005cE848AFdC",
57
+ [baseSepolia]: "0x9A7059cA00dA92843906Cb4bCa1D005cE848AFdC",
58
+ [baseMainnet]: "0x51Bba15255406Cfe7099a42183302640ba7dAFDC",
59
+ },
60
+ FastFlaunchZapAddress: {
61
+ "0x14a34": "0x251e97446a7019E5DA4860d4CF47291321C693D0",
62
+ [baseSepolia]: "0x251e97446a7019E5DA4860d4CF47291321C693D0",
63
+ [baseMainnet]: "0x0000000000000000000000000000000000000000",
64
+ },
65
+ FLETHHooksAddress: {
66
+ ...actualConstants.FLETHHooksAddress,
67
+ "0x14a34": "0x4bd2ca15286c96e4e731337de8b375da6841e888",
68
+ },
69
+ FLETHAddress: {
70
+ ...actualConstants.FLETHAddress,
71
+ "0x14a34": "0x79FC52701cD4BE6f9Ba9aDC94c207DE37e3314eb",
72
+ },
73
+ QuoterAddress: {
74
+ ...actualConstants.QuoterAddress,
75
+ "0x14a34": "0x4a6513c898fe1b2d0e78d3b0e0a4a151589b1cba",
76
+ },
77
+ UniversalRouterAddress: {
78
+ ...actualConstants.UniversalRouterAddress,
79
+ "0x14a34": "0x492E6456D9528771018DeB9E87ef7750EF184104",
80
+ },
81
+ Permit2Address: {
82
+ ...actualConstants.Permit2Address,
83
+ "0x14a34": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
84
+ },
85
+ };
86
+ });
87
+ describe("FlaunchActionProvider", () => {
88
+ const provider = new flaunchActionProvider_1.FlaunchActionProvider({ pinataJwt: "test-jwt" });
89
+ let mockWalletProvider;
90
+ beforeEach(() => {
91
+ mockWalletProvider = {
92
+ getAddress: jest.fn().mockReturnValue("0x1234567890123456789012345678901234567890"),
93
+ getBalance: jest.fn(),
94
+ getName: jest.fn(),
95
+ getNetwork: jest.fn().mockReturnValue({
96
+ protocolFamily: "evm",
97
+ networkId: "base-sepolia",
98
+ chainId: "0x14a34",
99
+ }),
100
+ nativeTransfer: jest.fn(),
101
+ sendTransaction: jest.fn().mockResolvedValue("0xtxhash"),
102
+ waitForTransactionReceipt: jest.fn().mockResolvedValue({
103
+ logs: [
104
+ {
105
+ address: "0x9A7059cA00dA92843906Cb4bCa1D005cE848AFdC", // FlaunchPositionManagerAddress for base-sepolia
106
+ data: "0x0000000000000000000000001234567890123456789012345678901234567890",
107
+ topics: ["0x"],
108
+ },
109
+ ],
110
+ }),
111
+ readContract: jest.fn().mockImplementation(({ functionName }) => {
112
+ if (functionName === "symbol")
113
+ return "TEST";
114
+ if (functionName === "allowance")
115
+ return [BigInt(0), BigInt(0)];
116
+ return undefined;
117
+ }),
118
+ signTypedData: jest.fn().mockResolvedValue("0xsignature"),
119
+ };
120
+ });
121
+ describe("network support", () => {
122
+ it("should support the supported networks", () => {
123
+ expect(provider.supportsNetwork({
124
+ protocolFamily: "evm",
125
+ networkId: "base-mainnet",
126
+ })).toBe(true);
127
+ expect(provider.supportsNetwork({
128
+ protocolFamily: "evm",
129
+ networkId: "base-sepolia",
130
+ })).toBe(true);
131
+ });
132
+ it("should not support other protocol families", () => {
133
+ expect(provider.supportsNetwork({
134
+ protocolFamily: "other-protocol-family",
135
+ networkId: "base-mainnet",
136
+ })).toBe(false);
137
+ });
138
+ it("should not support unsupported networks", () => {
139
+ expect(provider.supportsNetwork({
140
+ protocolFamily: "evm",
141
+ networkId: "ethereum",
142
+ })).toBe(false);
143
+ });
144
+ it("should handle invalid network objects", () => {
145
+ expect(provider.supportsNetwork({})).toBe(false);
146
+ });
147
+ });
148
+ describe("action validation", () => {
149
+ it("should validate flaunch schema", () => {
150
+ const validInput = {
151
+ name: "Test Token",
152
+ symbol: "TEST",
153
+ imageUrl: "https://example.com/image.png",
154
+ description: "A test token",
155
+ websiteUrl: "https://example.com",
156
+ };
157
+ const parseResult = schemas_1.FlaunchSchema.safeParse(validInput);
158
+ expect(parseResult.success).toBe(true);
159
+ });
160
+ it("should reject invalid flaunch input", () => {
161
+ const invalidInput = {
162
+ name: "",
163
+ symbol: "",
164
+ imageUrl: "not-a-url",
165
+ description: "",
166
+ };
167
+ const parseResult = schemas_1.FlaunchSchema.safeParse(invalidInput);
168
+ expect(parseResult.success).toBe(false);
169
+ });
170
+ it("should validate buyCoinWithETHInput schema", () => {
171
+ const validInput = {
172
+ coinAddress: "0x1234567890123456789012345678901234567890",
173
+ amountIn: "0.1",
174
+ slippagePercent: 3,
175
+ };
176
+ const parseResult = schemas_1.BuyCoinWithETHInputSchema.safeParse(validInput);
177
+ expect(parseResult.success).toBe(true);
178
+ });
179
+ it("should validate buyCoinWithCoinInput schema", () => {
180
+ const validInput = {
181
+ coinAddress: "0x1234567890123456789012345678901234567890",
182
+ amountOut: "1000",
183
+ slippagePercent: 3,
184
+ };
185
+ const parseResult = schemas_1.BuyCoinWithCoinInputSchema.safeParse(validInput);
186
+ expect(parseResult.success).toBe(true);
187
+ });
188
+ it("should validate sellCoin schema", () => {
189
+ const validInput = {
190
+ coinAddress: "0x1234567890123456789012345678901234567890",
191
+ amountIn: "1000",
192
+ slippagePercent: 3,
193
+ };
194
+ const parseResult = schemas_1.SellCoinSchema.safeParse(validInput);
195
+ expect(parseResult.success).toBe(true);
196
+ });
197
+ });
198
+ describe("flaunch action", () => {
199
+ it("should execute flaunch action with wallet provider", async () => {
200
+ const args = {
201
+ name: "Test Token",
202
+ symbol: "TEST",
203
+ imageUrl: "https://example.com/image.png",
204
+ description: "A test token",
205
+ websiteUrl: "https://example.com",
206
+ };
207
+ const result = await provider.flaunch(mockWalletProvider, args);
208
+ console.log("Test result:", result);
209
+ expect(result).toContain("Flaunched");
210
+ expect(result).toContain("TEST");
211
+ expect(mockWalletProvider.getNetwork).toHaveBeenCalled();
212
+ expect(mockWalletProvider.sendTransaction).toHaveBeenCalled();
213
+ expect(mockWalletProvider.waitForTransactionReceipt).toHaveBeenCalled();
214
+ });
215
+ });
216
+ describe("buyCoinWithETHInput action", () => {
217
+ it("should execute buyCoinWithETHInput action with wallet provider", async () => {
218
+ const args = {
219
+ coinAddress: "0x1234567890123456789012345678901234567890",
220
+ amountIn: "0.1",
221
+ slippagePercent: 3,
222
+ };
223
+ const result = await provider.buyCoinWithETHInput(mockWalletProvider, args);
224
+ expect(result).toContain("Bought");
225
+ expect(result).toContain("TEST");
226
+ expect(result).toContain((0, viem_1.formatEther)(BigInt(1000000000000000000)));
227
+ expect(mockWalletProvider.getNetwork).toHaveBeenCalled();
228
+ expect(mockWalletProvider.sendTransaction).toHaveBeenCalled();
229
+ expect(mockWalletProvider.readContract).toHaveBeenCalled();
230
+ expect(mockWalletProvider.waitForTransactionReceipt).toHaveBeenCalled();
231
+ });
232
+ it("should handle errors in buyCoinWithETHInput", async () => {
233
+ mockWalletProvider.sendTransaction.mockRejectedValueOnce(new Error("Transaction failed"));
234
+ const args = {
235
+ coinAddress: "0x1234567890123456789012345678901234567890",
236
+ amountIn: "0.1",
237
+ slippagePercent: 3,
238
+ };
239
+ const result = await provider.buyCoinWithETHInput(mockWalletProvider, args);
240
+ expect(result).toContain("Error buying coin");
241
+ });
242
+ });
243
+ describe("buyCoinWithCoinInput action", () => {
244
+ it("should execute buyCoinWithCoinInput action with wallet provider", async () => {
245
+ const args = {
246
+ coinAddress: "0x1234567890123456789012345678901234567890",
247
+ amountOut: "1000",
248
+ slippagePercent: 3,
249
+ };
250
+ const result = await provider.buyCoinWithCoinInput(mockWalletProvider, args);
251
+ expect(result).toContain("Bought");
252
+ expect(result).toContain("TEST");
253
+ expect(result).toContain((0, viem_1.formatEther)(BigInt(1000000000000000000)));
254
+ expect(mockWalletProvider.getNetwork).toHaveBeenCalled();
255
+ expect(mockWalletProvider.sendTransaction).toHaveBeenCalled();
256
+ expect(mockWalletProvider.readContract).toHaveBeenCalled();
257
+ expect(mockWalletProvider.waitForTransactionReceipt).toHaveBeenCalled();
258
+ });
259
+ it("should handle errors in buyCoinWithCoinInput", async () => {
260
+ mockWalletProvider.sendTransaction.mockRejectedValueOnce(new Error("Transaction failed"));
261
+ const args = {
262
+ coinAddress: "0x1234567890123456789012345678901234567890",
263
+ amountOut: "1000",
264
+ slippagePercent: 3,
265
+ };
266
+ const result = await provider.buyCoinWithCoinInput(mockWalletProvider, args);
267
+ expect(result).toContain("Error buying coin");
268
+ });
269
+ });
270
+ describe("sellCoin action", () => {
271
+ it("should execute sellCoin action with wallet provider", async () => {
272
+ const args = {
273
+ coinAddress: "0x1234567890123456789012345678901234567890",
274
+ amountIn: "1000",
275
+ slippagePercent: 3,
276
+ };
277
+ const result = await provider.sellCoin(mockWalletProvider, args);
278
+ expect(result).toContain("Sold");
279
+ expect(result).toContain("TEST");
280
+ expect(result).toContain((0, viem_1.formatEther)(BigInt(1000000000000000000)));
281
+ expect(mockWalletProvider.getNetwork).toHaveBeenCalled();
282
+ expect(mockWalletProvider.sendTransaction).toHaveBeenCalled();
283
+ expect(mockWalletProvider.readContract).toHaveBeenCalled();
284
+ expect(mockWalletProvider.waitForTransactionReceipt).toHaveBeenCalled();
285
+ });
286
+ it("should handle permit2 approval when allowance is insufficient", async () => {
287
+ const args = {
288
+ coinAddress: "0x1234567890123456789012345678901234567890",
289
+ amountIn: "1000",
290
+ slippagePercent: 3,
291
+ };
292
+ const result = await provider.sellCoin(mockWalletProvider, args);
293
+ expect(result).toContain("Sold");
294
+ expect(mockWalletProvider.signTypedData).toHaveBeenCalled();
295
+ });
296
+ it("should handle errors in sellCoin", async () => {
297
+ mockWalletProvider.sendTransaction.mockRejectedValueOnce(new Error("Transaction failed"));
298
+ const args = {
299
+ coinAddress: "0x1234567890123456789012345678901234567890",
300
+ amountIn: "1000",
301
+ slippagePercent: 3,
302
+ };
303
+ const result = await provider.sellCoin(mockWalletProvider, args);
304
+ expect(result).toContain("Error selling coin");
305
+ });
306
+ });
307
+ });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Exports for flaunch action provider
3
+ *
4
+ * @module flaunch
5
+ */
6
+ export * from "./flaunchActionProvider";
7
+ export * from "./schemas";
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /**
3
+ * Exports for flaunch action provider
4
+ *
5
+ * @module flaunch
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ __exportStar(require("./flaunchActionProvider"), exports);
23
+ __exportStar(require("./schemas"), exports);
@@ -0,0 +1,77 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Action schemas for the flaunch action provider.
4
+ *
5
+ * This file contains the Zod schemas that define the shape and validation
6
+ * rules for action parameters in the flaunch action provider.
7
+ */
8
+ /**
9
+ * Schema for Flaunch token creation
10
+ */
11
+ export declare const FlaunchSchema: z.ZodObject<{
12
+ name: z.ZodString;
13
+ symbol: z.ZodString;
14
+ imageUrl: z.ZodString;
15
+ description: z.ZodString;
16
+ websiteUrl: z.ZodOptional<z.ZodString>;
17
+ discordUrl: z.ZodOptional<z.ZodString>;
18
+ twitterUrl: z.ZodOptional<z.ZodString>;
19
+ telegramUrl: z.ZodOptional<z.ZodString>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ symbol: string;
22
+ name: string;
23
+ description: string;
24
+ imageUrl: string;
25
+ websiteUrl?: string | undefined;
26
+ discordUrl?: string | undefined;
27
+ twitterUrl?: string | undefined;
28
+ telegramUrl?: string | undefined;
29
+ }, {
30
+ symbol: string;
31
+ name: string;
32
+ description: string;
33
+ imageUrl: string;
34
+ websiteUrl?: string | undefined;
35
+ discordUrl?: string | undefined;
36
+ twitterUrl?: string | undefined;
37
+ telegramUrl?: string | undefined;
38
+ }>;
39
+ export declare const BuyCoinWithETHInputSchema: z.ZodObject<{
40
+ coinAddress: z.ZodString;
41
+ amountIn: z.ZodString;
42
+ slippagePercent: z.ZodDefault<z.ZodNumber>;
43
+ }, "strip", z.ZodTypeAny, {
44
+ amountIn: string;
45
+ coinAddress: string;
46
+ slippagePercent: number;
47
+ }, {
48
+ amountIn: string;
49
+ coinAddress: string;
50
+ slippagePercent?: number | undefined;
51
+ }>;
52
+ export declare const BuyCoinWithCoinInputSchema: z.ZodObject<{
53
+ coinAddress: z.ZodString;
54
+ amountOut: z.ZodString;
55
+ slippagePercent: z.ZodDefault<z.ZodNumber>;
56
+ }, "strip", z.ZodTypeAny, {
57
+ amountOut: string;
58
+ coinAddress: string;
59
+ slippagePercent: number;
60
+ }, {
61
+ amountOut: string;
62
+ coinAddress: string;
63
+ slippagePercent?: number | undefined;
64
+ }>;
65
+ export declare const SellCoinSchema: z.ZodObject<{
66
+ coinAddress: z.ZodString;
67
+ amountIn: z.ZodString;
68
+ slippagePercent: z.ZodDefault<z.ZodNumber>;
69
+ }, "strip", z.ZodTypeAny, {
70
+ amountIn: string;
71
+ coinAddress: string;
72
+ slippagePercent: number;
73
+ }, {
74
+ amountIn: string;
75
+ coinAddress: string;
76
+ slippagePercent?: number | undefined;
77
+ }>;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SellCoinSchema = exports.BuyCoinWithCoinInputSchema = exports.BuyCoinWithETHInputSchema = exports.FlaunchSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * Action schemas for the flaunch action provider.
7
+ *
8
+ * This file contains the Zod schemas that define the shape and validation
9
+ * rules for action parameters in the flaunch action provider.
10
+ */
11
+ /**
12
+ * Schema for Flaunch token creation
13
+ */
14
+ exports.FlaunchSchema = zod_1.z.object({
15
+ name: zod_1.z.string().min(1).describe("The name of the token"),
16
+ symbol: zod_1.z.string().min(1).describe("The symbol of the token"),
17
+ imageUrl: zod_1.z.string().url().describe("The URL to the token image"),
18
+ description: zod_1.z.string().describe("The description of the token"),
19
+ websiteUrl: zod_1.z.string().url().optional().describe("The (optional) URL to the token website"),
20
+ discordUrl: zod_1.z.string().url().optional().describe("The (optional) URL to the token Discord"),
21
+ twitterUrl: zod_1.z.string().url().optional().describe("The (optional) URL to the token Twitter"),
22
+ telegramUrl: zod_1.z.string().url().optional().describe("The (optional) URL to the token Telegram"),
23
+ });
24
+ exports.BuyCoinWithETHInputSchema = zod_1.z.object({
25
+ coinAddress: zod_1.z
26
+ .string()
27
+ .describe("The address of the flaunch coin to buy")
28
+ .regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format"),
29
+ amountIn: zod_1.z
30
+ .string()
31
+ .regex(/^\d+(\.\d+)?$/, "Must be a valid integer or decimal value")
32
+ .describe("The quantity of ETH to spend on the flaunch coin, in whole units"),
33
+ slippagePercent: zod_1.z
34
+ .number()
35
+ .min(0)
36
+ .max(100)
37
+ .default(5)
38
+ .describe("The slippage percentage. Default to 5%"),
39
+ });
40
+ exports.BuyCoinWithCoinInputSchema = zod_1.z.object({
41
+ coinAddress: zod_1.z
42
+ .string()
43
+ .describe("The address of the flaunch coin to buy")
44
+ .regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format"),
45
+ amountOut: zod_1.z
46
+ .string()
47
+ .regex(/^\d+(\.\d+)?$/, "Must be a valid integer or decimal value")
48
+ .describe("The quantity of the flaunch coin to buy, in whole units"),
49
+ slippagePercent: zod_1.z
50
+ .number()
51
+ .min(0)
52
+ .max(100)
53
+ .default(5)
54
+ .describe("The slippage percentage. Default to 5%"),
55
+ });
56
+ exports.SellCoinSchema = zod_1.z.object({
57
+ coinAddress: zod_1.z
58
+ .string()
59
+ .describe("The address of the flaunch coin to sell")
60
+ .regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format"),
61
+ amountIn: zod_1.z
62
+ .string()
63
+ .regex(/^\d+(\.\d+)?$/, "Must be a valid integer or decimal value")
64
+ .describe("The quantity of the flaunch coin to sell, in whole units"),
65
+ slippagePercent: zod_1.z
66
+ .number()
67
+ .min(0)
68
+ .max(100)
69
+ .default(5)
70
+ .describe("The slippage percentage. Default to 5%"),
71
+ });
@@ -0,0 +1,64 @@
1
+ import { Address } from "viem";
2
+ import { PERMIT_TYPES } from "./constants";
3
+ export interface Addresses {
4
+ [chainId: number]: Address;
5
+ }
6
+ type BuyCoinBase = {
7
+ coinAddress: Address;
8
+ slippagePercent: number;
9
+ referrer?: Address;
10
+ };
11
+ export type BuyCoinExactInParams = BuyCoinBase & {
12
+ swapType: "EXACT_IN";
13
+ amountIn: bigint;
14
+ amountOutMin?: bigint;
15
+ };
16
+ export type BuyCoinExactOutParams = BuyCoinBase & {
17
+ swapType: "EXACT_OUT";
18
+ amountOut: bigint;
19
+ amountInMax?: bigint;
20
+ };
21
+ export type PoolSwapEventArgs = {
22
+ flAmount0: bigint;
23
+ flAmount1: bigint;
24
+ flFee0: bigint;
25
+ flFee1: bigint;
26
+ ispAmount0: bigint;
27
+ ispAmount1: bigint;
28
+ ispFee0: bigint;
29
+ ispFee1: bigint;
30
+ uniAmount0: bigint;
31
+ uniAmount1: bigint;
32
+ uniFee0: bigint;
33
+ uniFee1: bigint;
34
+ };
35
+ export type BuySwapAmounts = {
36
+ coinsBought: bigint;
37
+ ethSold: bigint;
38
+ };
39
+ export type SellSwapAmounts = {
40
+ coinsSold: bigint;
41
+ ethBought: bigint;
42
+ };
43
+ export type PermitDetails = {
44
+ token: Address;
45
+ amount: bigint;
46
+ expiration: number;
47
+ nonce: number;
48
+ };
49
+ export type PermitSingle = {
50
+ details: PermitDetails;
51
+ spender: Address;
52
+ sigDeadline: bigint;
53
+ };
54
+ export type PermitTypedData = {
55
+ primaryType: string;
56
+ domain: {
57
+ name: string;
58
+ chainId: number;
59
+ verifyingContract: Address;
60
+ };
61
+ types: typeof PERMIT_TYPES;
62
+ message: PermitSingle;
63
+ };
64
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,60 @@
1
+ import { Address, Hex, TransactionReceipt } from "viem";
2
+ import { BuySwapAmounts, SellSwapAmounts, PermitSingle, PoolSwapEventArgs } from "./types";
3
+ /**
4
+ * Configuration for Pinata
5
+ */
6
+ interface PinataConfig {
7
+ jwt: string;
8
+ }
9
+ interface TokenUriParams {
10
+ metadata: {
11
+ imageUrl: string;
12
+ description: string;
13
+ websiteUrl?: string;
14
+ discordUrl?: string;
15
+ twitterUrl?: string;
16
+ telegramUrl?: string;
17
+ };
18
+ pinataConfig: PinataConfig;
19
+ }
20
+ export declare const generateTokenUri: (name: string, params: TokenUriParams) => Promise<string>;
21
+ export declare const getAmountWithSlippage: (amount: bigint | undefined, slippage: string, swapType: "EXACT_IN" | "EXACT_OUT") => bigint;
22
+ export declare const ethToMemecoin: (params: {
23
+ sender: Address;
24
+ memecoin: Address;
25
+ chainId: number;
26
+ referrer: Address | null;
27
+ swapType: "EXACT_IN" | "EXACT_OUT";
28
+ amountIn?: bigint;
29
+ amountOutMin?: bigint;
30
+ amountOut?: bigint;
31
+ amountInMax?: bigint;
32
+ }) => {
33
+ calldata: `0x${string}`;
34
+ commands: `0x${string}`;
35
+ inputs: `0x${string}`[];
36
+ };
37
+ export declare const memecoinToEthWithPermit2: (params: {
38
+ chainId: number;
39
+ memecoin: Address;
40
+ amountIn: bigint;
41
+ ethOutMin: bigint;
42
+ permitSingle: PermitSingle | undefined;
43
+ signature: Hex | undefined;
44
+ referrer: Address | null;
45
+ }) => {
46
+ calldata: `0x${string}`;
47
+ commands: `0x${string}`;
48
+ inputs: `0x${string}`[];
49
+ };
50
+ export declare const getSwapAmountsFromLog: ({ filteredPoolSwapEvent, coinAddress, chainId, }: {
51
+ filteredPoolSwapEvent: PoolSwapEventArgs;
52
+ coinAddress: Address;
53
+ chainId: number;
54
+ }) => BuySwapAmounts | SellSwapAmounts;
55
+ export declare const getSwapAmountsFromReceipt: ({ receipt, coinAddress, chainId, }: {
56
+ receipt: TransactionReceipt;
57
+ coinAddress: Address;
58
+ chainId: number;
59
+ }) => BuySwapAmounts | SellSwapAmounts;
60
+ export {};