@kasarlabs/fibrous-mcp 0.1.0

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 (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +29 -0
  3. package/bin/fibrous-mcp.js +14 -0
  4. package/build/index.d.ts +2 -0
  5. package/build/index.js +58 -0
  6. package/build/index.js.map +1 -0
  7. package/build/lib/abis/erc20Abi.d.ts +89 -0
  8. package/build/lib/abis/erc20Abi.js +128 -0
  9. package/build/lib/abis/erc20Abi.js.map +1 -0
  10. package/build/lib/constants/index.d.ts +2 -0
  11. package/build/lib/constants/index.js +3 -0
  12. package/build/lib/constants/index.js.map +1 -0
  13. package/build/lib/dependances/types.d.ts +85 -0
  14. package/build/lib/dependances/types.js +51 -0
  15. package/build/lib/dependances/types.js.map +1 -0
  16. package/build/lib/types/index.d.ts +48 -0
  17. package/build/lib/types/index.js +2 -0
  18. package/build/lib/types/index.js.map +1 -0
  19. package/build/lib/utils/contractInteractor.d.ts +16 -0
  20. package/build/lib/utils/contractInteractor.js +114 -0
  21. package/build/lib/utils/contractInteractor.js.map +1 -0
  22. package/build/lib/utils/transactionMonitor.d.ts +11 -0
  23. package/build/lib/utils/transactionMonitor.js +82 -0
  24. package/build/lib/utils/transactionMonitor.js.map +1 -0
  25. package/build/lib/utils/utils.d.ts +10 -0
  26. package/build/lib/utils/utils.js +15 -0
  27. package/build/lib/utils/utils.js.map +1 -0
  28. package/build/schemas/index.d.ts +41 -0
  29. package/build/schemas/index.js +25 -0
  30. package/build/schemas/index.js.map +1 -0
  31. package/build/tools/approval.d.ts +6 -0
  32. package/build/tools/approval.js +39 -0
  33. package/build/tools/approval.js.map +1 -0
  34. package/build/tools/batchSwap.d.ts +62 -0
  35. package/build/tools/batchSwap.js +120 -0
  36. package/build/tools/batchSwap.js.map +1 -0
  37. package/build/tools/fetchRoute.d.ts +15 -0
  38. package/build/tools/fetchRoute.js +57 -0
  39. package/build/tools/fetchRoute.js.map +1 -0
  40. package/build/tools/fetchTokens.d.ts +10 -0
  41. package/build/tools/fetchTokens.js +26 -0
  42. package/build/tools/fetchTokens.js.map +1 -0
  43. package/build/tools/swap.d.ts +19 -0
  44. package/build/tools/swap.js +100 -0
  45. package/build/tools/swap.js.map +1 -0
  46. package/package.json +45 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Kasar Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Snak - Fibrous Plugin
2
+
3
+ The Fibrous Plugin provides comprehensive tools for token swapping on Starknet using the Fibrous Router protocol, which finds the best routes across multiple DEXs.
4
+
5
+ ## Features
6
+
7
+ This plugin adds the following tools:
8
+
9
+ - **fibrous_swap**: Swap a token for another token using the optimal route.
10
+ - **fibrous_batch_swap**: Swap multiple tokens for another token in a single transaction.
11
+ - **fibrous_get_route**: Get a specific route for swapping tokens with detailed path information.
12
+
13
+ ## Usage
14
+
15
+ The Fibrous Plugin is used internally by the Starknet Agent and doesn't need to be called directly. When the agent is initialized, it automatically registers these tools, making them available for use.
16
+
17
+ ## Example
18
+
19
+ When asking the agent to perform Fibrous-related tasks, it will use the appropriate tool from this plugin:
20
+
21
+ ```
22
+ "Swap 100 USDC for ETH" // Uses fibrous_swap
23
+ "What's the best route to swap DAI for STRK?" // Uses fibrous_get_route
24
+ "Swap multiple tokens to USDC" // Uses fibrous_batch_swap
25
+ ```
26
+
27
+ ## Development
28
+
29
+ To extend this plugin, add new tools in the `src/tools` directory and register them in the `registerTools` function in `src/index.ts`.
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ import { existsSync } from 'fs';
3
+ import { fileURLToPath } from 'url';
4
+ import { dirname, join } from 'path';
5
+
6
+ const __dirname = dirname(fileURLToPath(import.meta.url));
7
+ const buildPath = join(__dirname, '..', 'build', 'index.js');
8
+
9
+ if (!existsSync(buildPath)) {
10
+ console.error('Build not found. Run: npm run build');
11
+ process.exit(1);
12
+ }
13
+
14
+ await import(buildPath);
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export declare const RegisterToolInServer: () => Promise<void>;
package/build/index.js ADDED
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env node
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
+ import { registerToolsWithServer, getOnchainWrite, } from '@kasarlabs/ask-starknet-core';
5
+ import dotenv from 'dotenv';
6
+ import { swapSchema, batchSwapSchema, routeSchema, } from './schemas/index.js';
7
+ import { swapTokensFibrous } from './tools/swap.js';
8
+ import { batchSwapTokens } from './tools/batchSwap.js';
9
+ import { getRouteFibrous } from './tools/fetchRoute.js';
10
+ dotenv.config();
11
+ const server = new McpServer({
12
+ name: 'starknet-fibrous-mcp',
13
+ version: '0.0.1',
14
+ });
15
+ const registerTools = (FibrousToolRegistry) => {
16
+ FibrousToolRegistry.push({
17
+ name: 'fibrous_swap',
18
+ description: 'Swap a token for another token',
19
+ schema: swapSchema,
20
+ execute: async (params) => {
21
+ const onchainWrite = getOnchainWrite();
22
+ return await swapTokensFibrous(onchainWrite, params);
23
+ },
24
+ });
25
+ FibrousToolRegistry.push({
26
+ name: 'fibrous_batch_swap',
27
+ description: 'Swap multiple tokens for another token',
28
+ schema: batchSwapSchema,
29
+ execute: async (params) => {
30
+ const onchainWrite = getOnchainWrite();
31
+ return await batchSwapTokens(onchainWrite, params);
32
+ },
33
+ });
34
+ FibrousToolRegistry.push({
35
+ name: 'fibrous_get_route',
36
+ description: 'Get a specific route for swapping tokens',
37
+ schema: routeSchema,
38
+ execute: async (params) => {
39
+ return await getRouteFibrous(params);
40
+ },
41
+ });
42
+ };
43
+ export const RegisterToolInServer = async () => {
44
+ const tools = [];
45
+ registerTools(tools);
46
+ await registerToolsWithServer(server, tools);
47
+ };
48
+ async function main() {
49
+ const transport = new StdioServerTransport();
50
+ await RegisterToolInServer();
51
+ await server.connect(transport);
52
+ console.error('Starknet Fibrous MCP Server running on stdio');
53
+ }
54
+ main().catch((error) => {
55
+ console.error('Fatal error in main():', error);
56
+ process.exit(1);
57
+ });
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAEL,uBAAuB,EACvB,eAAe,GAChB,MAAM,8BAA8B,CAAC;AACtC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EACL,UAAU,EACV,eAAe,EACf,WAAW,GAEZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAA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,aAAa,CAAC,KAAK,CAAC,CAAC;IACrB,MAAM,uBAAuB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAE7C,MAAM,oBAAoB,EAAE,CAAC;IAC7B,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;AAChE,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,89 @@
1
+ export declare const ERC20_ABI: readonly [{
2
+ readonly type: "function";
3
+ readonly name: "name";
4
+ readonly inputs: readonly [];
5
+ readonly outputs: readonly [{
6
+ readonly type: "core::felt252";
7
+ }];
8
+ readonly state_mutability: "view";
9
+ }, {
10
+ readonly type: "function";
11
+ readonly name: "symbol";
12
+ readonly inputs: readonly [];
13
+ readonly outputs: readonly [{
14
+ readonly type: "core::felt252";
15
+ }];
16
+ readonly state_mutability: "view";
17
+ }, {
18
+ readonly type: "function";
19
+ readonly name: "decimals";
20
+ readonly inputs: readonly [];
21
+ readonly outputs: readonly [{
22
+ readonly type: "core::integer::u8";
23
+ }];
24
+ readonly state_mutability: "view";
25
+ }, {
26
+ readonly type: "function";
27
+ readonly name: "balance_of";
28
+ readonly inputs: readonly [{
29
+ readonly name: "account";
30
+ readonly type: "core::starknet::contract_address::ContractAddress";
31
+ }];
32
+ readonly outputs: readonly [{
33
+ readonly type: "core::integer::u256";
34
+ }];
35
+ readonly state_mutability: "view";
36
+ }, {
37
+ readonly type: "function";
38
+ readonly name: "balanceOf";
39
+ readonly inputs: readonly [{
40
+ readonly name: "account";
41
+ readonly type: "core::starknet::contract_address::ContractAddress";
42
+ }];
43
+ readonly outputs: readonly [{
44
+ readonly type: "core::integer::u256";
45
+ }];
46
+ readonly state_mutability: "view";
47
+ }, {
48
+ readonly type: "function";
49
+ readonly name: "allowance";
50
+ readonly inputs: readonly [{
51
+ readonly name: "owner";
52
+ readonly type: "core::starknet::contract_address::ContractAddress";
53
+ }, {
54
+ readonly name: "spender";
55
+ readonly type: "core::starknet::contract_address::ContractAddress";
56
+ }];
57
+ readonly outputs: readonly [{
58
+ readonly type: "core::integer::u256";
59
+ }];
60
+ readonly state_mutability: "view";
61
+ }, {
62
+ readonly type: "function";
63
+ readonly name: "approve";
64
+ readonly inputs: readonly [{
65
+ readonly name: "spender";
66
+ readonly type: "core::starknet::contract_address::ContractAddress";
67
+ }, {
68
+ readonly name: "amount";
69
+ readonly type: "core::integer::u256";
70
+ }];
71
+ readonly outputs: readonly [{
72
+ readonly type: "core::bool";
73
+ }];
74
+ readonly state_mutability: "external";
75
+ }, {
76
+ readonly type: "function";
77
+ readonly name: "transfer";
78
+ readonly inputs: readonly [{
79
+ readonly name: "recipient";
80
+ readonly type: "core::starknet::contract_address::ContractAddress";
81
+ }, {
82
+ readonly name: "amount";
83
+ readonly type: "core::integer::u256";
84
+ }];
85
+ readonly outputs: readonly [{
86
+ readonly type: "core::bool";
87
+ }];
88
+ readonly state_mutability: "external";
89
+ }];
@@ -0,0 +1,128 @@
1
+ export const ERC20_ABI = [
2
+ {
3
+ type: 'function',
4
+ name: 'name',
5
+ inputs: [],
6
+ outputs: [
7
+ {
8
+ type: 'core::felt252',
9
+ },
10
+ ],
11
+ state_mutability: 'view',
12
+ },
13
+ {
14
+ type: 'function',
15
+ name: 'symbol',
16
+ inputs: [],
17
+ outputs: [
18
+ {
19
+ type: 'core::felt252',
20
+ },
21
+ ],
22
+ state_mutability: 'view',
23
+ },
24
+ {
25
+ type: 'function',
26
+ name: 'decimals',
27
+ inputs: [],
28
+ outputs: [
29
+ {
30
+ type: 'core::integer::u8',
31
+ },
32
+ ],
33
+ state_mutability: 'view',
34
+ },
35
+ {
36
+ type: 'function',
37
+ name: 'balance_of',
38
+ inputs: [
39
+ {
40
+ name: 'account',
41
+ type: 'core::starknet::contract_address::ContractAddress',
42
+ },
43
+ ],
44
+ outputs: [
45
+ {
46
+ type: 'core::integer::u256',
47
+ },
48
+ ],
49
+ state_mutability: 'view',
50
+ },
51
+ {
52
+ type: 'function',
53
+ name: 'balanceOf',
54
+ inputs: [
55
+ {
56
+ name: 'account',
57
+ type: 'core::starknet::contract_address::ContractAddress',
58
+ },
59
+ ],
60
+ outputs: [
61
+ {
62
+ type: 'core::integer::u256',
63
+ },
64
+ ],
65
+ state_mutability: 'view',
66
+ },
67
+ {
68
+ type: 'function',
69
+ name: 'allowance',
70
+ inputs: [
71
+ {
72
+ name: 'owner',
73
+ type: 'core::starknet::contract_address::ContractAddress',
74
+ },
75
+ {
76
+ name: 'spender',
77
+ type: 'core::starknet::contract_address::ContractAddress',
78
+ },
79
+ ],
80
+ outputs: [
81
+ {
82
+ type: 'core::integer::u256',
83
+ },
84
+ ],
85
+ state_mutability: 'view',
86
+ },
87
+ {
88
+ type: 'function',
89
+ name: 'approve',
90
+ inputs: [
91
+ {
92
+ name: 'spender',
93
+ type: 'core::starknet::contract_address::ContractAddress',
94
+ },
95
+ {
96
+ name: 'amount',
97
+ type: 'core::integer::u256',
98
+ },
99
+ ],
100
+ outputs: [
101
+ {
102
+ type: 'core::bool',
103
+ },
104
+ ],
105
+ state_mutability: 'external',
106
+ },
107
+ {
108
+ type: 'function',
109
+ name: 'transfer',
110
+ inputs: [
111
+ {
112
+ name: 'recipient',
113
+ type: 'core::starknet::contract_address::ContractAddress',
114
+ },
115
+ {
116
+ name: 'amount',
117
+ type: 'core::integer::u256',
118
+ },
119
+ ],
120
+ outputs: [
121
+ {
122
+ type: 'core::bool',
123
+ },
124
+ ],
125
+ state_mutability: 'external',
126
+ },
127
+ ];
128
+ //# sourceMappingURL=erc20Abi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"erc20Abi.js","sourceRoot":"","sources":["../../../src/lib/abis/erc20Abi.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG;IAEvB;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,EAAE;QACV,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,eAAe;aACtB;SACF;QACD,gBAAgB,EAAE,MAAM;KACzB;IAED;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,EAAE;QACV,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,eAAe;aACtB;SACF;QACD,gBAAgB,EAAE,MAAM;KACzB;IAED;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,EAAE;QACV,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,mBAAmB;aAC1B;SACF;QACD,gBAAgB,EAAE,MAAM;KACzB;IAED;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,mDAAmD;aAC1D;SACF;QACD,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,qBAAqB;aAC5B;SACF;QACD,gBAAgB,EAAE,MAAM;KACzB;IAED;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,WAAW;QACjB,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,mDAAmD;aAC1D;SACF;QACD,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,qBAAqB;aAC5B;SACF;QACD,gBAAgB,EAAE,MAAM;KACzB;IAED;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,WAAW;QACjB,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,mDAAmD;aAC1D;YACD;gBACE,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,mDAAmD;aAC1D;SACF;QACD,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,qBAAqB;aAC5B;SACF;QACD,gBAAgB,EAAE,MAAM;KACzB;IAED;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,SAAS;QACf,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,mDAAmD;aAC1D;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,qBAAqB;aAC5B;SACF;QACD,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,YAAY;aACnB;SACF;QACD,gBAAgB,EAAE,UAAU;KAC7B;IAED;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,mDAAmD;aAC1D;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,qBAAqB;aAC5B;SACF;QACD,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,YAAY;aACnB;SACF;QACD,gBAAgB,EAAE,UAAU;KAC7B;CACO,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const SLIPPAGE_PERCENTAGE = 0.5;
2
+ export declare const DEFAULT_QUOTE_SIZE = 1;
@@ -0,0 +1,3 @@
1
+ export const SLIPPAGE_PERCENTAGE = 0.5;
2
+ export const DEFAULT_QUOTE_SIZE = 1;
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/constants/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AACvC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { RpcProvider } from 'starknet';
2
+ import { SystemMessage } from '@langchain/core/messages';
3
+ import { z as Zod } from 'zod';
4
+ export interface StarknetTool<P = unknown> {
5
+ name: string;
6
+ plugins: string;
7
+ description: string;
8
+ schema?: Zod.AnyZodObject;
9
+ responseFormat?: string;
10
+ execute: (agent: SnakAgentInterface, params: P, plugins_manager?: any) => Promise<unknown>;
11
+ }
12
+ export interface SignatureTool<P = any> {
13
+ name: string;
14
+ categorie?: string;
15
+ description: string;
16
+ schema?: object;
17
+ execute: (params: P) => Promise<unknown>;
18
+ }
19
+ export declare enum AgentMode {
20
+ INTERACTIVE = "interactive",
21
+ AUTONOMOUS = "autonomous",
22
+ HYBRID = "hybrid"
23
+ }
24
+ export interface RawAgentConfig {
25
+ name: string;
26
+ group: string;
27
+ description: string;
28
+ lore: string[];
29
+ objectives: string[];
30
+ knowledge: string[];
31
+ interval: number;
32
+ plugins: string[];
33
+ memory: MemoryConfig;
34
+ rag?: RagConfig;
35
+ mcpServers?: Record<string, any>;
36
+ mode: AgentMode;
37
+ }
38
+ export interface MemoryConfig {
39
+ enabled?: boolean;
40
+ shortTermMemorySize?: number;
41
+ memorySize?: number;
42
+ maxIterations?: number;
43
+ embeddingModel?: string;
44
+ }
45
+ export interface RagConfig {
46
+ enabled?: boolean;
47
+ topK?: number;
48
+ embeddingModel?: string;
49
+ }
50
+ export interface AgentConfig {
51
+ id: string;
52
+ name: string;
53
+ group: string;
54
+ description: string;
55
+ interval: number;
56
+ chatId: string;
57
+ plugins: string[];
58
+ memory: MemoryConfig;
59
+ rag?: RagConfig;
60
+ mcpServers?: Record<string, any>;
61
+ mode: AgentMode;
62
+ maxIterations: number;
63
+ prompt: SystemMessage;
64
+ }
65
+ export interface DatabaseCredentials {
66
+ host: string;
67
+ port: number;
68
+ user: string;
69
+ password: string;
70
+ database: string;
71
+ }
72
+ export interface SnakAgentInterface {
73
+ getAccountCredentials: () => {
74
+ accountPublicKey: string;
75
+ accountPrivateKey: string;
76
+ };
77
+ getDatabaseCredentials: () => DatabaseCredentials;
78
+ getSignature: () => {
79
+ signature: string;
80
+ };
81
+ getProvider: () => RpcProvider;
82
+ getAgentConfig: () => AgentConfig;
83
+ }
84
+ import winston from 'winston';
85
+ export declare const logger: winston.Logger;
@@ -0,0 +1,51 @@
1
+ export var AgentMode;
2
+ (function (AgentMode) {
3
+ AgentMode["INTERACTIVE"] = "interactive";
4
+ AgentMode["AUTONOMOUS"] = "autonomous";
5
+ AgentMode["HYBRID"] = "hybrid";
6
+ })(AgentMode || (AgentMode = {}));
7
+ import winston from 'winston';
8
+ const levels = {
9
+ error: 0,
10
+ warn: 1,
11
+ info: 2,
12
+ http: 3,
13
+ debug: 4,
14
+ };
15
+ const colors = {
16
+ error: 'red',
17
+ warn: 'yellow',
18
+ info: 'green',
19
+ http: 'magenta',
20
+ debug: 'blue',
21
+ };
22
+ winston.addColors(colors);
23
+ const level = () => {
24
+ if (process.env.LOG_LEVEL) {
25
+ return process.env.LOG_LEVEL.toLowerCase();
26
+ }
27
+ const env = process.env.NODE_ENV || 'production';
28
+ return env === 'development' ? 'debug' : 'info';
29
+ };
30
+ const format = winston.format.combine(winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), winston.format.colorize({ all: true }), winston.format.printf((info) => `${info.timestamp} ${info.level}: ${info.message}`));
31
+ let transports;
32
+ try {
33
+ transports = [
34
+ new winston.transports.Console(),
35
+ new winston.transports.File({
36
+ filename: 'logs/error.log',
37
+ level: 'error',
38
+ }),
39
+ new winston.transports.File({ filename: 'logs/combined.log' }),
40
+ ];
41
+ }
42
+ catch (error) {
43
+ transports = [new winston.transports.Console()];
44
+ }
45
+ export const logger = winston.createLogger({
46
+ level: level(),
47
+ levels,
48
+ format,
49
+ transports,
50
+ });
51
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/dependances/types.ts"],"names":[],"mappings":"AAqCA,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,wCAA2B,CAA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ACf,IAAI,CAAC;IACH,UAAU,GAAG;QACX,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE;QAEhC,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC;YAC1B,QAAQ,EAAE,gBAAgB;YAC1B,KAAK,EAAE,OAAO;SACf,CAAC;QAEF,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,mBAAmB,EAAE,CAAC;KAC/D,CAAC;AACJ,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,UAAU,GAAG,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IACzC,KAAK,EAAE,KAAK,EAAE;IACd,MAAM;IACN,MAAM;IACN,UAAU;CACX,CAAC,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { BigNumber } from '@ethersproject/bignumber';
2
+ import { ProviderInterface } from 'starknet';
3
+ export interface SwapParams {
4
+ sellTokenSymbol: string;
5
+ buyTokenSymbol: string;
6
+ sellAmount: number;
7
+ }
8
+ export interface BatchSwapParams {
9
+ sellTokenSymbols: string[];
10
+ buyTokenSymbols: string[];
11
+ sellAmounts: number[] | BigNumber[];
12
+ }
13
+ export interface Token {
14
+ name: string;
15
+ address: string;
16
+ symbol: string;
17
+ decimals: number;
18
+ logoUri: string | null;
19
+ volume: string;
20
+ price: string;
21
+ verified: boolean;
22
+ category: string;
23
+ }
24
+ export interface SwapResult {
25
+ status: 'success' | 'failure';
26
+ message?: string;
27
+ error?: string;
28
+ transactionHash?: string;
29
+ sellAmount?: number;
30
+ sellToken?: string;
31
+ buyToken?: string;
32
+ amountReceived?: string;
33
+ receipt?: any;
34
+ events?: any[];
35
+ }
36
+ export interface BaseUtilityClass {
37
+ provider: ProviderInterface;
38
+ }
39
+ export interface ContractDeployResult {
40
+ transactionHash: string;
41
+ contractAddress: string | string[];
42
+ }
43
+ export interface TransactionResult {
44
+ status: 'success' | 'failure';
45
+ transactionHash?: string;
46
+ contractAddress?: string;
47
+ error?: string;
48
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/types/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import { Account, Contract, Call, EstimateFee } from 'starknet';
2
+ import { BaseUtilityClass, ContractDeployResult, TransactionResult } from '../types/index.js';
3
+ export declare class ContractInteractor implements BaseUtilityClass {
4
+ provider: any;
5
+ constructor(provider: any);
6
+ deployContract(account: Account, classHash: string, constructorCalldata?: any[], salt?: string): Promise<ContractDeployResult>;
7
+ estimateContractDeploy(account: Account, classHash: string, constructorCalldata?: any[], salt?: string): Promise<EstimateFee>;
8
+ multicall(account: Account, calls: Call[]): Promise<TransactionResult>;
9
+ estimateMulticall(account: Account, calls: Call[]): Promise<EstimateFee>;
10
+ createContract(abi: any[], address: string, account?: Account): Contract;
11
+ readContract(contract: Contract, method: string, args?: any[]): Promise<any>;
12
+ writeContract(contract: Contract, method: string, args?: any[]): Promise<TransactionResult>;
13
+ estimateContractWrite(contract: Contract, method: string, args?: any[]): Promise<EstimateFee>;
14
+ formatTokenAmount(amount: string | number, decimals?: number): string;
15
+ parseTokenAmount(amount: string, decimals?: number): string;
16
+ }