safehands-pharos 1.3.0 → 1.4.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 (159) hide show
  1. package/.env.example +64 -26
  2. package/README.md +333 -445
  3. package/dist/cli.d.ts +5 -5
  4. package/dist/cli.d.ts.map +1 -1
  5. package/dist/cli.js +124 -98
  6. package/dist/cli.js.map +1 -1
  7. package/dist/demo.d.ts +1 -1
  8. package/dist/demo.js +171 -171
  9. package/dist/index.d.ts +2 -2
  10. package/dist/index.js +138 -85
  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/auditLog.d.ts +9 -0
  15. package/dist/lib/auditLog.d.ts.map +1 -0
  16. package/dist/lib/auditLog.js +30 -0
  17. package/dist/lib/auditLog.js.map +1 -0
  18. package/dist/lib/constants.d.ts +291 -291
  19. package/dist/lib/constants.js +292 -292
  20. package/dist/lib/dodoApi.d.ts +78 -70
  21. package/dist/lib/dodoApi.d.ts.map +1 -1
  22. package/dist/lib/dodoApi.js +196 -178
  23. package/dist/lib/dodoApi.js.map +1 -1
  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.d.ts.map +1 -1
  28. package/dist/lib/pharosClient.js +63 -53
  29. package/dist/lib/pharosClient.js.map +1 -1
  30. package/dist/lib/policy/actionPolicyEngine.d.ts +53 -53
  31. package/dist/lib/policy/actionPolicyEngine.js +212 -212
  32. package/dist/lib/riskEngine.d.ts +26 -26
  33. package/dist/lib/riskEngine.js +283 -283
  34. package/dist/lib/signer/index.d.ts +24 -24
  35. package/dist/lib/signer/index.d.ts.map +1 -1
  36. package/dist/lib/signer/index.js +88 -89
  37. package/dist/lib/signer/index.js.map +1 -1
  38. package/dist/lib/spendAccumulator.d.ts +10 -0
  39. package/dist/lib/spendAccumulator.d.ts.map +1 -0
  40. package/dist/lib/spendAccumulator.js +54 -0
  41. package/dist/lib/spendAccumulator.js.map +1 -0
  42. package/dist/lib/testDodoLive.d.ts +1 -1
  43. package/dist/lib/testDodoLive.js +104 -104
  44. package/dist/lib/testLiveSafehands.d.ts +1 -1
  45. package/dist/lib/testLiveSafehands.js +92 -92
  46. package/dist/lib/testRpc.d.ts +1 -1
  47. package/dist/lib/testRpc.js +29 -29
  48. package/dist/lib/testRpcLive.d.ts +1 -1
  49. package/dist/lib/testRpcLive.js +88 -88
  50. package/dist/lib/testTools.d.ts +1 -1
  51. package/dist/lib/testTools.js +397 -397
  52. package/dist/lib/testX402Live.d.ts +1 -1
  53. package/dist/lib/testX402Live.js +159 -159
  54. package/dist/lib/toolResponse.d.ts +25 -25
  55. package/dist/lib/toolResponse.js +53 -53
  56. package/dist/lib/wallet/index.d.ts +37 -18
  57. package/dist/lib/wallet/index.d.ts.map +1 -1
  58. package/dist/lib/wallet/index.js +128 -70
  59. package/dist/lib/wallet/index.js.map +1 -1
  60. package/dist/scripts/checkDeploy.d.ts +1 -1
  61. package/dist/scripts/checkDeploy.js +24 -24
  62. package/dist/scripts/deployRegistry.d.ts +1 -1
  63. package/dist/scripts/deployRegistry.js +100 -100
  64. package/dist/scripts/testRegistry.d.ts +1 -1
  65. package/dist/scripts/testRegistry.js +43 -43
  66. package/dist/tools/approveToken.d.ts +45 -46
  67. package/dist/tools/approveToken.d.ts.map +1 -1
  68. package/dist/tools/approveToken.js +85 -83
  69. package/dist/tools/approveToken.js.map +1 -1
  70. package/dist/tools/assessRisk.d.ts +79 -79
  71. package/dist/tools/assessRisk.d.ts.map +1 -1
  72. package/dist/tools/assessRisk.js +104 -93
  73. package/dist/tools/assessRisk.js.map +1 -1
  74. package/dist/tools/checkAllowance.d.ts +43 -36
  75. package/dist/tools/checkAllowance.d.ts.map +1 -1
  76. package/dist/tools/checkAllowance.js +56 -42
  77. package/dist/tools/checkAllowance.js.map +1 -1
  78. package/dist/tools/checkTokenSecurity.d.ts +46 -46
  79. package/dist/tools/checkTokenSecurity.d.ts.map +1 -1
  80. package/dist/tools/checkTokenSecurity.js +95 -88
  81. package/dist/tools/checkTokenSecurity.js.map +1 -1
  82. package/dist/tools/createAgentWallet.d.ts +26 -26
  83. package/dist/tools/createAgentWallet.d.ts.map +1 -1
  84. package/dist/tools/createAgentWallet.js +58 -59
  85. package/dist/tools/createAgentWallet.js.map +1 -1
  86. package/dist/tools/estimateGas.d.ts +79 -79
  87. package/dist/tools/estimateGas.js +124 -124
  88. package/dist/tools/executeSwap.d.ts +61 -59
  89. package/dist/tools/executeSwap.d.ts.map +1 -1
  90. package/dist/tools/executeSwap.js +141 -129
  91. package/dist/tools/executeSwap.js.map +1 -1
  92. package/dist/tools/explainRisk.d.ts +29 -29
  93. package/dist/tools/explainRisk.js +32 -32
  94. package/dist/tools/getAgentWallet.d.ts +21 -21
  95. package/dist/tools/getAgentWallet.js +27 -27
  96. package/dist/tools/getAgentWalletBalance.d.ts +11 -11
  97. package/dist/tools/getAgentWalletBalance.js +70 -70
  98. package/dist/tools/getExecutionHistory.d.ts +49 -51
  99. package/dist/tools/getExecutionHistory.d.ts.map +1 -1
  100. package/dist/tools/getExecutionHistory.js +154 -93
  101. package/dist/tools/getExecutionHistory.js.map +1 -1
  102. package/dist/tools/getGasPrice.d.ts +43 -43
  103. package/dist/tools/getGasPrice.js +59 -59
  104. package/dist/tools/getPoolInfo.d.ts +75 -75
  105. package/dist/tools/getPoolInfo.js +137 -137
  106. package/dist/tools/getTokenPrice.d.ts +113 -113
  107. package/dist/tools/getTokenPrice.js +117 -117
  108. package/dist/tools/getTransactionStatus.d.ts +43 -57
  109. package/dist/tools/getTransactionStatus.d.ts.map +1 -1
  110. package/dist/tools/getTransactionStatus.js +59 -67
  111. package/dist/tools/getTransactionStatus.js.map +1 -1
  112. package/dist/tools/getWalletBalance.d.ts +68 -68
  113. package/dist/tools/getWalletBalance.js +87 -87
  114. package/dist/tools/publishRiskScore.d.ts +63 -63
  115. package/dist/tools/publishRiskScore.d.ts.map +1 -1
  116. package/dist/tools/publishRiskScore.js +88 -85
  117. package/dist/tools/publishRiskScore.js.map +1 -1
  118. package/dist/tools/queryRiskRegistry.d.ts +38 -48
  119. package/dist/tools/queryRiskRegistry.d.ts.map +1 -1
  120. package/dist/tools/queryRiskRegistry.js +55 -60
  121. package/dist/tools/queryRiskRegistry.js.map +1 -1
  122. package/dist/tools/safehandsPreflightCheck.d.ts +77 -77
  123. package/dist/tools/safehandsPreflightCheck.js +47 -47
  124. package/dist/tools/safehandsRiskReport.d.ts +81 -81
  125. package/dist/tools/safehandsRiskReport.js +28 -28
  126. package/dist/tools/safehandsSafeExecute.d.ts +20 -20
  127. package/dist/tools/safehandsSafeExecute.d.ts.map +1 -1
  128. package/dist/tools/safehandsSafeExecute.js +81 -75
  129. package/dist/tools/safehandsSafeExecute.js.map +1 -1
  130. package/dist/tools/safehandsWalletHealth.d.ts +14 -14
  131. package/dist/tools/safehandsWalletHealth.js +103 -103
  132. package/dist/tools/safehandsX402Preflight.d.ts +26 -26
  133. package/dist/tools/safehandsX402Preflight.js +65 -65
  134. package/dist/tools/sendPayment.d.ts +57 -58
  135. package/dist/tools/sendPayment.d.ts.map +1 -1
  136. package/dist/tools/sendPayment.js +117 -108
  137. package/dist/tools/sendPayment.js.map +1 -1
  138. package/dist/tools/simulateTransaction.d.ts +60 -81
  139. package/dist/tools/simulateTransaction.d.ts.map +1 -1
  140. package/dist/tools/simulateTransaction.js +83 -88
  141. package/dist/tools/simulateTransaction.js.map +1 -1
  142. package/dist/tools/tokenRegistryStatus.d.ts +26 -26
  143. package/dist/tools/tokenRegistryStatus.js +96 -96
  144. package/dist/tools/x402PayAndFetch.d.ts +81 -81
  145. package/dist/tools/x402PayAndFetch.d.ts.map +1 -1
  146. package/dist/tools/x402PayAndFetch.js +152 -149
  147. package/dist/tools/x402PayAndFetch.js.map +1 -1
  148. package/dist/x402Server.d.ts +1 -1
  149. package/dist/x402Server.js +252 -252
  150. package/examples/dashboard/index.html +337 -0
  151. package/package.json +83 -84
  152. package/.agents/skill/safehands/SKILL.md +0 -212
  153. package/.agents/skill/safehands/assets/networks.json +0 -24
  154. package/.agents/skill/safehands/assets/tokens.json +0 -66
  155. package/.agents/wallets.json +0 -20
  156. package/docs/reports/OFFICIAL_DOCS_ALIGNMENT_REPORT.md +0 -137
  157. package/docs/reports/final_audit_report.md +0 -307
  158. package/docs/reports/live_verification_report.md +0 -147
  159. package/docs/reports/pharos_skill_engine_alignment_report.md +0 -85
