nyxora 1.0.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.
- package/.env.example +17 -0
- package/IDENTITY.md +8 -0
- package/README.md +61 -0
- package/SECURITY.md +19 -0
- package/config.yaml +10 -0
- package/dashboard/README.md +73 -0
- package/dashboard/eslint.config.js +22 -0
- package/dashboard/index.html +13 -0
- package/dashboard/package-lock.json +2737 -0
- package/dashboard/package.json +31 -0
- package/dashboard/public/favicon.svg +1 -0
- package/dashboard/public/icons.svg +24 -0
- package/dashboard/src/App.css +184 -0
- package/dashboard/src/App.tsx +485 -0
- package/dashboard/src/BalanceWidget.tsx +65 -0
- package/dashboard/src/MarketWidget.tsx +73 -0
- package/dashboard/src/Memory.tsx +109 -0
- package/dashboard/src/Overview.tsx +156 -0
- package/dashboard/src/Settings.tsx +213 -0
- package/dashboard/src/Skills.tsx +97 -0
- package/dashboard/src/SwapWidget.tsx +130 -0
- package/dashboard/src/TransactionWidget.tsx +86 -0
- package/dashboard/src/assets/hero.png +0 -0
- package/dashboard/src/assets/react.svg +1 -0
- package/dashboard/src/assets/vite.svg +1 -0
- package/dashboard/src/index.css +508 -0
- package/dashboard/src/main.tsx +10 -0
- package/dashboard/src/overview.css +304 -0
- package/dashboard/tsconfig.app.json +25 -0
- package/dashboard/tsconfig.json +7 -0
- package/dashboard/tsconfig.node.json +24 -0
- package/dashboard/vite.config.ts +7 -0
- package/dist/agent/reasoning.js +254 -0
- package/dist/config/parser.js +36 -0
- package/dist/config/paths.js +35 -0
- package/dist/gateway/cli.js +86 -0
- package/dist/gateway/server.js +154 -0
- package/dist/gateway/telegram.js +45 -0
- package/dist/gateway/test.js +50 -0
- package/dist/gateway/tracker.js +49 -0
- package/dist/memory/logger.js +50 -0
- package/dist/src/agent/reasoning.js +96 -0
- package/dist/src/config/parser.js +25 -0
- package/dist/src/gateway/cli.js +79 -0
- package/dist/src/memory/logger.js +50 -0
- package/dist/src/web3/config.js +80 -0
- package/dist/src/web3/skills/getBalance.js +43 -0
- package/dist/web3/config.js +83 -0
- package/dist/web3/skills/getBalance.js +80 -0
- package/dist/web3/skills/getPrice.js +44 -0
- package/dist/web3/skills/swapToken.js +71 -0
- package/dist/web3/skills/transfer.js +48 -0
- package/package.json +38 -0
- package/src/agent/reasoning.d.ts +2 -0
- package/src/agent/reasoning.d.ts.map +1 -0
- package/src/agent/reasoning.js +97 -0
- package/src/agent/reasoning.js.map +1 -0
- package/src/agent/reasoning.ts +232 -0
- package/src/config/parser.d.ts +17 -0
- package/src/config/parser.d.ts.map +1 -0
- package/src/config/parser.js +26 -0
- package/src/config/parser.js.map +1 -0
- package/src/config/parser.ts +47 -0
- package/src/config/paths.ts +33 -0
- package/src/gateway/cli.d.ts +3 -0
- package/src/gateway/cli.d.ts.map +1 -0
- package/src/gateway/cli.js +80 -0
- package/src/gateway/cli.js.map +1 -0
- package/src/gateway/cli.ts +58 -0
- package/src/gateway/server.ts +131 -0
- package/src/gateway/telegram.ts +47 -0
- package/src/gateway/test.ts +16 -0
- package/src/gateway/tracker.ts +70 -0
- package/src/memory/logger.d.ts +18 -0
- package/src/memory/logger.d.ts.map +1 -0
- package/src/memory/logger.js +51 -0
- package/src/memory/logger.js.map +1 -0
- package/src/memory/logger.ts +57 -0
- package/src/web3/config.d.ts +793 -0
- package/src/web3/config.d.ts.map +1 -0
- package/src/web3/config.js +81 -0
- package/src/web3/config.js.map +1 -0
- package/src/web3/config.ts +51 -0
- package/src/web3/skills/getBalance.d.ts +25 -0
- package/src/web3/skills/getBalance.d.ts.map +1 -0
- package/src/web3/skills/getBalance.js +46 -0
- package/src/web3/skills/getBalance.js.map +1 -0
- package/src/web3/skills/getBalance.ts +48 -0
- package/src/web3/skills/getPrice.ts +43 -0
- package/src/web3/skills/swapToken.ts +69 -0
- package/src/web3/skills/transfer.ts +47 -0
- package/tsconfig.json +13 -0
- package/user.md +10 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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C;8BAAmD,CAAC;;;;;;yFAA2P,CAAC;gCAAuD,CAAC;+BAAiD,CAAC;;;kCAAmJ,CAAC;;;;;;;;wBAAua,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;CAnC92W,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,OAAO,eAAe,CAAC;AAErD,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,YAAY,CAQlE;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,YAAY,CAclE;AAED,wBAAgB,UAAU,kBAIzB"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.supportedChains = void 0;
|
|
37
|
+
exports.getPublicClient = getPublicClient;
|
|
38
|
+
exports.getWalletClient = getWalletClient;
|
|
39
|
+
exports.getAddress = getAddress;
|
|
40
|
+
const viem_1 = require("viem");
|
|
41
|
+
const accounts_1 = require("viem/accounts");
|
|
42
|
+
const chains_1 = require("viem/chains");
|
|
43
|
+
const dotenv = __importStar(require("dotenv"));
|
|
44
|
+
dotenv.config();
|
|
45
|
+
exports.supportedChains = {
|
|
46
|
+
ethereum: chains_1.mainnet,
|
|
47
|
+
base: chains_1.base,
|
|
48
|
+
bsc: chains_1.bsc,
|
|
49
|
+
arbitrum: chains_1.arbitrum,
|
|
50
|
+
optimism: chains_1.optimism,
|
|
51
|
+
};
|
|
52
|
+
function getPublicClient(chainName) {
|
|
53
|
+
const chain = exports.supportedChains[chainName];
|
|
54
|
+
if (!chain)
|
|
55
|
+
throw new Error(`Unsupported chain: ${chainName}`);
|
|
56
|
+
return (0, viem_1.createPublicClient)({
|
|
57
|
+
chain,
|
|
58
|
+
transport: (0, viem_1.http)(), // Falls back to public RPC, can be customized with process.env
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function getWalletClient(chainName) {
|
|
62
|
+
const chain = exports.supportedChains[chainName];
|
|
63
|
+
if (!chain)
|
|
64
|
+
throw new Error(`Unsupported chain: ${chainName}`);
|
|
65
|
+
const privateKey = process.env.PRIVATE_KEY;
|
|
66
|
+
if (!privateKey)
|
|
67
|
+
throw new Error('PRIVATE_KEY is not set in .env');
|
|
68
|
+
const account = (0, accounts_1.privateKeyToAccount)(privateKey);
|
|
69
|
+
return (0, viem_1.createWalletClient)({
|
|
70
|
+
account,
|
|
71
|
+
chain,
|
|
72
|
+
transport: (0, viem_1.http)(),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function getAddress() {
|
|
76
|
+
const privateKey = process.env.PRIVATE_KEY;
|
|
77
|
+
if (!privateKey)
|
|
78
|
+
throw new Error('PRIVATE_KEY is not set in .env');
|
|
79
|
+
return (0, accounts_1.privateKeyToAccount)(privateKey).address;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,0CAQC;AAED,0CAcC;AAED,gCAIC;AA/CD,+BAAgG;AAChG,4CAAoD;AACpD,wCAAqE;AACrE,+CAAiC;AAEjC,MAAM,CAAC,MAAM,EAAE,CAAC;AAEH,QAAA,eAAe,GAAG;IAC7B,QAAQ,EAAE,gBAAO;IACjB,IAAI,EAAE,aAAI;IACV,GAAG,EAAE,YAAG;IACR,QAAQ,EAAE,iBAAQ;IAClB,QAAQ,EAAE,iBAAQ;CACnB,CAAC;AAIF,SAAgB,eAAe,CAAC,SAAoB;IAClD,MAAM,KAAK,GAAG,uBAAe,CAAC,SAAS,CAAC,CAAC;IACzC,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,SAAS,EAAE,CAAC,CAAC;IAE/D,OAAO,IAAA,yBAAkB,EAAC;QACxB,KAAK;QACL,SAAS,EAAE,IAAA,WAAI,GAAE,EAAE,+DAA+D;KACnF,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,eAAe,CAAC,SAAoB;IAClD,MAAM,KAAK,GAAG,uBAAe,CAAC,SAAS,CAAC,CAAC;IACzC,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,SAAS,EAAE,CAAC,CAAC;IAE/D,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,WAA4B,CAAC;IAC5D,IAAI,CAAC,UAAU;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IAEnE,MAAM,OAAO,GAAG,IAAA,8BAAmB,EAAC,UAAU,CAAC,CAAC;IAEhD,OAAO,IAAA,yBAAkB,EAAC;QACxB,OAAO;QACP,KAAK;QACL,SAAS,EAAE,IAAA,WAAI,GAAE;KAClB,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,UAAU;IACxB,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,WAA4B,CAAC;IAC5D,IAAI,CAAC,UAAU;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACnE,OAAO,IAAA,8BAAmB,EAAC,UAAU,CAAC,CAAC,OAAO,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createPublicClient, createWalletClient, http, PublicClient, WalletClient } from 'viem';
|
|
2
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
3
|
+
import { mainnet, base, bsc, arbitrum, optimism, sepolia } from 'viem/chains';
|
|
4
|
+
import * as dotenv from 'dotenv';
|
|
5
|
+
|
|
6
|
+
dotenv.config();
|
|
7
|
+
|
|
8
|
+
export const supportedChains = {
|
|
9
|
+
ethereum: mainnet,
|
|
10
|
+
base: base,
|
|
11
|
+
bsc: bsc,
|
|
12
|
+
arbitrum: arbitrum,
|
|
13
|
+
optimism: optimism,
|
|
14
|
+
sepolia: sepolia,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type ChainName = keyof typeof supportedChains;
|
|
18
|
+
|
|
19
|
+
export function getPublicClient(chainName: ChainName): PublicClient {
|
|
20
|
+
const chain = supportedChains[chainName];
|
|
21
|
+
if (!chain) throw new Error(`Unsupported chain: ${chainName}`);
|
|
22
|
+
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
return createPublicClient({
|
|
25
|
+
chain,
|
|
26
|
+
transport: http(), // Falls back to public RPC, can be customized with process.env
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function getWalletClient(chainName: ChainName): WalletClient {
|
|
31
|
+
const chain = supportedChains[chainName];
|
|
32
|
+
if (!chain) throw new Error(`Unsupported chain: ${chainName}`);
|
|
33
|
+
|
|
34
|
+
const privateKey = process.env.PRIVATE_KEY as `0x${string}`;
|
|
35
|
+
if (!privateKey) throw new Error('PRIVATE_KEY is not set in .env');
|
|
36
|
+
|
|
37
|
+
const account = privateKeyToAccount(privateKey);
|
|
38
|
+
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
return createWalletClient({
|
|
41
|
+
account,
|
|
42
|
+
chain,
|
|
43
|
+
transport: http(),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function getAddress() {
|
|
48
|
+
const privateKey = process.env.PRIVATE_KEY as `0x${string}`;
|
|
49
|
+
if (!privateKey) throw new Error('PRIVATE_KEY is not set in .env');
|
|
50
|
+
return privateKeyToAccount(privateKey).address;
|
|
51
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ChainName } from '../config';
|
|
2
|
+
export declare function getBalance(chainName: ChainName, address?: `0x${string}`): Promise<string>;
|
|
3
|
+
export declare const getBalanceToolDefinition: {
|
|
4
|
+
type: string;
|
|
5
|
+
function: {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
parameters: {
|
|
9
|
+
type: string;
|
|
10
|
+
properties: {
|
|
11
|
+
chainName: {
|
|
12
|
+
type: string;
|
|
13
|
+
enum: string[];
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
address: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
required: string[];
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=getBalance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBalance.d.ts","sourceRoot":"","sources":["getBalance.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,SAAS,EAAE,MAAM,WAAW,CAAC;AAEvD,wBAAsB,UAAU,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,KAAK,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAkB/F;AAED,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;CAqBpC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBalanceToolDefinition = void 0;
|
|
4
|
+
exports.getBalance = getBalance;
|
|
5
|
+
const viem_1 = require("viem");
|
|
6
|
+
const config_1 = require("../config");
|
|
7
|
+
async function getBalance(chainName, address) {
|
|
8
|
+
try {
|
|
9
|
+
const client = (0, config_1.getPublicClient)(chainName);
|
|
10
|
+
let targetAddress = address;
|
|
11
|
+
if (!targetAddress) {
|
|
12
|
+
// If address is not provided, try to get it from our own wallet
|
|
13
|
+
const { getAddress } = await import('../config');
|
|
14
|
+
targetAddress = getAddress();
|
|
15
|
+
}
|
|
16
|
+
const balanceWei = await client.getBalance({ address: targetAddress });
|
|
17
|
+
const balanceEth = (0, viem_1.formatEther)(balanceWei);
|
|
18
|
+
return `${balanceEth} on ${chainName}`;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return `Failed to get balance: ${error.message}`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.getBalanceToolDefinition = {
|
|
25
|
+
type: "function",
|
|
26
|
+
function: {
|
|
27
|
+
name: "get_balance",
|
|
28
|
+
description: "Get the native token balance (ETH, BNB, etc) of a wallet address on a specific chain. If address is omitted, it returns the balance of the agent's own wallet.",
|
|
29
|
+
parameters: {
|
|
30
|
+
type: "object",
|
|
31
|
+
properties: {
|
|
32
|
+
chainName: {
|
|
33
|
+
type: "string",
|
|
34
|
+
enum: ["ethereum", "base", "bsc", "arbitrum", "optimism"],
|
|
35
|
+
description: "The name of the blockchain to check."
|
|
36
|
+
},
|
|
37
|
+
address: {
|
|
38
|
+
type: "string",
|
|
39
|
+
description: "Optional. The 0x... address of the wallet. If not provided, it uses the agent's wallet."
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
required: ["chainName"]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=getBalance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBalance.js","sourceRoot":"","sources":["getBalance.ts"],"names":[],"mappings":";;;AAGA,gCAkBC;AArBD,+BAAmC;AACnC,sCAAuD;AAEhD,KAAK,UAAU,UAAU,CAAC,SAAoB,EAAE,OAAuB;IAC5E,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAA,wBAAe,EAAC,SAAS,CAAC,CAAC;QAE1C,IAAI,aAAa,GAAG,OAAO,CAAC;QAC5B,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,gEAAgE;YAChE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC;YACjD,aAAa,GAAG,UAAU,EAAE,CAAC;QAC/B,CAAC;QAED,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,CAAC;QACvE,MAAM,UAAU,GAAG,IAAA,kBAAW,EAAC,UAAU,CAAC,CAAC;QAE3C,OAAO,GAAG,UAAU,OAAO,SAAS,EAAE,CAAC;IACzC,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,0BAA0B,KAAK,CAAC,OAAO,EAAE,CAAC;IACnD,CAAC;AACH,CAAC;AAEY,QAAA,wBAAwB,GAAG;IACtC,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE;QACR,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,gKAAgK;QAC7K,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,SAAS,EAAE;oBACT,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,CAAC;oBACzD,WAAW,EAAE,sCAAsC;iBACpD;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,yFAAyF;iBACvG;aACF;YACD,QAAQ,EAAE,CAAC,WAAW,CAAC;SACxB;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { formatEther } from 'viem';
|
|
2
|
+
import { getPublicClient, ChainName } from '../config';
|
|
3
|
+
|
|
4
|
+
export async function getBalance(chainName: ChainName, address?: `0x${string}`): Promise<string> {
|
|
5
|
+
try {
|
|
6
|
+
const client = getPublicClient(chainName);
|
|
7
|
+
|
|
8
|
+
let targetAddress = address;
|
|
9
|
+
if (!targetAddress) {
|
|
10
|
+
const { getAddress } = await import('../config');
|
|
11
|
+
targetAddress = getAddress();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (!targetAddress) {
|
|
15
|
+
throw new Error('Address is required but could not be resolved from private key.');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const balanceWei = await client.getBalance({ address: targetAddress as `0x${string}` });
|
|
19
|
+
const balanceEth = formatEther(balanceWei);
|
|
20
|
+
|
|
21
|
+
return `${balanceEth} on ${chainName}`;
|
|
22
|
+
} catch (error: any) {
|
|
23
|
+
return `Failed to get balance: ${error.message}`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const getBalanceToolDefinition = {
|
|
28
|
+
type: "function",
|
|
29
|
+
function: {
|
|
30
|
+
name: "get_balance",
|
|
31
|
+
description: "Get the native token balance (ETH, BNB, etc) of a wallet address on a specific chain. If address is omitted, it returns the balance of the agent's own wallet.",
|
|
32
|
+
parameters: {
|
|
33
|
+
type: "object",
|
|
34
|
+
properties: {
|
|
35
|
+
chainName: {
|
|
36
|
+
type: "string",
|
|
37
|
+
enum: ["ethereum", "base", "bsc", "arbitrum", "optimism", "sepolia"],
|
|
38
|
+
description: "The name of the blockchain to check."
|
|
39
|
+
},
|
|
40
|
+
address: {
|
|
41
|
+
type: "string",
|
|
42
|
+
description: "Optional. The 0x... address of the wallet. If not provided, it uses the agent's wallet."
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
required: ["chainName"]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export const getPriceToolDefinition = {
|
|
2
|
+
type: "function",
|
|
3
|
+
function: {
|
|
4
|
+
name: "get_price",
|
|
5
|
+
description: "Fetches the current price of a cryptocurrency in USD along with its 24h change percentage.",
|
|
6
|
+
parameters: {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
coinId: {
|
|
10
|
+
type: "string",
|
|
11
|
+
description: "The CoinGecko ID of the coin (e.g., 'ethereum', 'bitcoin', 'solana')."
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
required: ["coinId"]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export async function getPrice(coinId: string): Promise<string> {
|
|
20
|
+
try {
|
|
21
|
+
const url = `https://api.coingecko.com/api/v3/simple/price?ids=${coinId}&vs_currencies=usd&include_24hr_change=true`;
|
|
22
|
+
const response = await fetch(url);
|
|
23
|
+
if (!response.ok) {
|
|
24
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
25
|
+
}
|
|
26
|
+
const data = await response.json();
|
|
27
|
+
|
|
28
|
+
if (!data[coinId]) {
|
|
29
|
+
return JSON.stringify({ error: `Could not find price data for ${coinId}` });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const price = data[coinId].usd;
|
|
33
|
+
const change24h = data[coinId].usd_24h_change;
|
|
34
|
+
|
|
35
|
+
return JSON.stringify({
|
|
36
|
+
coin: coinId,
|
|
37
|
+
priceUsd: price,
|
|
38
|
+
change24h: change24h
|
|
39
|
+
});
|
|
40
|
+
} catch (error: any) {
|
|
41
|
+
return JSON.stringify({ error: `Failed to fetch price: ${error.message}` });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export const swapTokenToolDefinition = {
|
|
2
|
+
type: "function",
|
|
3
|
+
function: {
|
|
4
|
+
name: "swap_token",
|
|
5
|
+
description: "Executes a decentralized token swap (DEX) to exchange one cryptocurrency for another.",
|
|
6
|
+
parameters: {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
chainName: {
|
|
10
|
+
type: "string",
|
|
11
|
+
description: "The blockchain network (e.g., 'ethereum', 'base', 'arbitrum', 'sepolia')",
|
|
12
|
+
},
|
|
13
|
+
fromToken: {
|
|
14
|
+
type: "string",
|
|
15
|
+
description: "The token symbol to sell/swap from (e.g., 'ETH', 'USDC')",
|
|
16
|
+
},
|
|
17
|
+
toToken: {
|
|
18
|
+
type: "string",
|
|
19
|
+
description: "The token symbol to buy/swap to (e.g., 'USDC', 'UNI')",
|
|
20
|
+
},
|
|
21
|
+
amount: {
|
|
22
|
+
type: "number",
|
|
23
|
+
description: "The amount of fromToken to swap",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
required: ["chainName", "fromToken", "toToken", "amount"],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export async function swapToken(chainName: string, fromToken: string, toToken: string, amount: number): Promise<string> {
|
|
32
|
+
try {
|
|
33
|
+
// Generate simulated exchange rate for testnet/demo purposes
|
|
34
|
+
let rate = 1.0;
|
|
35
|
+
|
|
36
|
+
// Simple mock rates based on common pairs
|
|
37
|
+
if (fromToken.toUpperCase() === 'ETH' && toToken.toUpperCase() === 'USDC') rate = 3200;
|
|
38
|
+
if (fromToken.toUpperCase() === 'USDC' && toToken.toUpperCase() === 'ETH') rate = 1 / 3200;
|
|
39
|
+
if (fromToken.toUpperCase() === 'ETH' && toToken.toUpperCase() === 'LINK') rate = 200;
|
|
40
|
+
if (fromToken.toUpperCase() === 'SOL' && toToken.toUpperCase() === 'USDC') rate = 150;
|
|
41
|
+
|
|
42
|
+
// Add a slight random variance (±1%) to simulate live market slippage
|
|
43
|
+
const variance = 1 + (Math.random() * 0.02 - 0.01);
|
|
44
|
+
const finalRate = rate * variance;
|
|
45
|
+
const toAmount = amount * finalRate;
|
|
46
|
+
|
|
47
|
+
// Simulate transaction execution delay
|
|
48
|
+
await new Promise(resolve => setTimeout(resolve, 2500));
|
|
49
|
+
|
|
50
|
+
// Generate mock transaction hash
|
|
51
|
+
const txHash = '0x' + Array.from({length: 64}, () => Math.floor(Math.random() * 16).toString(16)).join('');
|
|
52
|
+
|
|
53
|
+
const swapResult = {
|
|
54
|
+
chain: chainName,
|
|
55
|
+
fromToken: fromToken.toUpperCase(),
|
|
56
|
+
toToken: toToken.toUpperCase(),
|
|
57
|
+
fromAmount: amount.toFixed(4),
|
|
58
|
+
toAmount: toAmount.toFixed(4),
|
|
59
|
+
exchangeRate: finalRate.toFixed(6),
|
|
60
|
+
gasFee: (Math.random() * 0.005).toFixed(4) + ' ETH',
|
|
61
|
+
txHash: txHash,
|
|
62
|
+
status: 'SUCCESS'
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return JSON.stringify(swapResult);
|
|
66
|
+
} catch (error: any) {
|
|
67
|
+
return JSON.stringify({ error: `Failed to execute swap: ${error.message}` });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { parseEther } from 'viem';
|
|
2
|
+
import { getWalletClient, ChainName } from '../config';
|
|
3
|
+
|
|
4
|
+
export async function transferNative(chainName: ChainName, toAddress: `0x${string}`, amountEth: string): Promise<string> {
|
|
5
|
+
try {
|
|
6
|
+
const client = getWalletClient(chainName);
|
|
7
|
+
|
|
8
|
+
// Attempt to send the transaction
|
|
9
|
+
const hash = await client.sendTransaction({
|
|
10
|
+
account: client.account!,
|
|
11
|
+
chain: client.chain,
|
|
12
|
+
to: toAddress,
|
|
13
|
+
value: parseEther(amountEth),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return `Successfully transferred ${amountEth} native token on ${chainName}. Transaction hash: ${hash}`;
|
|
17
|
+
} catch (error: any) {
|
|
18
|
+
return `Failed to transfer: ${error.message}`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const transferToolDefinition = {
|
|
23
|
+
type: "function",
|
|
24
|
+
function: {
|
|
25
|
+
name: "transfer_native",
|
|
26
|
+
description: "Transfer native tokens (ETH, BNB, etc.) from the agent's wallet to a destination address.",
|
|
27
|
+
parameters: {
|
|
28
|
+
type: "object",
|
|
29
|
+
properties: {
|
|
30
|
+
chainName: {
|
|
31
|
+
type: "string",
|
|
32
|
+
enum: ["ethereum", "base", "bsc", "arbitrum", "optimism", "sepolia"],
|
|
33
|
+
description: "The name of the blockchain to execute the transfer on."
|
|
34
|
+
},
|
|
35
|
+
toAddress: {
|
|
36
|
+
type: "string",
|
|
37
|
+
description: "The destination 0x... wallet address."
|
|
38
|
+
},
|
|
39
|
+
amountEth: {
|
|
40
|
+
type: "string",
|
|
41
|
+
description: "The amount of tokens to send in ETH units (e.g. '0.01')."
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
required: ["chainName", "toAddress", "amountEth"]
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "CommonJS",
|
|
5
|
+
"esModuleInterop": true,
|
|
6
|
+
"strict": true,
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"forceConsistentCasingInFileNames": true,
|
|
9
|
+
"rootDir": "./src",
|
|
10
|
+
"outDir": "./dist"
|
|
11
|
+
},
|
|
12
|
+
"include": ["src/**/*"]
|
|
13
|
+
}
|
package/user.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Tuliskan instruksi kustom, aturan khusus, profil pengguna, atau persona yang Anda inginkan untuk Nyxora AI di file ini.
|
|
2
|
+
|
|
3
|
+
Setiap kali agen membaca pesan Anda, ia akan membaca file ini terlebih dahulu sebagai pedoman utama.
|
|
4
|
+
|
|
5
|
+
Contoh:
|
|
6
|
+
|
|
7
|
+
* "Panggil saya dengan sebutan Yudha"
|
|
8
|
+
* "Gunakan gaya bahasa santai dan gaul"
|
|
9
|
+
* "Fokuskan analisis pada sudut pandang teknikal trading"
|
|
10
|
+
|