safehands-pharos 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skill/safehands/SKILL.md +169 -0
- package/LICENSE +21 -0
- package/README.md +382 -0
- package/contracts/RiskRegistry.json +149 -0
- package/contracts/RiskRegistry.sol +30 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +98 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/constants.d.ts +173 -0
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/constants.js +151 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/dodoApi.d.ts +57 -0
- package/dist/lib/dodoApi.d.ts.map +1 -0
- package/dist/lib/dodoApi.js +123 -0
- package/dist/lib/dodoApi.js.map +1 -0
- package/dist/lib/pharosClient.d.ts +58 -0
- package/dist/lib/pharosClient.d.ts.map +1 -0
- package/dist/lib/pharosClient.js +51 -0
- package/dist/lib/pharosClient.js.map +1 -0
- package/dist/lib/riskEngine.d.ts +27 -0
- package/dist/lib/riskEngine.d.ts.map +1 -0
- package/dist/lib/riskEngine.js +284 -0
- package/dist/lib/riskEngine.js.map +1 -0
- package/dist/lib/testRpc.d.ts +2 -0
- package/dist/lib/testRpc.d.ts.map +1 -0
- package/dist/lib/testRpc.js +30 -0
- package/dist/lib/testRpc.js.map +1 -0
- package/dist/lib/testTools.d.ts +2 -0
- package/dist/lib/testTools.d.ts.map +1 -0
- package/dist/lib/testTools.js +263 -0
- package/dist/lib/testTools.js.map +1 -0
- package/dist/scripts/checkDeploy.d.ts +2 -0
- package/dist/scripts/checkDeploy.d.ts.map +1 -0
- package/dist/scripts/checkDeploy.js +25 -0
- package/dist/scripts/checkDeploy.js.map +1 -0
- package/dist/scripts/deployRegistry.d.ts +2 -0
- package/dist/scripts/deployRegistry.d.ts.map +1 -0
- package/dist/scripts/deployRegistry.js +101 -0
- package/dist/scripts/deployRegistry.js.map +1 -0
- package/dist/scripts/testRegistry.d.ts +2 -0
- package/dist/scripts/testRegistry.d.ts.map +1 -0
- package/dist/scripts/testRegistry.js +44 -0
- package/dist/scripts/testRegistry.js.map +1 -0
- package/dist/tools/approveToken.d.ts +60 -0
- package/dist/tools/approveToken.d.ts.map +1 -0
- package/dist/tools/approveToken.js +59 -0
- package/dist/tools/approveToken.js.map +1 -0
- package/dist/tools/assessRisk.d.ts +67 -0
- package/dist/tools/assessRisk.d.ts.map +1 -0
- package/dist/tools/assessRisk.js +71 -0
- package/dist/tools/assessRisk.js.map +1 -0
- package/dist/tools/checkAllowance.d.ts +37 -0
- package/dist/tools/checkAllowance.d.ts.map +1 -0
- package/dist/tools/checkAllowance.js +43 -0
- package/dist/tools/checkAllowance.js.map +1 -0
- package/dist/tools/estimateGas.d.ts +70 -0
- package/dist/tools/estimateGas.d.ts.map +1 -0
- package/dist/tools/estimateGas.js +129 -0
- package/dist/tools/estimateGas.js.map +1 -0
- package/dist/tools/executeSwap.d.ts +94 -0
- package/dist/tools/executeSwap.d.ts.map +1 -0
- package/dist/tools/executeSwap.js +107 -0
- package/dist/tools/executeSwap.js.map +1 -0
- package/dist/tools/getExecutionHistory.d.ts +52 -0
- package/dist/tools/getExecutionHistory.d.ts.map +1 -0
- package/dist/tools/getExecutionHistory.js +94 -0
- package/dist/tools/getExecutionHistory.js.map +1 -0
- package/dist/tools/getGasPrice.d.ts +26 -0
- package/dist/tools/getGasPrice.d.ts.map +1 -0
- package/dist/tools/getGasPrice.js +52 -0
- package/dist/tools/getGasPrice.js.map +1 -0
- package/dist/tools/getPoolInfo.d.ts +88 -0
- package/dist/tools/getPoolInfo.d.ts.map +1 -0
- package/dist/tools/getPoolInfo.js +99 -0
- package/dist/tools/getPoolInfo.js.map +1 -0
- package/dist/tools/getTokenPrice.d.ts +28 -0
- package/dist/tools/getTokenPrice.d.ts.map +1 -0
- package/dist/tools/getTokenPrice.js +79 -0
- package/dist/tools/getTokenPrice.js.map +1 -0
- package/dist/tools/getTransactionStatus.d.ts +58 -0
- package/dist/tools/getTransactionStatus.d.ts.map +1 -0
- package/dist/tools/getTransactionStatus.js +68 -0
- package/dist/tools/getTransactionStatus.js.map +1 -0
- package/dist/tools/getWalletBalance.d.ts +40 -0
- package/dist/tools/getWalletBalance.d.ts.map +1 -0
- package/dist/tools/getWalletBalance.js +71 -0
- package/dist/tools/getWalletBalance.js.map +1 -0
- package/dist/tools/publishRiskScore.d.ts +74 -0
- package/dist/tools/publishRiskScore.d.ts.map +1 -0
- package/dist/tools/publishRiskScore.js +70 -0
- package/dist/tools/publishRiskScore.js.map +1 -0
- package/dist/tools/queryRiskRegistry.d.ts +49 -0
- package/dist/tools/queryRiskRegistry.d.ts.map +1 -0
- package/dist/tools/queryRiskRegistry.js +61 -0
- package/dist/tools/queryRiskRegistry.js.map +1 -0
- package/dist/tools/sendPayment.d.ts +70 -0
- package/dist/tools/sendPayment.d.ts.map +1 -0
- package/dist/tools/sendPayment.js +68 -0
- package/dist/tools/sendPayment.js.map +1 -0
- package/dist/tools/simulateTransaction.d.ts +82 -0
- package/dist/tools/simulateTransaction.d.ts.map +1 -0
- package/dist/tools/simulateTransaction.js +89 -0
- package/dist/tools/simulateTransaction.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
{
|
|
2
|
+
"abi": [
|
|
3
|
+
{
|
|
4
|
+
"anonymous": false,
|
|
5
|
+
"inputs": [
|
|
6
|
+
{
|
|
7
|
+
"indexed": true,
|
|
8
|
+
"internalType": "address",
|
|
9
|
+
"name": "wallet",
|
|
10
|
+
"type": "address"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"indexed": false,
|
|
14
|
+
"internalType": "uint256",
|
|
15
|
+
"name": "score",
|
|
16
|
+
"type": "uint256"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"indexed": false,
|
|
20
|
+
"internalType": "string",
|
|
21
|
+
"name": "riskLevel",
|
|
22
|
+
"type": "string"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"indexed": false,
|
|
26
|
+
"internalType": "address",
|
|
27
|
+
"name": "assessedBy",
|
|
28
|
+
"type": "address"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"name": "RiskPublished",
|
|
32
|
+
"type": "event"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"inputs": [
|
|
36
|
+
{
|
|
37
|
+
"internalType": "address",
|
|
38
|
+
"name": "wallet",
|
|
39
|
+
"type": "address"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"internalType": "uint256",
|
|
43
|
+
"name": "score",
|
|
44
|
+
"type": "uint256"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"internalType": "string",
|
|
48
|
+
"name": "riskLevel",
|
|
49
|
+
"type": "string"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"internalType": "string",
|
|
53
|
+
"name": "recommendation",
|
|
54
|
+
"type": "string"
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"name": "publish",
|
|
58
|
+
"outputs": [],
|
|
59
|
+
"stateMutability": "nonpayable",
|
|
60
|
+
"type": "function"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"inputs": [
|
|
64
|
+
{
|
|
65
|
+
"internalType": "address",
|
|
66
|
+
"name": "wallet",
|
|
67
|
+
"type": "address"
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"name": "query",
|
|
71
|
+
"outputs": [
|
|
72
|
+
{
|
|
73
|
+
"components": [
|
|
74
|
+
{
|
|
75
|
+
"internalType": "uint256",
|
|
76
|
+
"name": "score",
|
|
77
|
+
"type": "uint256"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"internalType": "string",
|
|
81
|
+
"name": "riskLevel",
|
|
82
|
+
"type": "string"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"internalType": "string",
|
|
86
|
+
"name": "recommendation",
|
|
87
|
+
"type": "string"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"internalType": "uint256",
|
|
91
|
+
"name": "timestamp",
|
|
92
|
+
"type": "uint256"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"internalType": "address",
|
|
96
|
+
"name": "assessedBy",
|
|
97
|
+
"type": "address"
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
"internalType": "struct RiskRegistry.RiskRecord",
|
|
101
|
+
"name": "",
|
|
102
|
+
"type": "tuple"
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
"stateMutability": "view",
|
|
106
|
+
"type": "function"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"inputs": [
|
|
110
|
+
{
|
|
111
|
+
"internalType": "address",
|
|
112
|
+
"name": "",
|
|
113
|
+
"type": "address"
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"name": "registry",
|
|
117
|
+
"outputs": [
|
|
118
|
+
{
|
|
119
|
+
"internalType": "uint256",
|
|
120
|
+
"name": "score",
|
|
121
|
+
"type": "uint256"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"internalType": "string",
|
|
125
|
+
"name": "riskLevel",
|
|
126
|
+
"type": "string"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"internalType": "string",
|
|
130
|
+
"name": "recommendation",
|
|
131
|
+
"type": "string"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"internalType": "uint256",
|
|
135
|
+
"name": "timestamp",
|
|
136
|
+
"type": "uint256"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"internalType": "address",
|
|
140
|
+
"name": "assessedBy",
|
|
141
|
+
"type": "address"
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
"stateMutability": "view",
|
|
145
|
+
"type": "function"
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
"bytecode": "0x6080604052348015600e575f5ffd5b5061089e8061001c5f395ff3fe608060405234801561000f575f5ffd5b506004361061003f575f3560e01c8063038defd714610043578063cf78537f14610070578063d4fc9fc614610085575b5f5ffd5b6100566100513660046104f6565b6100a5565b604051610067959493929190610544565b60405180910390f35b61008361007e3660046105d6565b6101e9565b005b6100986100933660046104f6565b610335565b604051610067919061065f565b5f60208190529081526040902080546001820180549192916100c6906106cd565b80601f01602080910402602001604051908101604052809291908181526020018280546100f2906106cd565b801561013d5780601f106101145761010080835404028352916020019161013d565b820191905f5260205f20905b81548152906001019060200180831161012057829003601f168201915b505050505090806002018054610152906106cd565b80601f016020809104026020016040519081016040528092919081815260200182805461017e906106cd565b80156101c95780601f106101a0576101008083540402835291602001916101c9565b820191905f5260205f20905b8154815290600101906020018083116101ac57829003601f168201915b5050505060038301546004909301549192916001600160a01b0316905085565b6040518060a0016040528086815260200185858080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250505090825250604080516020601f8601819004810282018101909252848152918101919085908590819084018382808284375f920182905250938552505042602080850191909152336040948501526001600160a01b038b1683528281529290912083518155918301516001830191506102a69082610765565b50604082015160028201906102bb9082610765565b5060608201516003820155608090910151600490910180546001600160a01b0319166001600160a01b03928316179055604051908716907ff1540e034908b7aedb3f7cc639f04615bf51f301d55b49f7b786fbfc97ba144e90610325908890889088903390610820565b60405180910390a2505050505050565b61036d6040518060a001604052805f815260200160608152602001606081526020015f81526020015f6001600160a01b031681525090565b6001600160a01b0382165f9081526020818152604091829020825160a081019093528054835260018101805491928401916103a7906106cd565b80601f01602080910402602001604051908101604052809291908181526020018280546103d3906106cd565b801561041e5780601f106103f55761010080835404028352916020019161041e565b820191905f5260205f20905b81548152906001019060200180831161040157829003601f168201915b50505050508152602001600282018054610437906106cd565b80601f0160208091040260200160405190810160405280929190818152602001828054610463906106cd565b80156104ae5780601f10610485576101008083540402835291602001916104ae565b820191905f5260205f20905b81548152906001019060200180831161049157829003601f168201915b5050509183525050600382015460208201526004909101546001600160a01b031660409091015292915050565b80356001600160a01b03811681146104f1575f5ffd5b919050565b5f60208284031215610506575f5ffd5b61050f826104db565b9392505050565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b85815260a060208201525f61055c60a0830187610516565b828103604084015261056e8187610516565b606084019590955250506001600160a01b03919091166080909101529392505050565b5f5f83601f8401126105a1575f5ffd5b50813567ffffffffffffffff8111156105b8575f5ffd5b6020830191508360208285010111156105cf575f5ffd5b9250929050565b5f5f5f5f5f5f608087890312156105eb575f5ffd5b6105f4876104db565b955060208701359450604087013567ffffffffffffffff811115610616575f5ffd5b61062289828a01610591565b909550935050606087013567ffffffffffffffff811115610641575f5ffd5b61064d89828a01610591565b979a9699509497509295939492505050565b60208152815160208201525f602083015160a0604084015261068460c0840182610516565b90506040840151601f198483030160608501526106a18282610516565b6060860151608086810191909152909501516001600160a01b031660a090940193909352509192915050565b600181811c908216806106e157607f821691505b6020821081036106ff57634e487b7160e01b5f52602260045260245ffd5b50919050565b634e487b7160e01b5f52604160045260245ffd5b601f82111561076057805f5260205f20601f840160051c8101602085101561073e5750805b601f840160051c820191505b8181101561075d575f815560010161074a565b50505b505050565b815167ffffffffffffffff81111561077f5761077f610705565b6107938161078d84546106cd565b84610719565b6020601f8211600181146107c5575f83156107ae5750848201515b5f19600385901b1c1916600184901b17845561075d565b5f84815260208120601f198516915b828110156107f457878501518255602094850194600190920191016107d4565b508482101561081157868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b84815260606020820152826060820152828460808301375f8184016080908101919091526001600160a01b03929092166040820152601f909201601f1916909101019291505056fea2646970667358221220ac15ca5780878f13b652a2641e23f1af863babde9f1a34b0b732780d086d0d5a64736f6c634300081c0033"
|
|
149
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.20;
|
|
3
|
+
|
|
4
|
+
contract RiskRegistry {
|
|
5
|
+
struct RiskRecord {
|
|
6
|
+
uint256 score;
|
|
7
|
+
string riskLevel;
|
|
8
|
+
string recommendation;
|
|
9
|
+
uint256 timestamp;
|
|
10
|
+
address assessedBy;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
mapping(address => RiskRecord) public registry;
|
|
14
|
+
|
|
15
|
+
event RiskPublished(address indexed wallet, uint256 score, string riskLevel, address assessedBy);
|
|
16
|
+
|
|
17
|
+
function publish(
|
|
18
|
+
address wallet,
|
|
19
|
+
uint256 score,
|
|
20
|
+
string calldata riskLevel,
|
|
21
|
+
string calldata recommendation
|
|
22
|
+
) external {
|
|
23
|
+
registry[wallet] = RiskRecord(score, riskLevel, recommendation, block.timestamp, msg.sender);
|
|
24
|
+
emit RiskPublished(wallet, score, riskLevel, msg.sender);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function query(address wallet) external view returns (RiskRecord memory) {
|
|
28
|
+
return registry[wallet];
|
|
29
|
+
}
|
|
30
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// ─── SafeHands MCP Server ──────────────────────────────────────────────
|
|
3
|
+
// Entry point — registers all 15 tools and starts the MCP server.
|
|
4
|
+
// ────────────────────────────────────────────────────────────────────────
|
|
5
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
|
+
import { assessRiskSchema, handleAssessRisk } from "./tools/assessRisk.js";
|
|
8
|
+
import { executeSwapSchema, handleExecuteSwap } from "./tools/executeSwap.js";
|
|
9
|
+
import { sendPaymentSchema, handleSendPayment } from "./tools/sendPayment.js";
|
|
10
|
+
import { simulateTransactionSchema, handleSimulateTransaction } from "./tools/simulateTransaction.js";
|
|
11
|
+
import { getExecutionHistorySchema, handleGetExecutionHistory } from "./tools/getExecutionHistory.js";
|
|
12
|
+
import { getTokenPriceSchema, handleGetTokenPrice } from "./tools/getTokenPrice.js";
|
|
13
|
+
import { getWalletBalanceSchema, handleGetWalletBalance } from "./tools/getWalletBalance.js";
|
|
14
|
+
import { checkAllowanceSchema, handleCheckAllowance } from "./tools/checkAllowance.js";
|
|
15
|
+
import { getTransactionStatusSchema, handleGetTransactionStatus } from "./tools/getTransactionStatus.js";
|
|
16
|
+
import { estimateGasSchema, handleEstimateGas } from "./tools/estimateGas.js";
|
|
17
|
+
import { publishRiskScoreSchema, handlePublishRiskScore } from "./tools/publishRiskScore.js";
|
|
18
|
+
import { queryRiskRegistrySchema, handleQueryRiskRegistry } from "./tools/queryRiskRegistry.js";
|
|
19
|
+
import { approveTokenSchema, handleApproveToken } from "./tools/approveToken.js";
|
|
20
|
+
import { getGasPriceSchema, handleGetGasPrice } from "./tools/getGasPrice.js";
|
|
21
|
+
import { getPoolInfoSchema, handleGetPoolInfo } from "./tools/getPoolInfo.js";
|
|
22
|
+
// ─── Server Setup ──────────────────────────────────────────────────────
|
|
23
|
+
const server = new McpServer({
|
|
24
|
+
name: "safehands",
|
|
25
|
+
version: "1.0.0",
|
|
26
|
+
});
|
|
27
|
+
// ─── Tool Registration ─────────────────────────────────────────────────
|
|
28
|
+
server.tool("assess_risk", "Evaluate the risk of a planned on-chain action (swap or transfer). Returns 0-100 risk score with 5-dimension breakdown.", assessRiskSchema.shape, async (params) => {
|
|
29
|
+
const result = await handleAssessRisk(params);
|
|
30
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
31
|
+
});
|
|
32
|
+
server.tool("execute_swap", "Swap tokens via FaroSwap with built-in risk gate. Runs risk assessment first, blocks if score > 80.", executeSwapSchema.shape, async (params) => {
|
|
33
|
+
const result = await handleExecuteSwap(params);
|
|
34
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
35
|
+
});
|
|
36
|
+
server.tool("send_payment", "Send native PHRS with pre-flight validation. Checks address, balance, and warns on high exposure.", sendPaymentSchema.shape, async (params) => {
|
|
37
|
+
const result = await handleSendPayment(params);
|
|
38
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
39
|
+
});
|
|
40
|
+
server.tool("simulate_transaction", "Dry run a swap or transfer via eth_call — no gas spent. Returns expected output and revert reasons.", simulateTransactionSchema.shape, async (params) => {
|
|
41
|
+
const result = await handleSimulateTransaction(params);
|
|
42
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
43
|
+
});
|
|
44
|
+
server.tool("get_execution_history", "Pull on-chain transaction history for a wallet. Filters by swap, transfer, or all.", getExecutionHistorySchema.shape, async (params) => {
|
|
45
|
+
const result = await handleGetExecutionHistory(params);
|
|
46
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
47
|
+
});
|
|
48
|
+
server.tool("get_token_price", "Fetch real-time price of PHRS, USDC, or USDT on Pharos using DODO liquidity quotes.", getTokenPriceSchema.shape, async (params) => {
|
|
49
|
+
const result = await handleGetTokenPrice(params);
|
|
50
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
51
|
+
});
|
|
52
|
+
server.tool("get_wallet_balance", "Return PHRS, USDC, USDT balances for a wallet with total USD estimate.", getWalletBalanceSchema.shape, async (params) => {
|
|
53
|
+
const result = await handleGetWalletBalance(params);
|
|
54
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
55
|
+
});
|
|
56
|
+
server.tool("check_allowance", "Check ERC-20 token allowance for DODO swap approval. Returns whether approval is needed.", checkAllowanceSchema.shape, async (params) => {
|
|
57
|
+
const result = await handleCheckAllowance(params);
|
|
58
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
59
|
+
});
|
|
60
|
+
server.tool("get_transaction_status", "Check on-chain transaction status by hash. Returns status, block, gas, and explorer link.", getTransactionStatusSchema.shape, async (params) => {
|
|
61
|
+
const result = await handleGetTransactionStatus(params);
|
|
62
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
63
|
+
});
|
|
64
|
+
server.tool("estimate_gas", "Estimate gas cost for a swap or transfer before executing. Returns cost in PHRS and USD.", estimateGasSchema.shape, async (params) => {
|
|
65
|
+
const result = await handleEstimateGas(params);
|
|
66
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
67
|
+
});
|
|
68
|
+
server.tool("publish_risk_score", "Run risk assessment and publish result to the on-chain RiskRegistry. Other agents can query it.", publishRiskScoreSchema.shape, async (params) => {
|
|
69
|
+
const result = await handlePublishRiskScore(params);
|
|
70
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
71
|
+
});
|
|
72
|
+
server.tool("query_risk_registry", "Query the on-chain RiskRegistry for a wallet's published risk score. Read-only, no private key needed.", queryRiskRegistrySchema.shape, async (params) => {
|
|
73
|
+
const result = await handleQueryRiskRegistry(params);
|
|
74
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
75
|
+
});
|
|
76
|
+
server.tool("approve_token", "Approve ERC-20 token spending for FaroSwap (DODO) router. Required before swapping non-native tokens.", approveTokenSchema.shape, async (params) => {
|
|
77
|
+
const result = await handleApproveToken(params);
|
|
78
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
79
|
+
});
|
|
80
|
+
server.tool("get_gas_price", "Get current gas price on Pharos with trend classification and cost estimates.", getGasPriceSchema.shape, async (params) => {
|
|
81
|
+
const result = await handleGetGasPrice(params);
|
|
82
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
83
|
+
});
|
|
84
|
+
server.tool("get_pool_info", "Fetch DODO liquidity pool info for a token pair on Pharos. Returns price ratio, impact, and fees.", getPoolInfoSchema.shape, async (params) => {
|
|
85
|
+
const result = await handleGetPoolInfo(params);
|
|
86
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
87
|
+
});
|
|
88
|
+
// ─── Start Server ──────────────────────────────────────────────────────
|
|
89
|
+
async function main() {
|
|
90
|
+
const transport = new StdioServerTransport();
|
|
91
|
+
await server.connect(transport);
|
|
92
|
+
console.error("🛡️ SafeHands MCP server running on stdio");
|
|
93
|
+
}
|
|
94
|
+
main().catch((error) => {
|
|
95
|
+
console.error("Fatal error:", error);
|
|
96
|
+
process.exit(1);
|
|
97
|
+
});
|
|
98
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,0EAA0E;AAC1E,kEAAkE;AAClE,2EAA2E;AAE3E,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AACtG,OAAO,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AACtG,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC7F,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACzG,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,wB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AAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
export declare const RPC_URL = "https://atlantic.dplabs-internal.com/";
|
|
2
|
+
export declare const CHAIN_ID = 688689;
|
|
3
|
+
export declare const EXPLORER_BASE = "https://atlantic.pharosscan.xyz/tx/";
|
|
4
|
+
/** Native PHRS — sentinel address used by DODO API for native token */
|
|
5
|
+
export declare const PHRS_ADDRESS: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
6
|
+
export declare const USDT_ADDRESS: "0xE7E84B8B4f39C507499c40B4ac199B050e2882d5";
|
|
7
|
+
export declare const USDC_ADDRESS: "0xE0BE08c77f415F577A1B3A9aD7a1Df1479564ec8";
|
|
8
|
+
export declare const TOKEN_DECIMALS: Record<string, number>;
|
|
9
|
+
export declare const TOKEN_MAP: Record<string, `0x${string}`>;
|
|
10
|
+
export declare const DODO_APPROVE_ADDRESS: "0x4Cf317b8918FbE8A890c01eDAb7d548555Ac2cE9";
|
|
11
|
+
export declare const DODO_ROUTE_PROXY_ADDRESS: "0x819829e5CF6e19F9fED92F6b4CC1edF45a2cC4A2";
|
|
12
|
+
export declare const POSITION_MANAGER_ADDRESS: "0x1c430d84DD6185b1Ea2d4693e0033799d193542f";
|
|
13
|
+
export declare const DODO_API_BASE = "https://api.dodoex.io";
|
|
14
|
+
export declare const DODO_API_KEY = "a37546505892e1a952";
|
|
15
|
+
export declare const DODO_DEFAULT_SLIPPAGE = 3.225;
|
|
16
|
+
export declare const DODO_ROUTE_ENDPOINT = "/route-service/v2/widget/getdodoroute";
|
|
17
|
+
export declare const RISK_BLOCK_THRESHOLD = 80;
|
|
18
|
+
export declare const RISK_WARN_THRESHOLD = 60;
|
|
19
|
+
export declare const MAX_SLIPPAGE_PCT = 5;
|
|
20
|
+
export declare const MAX_BALANCE_USAGE_PCT = 90;
|
|
21
|
+
export declare const RISK_WEIGHTS: {
|
|
22
|
+
readonly liquidityRisk: 0.25;
|
|
23
|
+
readonly slippageRisk: 0.25;
|
|
24
|
+
readonly counterpartyRisk: 0.2;
|
|
25
|
+
readonly balanceRisk: 0.15;
|
|
26
|
+
readonly marketConditionRisk: 0.15;
|
|
27
|
+
};
|
|
28
|
+
export declare const ERC20_ABI: readonly [{
|
|
29
|
+
readonly name: "approve";
|
|
30
|
+
readonly type: "function";
|
|
31
|
+
readonly stateMutability: "nonpayable";
|
|
32
|
+
readonly inputs: readonly [{
|
|
33
|
+
readonly name: "spender";
|
|
34
|
+
readonly type: "address";
|
|
35
|
+
}, {
|
|
36
|
+
readonly name: "amount";
|
|
37
|
+
readonly type: "uint256";
|
|
38
|
+
}];
|
|
39
|
+
readonly outputs: readonly [{
|
|
40
|
+
readonly name: "";
|
|
41
|
+
readonly type: "bool";
|
|
42
|
+
}];
|
|
43
|
+
}, {
|
|
44
|
+
readonly name: "allowance";
|
|
45
|
+
readonly type: "function";
|
|
46
|
+
readonly stateMutability: "view";
|
|
47
|
+
readonly inputs: readonly [{
|
|
48
|
+
readonly name: "owner";
|
|
49
|
+
readonly type: "address";
|
|
50
|
+
}, {
|
|
51
|
+
readonly name: "spender";
|
|
52
|
+
readonly type: "address";
|
|
53
|
+
}];
|
|
54
|
+
readonly outputs: readonly [{
|
|
55
|
+
readonly name: "";
|
|
56
|
+
readonly type: "uint256";
|
|
57
|
+
}];
|
|
58
|
+
}, {
|
|
59
|
+
readonly name: "balanceOf";
|
|
60
|
+
readonly type: "function";
|
|
61
|
+
readonly stateMutability: "view";
|
|
62
|
+
readonly inputs: readonly [{
|
|
63
|
+
readonly name: "account";
|
|
64
|
+
readonly type: "address";
|
|
65
|
+
}];
|
|
66
|
+
readonly outputs: readonly [{
|
|
67
|
+
readonly name: "";
|
|
68
|
+
readonly type: "uint256";
|
|
69
|
+
}];
|
|
70
|
+
}, {
|
|
71
|
+
readonly name: "decimals";
|
|
72
|
+
readonly type: "function";
|
|
73
|
+
readonly stateMutability: "view";
|
|
74
|
+
readonly inputs: readonly [];
|
|
75
|
+
readonly outputs: readonly [{
|
|
76
|
+
readonly name: "";
|
|
77
|
+
readonly type: "uint8";
|
|
78
|
+
}];
|
|
79
|
+
}, {
|
|
80
|
+
readonly name: "symbol";
|
|
81
|
+
readonly type: "function";
|
|
82
|
+
readonly stateMutability: "view";
|
|
83
|
+
readonly inputs: readonly [];
|
|
84
|
+
readonly outputs: readonly [{
|
|
85
|
+
readonly name: "";
|
|
86
|
+
readonly type: "string";
|
|
87
|
+
}];
|
|
88
|
+
}, {
|
|
89
|
+
readonly name: "transfer";
|
|
90
|
+
readonly type: "function";
|
|
91
|
+
readonly stateMutability: "nonpayable";
|
|
92
|
+
readonly inputs: readonly [{
|
|
93
|
+
readonly name: "to";
|
|
94
|
+
readonly type: "address";
|
|
95
|
+
}, {
|
|
96
|
+
readonly name: "amount";
|
|
97
|
+
readonly type: "uint256";
|
|
98
|
+
}];
|
|
99
|
+
readonly outputs: readonly [{
|
|
100
|
+
readonly name: "";
|
|
101
|
+
readonly type: "bool";
|
|
102
|
+
}];
|
|
103
|
+
}];
|
|
104
|
+
export declare const RISK_REGISTRY_ADDRESS: "0x71fc28ed3a31016b42f18764889cd911f22b67b8";
|
|
105
|
+
export declare const RISK_REGISTRY_ABI: readonly [{
|
|
106
|
+
readonly name: "publish";
|
|
107
|
+
readonly type: "function";
|
|
108
|
+
readonly stateMutability: "nonpayable";
|
|
109
|
+
readonly inputs: readonly [{
|
|
110
|
+
readonly name: "wallet";
|
|
111
|
+
readonly type: "address";
|
|
112
|
+
}, {
|
|
113
|
+
readonly name: "score";
|
|
114
|
+
readonly type: "uint256";
|
|
115
|
+
}, {
|
|
116
|
+
readonly name: "riskLevel";
|
|
117
|
+
readonly type: "string";
|
|
118
|
+
}, {
|
|
119
|
+
readonly name: "recommendation";
|
|
120
|
+
readonly type: "string";
|
|
121
|
+
}];
|
|
122
|
+
readonly outputs: readonly [];
|
|
123
|
+
}, {
|
|
124
|
+
readonly name: "query";
|
|
125
|
+
readonly type: "function";
|
|
126
|
+
readonly stateMutability: "view";
|
|
127
|
+
readonly inputs: readonly [{
|
|
128
|
+
readonly name: "wallet";
|
|
129
|
+
readonly type: "address";
|
|
130
|
+
}];
|
|
131
|
+
readonly outputs: readonly [{
|
|
132
|
+
readonly name: "";
|
|
133
|
+
readonly type: "tuple";
|
|
134
|
+
readonly components: readonly [{
|
|
135
|
+
readonly name: "score";
|
|
136
|
+
readonly type: "uint256";
|
|
137
|
+
}, {
|
|
138
|
+
readonly name: "riskLevel";
|
|
139
|
+
readonly type: "string";
|
|
140
|
+
}, {
|
|
141
|
+
readonly name: "recommendation";
|
|
142
|
+
readonly type: "string";
|
|
143
|
+
}, {
|
|
144
|
+
readonly name: "timestamp";
|
|
145
|
+
readonly type: "uint256";
|
|
146
|
+
}, {
|
|
147
|
+
readonly name: "assessedBy";
|
|
148
|
+
readonly type: "address";
|
|
149
|
+
}];
|
|
150
|
+
}];
|
|
151
|
+
}, {
|
|
152
|
+
readonly anonymous: false;
|
|
153
|
+
readonly name: "RiskPublished";
|
|
154
|
+
readonly type: "event";
|
|
155
|
+
readonly inputs: readonly [{
|
|
156
|
+
readonly indexed: true;
|
|
157
|
+
readonly name: "wallet";
|
|
158
|
+
readonly type: "address";
|
|
159
|
+
}, {
|
|
160
|
+
readonly indexed: false;
|
|
161
|
+
readonly name: "score";
|
|
162
|
+
readonly type: "uint256";
|
|
163
|
+
}, {
|
|
164
|
+
readonly indexed: false;
|
|
165
|
+
readonly name: "riskLevel";
|
|
166
|
+
readonly type: "string";
|
|
167
|
+
}, {
|
|
168
|
+
readonly indexed: false;
|
|
169
|
+
readonly name: "assessedBy";
|
|
170
|
+
readonly type: "address";
|
|
171
|
+
}];
|
|
172
|
+
}];
|
|
173
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CpB,CAAC"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// ─── SafeHands Constants ───────────────────────────────────────────────
|
|
2
|
+
// All contract addresses, token configs, and protocol constants for
|
|
3
|
+
// Pharos Atlantic Testnet (Chain ID: 688689)
|
|
4
|
+
// ────────────────────────────────────────────────────────────────────────
|
|
5
|
+
// ─── Network ───────────────────────────────────────────────────────────
|
|
6
|
+
export const RPC_URL = "https://atlantic.dplabs-internal.com/";
|
|
7
|
+
export const CHAIN_ID = 688689;
|
|
8
|
+
export const EXPLORER_BASE = "https://atlantic.pharosscan.xyz/tx/";
|
|
9
|
+
// ─── Token Addresses ───────────────────────────────────────────────────
|
|
10
|
+
/** Native PHRS — sentinel address used by DODO API for native token */
|
|
11
|
+
export const PHRS_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
12
|
+
export const USDT_ADDRESS = "0xE7E84B8B4f39C507499c40B4ac199B050e2882d5";
|
|
13
|
+
export const USDC_ADDRESS = "0xE0BE08c77f415F577A1B3A9aD7a1Df1479564ec8";
|
|
14
|
+
// ─── Token Decimals ────────────────────────────────────────────────────
|
|
15
|
+
export const TOKEN_DECIMALS = {
|
|
16
|
+
PHRS: 18,
|
|
17
|
+
USDT: 6,
|
|
18
|
+
USDC: 6,
|
|
19
|
+
[PHRS_ADDRESS.toLowerCase()]: 18,
|
|
20
|
+
[USDT_ADDRESS.toLowerCase()]: 6,
|
|
21
|
+
[USDC_ADDRESS.toLowerCase()]: 6,
|
|
22
|
+
};
|
|
23
|
+
// ─── Token Symbol → Address Mapping ────────────────────────────────────
|
|
24
|
+
export const TOKEN_MAP = {
|
|
25
|
+
PHRS: PHRS_ADDRESS,
|
|
26
|
+
USDT: USDT_ADDRESS,
|
|
27
|
+
USDC: USDC_ADDRESS,
|
|
28
|
+
};
|
|
29
|
+
// ─── FaroSwap / DODO Protocol ──────────────────────────────────────────
|
|
30
|
+
export const DODO_APPROVE_ADDRESS = "0x4Cf317b8918FbE8A890c01eDAb7d548555Ac2cE9";
|
|
31
|
+
export const DODO_ROUTE_PROXY_ADDRESS = "0x819829e5CF6e19F9fED92F6b4CC1edF45a2cC4A2";
|
|
32
|
+
export const POSITION_MANAGER_ADDRESS = "0x1c430d84DD6185b1Ea2d4693e0033799d193542f";
|
|
33
|
+
// ─── DODO API ──────────────────────────────────────────────────────────
|
|
34
|
+
export const DODO_API_BASE = "https://api.dodoex.io";
|
|
35
|
+
export const DODO_API_KEY = "a37546505892e1a952";
|
|
36
|
+
export const DODO_DEFAULT_SLIPPAGE = 3.225;
|
|
37
|
+
export const DODO_ROUTE_ENDPOINT = "/route-service/v2/widget/getdodoroute";
|
|
38
|
+
// ─── Risk Engine Thresholds ────────────────────────────────────────────
|
|
39
|
+
export const RISK_BLOCK_THRESHOLD = 80;
|
|
40
|
+
export const RISK_WARN_THRESHOLD = 60;
|
|
41
|
+
export const MAX_SLIPPAGE_PCT = 5;
|
|
42
|
+
export const MAX_BALANCE_USAGE_PCT = 90;
|
|
43
|
+
// ─── Risk Weights ──────────────────────────────────────────────────────
|
|
44
|
+
export const RISK_WEIGHTS = {
|
|
45
|
+
liquidityRisk: 0.25,
|
|
46
|
+
slippageRisk: 0.25,
|
|
47
|
+
counterpartyRisk: 0.20,
|
|
48
|
+
balanceRisk: 0.15,
|
|
49
|
+
marketConditionRisk: 0.15,
|
|
50
|
+
};
|
|
51
|
+
// ─── ERC-20 Minimal ABI ────────────────────────────────────────────────
|
|
52
|
+
export const ERC20_ABI = [
|
|
53
|
+
{
|
|
54
|
+
name: "approve",
|
|
55
|
+
type: "function",
|
|
56
|
+
stateMutability: "nonpayable",
|
|
57
|
+
inputs: [
|
|
58
|
+
{ name: "spender", type: "address" },
|
|
59
|
+
{ name: "amount", type: "uint256" },
|
|
60
|
+
],
|
|
61
|
+
outputs: [{ name: "", type: "bool" }],
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "allowance",
|
|
65
|
+
type: "function",
|
|
66
|
+
stateMutability: "view",
|
|
67
|
+
inputs: [
|
|
68
|
+
{ name: "owner", type: "address" },
|
|
69
|
+
{ name: "spender", type: "address" },
|
|
70
|
+
],
|
|
71
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "balanceOf",
|
|
75
|
+
type: "function",
|
|
76
|
+
stateMutability: "view",
|
|
77
|
+
inputs: [{ name: "account", type: "address" }],
|
|
78
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "decimals",
|
|
82
|
+
type: "function",
|
|
83
|
+
stateMutability: "view",
|
|
84
|
+
inputs: [],
|
|
85
|
+
outputs: [{ name: "", type: "uint8" }],
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "symbol",
|
|
89
|
+
type: "function",
|
|
90
|
+
stateMutability: "view",
|
|
91
|
+
inputs: [],
|
|
92
|
+
outputs: [{ name: "", type: "string" }],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "transfer",
|
|
96
|
+
type: "function",
|
|
97
|
+
stateMutability: "nonpayable",
|
|
98
|
+
inputs: [
|
|
99
|
+
{ name: "to", type: "address" },
|
|
100
|
+
{ name: "amount", type: "uint256" },
|
|
101
|
+
],
|
|
102
|
+
outputs: [{ name: "", type: "bool" }],
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
// ─── Risk Registry Contract ────────────────────────────────────────────
|
|
106
|
+
export const RISK_REGISTRY_ADDRESS = "0x71fc28ed3a31016b42f18764889cd911f22b67b8";
|
|
107
|
+
export const RISK_REGISTRY_ABI = [
|
|
108
|
+
{
|
|
109
|
+
name: "publish",
|
|
110
|
+
type: "function",
|
|
111
|
+
stateMutability: "nonpayable",
|
|
112
|
+
inputs: [
|
|
113
|
+
{ name: "wallet", type: "address" },
|
|
114
|
+
{ name: "score", type: "uint256" },
|
|
115
|
+
{ name: "riskLevel", type: "string" },
|
|
116
|
+
{ name: "recommendation", type: "string" },
|
|
117
|
+
],
|
|
118
|
+
outputs: [],
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "query",
|
|
122
|
+
type: "function",
|
|
123
|
+
stateMutability: "view",
|
|
124
|
+
inputs: [{ name: "wallet", type: "address" }],
|
|
125
|
+
outputs: [
|
|
126
|
+
{
|
|
127
|
+
name: "",
|
|
128
|
+
type: "tuple",
|
|
129
|
+
components: [
|
|
130
|
+
{ name: "score", type: "uint256" },
|
|
131
|
+
{ name: "riskLevel", type: "string" },
|
|
132
|
+
{ name: "recommendation", type: "string" },
|
|
133
|
+
{ name: "timestamp", type: "uint256" },
|
|
134
|
+
{ name: "assessedBy", type: "address" },
|
|
135
|
+
],
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
anonymous: false,
|
|
141
|
+
name: "RiskPublished",
|
|
142
|
+
type: "event",
|
|
143
|
+
inputs: [
|
|
144
|
+
{ indexed: true, name: "wallet", type: "address" },
|
|
145
|
+
{ indexed: false, name: "score", type: "uint256" },
|
|
146
|
+
{ indexed: false, name: "riskLevel", type: "string" },
|
|
147
|
+
{ indexed: false, name: "assessedBy", type: "address" },
|
|
148
|
+
],
|
|
149
|
+
},
|
|
150
|
+
];
|
|
151
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,oEAAoE;AACpE,6CAA6C;AAC7C,2EAA2E;AAE3E,0EAA0E;AAE1E,MAAM,CAAC,MAAM,OAAO,GAAG,uCAAuC,CAAC;AAC/D,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC;AAC/B,MAAM,CAAC,MAAM,aAAa,GA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