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.
Files changed (124) hide show
  1. package/README.md +174 -63
  2. package/dist/cli.d.ts +5 -5
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +126 -124
  5. package/dist/cli.js.map +1 -1
  6. package/dist/demo.d.ts +1 -1
  7. package/dist/demo.js +171 -171
  8. package/dist/index.d.ts +2 -2
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +73 -65
  11. package/dist/index.js.map +1 -1
  12. package/dist/init.d.ts +1 -1
  13. package/dist/init.js +65 -65
  14. package/dist/lib/constants.d.ts +303 -291
  15. package/dist/lib/constants.d.ts.map +1 -1
  16. package/dist/lib/constants.js +302 -292
  17. package/dist/lib/constants.js.map +1 -1
  18. package/dist/lib/dodoApi.d.ts +78 -78
  19. package/dist/lib/dodoApi.js +196 -196
  20. package/dist/lib/envLoader.d.ts +2 -0
  21. package/dist/lib/envLoader.d.ts.map +1 -0
  22. package/dist/lib/envLoader.js +44 -0
  23. package/dist/lib/envLoader.js.map +1 -0
  24. package/dist/lib/http.d.ts +14 -14
  25. package/dist/lib/http.js +118 -118
  26. package/dist/lib/pharosClient.d.ts +58 -58
  27. package/dist/lib/pharosClient.js +63 -63
  28. package/dist/lib/policy/actionPolicyEngine.d.ts +53 -53
  29. package/dist/lib/policy/actionPolicyEngine.js +212 -212
  30. package/dist/lib/riskEngine.d.ts +26 -26
  31. package/dist/lib/riskEngine.d.ts.map +1 -1
  32. package/dist/lib/riskEngine.js +288 -283
  33. package/dist/lib/riskEngine.js.map +1 -1
  34. package/dist/lib/signer/index.d.ts +24 -24
  35. package/dist/lib/signer/index.js +88 -88
  36. package/dist/lib/testDodoLive.d.ts +1 -1
  37. package/dist/lib/testDodoLive.js +104 -104
  38. package/dist/lib/testLiveSafehands.d.ts +1 -1
  39. package/dist/lib/testLiveSafehands.js +92 -92
  40. package/dist/lib/testRpcLive.d.ts +1 -1
  41. package/dist/lib/testRpcLive.js +88 -88
  42. package/dist/lib/testTools.js +397 -398
  43. package/dist/lib/testX402Live.d.ts +1 -1
  44. package/dist/lib/testX402Live.js +159 -159
  45. package/dist/lib/toolResponse.d.ts +25 -25
  46. package/dist/lib/toolResponse.js +53 -53
  47. package/dist/lib/wallet/index.d.ts +37 -37
  48. package/dist/lib/wallet/index.js +128 -128
  49. package/dist/scripts/checkDeploy.d.ts +1 -1
  50. package/dist/scripts/checkDeploy.js +24 -24
  51. package/dist/scripts/deployRegistry.d.ts +1 -1
  52. package/dist/scripts/deployRegistry.js +100 -100
  53. package/dist/scripts/testRegistry.d.ts +1 -1
  54. package/dist/scripts/testRegistry.js +43 -43
  55. package/dist/tools/approveToken.d.ts +45 -45
  56. package/dist/tools/approveToken.js +85 -85
  57. package/dist/tools/assessRisk.d.ts +79 -79
  58. package/dist/tools/assessRisk.js +104 -104
  59. package/dist/tools/checkAllowance.d.ts +43 -43
  60. package/dist/tools/checkAllowance.js +56 -56
  61. package/dist/tools/checkTokenSecurity.d.ts +46 -46
  62. package/dist/tools/checkTokenSecurity.js +95 -95
  63. package/dist/tools/createAgentWallet.d.ts +28 -26
  64. package/dist/tools/createAgentWallet.d.ts.map +1 -1
  65. package/dist/tools/createAgentWallet.js +82 -58
  66. package/dist/tools/createAgentWallet.js.map +1 -1
  67. package/dist/tools/estimateGas.d.ts +79 -79
  68. package/dist/tools/estimateGas.js +124 -124
  69. package/dist/tools/executeSwap.d.ts +61 -61
  70. package/dist/tools/executeSwap.js +141 -141
  71. package/dist/tools/explainRisk.d.ts +29 -29
  72. package/dist/tools/explainRisk.js +32 -32
  73. package/dist/tools/getAgentWallet.d.ts +21 -21
  74. package/dist/tools/getAgentWallet.js +27 -27
  75. package/dist/tools/getAgentWalletBalance.d.ts +11 -11
  76. package/dist/tools/getAgentWalletBalance.js +70 -70
  77. package/dist/tools/getExecutionHistory.d.ts +49 -49
  78. package/dist/tools/getExecutionHistory.js +154 -154
  79. package/dist/tools/getGasPrice.d.ts +43 -43
  80. package/dist/tools/getGasPrice.js +59 -59
  81. package/dist/tools/getPoolInfo.d.ts +75 -75
  82. package/dist/tools/getPoolInfo.js +137 -137
  83. package/dist/tools/getTokenPrice.d.ts +113 -113
  84. package/dist/tools/getTokenPrice.js +117 -117
  85. package/dist/tools/getTransactionStatus.d.ts +43 -43
  86. package/dist/tools/getTransactionStatus.js +59 -59
  87. package/dist/tools/getWalletBalance.d.ts +68 -68
  88. package/dist/tools/getWalletBalance.js +87 -87
  89. package/dist/tools/publishRiskScore.d.ts +63 -63
  90. package/dist/tools/publishRiskScore.js +88 -88
  91. package/dist/tools/queryRiskRegistry.d.ts +38 -38
  92. package/dist/tools/queryRiskRegistry.js +55 -55
  93. package/dist/tools/safehandsPreflightCheck.d.ts +77 -77
  94. package/dist/tools/safehandsPreflightCheck.js +47 -47
  95. package/dist/tools/safehandsRiskReport.d.ts +81 -81
  96. package/dist/tools/safehandsRiskReport.js +28 -28
  97. package/dist/tools/safehandsSafeExecute.d.ts +20 -20
  98. package/dist/tools/safehandsSafeExecute.js +81 -81
  99. package/dist/tools/safehandsWalletHealth.d.ts +14 -14
  100. package/dist/tools/safehandsWalletHealth.js +103 -103
  101. package/dist/tools/safehandsX402Preflight.d.ts +26 -26
  102. package/dist/tools/safehandsX402Preflight.js +65 -65
  103. package/dist/tools/sendPayment.d.ts +57 -57
  104. package/dist/tools/sendPayment.js +117 -117
  105. package/dist/tools/simulateTransaction.d.ts +60 -60
  106. package/dist/tools/simulateTransaction.js +83 -83
  107. package/dist/tools/tokenRegistryStatus.d.ts +26 -26
  108. package/dist/tools/tokenRegistryStatus.js +96 -96
  109. package/dist/tools/x402PayAndFetch.d.ts +81 -81
  110. package/dist/tools/x402PayAndFetch.js +152 -152
  111. package/dist/x402Server.d.ts +1 -1
  112. package/dist/x402Server.js +300 -252
  113. package/dist/x402Server.js.map +1 -1
  114. package/package.json +6 -16
  115. package/examples/dashboard/index.html +0 -337
  116. package/examples/pharos-skill-engine/SKILL.safehands.md +0 -85
  117. package/examples/pharos-skill-engine/assets/safehands/example-actions.json +0 -49
  118. package/examples/pharos-skill-engine/assets/safehands/policy-defaults.json +0 -11
  119. package/examples/pharos-skill-engine/references/safehands.md +0 -345
  120. package/examples/scenario-hack.ts +0 -38
  121. package/skill/SKILL.md +0 -133
  122. package/skill/assets/safehands/example-actions.json +0 -49
  123. package/skill/assets/safehands/policy-defaults.json +0 -11
  124. package/skill/references/safehands.md +0 -345
