safehands-pharos 1.4.0 → 1.5.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/README.md +174 -63
- package/dist/cli.d.ts +5 -5
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +126 -124
- package/dist/cli.js.map +1 -1
- package/dist/demo.d.ts +1 -1
- package/dist/demo.js +171 -171
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +73 -65
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +1 -1
- package/dist/init.js +65 -65
- package/dist/lib/constants.d.ts +303 -291
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/constants.js +302 -292
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/dodoApi.d.ts +78 -78
- package/dist/lib/dodoApi.js +196 -196
- package/dist/lib/envLoader.d.ts +2 -0
- package/dist/lib/envLoader.d.ts.map +1 -0
- package/dist/lib/envLoader.js +44 -0
- package/dist/lib/envLoader.js.map +1 -0
- package/dist/lib/http.d.ts +14 -14
- package/dist/lib/http.js +118 -118
- package/dist/lib/pharosClient.d.ts +58 -58
- package/dist/lib/pharosClient.js +63 -63
- package/dist/lib/policy/actionPolicyEngine.d.ts +53 -53
- package/dist/lib/policy/actionPolicyEngine.js +212 -212
- package/dist/lib/riskEngine.d.ts +26 -26
- package/dist/lib/riskEngine.d.ts.map +1 -1
- package/dist/lib/riskEngine.js +288 -283
- package/dist/lib/riskEngine.js.map +1 -1
- package/dist/lib/signer/index.d.ts +24 -24
- package/dist/lib/signer/index.js +88 -88
- package/dist/lib/testDodoLive.d.ts +1 -1
- package/dist/lib/testDodoLive.js +104 -104
- package/dist/lib/testLiveSafehands.d.ts +1 -1
- package/dist/lib/testLiveSafehands.js +92 -92
- package/dist/lib/testRpcLive.d.ts +1 -1
- package/dist/lib/testRpcLive.js +88 -88
- package/dist/lib/testTools.js +397 -398
- package/dist/lib/testX402Live.d.ts +1 -1
- package/dist/lib/testX402Live.js +159 -159
- package/dist/lib/toolResponse.d.ts +25 -25
- package/dist/lib/toolResponse.js +53 -53
- package/dist/lib/wallet/index.d.ts +37 -37
- package/dist/lib/wallet/index.js +128 -128
- package/dist/scripts/checkDeploy.d.ts +1 -1
- package/dist/scripts/checkDeploy.js +24 -24
- package/dist/scripts/deployRegistry.d.ts +1 -1
- package/dist/scripts/deployRegistry.js +100 -100
- package/dist/scripts/testRegistry.d.ts +1 -1
- package/dist/scripts/testRegistry.js +43 -43
- package/dist/tools/approveToken.d.ts +45 -45
- package/dist/tools/approveToken.js +85 -85
- package/dist/tools/assessRisk.d.ts +79 -79
- package/dist/tools/assessRisk.js +104 -104
- package/dist/tools/checkAllowance.d.ts +43 -43
- package/dist/tools/checkAllowance.js +56 -56
- package/dist/tools/checkTokenSecurity.d.ts +46 -46
- package/dist/tools/checkTokenSecurity.js +95 -95
- package/dist/tools/createAgentWallet.d.ts +28 -26
- package/dist/tools/createAgentWallet.d.ts.map +1 -1
- package/dist/tools/createAgentWallet.js +82 -58
- package/dist/tools/createAgentWallet.js.map +1 -1
- package/dist/tools/estimateGas.d.ts +79 -79
- package/dist/tools/estimateGas.js +124 -124
- package/dist/tools/executeSwap.d.ts +61 -61
- package/dist/tools/executeSwap.js +141 -141
- package/dist/tools/explainRisk.d.ts +29 -29
- package/dist/tools/explainRisk.js +32 -32
- package/dist/tools/getAgentWallet.d.ts +21 -21
- package/dist/tools/getAgentWallet.js +27 -27
- package/dist/tools/getAgentWalletBalance.d.ts +11 -11
- package/dist/tools/getAgentWalletBalance.js +70 -70
- package/dist/tools/getExecutionHistory.d.ts +49 -49
- package/dist/tools/getExecutionHistory.js +154 -154
- package/dist/tools/getGasPrice.d.ts +43 -43
- package/dist/tools/getGasPrice.js +59 -59
- package/dist/tools/getPoolInfo.d.ts +75 -75
- package/dist/tools/getPoolInfo.js +137 -137
- package/dist/tools/getTokenPrice.d.ts +113 -113
- package/dist/tools/getTokenPrice.js +117 -117
- package/dist/tools/getTransactionStatus.d.ts +43 -43
- package/dist/tools/getTransactionStatus.js +59 -59
- package/dist/tools/getWalletBalance.d.ts +68 -68
- package/dist/tools/getWalletBalance.js +87 -87
- package/dist/tools/publishRiskScore.d.ts +63 -63
- package/dist/tools/publishRiskScore.js +88 -88
- package/dist/tools/queryRiskRegistry.d.ts +38 -38
- package/dist/tools/queryRiskRegistry.js +55 -55
- package/dist/tools/safehandsPreflightCheck.d.ts +77 -77
- package/dist/tools/safehandsPreflightCheck.js +47 -47
- package/dist/tools/safehandsRiskReport.d.ts +81 -81
- package/dist/tools/safehandsRiskReport.js +28 -28
- package/dist/tools/safehandsSafeExecute.d.ts +20 -20
- package/dist/tools/safehandsSafeExecute.js +81 -81
- package/dist/tools/safehandsWalletHealth.d.ts +14 -14
- package/dist/tools/safehandsWalletHealth.js +103 -103
- package/dist/tools/safehandsX402Preflight.d.ts +26 -26
- package/dist/tools/safehandsX402Preflight.js +65 -65
- package/dist/tools/sendPayment.d.ts +57 -57
- package/dist/tools/sendPayment.js +117 -117
- package/dist/tools/simulateTransaction.d.ts +60 -60
- package/dist/tools/simulateTransaction.js +83 -83
- package/dist/tools/tokenRegistryStatus.d.ts +26 -26
- package/dist/tools/tokenRegistryStatus.js +96 -96
- package/dist/tools/x402PayAndFetch.d.ts +81 -81
- package/dist/tools/x402PayAndFetch.js +152 -152
- package/dist/x402Server.d.ts +1 -1
- package/dist/x402Server.js +300 -252
- package/dist/x402Server.js.map +1 -1
- package/package.json +6 -16
- package/examples/dashboard/index.html +0 -337
- package/examples/pharos-skill-engine/SKILL.safehands.md +0 -85
- package/examples/pharos-skill-engine/assets/safehands/example-actions.json +0 -49
- package/examples/pharos-skill-engine/assets/safehands/policy-defaults.json +0 -11
- package/examples/pharos-skill-engine/references/safehands.md +0 -345
- package/examples/scenario-hack.ts +0 -38
- package/skill/SKILL.md +0 -133
- package/skill/assets/safehands/example-actions.json +0 -49
- package/skill/assets/safehands/policy-defaults.json +0 -11
- package/skill/references/safehands.md +0 -345
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const checkAllowanceSchema: z.ZodObject<{
|
|
3
|
-
walletAddress: z.ZodString;
|
|
4
|
-
token: z.ZodEnum<["USDC", "USDT"]>;
|
|
5
|
-
amount: z.ZodOptional<z.ZodString>;
|
|
6
|
-
}, "strip", z.ZodTypeAny, {
|
|
7
|
-
token: "USDC" | "USDT";
|
|
8
|
-
walletAddress: string;
|
|
9
|
-
amount?: string | undefined;
|
|
10
|
-
}, {
|
|
11
|
-
token: "USDC" | "USDT";
|
|
12
|
-
walletAddress: string;
|
|
13
|
-
amount?: string | undefined;
|
|
14
|
-
}>;
|
|
15
|
-
export type CheckAllowanceInput = z.input<typeof checkAllowanceSchema>;
|
|
16
|
-
export declare const checkAllowanceTool: {
|
|
17
|
-
name: string;
|
|
18
|
-
description: string;
|
|
19
|
-
inputSchema: z.ZodObject<{
|
|
20
|
-
walletAddress: z.ZodString;
|
|
21
|
-
token: z.ZodEnum<["USDC", "USDT"]>;
|
|
22
|
-
amount: z.ZodOptional<z.ZodString>;
|
|
23
|
-
}, "strip", z.ZodTypeAny, {
|
|
24
|
-
token: "USDC" | "USDT";
|
|
25
|
-
walletAddress: string;
|
|
26
|
-
amount?: string | undefined;
|
|
27
|
-
}, {
|
|
28
|
-
token: "USDC" | "USDT";
|
|
29
|
-
walletAddress: string;
|
|
30
|
-
amount?: string | undefined;
|
|
31
|
-
}>;
|
|
32
|
-
};
|
|
33
|
-
export declare function handleCheckAllowance(raw: CheckAllowanceInput): Promise<import("../lib/toolResponse.js").ToolSuccess<{
|
|
34
|
-
token: "USDC" | "USDT";
|
|
35
|
-
tokenAddress: "0xE7E84B8B4f39C507499c40B4ac199B050e2882d5" | "0xE0BE08c77f415F577A1B3A9aD7a1Df1479564ec8";
|
|
36
|
-
walletAddress: string;
|
|
37
|
-
spender: "0x4Cf317b8918FbE8A890c01eDAb7d548555Ac2cE9";
|
|
38
|
-
allowance: string;
|
|
39
|
-
allowanceRaw: string;
|
|
40
|
-
isApproved: boolean;
|
|
41
|
-
needsApproval: boolean;
|
|
42
|
-
approvalNote: string;
|
|
43
|
-
}>>;
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const checkAllowanceSchema: z.ZodObject<{
|
|
3
|
+
walletAddress: z.ZodString;
|
|
4
|
+
token: z.ZodEnum<["USDC", "USDT"]>;
|
|
5
|
+
amount: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
token: "USDC" | "USDT";
|
|
8
|
+
walletAddress: string;
|
|
9
|
+
amount?: string | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
token: "USDC" | "USDT";
|
|
12
|
+
walletAddress: string;
|
|
13
|
+
amount?: string | undefined;
|
|
14
|
+
}>;
|
|
15
|
+
export type CheckAllowanceInput = z.input<typeof checkAllowanceSchema>;
|
|
16
|
+
export declare const checkAllowanceTool: {
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
inputSchema: z.ZodObject<{
|
|
20
|
+
walletAddress: z.ZodString;
|
|
21
|
+
token: z.ZodEnum<["USDC", "USDT"]>;
|
|
22
|
+
amount: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
token: "USDC" | "USDT";
|
|
25
|
+
walletAddress: string;
|
|
26
|
+
amount?: string | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
token: "USDC" | "USDT";
|
|
29
|
+
walletAddress: string;
|
|
30
|
+
amount?: string | undefined;
|
|
31
|
+
}>;
|
|
32
|
+
};
|
|
33
|
+
export declare function handleCheckAllowance(raw: CheckAllowanceInput): Promise<import("../lib/toolResponse.js").ToolSuccess<{
|
|
34
|
+
token: "USDC" | "USDT";
|
|
35
|
+
tokenAddress: "0xE7E84B8B4f39C507499c40B4ac199B050e2882d5" | "0xE0BE08c77f415F577A1B3A9aD7a1Df1479564ec8";
|
|
36
|
+
walletAddress: string;
|
|
37
|
+
spender: "0x4Cf317b8918FbE8A890c01eDAb7d548555Ac2cE9";
|
|
38
|
+
allowance: string;
|
|
39
|
+
allowanceRaw: string;
|
|
40
|
+
isApproved: boolean;
|
|
41
|
+
needsApproval: boolean;
|
|
42
|
+
approvalNote: string;
|
|
43
|
+
}>>;
|
|
44
44
|
//# sourceMappingURL=checkAllowance.d.ts.map
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
// ─── Tool: check_allowance ─────────────────────────────────────────────
|
|
2
|
-
// Checks ERC-20 token allowance for DODO_APPROVE_ADDRESS.
|
|
3
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import { publicClient } from "../lib/pharosClient.js";
|
|
6
|
-
import { DODO_APPROVE_ADDRESS, USDC_ADDRESS, USDT_ADDRESS, ERC20_ABI, } from "../lib/constants.js";
|
|
7
|
-
import { formatUnits, parseUnits } from "viem";
|
|
8
|
-
import { ok } from "../lib/toolResponse.js";
|
|
9
|
-
export const checkAllowanceSchema = z.object({
|
|
10
|
-
walletAddress: z.string().describe("Wallet address to check allowance for"),
|
|
11
|
-
token: z.enum(["USDC", "USDT"]).describe("ERC-20 token to check"),
|
|
12
|
-
amount: z.string().optional().describe("Human-readable swap/transfer amount to check against. When provided, needsApproval is exact (allowance < amount). When omitted, only checks allowance > 0."),
|
|
13
|
-
});
|
|
14
|
-
export const checkAllowanceTool = {
|
|
15
|
-
name: "check_allowance",
|
|
16
|
-
description: "Check ERC-20 token allowance granted to DODO_APPROVE_ADDRESS for swaps. Returns current allowance and whether approval is needed.",
|
|
17
|
-
inputSchema: checkAllowanceSchema,
|
|
18
|
-
};
|
|
19
|
-
export async function handleCheckAllowance(raw) {
|
|
20
|
-
const input = checkAllowanceSchema.parse(raw);
|
|
21
|
-
const walletAddr = input.walletAddress;
|
|
22
|
-
const tokenAddress = input.token === "USDC" ? USDC_ADDRESS : USDT_ADDRESS;
|
|
23
|
-
const decimals = 6;
|
|
24
|
-
const allowanceRaw = (await publicClient.readContract({
|
|
25
|
-
address: tokenAddress,
|
|
26
|
-
abi: ERC20_ABI,
|
|
27
|
-
functionName: "allowance",
|
|
28
|
-
args: [walletAddr, DODO_APPROVE_ADDRESS],
|
|
29
|
-
}));
|
|
30
|
-
const allowanceFormatted = formatUnits(allowanceRaw, decimals);
|
|
31
|
-
let isApproved;
|
|
32
|
-
let needsApproval;
|
|
33
|
-
let approvalNote;
|
|
34
|
-
if (input.amount !== undefined) {
|
|
35
|
-
const requiredWei = parseUnits(input.amount, decimals);
|
|
36
|
-
isApproved = allowanceRaw >= requiredWei;
|
|
37
|
-
needsApproval = !isApproved;
|
|
38
|
-
approvalNote = `Amount-aware: allowance ${allowanceFormatted} vs required ${input.amount}`;
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
isApproved = allowanceRaw > 0n;
|
|
42
|
-
needsApproval = !isApproved;
|
|
43
|
-
approvalNote = "Heuristic (no amount provided): any nonzero allowance counts as approved. Pass 'amount' for an exact check.";
|
|
44
|
-
}
|
|
45
|
-
return ok({
|
|
46
|
-
token: input.token,
|
|
47
|
-
tokenAddress,
|
|
48
|
-
walletAddress: input.walletAddress,
|
|
49
|
-
spender: DODO_APPROVE_ADDRESS,
|
|
50
|
-
allowance: allowanceFormatted,
|
|
51
|
-
allowanceRaw: allowanceRaw.toString(),
|
|
52
|
-
isApproved,
|
|
53
|
-
needsApproval,
|
|
54
|
-
approvalNote,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
1
|
+
// ─── Tool: check_allowance ─────────────────────────────────────────────
|
|
2
|
+
// Checks ERC-20 token allowance for DODO_APPROVE_ADDRESS.
|
|
3
|
+
// ────────────────────────────────────────────────────────────────────────
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { publicClient } from "../lib/pharosClient.js";
|
|
6
|
+
import { DODO_APPROVE_ADDRESS, USDC_ADDRESS, USDT_ADDRESS, ERC20_ABI, } from "../lib/constants.js";
|
|
7
|
+
import { formatUnits, parseUnits } from "viem";
|
|
8
|
+
import { ok } from "../lib/toolResponse.js";
|
|
9
|
+
export const checkAllowanceSchema = z.object({
|
|
10
|
+
walletAddress: z.string().describe("Wallet address to check allowance for"),
|
|
11
|
+
token: z.enum(["USDC", "USDT"]).describe("ERC-20 token to check"),
|
|
12
|
+
amount: z.string().optional().describe("Human-readable swap/transfer amount to check against. When provided, needsApproval is exact (allowance < amount). When omitted, only checks allowance > 0."),
|
|
13
|
+
});
|
|
14
|
+
export const checkAllowanceTool = {
|
|
15
|
+
name: "check_allowance",
|
|
16
|
+
description: "Check ERC-20 token allowance granted to DODO_APPROVE_ADDRESS for swaps. Returns current allowance and whether approval is needed.",
|
|
17
|
+
inputSchema: checkAllowanceSchema,
|
|
18
|
+
};
|
|
19
|
+
export async function handleCheckAllowance(raw) {
|
|
20
|
+
const input = checkAllowanceSchema.parse(raw);
|
|
21
|
+
const walletAddr = input.walletAddress;
|
|
22
|
+
const tokenAddress = input.token === "USDC" ? USDC_ADDRESS : USDT_ADDRESS;
|
|
23
|
+
const decimals = 6;
|
|
24
|
+
const allowanceRaw = (await publicClient.readContract({
|
|
25
|
+
address: tokenAddress,
|
|
26
|
+
abi: ERC20_ABI,
|
|
27
|
+
functionName: "allowance",
|
|
28
|
+
args: [walletAddr, DODO_APPROVE_ADDRESS],
|
|
29
|
+
}));
|
|
30
|
+
const allowanceFormatted = formatUnits(allowanceRaw, decimals);
|
|
31
|
+
let isApproved;
|
|
32
|
+
let needsApproval;
|
|
33
|
+
let approvalNote;
|
|
34
|
+
if (input.amount !== undefined) {
|
|
35
|
+
const requiredWei = parseUnits(input.amount, decimals);
|
|
36
|
+
isApproved = allowanceRaw >= requiredWei;
|
|
37
|
+
needsApproval = !isApproved;
|
|
38
|
+
approvalNote = `Amount-aware: allowance ${allowanceFormatted} vs required ${input.amount}`;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
isApproved = allowanceRaw > 0n;
|
|
42
|
+
needsApproval = !isApproved;
|
|
43
|
+
approvalNote = "Heuristic (no amount provided): any nonzero allowance counts as approved. Pass 'amount' for an exact check.";
|
|
44
|
+
}
|
|
45
|
+
return ok({
|
|
46
|
+
token: input.token,
|
|
47
|
+
tokenAddress,
|
|
48
|
+
walletAddress: input.walletAddress,
|
|
49
|
+
spender: DODO_APPROVE_ADDRESS,
|
|
50
|
+
allowance: allowanceFormatted,
|
|
51
|
+
allowanceRaw: allowanceRaw.toString(),
|
|
52
|
+
isApproved,
|
|
53
|
+
needsApproval,
|
|
54
|
+
approvalNote,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
57
|
//# sourceMappingURL=checkAllowance.js.map
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const checkTokenSecuritySchema: z.ZodObject<{
|
|
3
|
-
tokenAddress: z.ZodString;
|
|
4
|
-
chainId: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
5
|
-
}, "strip", z.ZodTypeAny, {
|
|
6
|
-
tokenAddress: string;
|
|
7
|
-
chainId: number;
|
|
8
|
-
}, {
|
|
9
|
-
tokenAddress: string;
|
|
10
|
-
chainId?: number | undefined;
|
|
11
|
-
}>;
|
|
12
|
-
export type CheckTokenSecurityInput = z.input<typeof checkTokenSecuritySchema>;
|
|
13
|
-
export declare const checkTokenSecurityTool: {
|
|
14
|
-
name: string;
|
|
15
|
-
description: string;
|
|
16
|
-
inputSchema: z.ZodObject<{
|
|
17
|
-
tokenAddress: z.ZodString;
|
|
18
|
-
chainId: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
19
|
-
}, "strip", z.ZodTypeAny, {
|
|
20
|
-
tokenAddress: string;
|
|
21
|
-
chainId: number;
|
|
22
|
-
}, {
|
|
23
|
-
tokenAddress: string;
|
|
24
|
-
chainId?: number | undefined;
|
|
25
|
-
}>;
|
|
26
|
-
};
|
|
27
|
-
export declare function handleCheckTokenSecurity(raw: CheckTokenSecurityInput): Promise<import("../lib/toolResponse.js").ToolFailure | import("../lib/toolResponse.js").ToolSuccess<{
|
|
28
|
-
chainId: number;
|
|
29
|
-
environment: string;
|
|
30
|
-
isMainnet: boolean;
|
|
31
|
-
tokenAddress: `0x${string}`;
|
|
32
|
-
securityProfile: {
|
|
33
|
-
safetyScore: number;
|
|
34
|
-
isHoneypot: boolean;
|
|
35
|
-
buyTaxPercent: number;
|
|
36
|
-
sellTaxPercent: number;
|
|
37
|
-
isMintable: boolean;
|
|
38
|
-
transferPausable: boolean;
|
|
39
|
-
isProxy: boolean;
|
|
40
|
-
ownerAddress: any;
|
|
41
|
-
creatorAddress: any;
|
|
42
|
-
};
|
|
43
|
-
flags: string[];
|
|
44
|
-
source: string;
|
|
45
|
-
sourceStatus: string;
|
|
46
|
-
}>>;
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const checkTokenSecuritySchema: z.ZodObject<{
|
|
3
|
+
tokenAddress: z.ZodString;
|
|
4
|
+
chainId: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
tokenAddress: string;
|
|
7
|
+
chainId: number;
|
|
8
|
+
}, {
|
|
9
|
+
tokenAddress: string;
|
|
10
|
+
chainId?: number | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
export type CheckTokenSecurityInput = z.input<typeof checkTokenSecuritySchema>;
|
|
13
|
+
export declare const checkTokenSecurityTool: {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
inputSchema: z.ZodObject<{
|
|
17
|
+
tokenAddress: z.ZodString;
|
|
18
|
+
chainId: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
tokenAddress: string;
|
|
21
|
+
chainId: number;
|
|
22
|
+
}, {
|
|
23
|
+
tokenAddress: string;
|
|
24
|
+
chainId?: number | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
};
|
|
27
|
+
export declare function handleCheckTokenSecurity(raw: CheckTokenSecurityInput): Promise<import("../lib/toolResponse.js").ToolFailure | import("../lib/toolResponse.js").ToolSuccess<{
|
|
28
|
+
chainId: number;
|
|
29
|
+
environment: string;
|
|
30
|
+
isMainnet: boolean;
|
|
31
|
+
tokenAddress: `0x${string}`;
|
|
32
|
+
securityProfile: {
|
|
33
|
+
safetyScore: number;
|
|
34
|
+
isHoneypot: boolean;
|
|
35
|
+
buyTaxPercent: number;
|
|
36
|
+
sellTaxPercent: number;
|
|
37
|
+
isMintable: boolean;
|
|
38
|
+
transferPausable: boolean;
|
|
39
|
+
isProxy: boolean;
|
|
40
|
+
ownerAddress: any;
|
|
41
|
+
creatorAddress: any;
|
|
42
|
+
};
|
|
43
|
+
flags: string[];
|
|
44
|
+
source: string;
|
|
45
|
+
sourceStatus: string;
|
|
46
|
+
}>>;
|
|
47
47
|
//# sourceMappingURL=checkTokenSecurity.d.ts.map
|
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
// ─── Tool: check_token_security ─────────────────────────────────────────
|
|
2
|
-
// Fetches token security intelligence from GoPlus Security API.
|
|
3
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import { isAddress } from "viem";
|
|
6
|
-
import { CHAIN_ID, PHAROS_ENVIRONMENT } from "../lib/constants.js";
|
|
7
|
-
import { fetchWithTimeoutAndRetry } from "../lib/http.js";
|
|
8
|
-
import { classifyExternalError, fail, ok } from "../lib/toolResponse.js";
|
|
9
|
-
export const checkTokenSecuritySchema = z.object({
|
|
10
|
-
tokenAddress: z.string(),
|
|
11
|
-
chainId: z.number().optional().default(CHAIN_ID),
|
|
12
|
-
});
|
|
13
|
-
export const checkTokenSecurityTool = {
|
|
14
|
-
name: "check_token_security",
|
|
15
|
-
description: "Check token contract security (honeypot, mintable, ownership privileges, tax) via GoPlus Security API.",
|
|
16
|
-
inputSchema: checkTokenSecuritySchema,
|
|
17
|
-
};
|
|
18
|
-
export async function handleCheckTokenSecurity(raw) {
|
|
19
|
-
const input = checkTokenSecuritySchema.parse(raw);
|
|
20
|
-
const address = input.tokenAddress.toLowerCase().trim();
|
|
21
|
-
const chainId = input.chainId;
|
|
22
|
-
if (!isAddress(address)) {
|
|
23
|
-
return fail("INVALID_TOKEN_ADDRESS", `Invalid token address: ${input.tokenAddress}`, false, "check_token_security");
|
|
24
|
-
}
|
|
25
|
-
// GoPlus does not index Pharos Atlantic Testnet (chain 688689). Return a clear diagnostic
|
|
26
|
-
// rather than a confusing empty result from the API.
|
|
27
|
-
if (chainId === CHAIN_ID) {
|
|
28
|
-
return fail("CHAIN_NOT_SUPPORTED_BY_GOPLUS", `GoPlus Security API does not support Pharos Atlantic Testnet (chain ${CHAIN_ID}). ` +
|
|
29
|
-
"Token security data is unavailable for this chain. Use token_registry_status to check " +
|
|
30
|
-
"whether a token address is canonical, custom, or unknown on Pharos.", false, "check_token_security");
|
|
31
|
-
}
|
|
32
|
-
const url = `https://api.gopluslabs.io/api/v1/token_security/${chainId}?contract_addresses=${address}`;
|
|
33
|
-
try {
|
|
34
|
-
const res = await fetchWithTimeoutAndRetry(url, { timeoutMs: 10_000, retries: 2, retryDelayMs: 300 });
|
|
35
|
-
if (!res.ok) {
|
|
36
|
-
throw new Error(`GoPlus API returned status ${res.status}`);
|
|
37
|
-
}
|
|
38
|
-
const data = (await res.json());
|
|
39
|
-
if (data.code !== 1 || !data.result || !data.result[address]) {
|
|
40
|
-
return fail("TOKEN_SECURITY_DATA_UNAVAILABLE", data.message || "Token security data is not available for this contract on the specified chain.", true, "goplus_api");
|
|
41
|
-
}
|
|
42
|
-
const details = data.result[address];
|
|
43
|
-
const isHoneypot = details.is_honeypot === "1";
|
|
44
|
-
const buyTax = parseFloat(details.buy_tax || "0") * 100;
|
|
45
|
-
const sellTax = parseFloat(details.sell_tax || "0") * 100;
|
|
46
|
-
const isMintable = details.is_mintable === "1";
|
|
47
|
-
const transferPausable = details.transfer_pausable === "1";
|
|
48
|
-
let riskScore = 0;
|
|
49
|
-
const flags = [];
|
|
50
|
-
if (isHoneypot) {
|
|
51
|
-
riskScore += 80;
|
|
52
|
-
flags.push("Honeypot contract detected - buy at your own peril (cannot sell)");
|
|
53
|
-
}
|
|
54
|
-
if (buyTax > 10) {
|
|
55
|
-
riskScore += 15;
|
|
56
|
-
flags.push(`High buy tax: ${buyTax.toFixed(2)}%`);
|
|
57
|
-
}
|
|
58
|
-
if (sellTax > 10) {
|
|
59
|
-
riskScore += 15;
|
|
60
|
-
flags.push(`High sell tax: ${sellTax.toFixed(2)}%`);
|
|
61
|
-
}
|
|
62
|
-
if (isMintable) {
|
|
63
|
-
riskScore += 10;
|
|
64
|
-
flags.push("Token is mintable by owner/creator");
|
|
65
|
-
}
|
|
66
|
-
if (transferPausable) {
|
|
67
|
-
riskScore += 15;
|
|
68
|
-
flags.push("Trading/transfers can be paused by owner");
|
|
69
|
-
}
|
|
70
|
-
const safetyScore = Math.max(0, 100 - riskScore);
|
|
71
|
-
return ok({
|
|
72
|
-
chainId,
|
|
73
|
-
environment: chainId === CHAIN_ID ? PHAROS_ENVIRONMENT : "custom-chain",
|
|
74
|
-
isMainnet: false,
|
|
75
|
-
tokenAddress: address,
|
|
76
|
-
securityProfile: {
|
|
77
|
-
safetyScore,
|
|
78
|
-
isHoneypot,
|
|
79
|
-
buyTaxPercent: buyTax,
|
|
80
|
-
sellTaxPercent: sellTax,
|
|
81
|
-
isMintable,
|
|
82
|
-
transferPausable,
|
|
83
|
-
isProxy: details.is_proxy === "1",
|
|
84
|
-
ownerAddress: details.owner_address || "0x0000000000000000000000000000000000000000",
|
|
85
|
-
creatorAddress: details.creator_address || "0x0000000000000000000000000000000000000000",
|
|
86
|
-
},
|
|
87
|
-
flags,
|
|
88
|
-
source: "goplus_api",
|
|
89
|
-
sourceStatus: "ok",
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
catch (err) {
|
|
93
|
-
return classifyExternalError("goplus_api", err);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
1
|
+
// ─── Tool: check_token_security ─────────────────────────────────────────
|
|
2
|
+
// Fetches token security intelligence from GoPlus Security API.
|
|
3
|
+
// ────────────────────────────────────────────────────────────────────────
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { isAddress } from "viem";
|
|
6
|
+
import { CHAIN_ID, PHAROS_ENVIRONMENT } from "../lib/constants.js";
|
|
7
|
+
import { fetchWithTimeoutAndRetry } from "../lib/http.js";
|
|
8
|
+
import { classifyExternalError, fail, ok } from "../lib/toolResponse.js";
|
|
9
|
+
export const checkTokenSecuritySchema = z.object({
|
|
10
|
+
tokenAddress: z.string(),
|
|
11
|
+
chainId: z.number().optional().default(CHAIN_ID),
|
|
12
|
+
});
|
|
13
|
+
export const checkTokenSecurityTool = {
|
|
14
|
+
name: "check_token_security",
|
|
15
|
+
description: "Check token contract security (honeypot, mintable, ownership privileges, tax) via GoPlus Security API.",
|
|
16
|
+
inputSchema: checkTokenSecuritySchema,
|
|
17
|
+
};
|
|
18
|
+
export async function handleCheckTokenSecurity(raw) {
|
|
19
|
+
const input = checkTokenSecuritySchema.parse(raw);
|
|
20
|
+
const address = input.tokenAddress.toLowerCase().trim();
|
|
21
|
+
const chainId = input.chainId;
|
|
22
|
+
if (!isAddress(address)) {
|
|
23
|
+
return fail("INVALID_TOKEN_ADDRESS", `Invalid token address: ${input.tokenAddress}`, false, "check_token_security");
|
|
24
|
+
}
|
|
25
|
+
// GoPlus does not index Pharos Atlantic Testnet (chain 688689). Return a clear diagnostic
|
|
26
|
+
// rather than a confusing empty result from the API.
|
|
27
|
+
if (chainId === CHAIN_ID) {
|
|
28
|
+
return fail("CHAIN_NOT_SUPPORTED_BY_GOPLUS", `GoPlus Security API does not support Pharos Atlantic Testnet (chain ${CHAIN_ID}). ` +
|
|
29
|
+
"Token security data is unavailable for this chain. Use token_registry_status to check " +
|
|
30
|
+
"whether a token address is canonical, custom, or unknown on Pharos.", false, "check_token_security");
|
|
31
|
+
}
|
|
32
|
+
const url = `https://api.gopluslabs.io/api/v1/token_security/${chainId}?contract_addresses=${address}`;
|
|
33
|
+
try {
|
|
34
|
+
const res = await fetchWithTimeoutAndRetry(url, { timeoutMs: 10_000, retries: 2, retryDelayMs: 300 });
|
|
35
|
+
if (!res.ok) {
|
|
36
|
+
throw new Error(`GoPlus API returned status ${res.status}`);
|
|
37
|
+
}
|
|
38
|
+
const data = (await res.json());
|
|
39
|
+
if (data.code !== 1 || !data.result || !data.result[address]) {
|
|
40
|
+
return fail("TOKEN_SECURITY_DATA_UNAVAILABLE", data.message || "Token security data is not available for this contract on the specified chain.", true, "goplus_api");
|
|
41
|
+
}
|
|
42
|
+
const details = data.result[address];
|
|
43
|
+
const isHoneypot = details.is_honeypot === "1";
|
|
44
|
+
const buyTax = parseFloat(details.buy_tax || "0") * 100;
|
|
45
|
+
const sellTax = parseFloat(details.sell_tax || "0") * 100;
|
|
46
|
+
const isMintable = details.is_mintable === "1";
|
|
47
|
+
const transferPausable = details.transfer_pausable === "1";
|
|
48
|
+
let riskScore = 0;
|
|
49
|
+
const flags = [];
|
|
50
|
+
if (isHoneypot) {
|
|
51
|
+
riskScore += 80;
|
|
52
|
+
flags.push("Honeypot contract detected - buy at your own peril (cannot sell)");
|
|
53
|
+
}
|
|
54
|
+
if (buyTax > 10) {
|
|
55
|
+
riskScore += 15;
|
|
56
|
+
flags.push(`High buy tax: ${buyTax.toFixed(2)}%`);
|
|
57
|
+
}
|
|
58
|
+
if (sellTax > 10) {
|
|
59
|
+
riskScore += 15;
|
|
60
|
+
flags.push(`High sell tax: ${sellTax.toFixed(2)}%`);
|
|
61
|
+
}
|
|
62
|
+
if (isMintable) {
|
|
63
|
+
riskScore += 10;
|
|
64
|
+
flags.push("Token is mintable by owner/creator");
|
|
65
|
+
}
|
|
66
|
+
if (transferPausable) {
|
|
67
|
+
riskScore += 15;
|
|
68
|
+
flags.push("Trading/transfers can be paused by owner");
|
|
69
|
+
}
|
|
70
|
+
const safetyScore = Math.max(0, 100 - riskScore);
|
|
71
|
+
return ok({
|
|
72
|
+
chainId,
|
|
73
|
+
environment: chainId === CHAIN_ID ? PHAROS_ENVIRONMENT : "custom-chain",
|
|
74
|
+
isMainnet: false,
|
|
75
|
+
tokenAddress: address,
|
|
76
|
+
securityProfile: {
|
|
77
|
+
safetyScore,
|
|
78
|
+
isHoneypot,
|
|
79
|
+
buyTaxPercent: buyTax,
|
|
80
|
+
sellTaxPercent: sellTax,
|
|
81
|
+
isMintable,
|
|
82
|
+
transferPausable,
|
|
83
|
+
isProxy: details.is_proxy === "1",
|
|
84
|
+
ownerAddress: details.owner_address || "0x0000000000000000000000000000000000000000",
|
|
85
|
+
creatorAddress: details.creator_address || "0x0000000000000000000000000000000000000000",
|
|
86
|
+
},
|
|
87
|
+
flags,
|
|
88
|
+
source: "goplus_api",
|
|
89
|
+
sourceStatus: "ok",
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
return classifyExternalError("goplus_api", err);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
96
|
//# sourceMappingURL=checkTokenSecurity.js.map
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { type ToolResponse } from "../lib/toolResponse.js";
|
|
3
|
-
export declare const createAgentWalletSchema: z.ZodObject<{
|
|
4
|
-
agentId: z.ZodString;
|
|
5
|
-
overwrite: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
6
|
-
}, "strip", z.ZodTypeAny, {
|
|
7
|
-
agentId: string;
|
|
8
|
-
overwrite: boolean;
|
|
9
|
-
}, {
|
|
10
|
-
agentId: string;
|
|
11
|
-
overwrite?: boolean | undefined;
|
|
12
|
-
}>;
|
|
13
|
-
export type CreateAgentWalletParams = z.infer<typeof createAgentWalletSchema>;
|
|
14
|
-
interface CreateAgentWalletData {
|
|
15
|
-
agentId: string;
|
|
16
|
-
address: string;
|
|
17
|
-
environment: string;
|
|
18
|
-
chainId: number;
|
|
19
|
-
isMainnet: boolean;
|
|
20
|
-
isTestnet: boolean;
|
|
21
|
-
createdAt: string;
|
|
22
|
-
warning: string;
|
|
23
|
-
instructions: string;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type ToolResponse } from "../lib/toolResponse.js";
|
|
3
|
+
export declare const createAgentWalletSchema: z.ZodObject<{
|
|
4
|
+
agentId: z.ZodString;
|
|
5
|
+
overwrite: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
agentId: string;
|
|
8
|
+
overwrite: boolean;
|
|
9
|
+
}, {
|
|
10
|
+
agentId: string;
|
|
11
|
+
overwrite?: boolean | undefined;
|
|
12
|
+
}>;
|
|
13
|
+
export type CreateAgentWalletParams = z.infer<typeof createAgentWalletSchema>;
|
|
14
|
+
interface CreateAgentWalletData {
|
|
15
|
+
agentId: string;
|
|
16
|
+
address: string;
|
|
17
|
+
environment: string;
|
|
18
|
+
chainId: number;
|
|
19
|
+
isMainnet: boolean;
|
|
20
|
+
isTestnet: boolean;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
warning: string;
|
|
23
|
+
instructions: string;
|
|
24
|
+
riskRegistryAuthorized: boolean;
|
|
25
|
+
riskRegistryAuthTxHash: string | null;
|
|
26
|
+
}
|
|
27
|
+
export declare function handleCreateAgentWallet(params: CreateAgentWalletParams): Promise<ToolResponse<CreateAgentWalletData>>;
|
|
28
|
+
export {};
|
|
27
29
|
//# sourceMappingURL=createAgentWallet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAgentWallet.d.ts","sourceRoot":"","sources":["../../src/tools/createAgentWallet.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"createAgentWallet.d.ts","sourceRoot":"","sources":["../../src/tools/createAgentWallet.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAKrE,eAAO,MAAM,uBAAuB;;;;;;;;;EAWlC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE9E,UAAU,qBAAqB;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,sBAAsB,EAAE,OAAO,CAAC;IAChC,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC;AAED,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAC,CA6E9C"}
|