@@ -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,58 +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<{
22
- txHash: string;
23
- status: 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
- error?: undefined;
33
- } | {
34
- txHash: string;
35
- status: "pending";
36
- blockNumber: null;
37
- blockHash: null;
38
- from: `0x${string}`;
39
- to: `0x${string}` | null;
40
- gasUsed: null;
41
- effectiveGasPrice: null;
42
- value: string;
43
- explorerUrl: string;
44
- error?: undefined;
45
- } | {
46
- txHash: string;
47
- status: "not_found";
48
- blockNumber: null;
49
- blockHash: null;
50
- from: null;
51
- to: null;
52
- gasUsed: null;
53
- effectiveGasPrice: null;
54
- value: null;
55
- explorerUrl: string;
56
- error: string;
57
- }>;
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
+ }>>;
58
44
  //# sourceMappingURL=getTransactionStatus.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getTransactionStatus.d.ts","sourceRoot":"","sources":["../../src/tools/getTransactionStatus.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,0BAA0B;;;;;;EAErC,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAEnF,eAAO,MAAM,wBAAwB;;;;;;;;;;CAKpC,CAAC;AAEF,wBAAsB,0BAA0B,CAAC,GAAG,EAAE,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqD9E"}
1
+ {"version":3,"file":"getTransactionStatus.d.ts","sourceRoot":"","sources":["../../src/tools/getTransactionStatus.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,0BAA0B;;;;;;EAErC,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAEnF,eAAO,MAAM,wBAAwB;;;;;;;;;;CAKpC,CAAC;AAEF,wBAAsB,0BAA0B,CAAC,GAAG,EAAE,yBAAyB;;;;;;;;;;;;;;;;;;;;;;IA8C9E"}