@@ -1,114 +1,114 @@
1
- import { z } from "zod";
2
- export declare const getTokenPriceSchema: z.ZodObject<{
3
- token: z.ZodEnum<["PHRS", "USDC", "USDT"]>;
4
- }, "strip", z.ZodTypeAny, {
5
- token: "PHRS" | "USDC" | "USDT";
6
- }, {
7
- token: "PHRS" | "USDC" | "USDT";
8
- }>;
9
- export type GetTokenPriceInput = z.input<typeof getTokenPriceSchema>;
10
- export declare const getTokenPriceTool: {
11
- name: string;
12
- description: string;
13
- inputSchema: z.ZodObject<{
14
- token: z.ZodEnum<["PHRS", "USDC", "USDT"]>;
15
- }, "strip", z.ZodTypeAny, {
16
- token: "PHRS" | "USDC" | "USDT";
17
- }, {
18
- token: "PHRS" | "USDC" | "USDT";
19
- }>;
20
- };
21
- export declare function handleGetTokenPrice(raw: GetTokenPriceInput): Promise<import("../lib/toolResponse.js").ToolFailure | import("../lib/toolResponse.js").ToolSuccess<{
22
- token: string;
23
- tokenRegistry: {
24
- readonly symbol: "USDC";
25
- readonly address: "0xE0BE08c77f415F577A1B3A9aD7a1Df1479564ec8";
26
- readonly decimals: 6;
27
- readonly chainId: number;
28
- readonly environment: string;
29
- readonly isMainnet: false;
30
- readonly isCanonical: true;
31
- readonly isTestToken: true;
32
- readonly purpose: "Pharos Skill Engine USDC — the USDC listed in the official pharos-skill-engine-0.1.0 assets/tokens.json for atlantic-testnet";
33
- readonly docsSource: "pharos-skill-engine-0.1.0/assets/tokens.json";
34
- readonly verificationStatus: "DOCS_VERIFIED_FROM_PHAROS_SKILL_ENGINE";
35
- };
36
- priceUsd: {
37
- value: string;
38
- unit: string;
39
- };
40
- priceInPHRS: {
41
- value: string | null;
42
- unit: string;
43
- };
44
- source: string;
45
- sourceStatus: "ok" | "unavailable" | "no_route_available" | "auth_required";
46
- routeAvailable: boolean;
47
- publicMode: boolean;
48
- confidence: string;
49
- chainId: number;
50
- environment: string;
51
- isMainnet: boolean;
52
- }> | import("../lib/toolResponse.js").ToolSuccess<{
53
- token: string;
54
- tokenRegistry: {
55
- readonly symbol: "USDT";
56
- readonly address: "0xE7E84B8B4f39C507499c40B4ac199B050e2882d5";
57
- readonly decimals: 6;
58
- readonly chainId: number;
59
- readonly environment: string;
60
- readonly isMainnet: false;
61
- readonly isCanonical: true;
62
- readonly isTestToken: true;
63
- readonly purpose: "canonical Pharos Atlantic Testnet USDT (Tether USD)";
64
- readonly docsSource: "https://docs.pharos.xyz/getting-started/token-registry";
65
- readonly verificationStatus: "DOCS_VERIFIED";
66
- };
67
- priceUsd: {
68
- value: string;
69
- unit: string;
70
- };
71
- priceInPHRS: {
72
- value: string | null;
73
- unit: string;
74
- };
75
- source: string;
76
- sourceStatus: string;
77
- routeAvailable: boolean;
78
- publicMode: boolean;
79
- confidence: string;
80
- chainId: number;
81
- environment: string;
82
- isMainnet: boolean;
83
- }> | import("../lib/toolResponse.js").ToolSuccess<{
84
- token: string;
85
- tokenRegistry: {
86
- readonly symbol: "PHRS";
87
- readonly address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
88
- readonly decimals: 18;
89
- readonly chainId: number;
90
- readonly environment: string;
91
- readonly isMainnet: false;
92
- readonly isCanonical: true;
93
- readonly isTestToken: true;
94
- readonly purpose: "native PHRS sentinel address for DODO route API";
95
- readonly docsSource: "https://docs.pharos.xyz/";
96
- };
97
- priceUsd: {
98
- value: string;
99
- unit: string;
100
- };
101
- priceInPHRS: {
102
- value: string;
103
- unit: string;
104
- };
105
- source: string;
106
- sourceStatus: "ok" | "unavailable" | "no_route_available" | "auth_required";
107
- routeAvailable: boolean;
108
- publicMode: boolean;
109
- confidence: string;
110
- chainId: number;
111
- environment: string;
112
- isMainnet: boolean;
113
- }>>;
1
+ import { z } from "zod";
2
+ export declare const getTokenPriceSchema: z.ZodObject<{
3
+ token: z.ZodEnum<["PHRS", "USDC", "USDT"]>;
4
+ }, "strip", z.ZodTypeAny, {
5
+ token: "PHRS" | "USDC" | "USDT";
6
+ }, {
7
+ token: "PHRS" | "USDC" | "USDT";
8
+ }>;
9
+ export type GetTokenPriceInput = z.input<typeof getTokenPriceSchema>;
10
+ export declare const getTokenPriceTool: {
11
+ name: string;
12
+ description: string;
13
+ inputSchema: z.ZodObject<{
14
+ token: z.ZodEnum<["PHRS", "USDC", "USDT"]>;
15
+ }, "strip", z.ZodTypeAny, {
16
+ token: "PHRS" | "USDC" | "USDT";
17
+ }, {
18
+ token: "PHRS" | "USDC" | "USDT";
19
+ }>;
20
+ };
21
+ export declare function handleGetTokenPrice(raw: GetTokenPriceInput): Promise<import("../lib/toolResponse.js").ToolFailure | import("../lib/toolResponse.js").ToolSuccess<{
22
+ token: string;
23
+ tokenRegistry: {
24
+ readonly symbol: "USDC";
25
+ readonly address: "0xE0BE08c77f415F577A1B3A9aD7a1Df1479564ec8";
26
+ readonly decimals: 6;
27
+ readonly chainId: number;
28
+ readonly environment: string;
29
+ readonly isMainnet: false;
30
+ readonly isCanonical: true;
31
+ readonly isTestToken: true;
32
+ readonly purpose: "Pharos Skill Engine USDC — the USDC listed in the official pharos-skill-engine-0.1.0 assets/tokens.json for atlantic-testnet";
33
+ readonly docsSource: "pharos-skill-engine-0.1.0/assets/tokens.json";
34
+ readonly verificationStatus: "DOCS_VERIFIED_FROM_PHAROS_SKILL_ENGINE";
35
+ };
36
+ priceUsd: {
37
+ value: string;
38
+ unit: string;
39
+ };
40
+ priceInPHRS: {
41
+ value: string | null;
42
+ unit: string;
43
+ };
44
+ source: string;
45
+ sourceStatus: "ok" | "unavailable" | "no_route_available" | "auth_required";
46
+ routeAvailable: boolean;
47
+ publicMode: boolean;
48
+ confidence: string;
49
+ chainId: number;
50
+ environment: string;
51
+ isMainnet: boolean;
52
+ }> | import("../lib/toolResponse.js").ToolSuccess<{
53
+ token: string;
54
+ tokenRegistry: {
55
+ readonly symbol: "USDT";
56
+ readonly address: "0xE7E84B8B4f39C507499c40B4ac199B050e2882d5";
57
+ readonly decimals: 6;
58
+ readonly chainId: number;
59
+ readonly environment: string;
60
+ readonly isMainnet: false;
61
+ readonly isCanonical: true;
62
+ readonly isTestToken: true;
63
+ readonly purpose: "canonical Pharos Atlantic Testnet USDT (Tether USD)";
64
+ readonly docsSource: "https://docs.pharos.xyz/getting-started/token-registry";
65
+ readonly verificationStatus: "DOCS_VERIFIED";
66
+ };
67
+ priceUsd: {
68
+ value: string;
69
+ unit: string;
70
+ };
71
+ priceInPHRS: {
72
+ value: string | null;
73
+ unit: string;
74
+ };
75
+ source: string;
76
+ sourceStatus: string;
77
+ routeAvailable: boolean;
78
+ publicMode: boolean;
79
+ confidence: string;
80
+ chainId: number;
81
+ environment: string;
82
+ isMainnet: boolean;
83
+ }> | import("../lib/toolResponse.js").ToolSuccess<{
84
+ token: string;
85
+ tokenRegistry: {
86
+ readonly symbol: "PHRS";
87
+ readonly address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
88
+ readonly decimals: 18;
89
+ readonly chainId: number;
90
+ readonly environment: string;
91
+ readonly isMainnet: false;
92
+ readonly isCanonical: true;
93
+ readonly isTestToken: true;
94
+ readonly purpose: "native PHRS sentinel address for DODO route API";
95
+ readonly docsSource: "https://docs.pharos.xyz/";
96
+ };
97
+ priceUsd: {
98
+ value: string;
99
+ unit: string;
100
+ };
101
+ priceInPHRS: {
102
+ value: string;
103
+ unit: string;
104
+ };
105
+ source: string;
106
+ sourceStatus: "ok" | "unavailable" | "no_route_available" | "auth_required";
107
+ routeAvailable: boolean;
108
+ publicMode: boolean;
109
+ confidence: string;
110
+ chainId: number;
111
+ environment: string;
112
+ isMainnet: boolean;
113
+ }>>;
114
114
  //# sourceMappingURL=getTokenPrice.d.ts.map
