safehands-pharos 1.2.6 → 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.
- package/.env.example +64 -26
- package/README.md +333 -445
- package/dist/cli.d.ts +5 -5
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +124 -98
- 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.js +138 -87
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +1 -1
- package/dist/init.js +65 -65
- package/dist/lib/auditLog.d.ts +9 -0
- package/dist/lib/auditLog.d.ts.map +1 -0
- package/dist/lib/auditLog.js +30 -0
- package/dist/lib/auditLog.js.map +1 -0
- package/dist/lib/constants.d.ts +291 -291
- package/dist/lib/constants.js +292 -292
- package/dist/lib/dodoApi.d.ts +78 -70
- package/dist/lib/dodoApi.d.ts.map +1 -1
- package/dist/lib/dodoApi.js +196 -178
- package/dist/lib/dodoApi.js.map +1 -1
- 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.d.ts.map +1 -1
- package/dist/lib/pharosClient.js +63 -53
- package/dist/lib/pharosClient.js.map +1 -1
- package/dist/lib/policy/actionPolicyEngine.d.ts +53 -53
- package/dist/lib/policy/actionPolicyEngine.js +212 -212
- package/dist/lib/policy/actionPolicyEngine.js.map +1 -1
- package/dist/lib/riskEngine.d.ts +26 -26
- package/dist/lib/riskEngine.js +283 -283
- package/dist/lib/signer/index.d.ts +24 -24
- package/dist/lib/signer/index.d.ts.map +1 -1
- package/dist/lib/signer/index.js +88 -89
- package/dist/lib/signer/index.js.map +1 -1
- package/dist/lib/spendAccumulator.d.ts +10 -0
- package/dist/lib/spendAccumulator.d.ts.map +1 -0
- package/dist/lib/spendAccumulator.js +54 -0
- package/dist/lib/spendAccumulator.js.map +1 -0
- 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/testRpc.d.ts +1 -1
- package/dist/lib/testRpc.js +29 -29
- package/dist/lib/testRpcLive.d.ts +1 -1
- package/dist/lib/testRpcLive.js +88 -88
- package/dist/lib/testTools.d.ts +1 -1
- package/dist/lib/testTools.js +397 -397
- 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 -18
- package/dist/lib/wallet/index.d.ts.map +1 -1
- package/dist/lib/wallet/index.js +128 -70
- package/dist/lib/wallet/index.js.map +1 -1
- 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 -46
- package/dist/tools/approveToken.d.ts.map +1 -1
- package/dist/tools/approveToken.js +85 -83
- package/dist/tools/approveToken.js.map +1 -1
- package/dist/tools/assessRisk.d.ts +79 -79
- package/dist/tools/assessRisk.d.ts.map +1 -1
- package/dist/tools/assessRisk.js +104 -93
- package/dist/tools/assessRisk.js.map +1 -1
- package/dist/tools/checkAllowance.d.ts +43 -36
- package/dist/tools/checkAllowance.d.ts.map +1 -1
- package/dist/tools/checkAllowance.js +56 -42
- package/dist/tools/checkAllowance.js.map +1 -1
- package/dist/tools/checkTokenSecurity.d.ts +46 -46
- package/dist/tools/checkTokenSecurity.d.ts.map +1 -1
- package/dist/tools/checkTokenSecurity.js +95 -88
- package/dist/tools/checkTokenSecurity.js.map +1 -1
- package/dist/tools/createAgentWallet.d.ts +26 -26
- package/dist/tools/createAgentWallet.d.ts.map +1 -1
- package/dist/tools/createAgentWallet.js +58 -59
- 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 -59
- package/dist/tools/executeSwap.d.ts.map +1 -1
- package/dist/tools/executeSwap.js +141 -129
- package/dist/tools/executeSwap.js.map +1 -1
- 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 -51
- package/dist/tools/getExecutionHistory.d.ts.map +1 -1
- package/dist/tools/getExecutionHistory.js +154 -93
- package/dist/tools/getExecutionHistory.js.map +1 -1
- 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 -57
- package/dist/tools/getTransactionStatus.d.ts.map +1 -1
- package/dist/tools/getTransactionStatus.js +59 -67
- package/dist/tools/getTransactionStatus.js.map +1 -1
- 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.d.ts.map +1 -1
- package/dist/tools/publishRiskScore.js +88 -85
- package/dist/tools/publishRiskScore.js.map +1 -1
- package/dist/tools/queryRiskRegistry.d.ts +38 -48
- package/dist/tools/queryRiskRegistry.d.ts.map +1 -1
- package/dist/tools/queryRiskRegistry.js +55 -60
- package/dist/tools/queryRiskRegistry.js.map +1 -1
- 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.d.ts.map +1 -1
- package/dist/tools/safehandsSafeExecute.js +81 -75
- package/dist/tools/safehandsSafeExecute.js.map +1 -1
- 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 -58
- package/dist/tools/sendPayment.d.ts.map +1 -1
- package/dist/tools/sendPayment.js +117 -108
- package/dist/tools/sendPayment.js.map +1 -1
- package/dist/tools/simulateTransaction.d.ts +60 -81
- package/dist/tools/simulateTransaction.d.ts.map +1 -1
- package/dist/tools/simulateTransaction.js +83 -88
- package/dist/tools/simulateTransaction.js.map +1 -1
- 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.d.ts.map +1 -1
- package/dist/tools/x402PayAndFetch.js +152 -149
- package/dist/tools/x402PayAndFetch.js.map +1 -1
- package/dist/x402Server.d.ts +1 -1
- package/dist/x402Server.js +252 -252
- package/examples/dashboard/index.html +337 -0
- package/package.json +83 -82
- package/skill/SKILL.md +133 -133
package/dist/lib/constants.js
CHANGED
|
@@ -1,293 +1,293 @@
|
|
|
1
|
-
// ─── SafeHands Constants ───────────────────────────────────────────────
|
|
2
|
-
// Pharos Atlantic Testnet defaults. Values are labeled as testnet-only.
|
|
3
|
-
// Official references reviewed during QA:
|
|
4
|
-
// - Pharos Hardhat guide: Atlantic Testnet chain ID 688689, RPC https://atlantic.dplabs-internal.com
|
|
5
|
-
// - Official Pharos Skill Engine tokens.json: USDC = 0xE0BE08c77f415F577A1B3A9aD7a1Df1479564ec8
|
|
6
|
-
// - Circle USDC contract addresses page: Pharos Testnet = 0xcfC8330f4BCAB529c625D12781b1C19466A9Fc8B
|
|
7
|
-
// - For Pharos Skill Engine compatibility, SafeHands defaults to the Skill Engine token list.
|
|
8
|
-
// ────────────────────────────────────────────────────────────────────────
|
|
9
|
-
// ─── Network ───────────────────────────────────────────────────────────
|
|
10
|
-
export const PHAROS_ENVIRONMENT = process.env.PHAROS_ENVIRONMENT || "atlantic-testnet";
|
|
11
|
-
export const CHAIN_ID = Number(process.env.PHAROS_CHAIN_ID || "688689");
|
|
12
|
-
export const RPC_URL = process.env.PHAROS_RPC_URL || "https://atlantic.dplabs-internal.com/";
|
|
13
|
-
export const EXPLORER_BASE = process.env.PHAROS_EXPLORER_BASE || "https://atlantic.pharosscan.xyz/tx/";
|
|
14
|
-
export const IS_MAINNET = false;
|
|
15
|
-
export const CHAIN_REGISTRY = {
|
|
16
|
-
pharosAtlanticTestnet: {
|
|
17
|
-
environment: "atlantic-testnet",
|
|
18
|
-
chainId: 688689,
|
|
19
|
-
isMainnet: false,
|
|
20
|
-
rpcUrlEnv: "PHAROS_RPC_URL",
|
|
21
|
-
defaultRpcUrl: "https://atlantic.dplabs-internal.com/",
|
|
22
|
-
explorerUrl: "https://atlantic.pharosscan.xyz/",
|
|
23
|
-
docsSource: "https://docs.pharosnetwork.xyz/developer-guide/hardhat/write-your-first-nft",
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
// ─── Token Addresses ───────────────────────────────────────────────────
|
|
27
|
-
// The official Pharos Skill Engine (pharos-skill-engine-0.1.0) assets/tokens.json
|
|
28
|
-
// lists 0xE0BE... as USDC for atlantic-testnet.
|
|
29
|
-
// Circle's USDC contract addresses page lists 0xcfC8... for Pharos Testnet.
|
|
30
|
-
// For Skill Engine hackathon compatibility, SafeHands defaults to the Skill Engine list.
|
|
31
|
-
// Both addresses are documented; neither is deleted.
|
|
32
|
-
/** Native PHRS — sentinel address used by DODO API for native token */
|
|
33
|
-
export const PHRS_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
34
|
-
export const USDT_ADDRESS = "0xE7E84B8B4f39C507499c40B4ac199B050e2882d5";
|
|
35
|
-
/** Primary USDC for Pharos Skill Engine (from official tokens.json) */
|
|
36
|
-
export const USDC_ADDRESS = "0xE0BE08c77f415F577A1B3A9aD7a1Df1479564ec8";
|
|
37
|
-
/** Alternate USDC listed by Circle's contract addresses page (not in Skill Engine tokens.json) */
|
|
38
|
-
export const CIRCLE_USDC_ADDRESS = "0xcfC8330f4BCAB529c625D12781b1C19466A9Fc8B";
|
|
39
|
-
/** @deprecated Use USDC_ADDRESS instead. Kept for backward compatibility. */
|
|
40
|
-
export const X402_DEMO_USDC_ADDRESS = USDC_ADDRESS;
|
|
41
|
-
export const TEST_USDC_ADDRESS = USDC_ADDRESS;
|
|
42
|
-
export const WBTC_ADDRESS = "0x0c64F03EEa5c30946D5c55B4b532D08ad74638a4";
|
|
43
|
-
export const WETH_ADDRESS = "0x7d211F77525ea39A0592794f793cC1036eEaccD5";
|
|
44
|
-
export const WPHRS_ADDRESS = "0x838800b758277CC111B2d48Ab01e5E164f8E9471";
|
|
45
|
-
export const TOKEN_REGISTRY = {
|
|
46
|
-
PHRS: {
|
|
47
|
-
symbol: "PHRS",
|
|
48
|
-
address: PHRS_ADDRESS,
|
|
49
|
-
decimals: 18,
|
|
50
|
-
chainId: CHAIN_ID,
|
|
51
|
-
environment: PHAROS_ENVIRONMENT,
|
|
52
|
-
isMainnet: false,
|
|
53
|
-
isCanonical: true,
|
|
54
|
-
isTestToken: true,
|
|
55
|
-
purpose: "native PHRS sentinel address for DODO route API",
|
|
56
|
-
docsSource: "https://docs.pharos.xyz/",
|
|
57
|
-
},
|
|
58
|
-
USDC: {
|
|
59
|
-
symbol: "USDC",
|
|
60
|
-
address: USDC_ADDRESS,
|
|
61
|
-
decimals: 6,
|
|
62
|
-
chainId: CHAIN_ID,
|
|
63
|
-
environment: PHAROS_ENVIRONMENT,
|
|
64
|
-
isMainnet: false,
|
|
65
|
-
isCanonical: true,
|
|
66
|
-
isTestToken: true,
|
|
67
|
-
purpose: "Pharos Skill Engine USDC — the USDC listed in the official pharos-skill-engine-0.1.0 assets/tokens.json for atlantic-testnet",
|
|
68
|
-
docsSource: "pharos-skill-engine-0.1.0/assets/tokens.json",
|
|
69
|
-
verificationStatus: "DOCS_VERIFIED_FROM_PHAROS_SKILL_ENGINE",
|
|
70
|
-
},
|
|
71
|
-
CIRCLE_USDC: {
|
|
72
|
-
symbol: "CIRCLE_USDC",
|
|
73
|
-
address: CIRCLE_USDC_ADDRESS,
|
|
74
|
-
decimals: 6,
|
|
75
|
-
chainId: CHAIN_ID,
|
|
76
|
-
environment: PHAROS_ENVIRONMENT,
|
|
77
|
-
isMainnet: false,
|
|
78
|
-
isCanonical: true,
|
|
79
|
-
isTestToken: true,
|
|
80
|
-
purpose: "Alternate USDC listed by Circle contract addresses page and Pharos docs token registry; not the primary token in Skill Engine tokens.json",
|
|
81
|
-
docsSource: "https://developers.circle.com/stablecoins/usdc-contract-addresses and https://docs.pharos.xyz/getting-started/token-registry",
|
|
82
|
-
verificationStatus: "CIRCLE_REFERENCED_USDC",
|
|
83
|
-
},
|
|
84
|
-
USDT: {
|
|
85
|
-
symbol: "USDT",
|
|
86
|
-
address: USDT_ADDRESS,
|
|
87
|
-
decimals: 6,
|
|
88
|
-
chainId: CHAIN_ID,
|
|
89
|
-
environment: PHAROS_ENVIRONMENT,
|
|
90
|
-
isMainnet: false,
|
|
91
|
-
isCanonical: true,
|
|
92
|
-
isTestToken: true,
|
|
93
|
-
purpose: "canonical Pharos Atlantic Testnet USDT (Tether USD)",
|
|
94
|
-
docsSource: "https://docs.pharos.xyz/getting-started/token-registry",
|
|
95
|
-
verificationStatus: "DOCS_VERIFIED",
|
|
96
|
-
},
|
|
97
|
-
WBTC: {
|
|
98
|
-
symbol: "WBTC",
|
|
99
|
-
address: WBTC_ADDRESS,
|
|
100
|
-
decimals: 18,
|
|
101
|
-
chainId: CHAIN_ID,
|
|
102
|
-
environment: PHAROS_ENVIRONMENT,
|
|
103
|
-
isMainnet: false,
|
|
104
|
-
isCanonical: true,
|
|
105
|
-
isTestToken: true,
|
|
106
|
-
purpose: "canonical Pharos Atlantic Testnet WBTC (Wrapped BTC)",
|
|
107
|
-
docsSource: "https://docs.pharos.xyz/getting-started/token-registry",
|
|
108
|
-
verificationStatus: "DOCS_VERIFIED",
|
|
109
|
-
},
|
|
110
|
-
WETH: {
|
|
111
|
-
symbol: "WETH",
|
|
112
|
-
address: WETH_ADDRESS,
|
|
113
|
-
decimals: 18,
|
|
114
|
-
chainId: CHAIN_ID,
|
|
115
|
-
environment: PHAROS_ENVIRONMENT,
|
|
116
|
-
isMainnet: false,
|
|
117
|
-
isCanonical: true,
|
|
118
|
-
isTestToken: true,
|
|
119
|
-
purpose: "canonical Pharos Atlantic Testnet WETH (Wrapped ETH)",
|
|
120
|
-
docsSource: "https://docs.pharos.xyz/getting-started/token-registry",
|
|
121
|
-
verificationStatus: "DOCS_VERIFIED",
|
|
122
|
-
},
|
|
123
|
-
WPHRS: {
|
|
124
|
-
symbol: "WPHRS",
|
|
125
|
-
address: WPHRS_ADDRESS,
|
|
126
|
-
decimals: 18,
|
|
127
|
-
chainId: CHAIN_ID,
|
|
128
|
-
environment: PHAROS_ENVIRONMENT,
|
|
129
|
-
isMainnet: false,
|
|
130
|
-
isCanonical: true,
|
|
131
|
-
isTestToken: true,
|
|
132
|
-
purpose: "canonical Pharos Atlantic Testnet WPHRS (Wrapped PHRS)",
|
|
133
|
-
docsSource: "https://docs.pharos.xyz/getting-started/token-registry",
|
|
134
|
-
verificationStatus: "DOCS_VERIFIED",
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
// ─── Token Decimals ────────────────────────────────────────────────────
|
|
138
|
-
export const TOKEN_DECIMALS = {
|
|
139
|
-
PHRS: 18,
|
|
140
|
-
USDT: 6,
|
|
141
|
-
USDC: 6,
|
|
142
|
-
CIRCLE_USDC: 6,
|
|
143
|
-
WBTC: 18,
|
|
144
|
-
WETH: 18,
|
|
145
|
-
WPHRS: 18,
|
|
146
|
-
[PHRS_ADDRESS.toLowerCase()]: 18,
|
|
147
|
-
[USDT_ADDRESS.toLowerCase()]: 6,
|
|
148
|
-
[USDC_ADDRESS.toLowerCase()]: 6,
|
|
149
|
-
[CIRCLE_USDC_ADDRESS.toLowerCase()]: 6,
|
|
150
|
-
[WBTC_ADDRESS.toLowerCase()]: 18,
|
|
151
|
-
[WETH_ADDRESS.toLowerCase()]: 18,
|
|
152
|
-
[WPHRS_ADDRESS.toLowerCase()]: 18,
|
|
153
|
-
};
|
|
154
|
-
// ─── Token Symbol → Address Mapping ────────────────────────────────────
|
|
155
|
-
export const TOKEN_MAP = {
|
|
156
|
-
PHRS: PHRS_ADDRESS,
|
|
157
|
-
USDT: USDT_ADDRESS,
|
|
158
|
-
USDC: USDC_ADDRESS,
|
|
159
|
-
CIRCLE_USDC: CIRCLE_USDC_ADDRESS,
|
|
160
|
-
WBTC: WBTC_ADDRESS,
|
|
161
|
-
WETH: WETH_ADDRESS,
|
|
162
|
-
WPHRS: WPHRS_ADDRESS,
|
|
163
|
-
};
|
|
164
|
-
// ─── FaroSwap / DODO Protocol ──────────────────────────────────────────
|
|
165
|
-
export const DODO_APPROVE_ADDRESS = "0x4Cf317b8918FbE8A890c01eDAb7d548555Ac2cE9";
|
|
166
|
-
export const DODO_ROUTE_PROXY_ADDRESS = "0x819829e5CF6e19F9fED92F6b4CC1edF45a2cC4A2";
|
|
167
|
-
export const POSITION_MANAGER_ADDRESS = "0x1c430d84DD6185b1Ea2d4693e0033799d193542f";
|
|
168
|
-
// ─── DODO API ──────────────────────────────────────────────────────────
|
|
169
|
-
export const DODO_API_BASE = process.env.DODO_API_BASE || "https://api.dodoex.io";
|
|
170
|
-
export const DODO_API_KEY = process.env.DODO_API_KEY;
|
|
171
|
-
export const DODO_DEFAULT_SLIPPAGE = 3.225;
|
|
172
|
-
export const DODO_ROUTE_ENDPOINT = "/route-service/v2/widget/getdodoroute";
|
|
173
|
-
// ─── Risk Engine Thresholds ────────────────────────────────────────────
|
|
174
|
-
export const RISK_BLOCK_THRESHOLD = 80;
|
|
175
|
-
export const RISK_WARN_THRESHOLD = 60;
|
|
176
|
-
export const MAX_SLIPPAGE_PCT = 5;
|
|
177
|
-
export const MAX_BALANCE_USAGE_PCT = 90;
|
|
178
|
-
// ─── Safety Limits ─────────────────────────────────────────────────────
|
|
179
|
-
export const MAX_TX_AMOUNT_PHRS = process.env.MAX_TX_AMOUNT_PHRS || "0.1";
|
|
180
|
-
export const MAX_APPROVAL_AMOUNT_USDC = process.env.MAX_APPROVAL_AMOUNT_USDC || "10";
|
|
181
|
-
export const MAX_DAILY_SPEND_USD = process.env.MAX_DAILY_SPEND_USD || "10";
|
|
182
|
-
export const MAX_X402_PAYMENT_USDC = process.env.MAX_X402_PAYMENT_USDC || "0.01";
|
|
183
|
-
export const X402_PAYMENT_TOKEN_ADDRESS = (process.env.X402_PAYMENT_TOKEN_ADDRESS || USDC_ADDRESS);
|
|
184
|
-
// ─── Risk Weights ──────────────────────────────────────────────────────
|
|
185
|
-
export const RISK_WEIGHTS = {
|
|
186
|
-
liquidityRisk: 0.25,
|
|
187
|
-
slippageRisk: 0.25,
|
|
188
|
-
counterpartyRisk: 0.20,
|
|
189
|
-
balanceRisk: 0.15,
|
|
190
|
-
marketConditionRisk: 0.15,
|
|
191
|
-
};
|
|
192
|
-
// ─── ERC-20 Minimal ABI ────────────────────────────────────────────────
|
|
193
|
-
export const ERC20_ABI = [
|
|
194
|
-
{
|
|
195
|
-
name: "approve",
|
|
196
|
-
type: "function",
|
|
197
|
-
stateMutability: "nonpayable",
|
|
198
|
-
inputs: [
|
|
199
|
-
{ name: "spender", type: "address" },
|
|
200
|
-
{ name: "amount", type: "uint256" },
|
|
201
|
-
],
|
|
202
|
-
outputs: [{ name: "", type: "bool" }],
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
name: "allowance",
|
|
206
|
-
type: "function",
|
|
207
|
-
stateMutability: "view",
|
|
208
|
-
inputs: [
|
|
209
|
-
{ name: "owner", type: "address" },
|
|
210
|
-
{ name: "spender", type: "address" },
|
|
211
|
-
],
|
|
212
|
-
outputs: [{ name: "", type: "uint256" }],
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
name: "balanceOf",
|
|
216
|
-
type: "function",
|
|
217
|
-
stateMutability: "view",
|
|
218
|
-
inputs: [{ name: "account", type: "address" }],
|
|
219
|
-
outputs: [{ name: "", type: "uint256" }],
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
name: "decimals",
|
|
223
|
-
type: "function",
|
|
224
|
-
stateMutability: "view",
|
|
225
|
-
inputs: [],
|
|
226
|
-
outputs: [{ name: "", type: "uint8" }],
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
name: "symbol",
|
|
230
|
-
type: "function",
|
|
231
|
-
stateMutability: "view",
|
|
232
|
-
inputs: [],
|
|
233
|
-
outputs: [{ name: "", type: "string" }],
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
name: "transfer",
|
|
237
|
-
type: "function",
|
|
238
|
-
stateMutability: "nonpayable",
|
|
239
|
-
inputs: [
|
|
240
|
-
{ name: "to", type: "address" },
|
|
241
|
-
{ name: "amount", type: "uint256" },
|
|
242
|
-
],
|
|
243
|
-
outputs: [{ name: "", type: "bool" }],
|
|
244
|
-
},
|
|
245
|
-
];
|
|
246
|
-
// ─── Risk Registry Contract ────────────────────────────────────────────
|
|
247
|
-
export const RISK_REGISTRY_ADDRESS = (process.env.RISK_REGISTRY_ADDRESS ||
|
|
248
|
-
"0x61962a6c812ee9f57b207e1ea47c19ae70bb7141");
|
|
249
|
-
export const RISK_REGISTRY_ABI = [
|
|
250
|
-
{
|
|
251
|
-
name: "publish",
|
|
252
|
-
type: "function",
|
|
253
|
-
stateMutability: "nonpayable",
|
|
254
|
-
inputs: [
|
|
255
|
-
{ name: "wallet", type: "address" },
|
|
256
|
-
{ name: "score", type: "uint256" },
|
|
257
|
-
{ name: "riskLevel", type: "string" },
|
|
258
|
-
{ name: "recommendation", type: "string" },
|
|
259
|
-
],
|
|
260
|
-
outputs: [],
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
name: "query",
|
|
264
|
-
type: "function",
|
|
265
|
-
stateMutability: "view",
|
|
266
|
-
inputs: [{ name: "wallet", type: "address" }],
|
|
267
|
-
outputs: [
|
|
268
|
-
{
|
|
269
|
-
name: "",
|
|
270
|
-
type: "tuple",
|
|
271
|
-
components: [
|
|
272
|
-
{ name: "score", type: "uint256" },
|
|
273
|
-
{ name: "riskLevel", type: "string" },
|
|
274
|
-
{ name: "recommendation", type: "string" },
|
|
275
|
-
{ name: "timestamp", type: "uint256" },
|
|
276
|
-
{ name: "assessedBy", type: "address" },
|
|
277
|
-
],
|
|
278
|
-
},
|
|
279
|
-
],
|
|
280
|
-
},
|
|
281
|
-
{
|
|
282
|
-
anonymous: false,
|
|
283
|
-
name: "RiskPublished",
|
|
284
|
-
type: "event",
|
|
285
|
-
inputs: [
|
|
286
|
-
{ indexed: true, name: "wallet", type: "address" },
|
|
287
|
-
{ indexed: false, name: "score", type: "uint256" },
|
|
288
|
-
{ indexed: false, name: "riskLevel", type: "string" },
|
|
289
|
-
{ indexed: false, name: "assessedBy", type: "address" },
|
|
290
|
-
],
|
|
291
|
-
},
|
|
292
|
-
];
|
|
1
|
+
// ─── SafeHands Constants ───────────────────────────────────────────────
|
|
2
|
+
// Pharos Atlantic Testnet defaults. Values are labeled as testnet-only.
|
|
3
|
+
// Official references reviewed during QA:
|
|
4
|
+
// - Pharos Hardhat guide: Atlantic Testnet chain ID 688689, RPC https://atlantic.dplabs-internal.com
|
|
5
|
+
// - Official Pharos Skill Engine tokens.json: USDC = 0xE0BE08c77f415F577A1B3A9aD7a1Df1479564ec8
|
|
6
|
+
// - Circle USDC contract addresses page: Pharos Testnet = 0xcfC8330f4BCAB529c625D12781b1C19466A9Fc8B
|
|
7
|
+
// - For Pharos Skill Engine compatibility, SafeHands defaults to the Skill Engine token list.
|
|
8
|
+
// ────────────────────────────────────────────────────────────────────────
|
|
9
|
+
// ─── Network ───────────────────────────────────────────────────────────
|
|
10
|
+
export const PHAROS_ENVIRONMENT = process.env.PHAROS_ENVIRONMENT || "atlantic-testnet";
|
|
11
|
+
export const CHAIN_ID = Number(process.env.PHAROS_CHAIN_ID || "688689");
|
|
12
|
+
export const RPC_URL = process.env.PHAROS_RPC_URL || "https://atlantic.dplabs-internal.com/";
|
|
13
|
+
export const EXPLORER_BASE = process.env.PHAROS_EXPLORER_BASE || "https://atlantic.pharosscan.xyz/tx/";
|
|
14
|
+
export const IS_MAINNET = false;
|
|
15
|
+
export const CHAIN_REGISTRY = {
|
|
16
|
+
pharosAtlanticTestnet: {
|
|
17
|
+
environment: "atlantic-testnet",
|
|
18
|
+
chainId: 688689,
|
|
19
|
+
isMainnet: false,
|
|
20
|
+
rpcUrlEnv: "PHAROS_RPC_URL",
|
|
21
|
+
defaultRpcUrl: "https://atlantic.dplabs-internal.com/",
|
|
22
|
+
explorerUrl: "https://atlantic.pharosscan.xyz/",
|
|
23
|
+
docsSource: "https://docs.pharosnetwork.xyz/developer-guide/hardhat/write-your-first-nft",
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
// ─── Token Addresses ───────────────────────────────────────────────────
|
|
27
|
+
// The official Pharos Skill Engine (pharos-skill-engine-0.1.0) assets/tokens.json
|
|
28
|
+
// lists 0xE0BE... as USDC for atlantic-testnet.
|
|
29
|
+
// Circle's USDC contract addresses page lists 0xcfC8... for Pharos Testnet.
|
|
30
|
+
// For Skill Engine hackathon compatibility, SafeHands defaults to the Skill Engine list.
|
|
31
|
+
// Both addresses are documented; neither is deleted.
|
|
32
|
+
/** Native PHRS — sentinel address used by DODO API for native token */
|
|
33
|
+
export const PHRS_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
34
|
+
export const USDT_ADDRESS = "0xE7E84B8B4f39C507499c40B4ac199B050e2882d5";
|
|
35
|
+
/** Primary USDC for Pharos Skill Engine (from official tokens.json) */
|
|
36
|
+
export const USDC_ADDRESS = "0xE0BE08c77f415F577A1B3A9aD7a1Df1479564ec8";
|
|
37
|
+
/** Alternate USDC listed by Circle's contract addresses page (not in Skill Engine tokens.json) */
|
|
38
|
+
export const CIRCLE_USDC_ADDRESS = "0xcfC8330f4BCAB529c625D12781b1C19466A9Fc8B";
|
|
39
|
+
/** @deprecated Use USDC_ADDRESS instead. Kept for backward compatibility. */
|
|
40
|
+
export const X402_DEMO_USDC_ADDRESS = USDC_ADDRESS;
|
|
41
|
+
export const TEST_USDC_ADDRESS = USDC_ADDRESS;
|
|
42
|
+
export const WBTC_ADDRESS = "0x0c64F03EEa5c30946D5c55B4b532D08ad74638a4";
|
|
43
|
+
export const WETH_ADDRESS = "0x7d211F77525ea39A0592794f793cC1036eEaccD5";
|
|
44
|
+
export const WPHRS_ADDRESS = "0x838800b758277CC111B2d48Ab01e5E164f8E9471";
|
|
45
|
+
export const TOKEN_REGISTRY = {
|
|
46
|
+
PHRS: {
|
|
47
|
+
symbol: "PHRS",
|
|
48
|
+
address: PHRS_ADDRESS,
|
|
49
|
+
decimals: 18,
|
|
50
|
+
chainId: CHAIN_ID,
|
|
51
|
+
environment: PHAROS_ENVIRONMENT,
|
|
52
|
+
isMainnet: false,
|
|
53
|
+
isCanonical: true,
|
|
54
|
+
isTestToken: true,
|
|
55
|
+
purpose: "native PHRS sentinel address for DODO route API",
|
|
56
|
+
docsSource: "https://docs.pharos.xyz/",
|
|
57
|
+
},
|
|
58
|
+
USDC: {
|
|
59
|
+
symbol: "USDC",
|
|
60
|
+
address: USDC_ADDRESS,
|
|
61
|
+
decimals: 6,
|
|
62
|
+
chainId: CHAIN_ID,
|
|
63
|
+
environment: PHAROS_ENVIRONMENT,
|
|
64
|
+
isMainnet: false,
|
|
65
|
+
isCanonical: true,
|
|
66
|
+
isTestToken: true,
|
|
67
|
+
purpose: "Pharos Skill Engine USDC — the USDC listed in the official pharos-skill-engine-0.1.0 assets/tokens.json for atlantic-testnet",
|
|
68
|
+
docsSource: "pharos-skill-engine-0.1.0/assets/tokens.json",
|
|
69
|
+
verificationStatus: "DOCS_VERIFIED_FROM_PHAROS_SKILL_ENGINE",
|
|
70
|
+
},
|
|
71
|
+
CIRCLE_USDC: {
|
|
72
|
+
symbol: "CIRCLE_USDC",
|
|
73
|
+
address: CIRCLE_USDC_ADDRESS,
|
|
74
|
+
decimals: 6,
|
|
75
|
+
chainId: CHAIN_ID,
|
|
76
|
+
environment: PHAROS_ENVIRONMENT,
|
|
77
|
+
isMainnet: false,
|
|
78
|
+
isCanonical: true,
|
|
79
|
+
isTestToken: true,
|
|
80
|
+
purpose: "Alternate USDC listed by Circle contract addresses page and Pharos docs token registry; not the primary token in Skill Engine tokens.json",
|
|
81
|
+
docsSource: "https://developers.circle.com/stablecoins/usdc-contract-addresses and https://docs.pharos.xyz/getting-started/token-registry",
|
|
82
|
+
verificationStatus: "CIRCLE_REFERENCED_USDC",
|
|
83
|
+
},
|
|
84
|
+
USDT: {
|
|
85
|
+
symbol: "USDT",
|
|
86
|
+
address: USDT_ADDRESS,
|
|
87
|
+
decimals: 6,
|
|
88
|
+
chainId: CHAIN_ID,
|
|
89
|
+
environment: PHAROS_ENVIRONMENT,
|
|
90
|
+
isMainnet: false,
|
|
91
|
+
isCanonical: true,
|
|
92
|
+
isTestToken: true,
|
|
93
|
+
purpose: "canonical Pharos Atlantic Testnet USDT (Tether USD)",
|
|
94
|
+
docsSource: "https://docs.pharos.xyz/getting-started/token-registry",
|
|
95
|
+
verificationStatus: "DOCS_VERIFIED",
|
|
96
|
+
},
|
|
97
|
+
WBTC: {
|
|
98
|
+
symbol: "WBTC",
|
|
99
|
+
address: WBTC_ADDRESS,
|
|
100
|
+
decimals: 18,
|
|
101
|
+
chainId: CHAIN_ID,
|
|
102
|
+
environment: PHAROS_ENVIRONMENT,
|
|
103
|
+
isMainnet: false,
|
|
104
|
+
isCanonical: true,
|
|
105
|
+
isTestToken: true,
|
|
106
|
+
purpose: "canonical Pharos Atlantic Testnet WBTC (Wrapped BTC)",
|
|
107
|
+
docsSource: "https://docs.pharos.xyz/getting-started/token-registry",
|
|
108
|
+
verificationStatus: "DOCS_VERIFIED",
|
|
109
|
+
},
|
|
110
|
+
WETH: {
|
|
111
|
+
symbol: "WETH",
|
|
112
|
+
address: WETH_ADDRESS,
|
|
113
|
+
decimals: 18,
|
|
114
|
+
chainId: CHAIN_ID,
|
|
115
|
+
environment: PHAROS_ENVIRONMENT,
|
|
116
|
+
isMainnet: false,
|
|
117
|
+
isCanonical: true,
|
|
118
|
+
isTestToken: true,
|
|
119
|
+
purpose: "canonical Pharos Atlantic Testnet WETH (Wrapped ETH)",
|
|
120
|
+
docsSource: "https://docs.pharos.xyz/getting-started/token-registry",
|
|
121
|
+
verificationStatus: "DOCS_VERIFIED",
|
|
122
|
+
},
|
|
123
|
+
WPHRS: {
|
|
124
|
+
symbol: "WPHRS",
|
|
125
|
+
address: WPHRS_ADDRESS,
|
|
126
|
+
decimals: 18,
|
|
127
|
+
chainId: CHAIN_ID,
|
|
128
|
+
environment: PHAROS_ENVIRONMENT,
|
|
129
|
+
isMainnet: false,
|
|
130
|
+
isCanonical: true,
|
|
131
|
+
isTestToken: true,
|
|
132
|
+
purpose: "canonical Pharos Atlantic Testnet WPHRS (Wrapped PHRS)",
|
|
133
|
+
docsSource: "https://docs.pharos.xyz/getting-started/token-registry",
|
|
134
|
+
verificationStatus: "DOCS_VERIFIED",
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
// ─── Token Decimals ────────────────────────────────────────────────────
|
|
138
|
+
export const TOKEN_DECIMALS = {
|
|
139
|
+
PHRS: 18,
|
|
140
|
+
USDT: 6,
|
|
141
|
+
USDC: 6,
|
|
142
|
+
CIRCLE_USDC: 6,
|
|
143
|
+
WBTC: 18,
|
|
144
|
+
WETH: 18,
|
|
145
|
+
WPHRS: 18,
|
|
146
|
+
[PHRS_ADDRESS.toLowerCase()]: 18,
|
|
147
|
+
[USDT_ADDRESS.toLowerCase()]: 6,
|
|
148
|
+
[USDC_ADDRESS.toLowerCase()]: 6,
|
|
149
|
+
[CIRCLE_USDC_ADDRESS.toLowerCase()]: 6,
|
|
150
|
+
[WBTC_ADDRESS.toLowerCase()]: 18,
|
|
151
|
+
[WETH_ADDRESS.toLowerCase()]: 18,
|
|
152
|
+
[WPHRS_ADDRESS.toLowerCase()]: 18,
|
|
153
|
+
};
|
|
154
|
+
// ─── Token Symbol → Address Mapping ────────────────────────────────────
|
|
155
|
+
export const TOKEN_MAP = {
|
|
156
|
+
PHRS: PHRS_ADDRESS,
|
|
157
|
+
USDT: USDT_ADDRESS,
|
|
158
|
+
USDC: USDC_ADDRESS,
|
|
159
|
+
CIRCLE_USDC: CIRCLE_USDC_ADDRESS,
|
|
160
|
+
WBTC: WBTC_ADDRESS,
|
|
161
|
+
WETH: WETH_ADDRESS,
|
|
162
|
+
WPHRS: WPHRS_ADDRESS,
|
|
163
|
+
};
|
|
164
|
+
// ─── FaroSwap / DODO Protocol ──────────────────────────────────────────
|
|
165
|
+
export const DODO_APPROVE_ADDRESS = "0x4Cf317b8918FbE8A890c01eDAb7d548555Ac2cE9";
|
|
166
|
+
export const DODO_ROUTE_PROXY_ADDRESS = "0x819829e5CF6e19F9fED92F6b4CC1edF45a2cC4A2";
|
|
167
|
+
export const POSITION_MANAGER_ADDRESS = "0x1c430d84DD6185b1Ea2d4693e0033799d193542f";
|
|
168
|
+
// ─── DODO API ──────────────────────────────────────────────────────────
|
|
169
|
+
export const DODO_API_BASE = process.env.DODO_API_BASE || "https://api.dodoex.io";
|
|
170
|
+
export const DODO_API_KEY = process.env.DODO_API_KEY;
|
|
171
|
+
export const DODO_DEFAULT_SLIPPAGE = 3.225;
|
|
172
|
+
export const DODO_ROUTE_ENDPOINT = "/route-service/v2/widget/getdodoroute";
|
|
173
|
+
// ─── Risk Engine Thresholds ────────────────────────────────────────────
|
|
174
|
+
export const RISK_BLOCK_THRESHOLD = 80;
|
|
175
|
+
export const RISK_WARN_THRESHOLD = 60;
|
|
176
|
+
export const MAX_SLIPPAGE_PCT = 5;
|
|
177
|
+
export const MAX_BALANCE_USAGE_PCT = 90;
|
|
178
|
+
// ─── Safety Limits ─────────────────────────────────────────────────────
|
|
179
|
+
export const MAX_TX_AMOUNT_PHRS = process.env.MAX_TX_AMOUNT_PHRS || "0.1";
|
|
180
|
+
export const MAX_APPROVAL_AMOUNT_USDC = process.env.MAX_APPROVAL_AMOUNT_USDC || "10";
|
|
181
|
+
export const MAX_DAILY_SPEND_USD = process.env.MAX_DAILY_SPEND_USD || "10";
|
|
182
|
+
export const MAX_X402_PAYMENT_USDC = process.env.MAX_X402_PAYMENT_USDC || "0.01";
|
|
183
|
+
export const X402_PAYMENT_TOKEN_ADDRESS = (process.env.X402_PAYMENT_TOKEN_ADDRESS || USDC_ADDRESS);
|
|
184
|
+
// ─── Risk Weights ──────────────────────────────────────────────────────
|
|
185
|
+
export const RISK_WEIGHTS = {
|
|
186
|
+
liquidityRisk: 0.25,
|
|
187
|
+
slippageRisk: 0.25,
|
|
188
|
+
counterpartyRisk: 0.20,
|
|
189
|
+
balanceRisk: 0.15,
|
|
190
|
+
marketConditionRisk: 0.15,
|
|
191
|
+
};
|
|
192
|
+
// ─── ERC-20 Minimal ABI ────────────────────────────────────────────────
|
|
193
|
+
export const ERC20_ABI = [
|
|
194
|
+
{
|
|
195
|
+
name: "approve",
|
|
196
|
+
type: "function",
|
|
197
|
+
stateMutability: "nonpayable",
|
|
198
|
+
inputs: [
|
|
199
|
+
{ name: "spender", type: "address" },
|
|
200
|
+
{ name: "amount", type: "uint256" },
|
|
201
|
+
],
|
|
202
|
+
outputs: [{ name: "", type: "bool" }],
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: "allowance",
|
|
206
|
+
type: "function",
|
|
207
|
+
stateMutability: "view",
|
|
208
|
+
inputs: [
|
|
209
|
+
{ name: "owner", type: "address" },
|
|
210
|
+
{ name: "spender", type: "address" },
|
|
211
|
+
],
|
|
212
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: "balanceOf",
|
|
216
|
+
type: "function",
|
|
217
|
+
stateMutability: "view",
|
|
218
|
+
inputs: [{ name: "account", type: "address" }],
|
|
219
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
name: "decimals",
|
|
223
|
+
type: "function",
|
|
224
|
+
stateMutability: "view",
|
|
225
|
+
inputs: [],
|
|
226
|
+
outputs: [{ name: "", type: "uint8" }],
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
name: "symbol",
|
|
230
|
+
type: "function",
|
|
231
|
+
stateMutability: "view",
|
|
232
|
+
inputs: [],
|
|
233
|
+
outputs: [{ name: "", type: "string" }],
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
name: "transfer",
|
|
237
|
+
type: "function",
|
|
238
|
+
stateMutability: "nonpayable",
|
|
239
|
+
inputs: [
|
|
240
|
+
{ name: "to", type: "address" },
|
|
241
|
+
{ name: "amount", type: "uint256" },
|
|
242
|
+
],
|
|
243
|
+
outputs: [{ name: "", type: "bool" }],
|
|
244
|
+
},
|
|
245
|
+
];
|
|
246
|
+
// ─── Risk Registry Contract ────────────────────────────────────────────
|
|
247
|
+
export const RISK_REGISTRY_ADDRESS = (process.env.RISK_REGISTRY_ADDRESS ||
|
|
248
|
+
"0x61962a6c812ee9f57b207e1ea47c19ae70bb7141");
|
|
249
|
+
export const RISK_REGISTRY_ABI = [
|
|
250
|
+
{
|
|
251
|
+
name: "publish",
|
|
252
|
+
type: "function",
|
|
253
|
+
stateMutability: "nonpayable",
|
|
254
|
+
inputs: [
|
|
255
|
+
{ name: "wallet", type: "address" },
|
|
256
|
+
{ name: "score", type: "uint256" },
|
|
257
|
+
{ name: "riskLevel", type: "string" },
|
|
258
|
+
{ name: "recommendation", type: "string" },
|
|
259
|
+
],
|
|
260
|
+
outputs: [],
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
name: "query",
|
|
264
|
+
type: "function",
|
|
265
|
+
stateMutability: "view",
|
|
266
|
+
inputs: [{ name: "wallet", type: "address" }],
|
|
267
|
+
outputs: [
|
|
268
|
+
{
|
|
269
|
+
name: "",
|
|
270
|
+
type: "tuple",
|
|
271
|
+
components: [
|
|
272
|
+
{ name: "score", type: "uint256" },
|
|
273
|
+
{ name: "riskLevel", type: "string" },
|
|
274
|
+
{ name: "recommendation", type: "string" },
|
|
275
|
+
{ name: "timestamp", type: "uint256" },
|
|
276
|
+
{ name: "assessedBy", type: "address" },
|
|
277
|
+
],
|
|
278
|
+
},
|
|
279
|
+
],
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
anonymous: false,
|
|
283
|
+
name: "RiskPublished",
|
|
284
|
+
type: "event",
|
|
285
|
+
inputs: [
|
|
286
|
+
{ indexed: true, name: "wallet", type: "address" },
|
|
287
|
+
{ indexed: false, name: "score", type: "uint256" },
|
|
288
|
+
{ indexed: false, name: "riskLevel", type: "string" },
|
|
289
|
+
{ indexed: false, name: "assessedBy", type: "address" },
|
|
290
|
+
],
|
|
291
|
+
},
|
|
292
|
+
];
|
|
293
293
|
//# sourceMappingURL=constants.js.map
|