@@ -1,118 +1,118 @@
1
- // ─── Tool: get_token_price ─────────────────────────────────────────────
2
- // Fetches testnet token price from DODO/FaroSwap route quotes.
3
- // ────────────────────────────────────────────────────────────────────────
4
- import { z } from "zod";
5
- import { getDodoRoute } from "../lib/dodoApi.js";
6
- import { CHAIN_ID, PHAROS_ENVIRONMENT, TOKEN_REGISTRY } from "../lib/constants.js";
7
- import { classifyExternalError, fail, ok } from "../lib/toolResponse.js";
8
- export const getTokenPriceSchema = z.object({
9
- token: z.enum(["PHRS", "USDC", "USDT"]).describe("Token to get price for"),
10
- });
11
- export const getTokenPriceTool = {
12
- name: "get_token_price",
13
- description: "Fetch real-time testnet price of PHRS, USDC, or USDT on Pharos using DODO/FaroSwap liquidity quotes.",
14
- inputSchema: getTokenPriceSchema,
15
- };
16
- // Read-only address for price quotes (never signs transactions)
17
- const QUOTE_WALLET = "0x0000000000000000000000000000000000000001";
18
- export async function handleGetTokenPrice(raw) {
19
- const input = getTokenPriceSchema.parse(raw);
20
- try {
21
- if (input.token === "USDC") {
22
- const quote = await getDodoRoute({
23
- fromToken: "USDC",
24
- toToken: "PHRS",
25
- amountHuman: "1",
26
- walletAddress: QUOTE_WALLET,
27
- });
28
- return ok({
29
- token: "USDC",
30
- tokenRegistry: TOKEN_REGISTRY.USDC,
31
- priceUsd: { value: "1.00", unit: "USD" },
32
- priceInPHRS: {
33
- value: quote.routeAvailable ? parseFloat(quote.amountOut).toFixed(6) : null,
34
- unit: "PHRS",
35
- },
36
- source: "DODO Route API / FaroSwap liquidity on Pharos testnet",
37
- sourceStatus: quote.sourceStatus,
38
- routeAvailable: quote.routeAvailable,
39
- publicMode: !quote.usedApiKey,
40
- confidence: quote.routeAvailable ? "medium" : "low",
41
- chainId: CHAIN_ID,
42
- environment: PHAROS_ENVIRONMENT,
43
- isMainnet: false,
44
- });
45
- }
46
- if (input.token === "USDT") {
47
- const usdQuote = await getDodoRoute({
48
- fromToken: "USDT",
49
- toToken: "USDC",
50
- amountHuman: "1",
51
- walletAddress: QUOTE_WALLET,
52
- });
53
- const phrsQuote = await getDodoRoute({
54
- fromToken: "USDT",
55
- toToken: "PHRS",
56
- amountHuman: "1",
57
- walletAddress: QUOTE_WALLET,
58
- });
59
- return ok({
60
- token: "USDT",
61
- tokenRegistry: TOKEN_REGISTRY.USDT,
62
- priceUsd: {
63
- value: usdQuote.routeAvailable ? parseFloat(usdQuote.amountOut).toFixed(4) : "~1.00",
64
- unit: "USD",
65
- },
66
- priceInPHRS: {
67
- value: phrsQuote.routeAvailable ? parseFloat(phrsQuote.amountOut).toFixed(6) : null,
68
- unit: "PHRS",
69
- },
70
- source: "DODO Route API / FaroSwap liquidity on Pharos testnet",
71
- sourceStatus: usdQuote.routeAvailable && phrsQuote.routeAvailable ? "ok" : usdQuote.routeAvailable || phrsQuote.routeAvailable ? "partial" : "no_route_available",
72
- routeAvailable: usdQuote.routeAvailable || phrsQuote.routeAvailable,
73
- publicMode: !usdQuote.usedApiKey && !phrsQuote.usedApiKey,
74
- confidence: usdQuote.routeAvailable && phrsQuote.routeAvailable ? "medium" : "low",
75
- chainId: CHAIN_ID,
76
- environment: PHAROS_ENVIRONMENT,
77
- isMainnet: false,
78
- });
79
- }
80
- const usdcQuote = await getDodoRoute({
81
- fromToken: "PHRS",
82
- toToken: "USDC",
83
- amountHuman: "1",
84
- walletAddress: QUOTE_WALLET,
85
- });
86
- if (!usdcQuote.routeAvailable) {
87
- return fail("NO_ROUTE_AVAILABLE", "No PHRS -> USDC route is available for price discovery.", true, "dodo_api");
88
- }
89
- return ok({
90
- token: "PHRS",
91
- tokenRegistry: TOKEN_REGISTRY.PHRS,
92
- priceUsd: { value: parseFloat(usdcQuote.amountOut).toFixed(4), unit: "USD" },
93
- priceInPHRS: { value: "1.000000", unit: "PHRS" },
94
- source: "DODO Route API / FaroSwap liquidity on Pharos testnet",
95
- sourceStatus: usdcQuote.sourceStatus,
96
- routeAvailable: true,
97
- publicMode: !usdcQuote.usedApiKey,
98
- confidence: "medium",
99
- chainId: CHAIN_ID,
100
- environment: PHAROS_ENVIRONMENT,
101
- isMainnet: false,
102
- });
103
- }
104
- catch (err) {
105
- const message = err instanceof Error ? err.message : String(err);
106
- if (message.includes("DODO_API_AUTH_REQUIRED")) {
107
- return fail("DODO_API_AUTH_REQUIRED", "DODO/FaroSwap route API rejected public mode. Configure DODO_API_KEY only if this endpoint requires authenticated access.", false, "dodo_api");
108
- }
109
- if (message.includes("DODO_API_RATE_LIMITED")) {
110
- return fail("DODO_API_RATE_LIMITED", message, true, "dodo_api");
111
- }
112
- if (message.includes("INVALID_TOKEN_ADDRESS")) {
113
- return fail("INVALID_TOKEN_ADDRESS", message, false, "dodo_api");
114
- }
115
- return classifyExternalError("dodo_api", err);
116
- }
117
- }
1
+ // ─── Tool: get_token_price ─────────────────────────────────────────────
2
+ // Fetches testnet token price from DODO/FaroSwap route quotes.
3
+ // ────────────────────────────────────────────────────────────────────────
4
+ import { z } from "zod";
5
+ import { getDodoRoute } from "../lib/dodoApi.js";
6
+ import { CHAIN_ID, PHAROS_ENVIRONMENT, TOKEN_REGISTRY } from "../lib/constants.js";
7
+ import { classifyExternalError, fail, ok } from "../lib/toolResponse.js";
8
+ export const getTokenPriceSchema = z.object({
9
+ token: z.enum(["PHRS", "USDC", "USDT"]).describe("Token to get price for"),
10
+ });
11
+ export const getTokenPriceTool = {
12
+ name: "get_token_price",
13
+ description: "Fetch real-time testnet price of PHRS, USDC, or USDT on Pharos using DODO/FaroSwap liquidity quotes.",
14
+ inputSchema: getTokenPriceSchema,
15
+ };
16
+ // Read-only address for price quotes (never signs transactions)
17
+ const QUOTE_WALLET = "0x0000000000000000000000000000000000000001";
18
+ export async function handleGetTokenPrice(raw) {
19
+ const input = getTokenPriceSchema.parse(raw);
20
+ try {
21
+ if (input.token === "USDC") {
22
+ const quote = await getDodoRoute({
23
+ fromToken: "USDC",
24
+ toToken: "PHRS",
25
+ amountHuman: "1",
26
+ walletAddress: QUOTE_WALLET,
27
+ });
28
+ return ok({
29
+ token: "USDC",
30
+ tokenRegistry: TOKEN_REGISTRY.USDC,
31
+ priceUsd: { value: "1.00", unit: "USD" },
32
+ priceInPHRS: {
33
+ value: quote.routeAvailable ? parseFloat(quote.amountOut).toFixed(6) : null,
34
+ unit: "PHRS",
35
+ },
36
+ source: "DODO Route API / FaroSwap liquidity on Pharos testnet",
37
+ sourceStatus: quote.sourceStatus,
38
+ routeAvailable: quote.routeAvailable,
39
+ publicMode: !quote.usedApiKey,
40
+ confidence: quote.routeAvailable ? "medium" : "low",
41
+ chainId: CHAIN_ID,
42
+ environment: PHAROS_ENVIRONMENT,
43
+ isMainnet: false,
44
+ });
45
+ }
46
+ if (input.token === "USDT") {
47
+ const usdQuote = await getDodoRoute({
48
+ fromToken: "USDT",
49
+ toToken: "USDC",
50
+ amountHuman: "1",
51
+ walletAddress: QUOTE_WALLET,
52
+ });
53
+ const phrsQuote = await getDodoRoute({
54
+ fromToken: "USDT",
55
+ toToken: "PHRS",
56
+ amountHuman: "1",
57
+ walletAddress: QUOTE_WALLET,
58
+ });
59
+ return ok({
60
+ token: "USDT",
61
+ tokenRegistry: TOKEN_REGISTRY.USDT,
62
+ priceUsd: {
63
+ value: usdQuote.routeAvailable ? parseFloat(usdQuote.amountOut).toFixed(4) : "~1.00",
64
+ unit: "USD",
65
+ },
66
+ priceInPHRS: {
67
+ value: phrsQuote.routeAvailable ? parseFloat(phrsQuote.amountOut).toFixed(6) : null,
68
+ unit: "PHRS",
69
+ },
70
+ source: "DODO Route API / FaroSwap liquidity on Pharos testnet",
71
+ sourceStatus: usdQuote.routeAvailable && phrsQuote.routeAvailable ? "ok" : usdQuote.routeAvailable || phrsQuote.routeAvailable ? "partial" : "no_route_available",
72
+ routeAvailable: usdQuote.routeAvailable || phrsQuote.routeAvailable,
73
+ publicMode: !usdQuote.usedApiKey && !phrsQuote.usedApiKey,
74
+ confidence: usdQuote.routeAvailable && phrsQuote.routeAvailable ? "medium" : "low",
75
+ chainId: CHAIN_ID,
76
+ environment: PHAROS_ENVIRONMENT,
77
+ isMainnet: false,
78
+ });
79
+ }
80
+ const usdcQuote = await getDodoRoute({
81
+ fromToken: "PHRS",
82
+ toToken: "USDC",
83
+ amountHuman: "1",
84
+ walletAddress: QUOTE_WALLET,
85
+ });
86
+ if (!usdcQuote.routeAvailable) {
87
+ return fail("NO_ROUTE_AVAILABLE", "No PHRS -> USDC route is available for price discovery.", true, "dodo_api");
88
+ }
89
+ return ok({
90
+ token: "PHRS",
91
+ tokenRegistry: TOKEN_REGISTRY.PHRS,
92
+ priceUsd: { value: parseFloat(usdcQuote.amountOut).toFixed(4), unit: "USD" },
93
+ priceInPHRS: { value: "1.000000", unit: "PHRS" },
94
+ source: "DODO Route API / FaroSwap liquidity on Pharos testnet",
95
+ sourceStatus: usdcQuote.sourceStatus,
96
+ routeAvailable: true,
97
+ publicMode: !usdcQuote.usedApiKey,
98
+ confidence: "medium",
99
+ chainId: CHAIN_ID,
100
+ environment: PHAROS_ENVIRONMENT,
101
+ isMainnet: false,
102
+ });
103
+ }
104
+ catch (err) {
105
+ const message = err instanceof Error ? err.message : String(err);
106
+ if (message.includes("DODO_API_AUTH_REQUIRED")) {
107
+ return fail("DODO_API_AUTH_REQUIRED", "DODO/FaroSwap route API rejected public mode. Configure DODO_API_KEY only if this endpoint requires authenticated access.", false, "dodo_api");
108
+ }
109
+ if (message.includes("DODO_API_RATE_LIMITED")) {
110
+ return fail("DODO_API_RATE_LIMITED", message, true, "dodo_api");
111
+ }
112
+ if (message.includes("INVALID_TOKEN_ADDRESS")) {
113
+ return fail("INVALID_TOKEN_ADDRESS", message, false, "dodo_api");
114
+ }
115
+ return classifyExternalError("dodo_api", err);
116
+ }
117
+ }
118
118
  //# sourceMappingURL=getTokenPrice.js.map
@@ -1,44 +1,44 @@
1
- import { z } from "zod";
2
- export declare const getTransactionStatusSchema: z.ZodObject<{
3
- txHash: z.ZodString;
4
- }, "strip", z.ZodTypeAny, {
5
- txHash: string;
6
- }, {
7
- txHash: string;
8
- }>;
9
- export type GetTransactionStatusInput = z.input<typeof getTransactionStatusSchema>;
10
- export declare const getTransactionStatusTool: {
11
- name: string;
12
- description: string;
13
- inputSchema: z.ZodObject<{
14
- txHash: z.ZodString;
15
- }, "strip", z.ZodTypeAny, {
16
- txHash: string;
17
- }, {
18
- txHash: string;
19
- }>;
20
- };
21
- export declare function handleGetTransactionStatus(raw: GetTransactionStatusInput): Promise<import("../lib/toolResponse.js").ToolFailure | import("../lib/toolResponse.js").ToolSuccess<{
22
- txStatus: string;
23
- txHash: string;
24
- blockNumber: string;
25
- blockHash: `0x${string}`;
26
- from: `0x${string}`;
27
- to: `0x${string}` | null;
28
- gasUsed: string;
29
- effectiveGasPrice: string;
30
- value: string;
31
- explorerUrl: string;
32
- }> | import("../lib/toolResponse.js").ToolSuccess<{
33
- txHash: string;
34
- txStatus: "pending";
35
- blockNumber: null;
36
- blockHash: null;
37
- from: `0x${string}`;
38
- to: `0x${string}` | null;
39
- gasUsed: null;
40
- effectiveGasPrice: null;
41
- value: string;
42
- explorerUrl: string;
43
- }>>;
1
+ import { z } from "zod";
2
+ export declare const getTransactionStatusSchema: z.ZodObject<{
3
+ txHash: z.ZodString;
4
+ }, "strip", z.ZodTypeAny, {
5
+ txHash: string;
6
+ }, {
7
+ txHash: string;
8
+ }>;
9
+ export type GetTransactionStatusInput = z.input<typeof getTransactionStatusSchema>;
10
+ export declare const getTransactionStatusTool: {
11
+ name: string;
12
+ description: string;
13
+ inputSchema: z.ZodObject<{
14
+ txHash: z.ZodString;
15
+ }, "strip", z.ZodTypeAny, {
16
+ txHash: string;
17
+ }, {
18
+ txHash: string;
19
+ }>;
20
+ };
21
+ export declare function handleGetTransactionStatus(raw: GetTransactionStatusInput): Promise<import("../lib/toolResponse.js").ToolFailure | import("../lib/toolResponse.js").ToolSuccess<{
22
+ txStatus: string;
23
+ txHash: string;
24
+ blockNumber: string;
25
+ blockHash: `0x${string}`;
26
+ from: `0x${string}`;
27
+ to: `0x${string}` | null;
28
+ gasUsed: string;
29
+ effectiveGasPrice: string;
30
+ value: string;
31
+ explorerUrl: string;
32
+ }> | import("../lib/toolResponse.js").ToolSuccess<{
33
+ txHash: string;
34
+ txStatus: "pending";
35
+ blockNumber: null;
36
+ blockHash: null;
37
+ from: `0x${string}`;
38
+ to: `0x${string}` | null;
39
+ gasUsed: null;
40
+ effectiveGasPrice: null;
41
+ value: string;
42
+ explorerUrl: string;
43
+ }>>;
44
44
  //# sourceMappingURL=getTransactionStatus.d.ts.map