dexe-mcp 0.5.8 → 0.6.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/CHANGELOG.md +641 -536
- package/README.md +289 -270
- package/SECURITY.md +96 -46
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +60 -0
- package/dist/config.js.map +1 -1
- package/dist/governor/adapter.d.ts +90 -0
- package/dist/governor/adapter.d.ts.map +1 -0
- package/dist/governor/adapter.js +169 -0
- package/dist/governor/adapter.js.map +1 -0
- package/dist/governor/configs/compound.json +32 -0
- package/dist/governor/configs/optimism.json +28 -0
- package/dist/governor/configs/uniswap.json +32 -0
- package/dist/governor/encoder.d.ts +59 -0
- package/dist/governor/encoder.d.ts.map +1 -0
- package/dist/governor/encoder.js +290 -0
- package/dist/governor/encoder.js.map +1 -0
- package/dist/governor/index.d.ts +11 -0
- package/dist/governor/index.d.ts.map +1 -0
- package/dist/governor/index.js +20 -0
- package/dist/governor/index.js.map +1 -0
- package/dist/governor/loader.d.ts +42 -0
- package/dist/governor/loader.d.ts.map +1 -0
- package/dist/governor/loader.js +103 -0
- package/dist/governor/loader.js.map +1 -0
- package/dist/governor/tally.d.ts +48 -0
- package/dist/governor/tally.d.ts.map +1 -0
- package/dist/governor/tally.js +103 -0
- package/dist/governor/tally.js.map +1 -0
- package/dist/governor/tools/build.d.ts +3 -0
- package/dist/governor/tools/build.d.ts.map +1 -0
- package/dist/governor/tools/build.js +137 -0
- package/dist/governor/tools/build.js.map +1 -0
- package/dist/governor/tools/extras.d.ts +4 -0
- package/dist/governor/tools/extras.d.ts.map +1 -0
- package/dist/governor/tools/extras.js +197 -0
- package/dist/governor/tools/extras.js.map +1 -0
- package/dist/governor/tools/read.d.ts +4 -0
- package/dist/governor/tools/read.d.ts.map +1 -0
- package/dist/governor/tools/read.js +174 -0
- package/dist/governor/tools/read.js.map +1 -0
- package/dist/governor/tools/simulate.d.ts +6 -0
- package/dist/governor/tools/simulate.d.ts.map +1 -0
- package/dist/governor/tools/simulate.js +191 -0
- package/dist/governor/tools/simulate.js.map +1 -0
- package/dist/lib/broadcastGuards.d.ts +41 -0
- package/dist/lib/broadcastGuards.d.ts.map +1 -0
- package/dist/lib/broadcastGuards.js +85 -0
- package/dist/lib/broadcastGuards.js.map +1 -0
- package/dist/lib/ethersProvider.d.ts +96 -0
- package/dist/lib/ethersProvider.d.ts.map +1 -0
- package/dist/lib/ethersProvider.js +170 -0
- package/dist/lib/ethersProvider.js.map +1 -0
- package/dist/lib/signer.d.ts +2 -0
- package/dist/lib/signer.d.ts.map +1 -1
- package/dist/lib/signer.js +4 -0
- package/dist/lib/signer.js.map +1 -1
- package/dist/tools/flow.d.ts.map +1 -1
- package/dist/tools/flow.js +13 -0
- package/dist/tools/flow.js.map +1 -1
- package/dist/tools/getConfig.d.ts.map +1 -1
- package/dist/tools/getConfig.js +17 -0
- package/dist/tools/getConfig.js.map +1 -1
- package/dist/tools/inbox.js +8 -8
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +6 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/predict.js +17 -17
- package/dist/tools/safe.d.ts +5 -0
- package/dist/tools/safe.d.ts.map +1 -0
- package/dist/tools/safe.js +264 -0
- package/dist/tools/safe.js.map +1 -0
- package/dist/tools/simulate.d.ts +7 -0
- package/dist/tools/simulate.d.ts.map +1 -1
- package/dist/tools/simulate.js +8 -0
- package/dist/tools/simulate.js.map +1 -1
- package/dist/tools/subgraph.js +162 -162
- package/dist/tools/txSend.d.ts.map +1 -1
- package/dist/tools/txSend.js +25 -0
- package/dist/tools/txSend.js.map +1 -1
- package/package.json +95 -92
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "uniswap",
|
|
3
|
+
"chainId": 1,
|
|
4
|
+
"governorAddress": "0x408ED6354d4973f66138C91495F2f2FCbd8724C3",
|
|
5
|
+
"governorVersion": "bravo-v3",
|
|
6
|
+
"votingToken": {
|
|
7
|
+
"type": "ERC20VotesComp",
|
|
8
|
+
"address": "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984",
|
|
9
|
+
"symbol": "UNI",
|
|
10
|
+
"decimals": 18
|
|
11
|
+
},
|
|
12
|
+
"timelock": {
|
|
13
|
+
"address": "0x1a9C8182C09F50355CeA8fFF4b7E1649A535498a",
|
|
14
|
+
"minDelay": 172800
|
|
15
|
+
},
|
|
16
|
+
"votingParams": {
|
|
17
|
+
"votingDelay": 1,
|
|
18
|
+
"votingPeriod": 50400,
|
|
19
|
+
"proposalThreshold": "2500000000000000000000000",
|
|
20
|
+
"quorumNumerator": 4,
|
|
21
|
+
"quorumDenominator": 100
|
|
22
|
+
},
|
|
23
|
+
"executor": {
|
|
24
|
+
"type": "timelock",
|
|
25
|
+
"id": null
|
|
26
|
+
},
|
|
27
|
+
"explorer": {
|
|
28
|
+
"etherscanBase": "https://etherscan.io",
|
|
29
|
+
"tallyOrgSlug": "uniswap"
|
|
30
|
+
},
|
|
31
|
+
"notes": "Uniswap GovernorBravoDelegate (proxy). Bravo signatures: propose has signatures[], queue/execute take proposalId, quorum is fixed quorumVotes(), snapshot/deadline via proposals(uint256). ProposalState enum matches OZ canonical order."
|
|
32
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { GovernorConfig } from "./loader.js";
|
|
2
|
+
/**
|
|
3
|
+
* Write-side ABI fragments per governor family. The exact selectors differ
|
|
4
|
+
* between OZ v4+ and Bravo for propose / queue / execute, so build tools
|
|
5
|
+
* MUST encode against the correct family. `castVote` and `castVoteWithReason`
|
|
6
|
+
* share signatures across families.
|
|
7
|
+
*/
|
|
8
|
+
export declare const GOVERNOR_OZ_WRITE_ABI: readonly ["function propose(address[] targets, uint256[] values, bytes[] calldatas, string description) returns (uint256)", "function castVote(uint256 proposalId, uint8 support) returns (uint256)", "function castVoteWithReason(uint256 proposalId, uint8 support, string reason) returns (uint256)", "function queue(address[] targets, uint256[] values, bytes[] calldatas, bytes32 descriptionHash) returns (uint256)", "function execute(address[] targets, uint256[] values, bytes[] calldatas, bytes32 descriptionHash) payable returns (uint256)", "function cancel(address[] targets, uint256[] values, bytes[] calldatas, bytes32 descriptionHash) returns (uint256)", "function hashProposal(address[] targets, uint256[] values, bytes[] calldatas, bytes32 descriptionHash) pure returns (uint256)"];
|
|
9
|
+
export declare const GOVERNOR_BRAVO_WRITE_ABI: readonly ["function propose(address[] targets, uint256[] values, string[] signatures, bytes[] calldatas, string description) returns (uint256)", "function castVote(uint256 proposalId, uint8 support)", "function castVoteWithReason(uint256 proposalId, uint8 support, string reason)", "function queue(uint256 proposalId)", "function execute(uint256 proposalId) payable", "function cancel(uint256 proposalId)"];
|
|
10
|
+
export declare const IVOTES_WRITE_ABI: readonly ["function delegate(address delegatee)"];
|
|
11
|
+
export interface BuiltTx {
|
|
12
|
+
to: string;
|
|
13
|
+
value: string;
|
|
14
|
+
data: string;
|
|
15
|
+
selector: string;
|
|
16
|
+
method: string;
|
|
17
|
+
args: unknown;
|
|
18
|
+
family: "oz" | "bravo";
|
|
19
|
+
}
|
|
20
|
+
/** Upper bound on a proposal's action count. Guards the calldata builders
|
|
21
|
+
* against pathological array sizes; well above any real governance proposal. */
|
|
22
|
+
export declare const MAX_ACTIONS = 50;
|
|
23
|
+
export interface ProposeArgs {
|
|
24
|
+
targets: string[];
|
|
25
|
+
values: (string | number | bigint)[];
|
|
26
|
+
calldatas: string[];
|
|
27
|
+
description: string;
|
|
28
|
+
/** Bravo only: per-target function signature strings (e.g. "transfer(address,uint256)"). Defaults to []. */
|
|
29
|
+
signatures?: string[];
|
|
30
|
+
}
|
|
31
|
+
export declare function buildPropose(cfg: GovernorConfig, args: ProposeArgs): BuiltTx;
|
|
32
|
+
export type Support = 0 | 1 | 2;
|
|
33
|
+
export declare function buildVoteCast(cfg: GovernorConfig, proposalId: string | bigint, support: Support, reason?: string): BuiltTx;
|
|
34
|
+
export interface QueueExecuteArgs {
|
|
35
|
+
/** Bravo: proposalId. OZ: hash will be recomputed from the rest. */
|
|
36
|
+
proposalId?: string | bigint;
|
|
37
|
+
/** OZ only. */
|
|
38
|
+
targets?: string[];
|
|
39
|
+
/** OZ only. */
|
|
40
|
+
values?: (string | number | bigint)[];
|
|
41
|
+
/** OZ only. */
|
|
42
|
+
calldatas?: string[];
|
|
43
|
+
/** OZ only. Either the raw description (we hash it) or descriptionHash. */
|
|
44
|
+
description?: string;
|
|
45
|
+
descriptionHash?: string;
|
|
46
|
+
}
|
|
47
|
+
export declare function buildQueue(cfg: GovernorConfig, args: QueueExecuteArgs): BuiltTx;
|
|
48
|
+
export declare function buildExecute(cfg: GovernorConfig, args: QueueExecuteArgs, msgValue?: string | bigint): BuiltTx;
|
|
49
|
+
export declare function buildCancel(cfg: GovernorConfig, args: QueueExecuteArgs): BuiltTx;
|
|
50
|
+
export declare function buildDelegate(cfg: GovernorConfig, delegatee: string): BuiltTx;
|
|
51
|
+
/**
|
|
52
|
+
* Round-trip helper exposed for tests: decode calldata back into named args
|
|
53
|
+
* for selector-validity + arg-roundtrip assertions.
|
|
54
|
+
*/
|
|
55
|
+
export declare function decodeGovernorWrite(cfg: GovernorConfig, data: string): {
|
|
56
|
+
method: string;
|
|
57
|
+
args: unknown[];
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=encoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoder.d.ts","sourceRoot":"","sources":["../../src/governor/encoder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD;;;;;GAKG;AAEH,eAAO,MAAM,qBAAqB,qxBAQxB,CAAC;AAEX,eAAO,MAAM,wBAAwB,wZAO3B,CAAC;AAEX,eAAO,MAAM,gBAAgB,mDAEnB,CAAC;AAEX,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IA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B,GAAG,OAAO,CA+B/E;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAgC7G;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CA+BhF;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAa7E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,EAAE,CAAA;CAAE,CAK1G"}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { Interface, isAddress, keccak256, toUtf8Bytes } from "ethers";
|
|
2
|
+
import { isBravo } from "./adapter.js";
|
|
3
|
+
/**
|
|
4
|
+
* Write-side ABI fragments per governor family. The exact selectors differ
|
|
5
|
+
* between OZ v4+ and Bravo for propose / queue / execute, so build tools
|
|
6
|
+
* MUST encode against the correct family. `castVote` and `castVoteWithReason`
|
|
7
|
+
* share signatures across families.
|
|
8
|
+
*/
|
|
9
|
+
export const GOVERNOR_OZ_WRITE_ABI = [
|
|
10
|
+
"function propose(address[] targets, uint256[] values, bytes[] calldatas, string description) returns (uint256)",
|
|
11
|
+
"function castVote(uint256 proposalId, uint8 support) returns (uint256)",
|
|
12
|
+
"function castVoteWithReason(uint256 proposalId, uint8 support, string reason) returns (uint256)",
|
|
13
|
+
"function queue(address[] targets, uint256[] values, bytes[] calldatas, bytes32 descriptionHash) returns (uint256)",
|
|
14
|
+
"function execute(address[] targets, uint256[] values, bytes[] calldatas, bytes32 descriptionHash) payable returns (uint256)",
|
|
15
|
+
"function cancel(address[] targets, uint256[] values, bytes[] calldatas, bytes32 descriptionHash) returns (uint256)",
|
|
16
|
+
"function hashProposal(address[] targets, uint256[] values, bytes[] calldatas, bytes32 descriptionHash) pure returns (uint256)",
|
|
17
|
+
];
|
|
18
|
+
export const GOVERNOR_BRAVO_WRITE_ABI = [
|
|
19
|
+
"function propose(address[] targets, uint256[] values, string[] signatures, bytes[] calldatas, string description) returns (uint256)",
|
|
20
|
+
"function castVote(uint256 proposalId, uint8 support)",
|
|
21
|
+
"function castVoteWithReason(uint256 proposalId, uint8 support, string reason)",
|
|
22
|
+
"function queue(uint256 proposalId)",
|
|
23
|
+
"function execute(uint256 proposalId) payable",
|
|
24
|
+
"function cancel(uint256 proposalId)",
|
|
25
|
+
];
|
|
26
|
+
export const IVOTES_WRITE_ABI = [
|
|
27
|
+
"function delegate(address delegatee)",
|
|
28
|
+
];
|
|
29
|
+
function governorIface(cfg) {
|
|
30
|
+
return new Interface((isBravo(cfg) ? GOVERNOR_BRAVO_WRITE_ABI : GOVERNOR_OZ_WRITE_ABI));
|
|
31
|
+
}
|
|
32
|
+
function family(cfg) {
|
|
33
|
+
return isBravo(cfg) ? "bravo" : "oz";
|
|
34
|
+
}
|
|
35
|
+
function selectorOf(iface, method) {
|
|
36
|
+
const fn = iface.getFunction(method);
|
|
37
|
+
if (!fn)
|
|
38
|
+
throw new Error(`encoder: method ${method} missing from ABI`);
|
|
39
|
+
return fn.selector;
|
|
40
|
+
}
|
|
41
|
+
function ensureAddressArray(label, xs) {
|
|
42
|
+
if (!Array.isArray(xs))
|
|
43
|
+
throw new Error(`${label} must be an array`);
|
|
44
|
+
for (const a of xs)
|
|
45
|
+
if (typeof a !== "string" || !isAddress(a))
|
|
46
|
+
throw new Error(`${label} has invalid address: ${String(a)}`);
|
|
47
|
+
return xs;
|
|
48
|
+
}
|
|
49
|
+
function ensureBytesArray(label, xs) {
|
|
50
|
+
if (!Array.isArray(xs))
|
|
51
|
+
throw new Error(`${label} must be an array`);
|
|
52
|
+
for (const b of xs) {
|
|
53
|
+
if (typeof b !== "string" || !/^0x([a-fA-F0-9]{2})*$/.test(b)) {
|
|
54
|
+
throw new Error(`${label} has invalid 0x-prefixed hex: ${String(b)}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return xs;
|
|
58
|
+
}
|
|
59
|
+
function ensureUintArray(label, xs) {
|
|
60
|
+
if (!Array.isArray(xs))
|
|
61
|
+
throw new Error(`${label} must be an array`);
|
|
62
|
+
return xs.map((v, i) => {
|
|
63
|
+
try {
|
|
64
|
+
return BigInt(v);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
throw new Error(`${label}[${i}] is not a valid uint: ${String(v)}`);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function ensureStringArray(label, xs) {
|
|
72
|
+
if (!Array.isArray(xs))
|
|
73
|
+
throw new Error(`${label} must be an array`);
|
|
74
|
+
for (const s of xs)
|
|
75
|
+
if (typeof s !== "string")
|
|
76
|
+
throw new Error(`${label} must be string[]`);
|
|
77
|
+
return xs;
|
|
78
|
+
}
|
|
79
|
+
/** Upper bound on a proposal's action count. Guards the calldata builders
|
|
80
|
+
* against pathological array sizes; well above any real governance proposal. */
|
|
81
|
+
export const MAX_ACTIONS = 50;
|
|
82
|
+
/**
|
|
83
|
+
* Validates the OZ action tuple: equal lengths, non-empty (Governor reverts on
|
|
84
|
+
* empty proposals), and within MAX_ACTIONS. Shared by propose/queue/execute/cancel
|
|
85
|
+
* so every OZ path enforces the same shape.
|
|
86
|
+
*/
|
|
87
|
+
function ensureActionParity(label, targets, values, calldatas) {
|
|
88
|
+
if (targets.length !== values.length || targets.length !== calldatas.length) {
|
|
89
|
+
throw new Error(`${label}: target/value/calldata length mismatch (targets=${targets.length}, values=${values.length}, calldatas=${calldatas.length})`);
|
|
90
|
+
}
|
|
91
|
+
if (targets.length === 0)
|
|
92
|
+
throw new Error(`${label}: at least one action is required`);
|
|
93
|
+
if (targets.length > MAX_ACTIONS) {
|
|
94
|
+
throw new Error(`${label}: too many actions (${targets.length} > ${MAX_ACTIONS})`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export function buildPropose(cfg, args) {
|
|
98
|
+
const iface = governorIface(cfg);
|
|
99
|
+
const targets = ensureAddressArray("targets", args.targets);
|
|
100
|
+
const values = ensureUintArray("values", args.values);
|
|
101
|
+
const calldatas = ensureBytesArray("calldatas", args.calldatas);
|
|
102
|
+
if (typeof args.description !== "string")
|
|
103
|
+
throw new Error("description must be a string");
|
|
104
|
+
ensureActionParity("propose", targets, values, calldatas);
|
|
105
|
+
let data;
|
|
106
|
+
let argsOut;
|
|
107
|
+
if (isBravo(cfg)) {
|
|
108
|
+
const signatures = args.signatures
|
|
109
|
+
? ensureStringArray("signatures", args.signatures)
|
|
110
|
+
: new Array(targets.length).fill("");
|
|
111
|
+
if (signatures.length !== targets.length) {
|
|
112
|
+
throw new Error(`bravo propose: signatures length ${signatures.length} != targets length ${targets.length}`);
|
|
113
|
+
}
|
|
114
|
+
data = iface.encodeFunctionData("propose", [targets, values, signatures, calldatas, args.description]);
|
|
115
|
+
argsOut = { targets, values: values.map(String), signatures, calldatas, description: args.description };
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
data = iface.encodeFunctionData("propose", [targets, values, calldatas, args.description]);
|
|
119
|
+
argsOut = { targets, values: values.map(String), calldatas, description: args.description };
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
to: cfg.governorAddress,
|
|
123
|
+
value: "0",
|
|
124
|
+
data,
|
|
125
|
+
selector: data.slice(0, 10),
|
|
126
|
+
method: "propose",
|
|
127
|
+
args: argsOut,
|
|
128
|
+
family: family(cfg),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
export function buildVoteCast(cfg, proposalId, support, reason) {
|
|
132
|
+
if (![0, 1, 2].includes(support))
|
|
133
|
+
throw new Error(`support must be 0|1|2, got ${support}`);
|
|
134
|
+
const iface = governorIface(cfg);
|
|
135
|
+
const pid = BigInt(proposalId);
|
|
136
|
+
const method = reason !== undefined ? "castVoteWithReason" : "castVote";
|
|
137
|
+
const data = reason !== undefined
|
|
138
|
+
? iface.encodeFunctionData("castVoteWithReason", [pid, support, reason])
|
|
139
|
+
: iface.encodeFunctionData("castVote", [pid, support]);
|
|
140
|
+
return {
|
|
141
|
+
to: cfg.governorAddress,
|
|
142
|
+
value: "0",
|
|
143
|
+
data,
|
|
144
|
+
selector: data.slice(0, 10),
|
|
145
|
+
method,
|
|
146
|
+
args: reason !== undefined
|
|
147
|
+
? { proposalId: pid.toString(), support, reason }
|
|
148
|
+
: { proposalId: pid.toString(), support },
|
|
149
|
+
family: family(cfg),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function computeDescHash(args) {
|
|
153
|
+
if (args.descriptionHash) {
|
|
154
|
+
if (!/^0x[a-fA-F0-9]{64}$/.test(args.descriptionHash)) {
|
|
155
|
+
throw new Error(`descriptionHash must be 32-byte hex; got ${args.descriptionHash}`);
|
|
156
|
+
}
|
|
157
|
+
return args.descriptionHash;
|
|
158
|
+
}
|
|
159
|
+
if (typeof args.description !== "string") {
|
|
160
|
+
throw new Error("OZ queue/execute: either description or descriptionHash is required");
|
|
161
|
+
}
|
|
162
|
+
return keccak256(toUtf8Bytes(args.description));
|
|
163
|
+
}
|
|
164
|
+
export function buildQueue(cfg, args) {
|
|
165
|
+
const iface = governorIface(cfg);
|
|
166
|
+
if (isBravo(cfg)) {
|
|
167
|
+
if (args.proposalId === undefined)
|
|
168
|
+
throw new Error("bravo queue: proposalId required");
|
|
169
|
+
const pid = BigInt(args.proposalId);
|
|
170
|
+
const data = iface.encodeFunctionData("queue", [pid]);
|
|
171
|
+
return {
|
|
172
|
+
to: cfg.governorAddress,
|
|
173
|
+
value: "0",
|
|
174
|
+
data,
|
|
175
|
+
selector: data.slice(0, 10),
|
|
176
|
+
method: "queue",
|
|
177
|
+
args: { proposalId: pid.toString() },
|
|
178
|
+
family: "bravo",
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
const targets = ensureAddressArray("targets", args.targets);
|
|
182
|
+
const values = ensureUintArray("values", args.values);
|
|
183
|
+
const calldatas = ensureBytesArray("calldatas", args.calldatas);
|
|
184
|
+
ensureActionParity("queue", targets, values, calldatas);
|
|
185
|
+
const descriptionHash = computeDescHash(args);
|
|
186
|
+
const data = iface.encodeFunctionData("queue", [targets, values, calldatas, descriptionHash]);
|
|
187
|
+
return {
|
|
188
|
+
to: cfg.governorAddress,
|
|
189
|
+
value: "0",
|
|
190
|
+
data,
|
|
191
|
+
selector: data.slice(0, 10),
|
|
192
|
+
method: "queue",
|
|
193
|
+
args: { targets, values: values.map(String), calldatas, descriptionHash },
|
|
194
|
+
family: "oz",
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
export function buildExecute(cfg, args, msgValue) {
|
|
198
|
+
const iface = governorIface(cfg);
|
|
199
|
+
const value = msgValue === undefined ? "0" : BigInt(msgValue).toString();
|
|
200
|
+
if (isBravo(cfg)) {
|
|
201
|
+
if (args.proposalId === undefined)
|
|
202
|
+
throw new Error("bravo execute: proposalId required");
|
|
203
|
+
const pid = BigInt(args.proposalId);
|
|
204
|
+
const data = iface.encodeFunctionData("execute", [pid]);
|
|
205
|
+
return {
|
|
206
|
+
to: cfg.governorAddress,
|
|
207
|
+
value,
|
|
208
|
+
data,
|
|
209
|
+
selector: data.slice(0, 10),
|
|
210
|
+
method: "execute",
|
|
211
|
+
args: { proposalId: pid.toString() },
|
|
212
|
+
family: "bravo",
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
const targets = ensureAddressArray("targets", args.targets);
|
|
216
|
+
const values = ensureUintArray("values", args.values);
|
|
217
|
+
const calldatas = ensureBytesArray("calldatas", args.calldatas);
|
|
218
|
+
ensureActionParity("execute", targets, values, calldatas);
|
|
219
|
+
const descriptionHash = computeDescHash(args);
|
|
220
|
+
const data = iface.encodeFunctionData("execute", [targets, values, calldatas, descriptionHash]);
|
|
221
|
+
return {
|
|
222
|
+
to: cfg.governorAddress,
|
|
223
|
+
value,
|
|
224
|
+
data,
|
|
225
|
+
selector: data.slice(0, 10),
|
|
226
|
+
method: "execute",
|
|
227
|
+
args: { targets, values: values.map(String), calldatas, descriptionHash },
|
|
228
|
+
family: "oz",
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
export function buildCancel(cfg, args) {
|
|
232
|
+
const iface = governorIface(cfg);
|
|
233
|
+
if (isBravo(cfg)) {
|
|
234
|
+
if (args.proposalId === undefined)
|
|
235
|
+
throw new Error("bravo cancel: proposalId required");
|
|
236
|
+
const pid = BigInt(args.proposalId);
|
|
237
|
+
const data = iface.encodeFunctionData("cancel", [pid]);
|
|
238
|
+
return {
|
|
239
|
+
to: cfg.governorAddress,
|
|
240
|
+
value: "0",
|
|
241
|
+
data,
|
|
242
|
+
selector: data.slice(0, 10),
|
|
243
|
+
method: "cancel",
|
|
244
|
+
args: { proposalId: pid.toString() },
|
|
245
|
+
family: "bravo",
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
const targets = ensureAddressArray("targets", args.targets);
|
|
249
|
+
const values = ensureUintArray("values", args.values);
|
|
250
|
+
const calldatas = ensureBytesArray("calldatas", args.calldatas);
|
|
251
|
+
ensureActionParity("cancel", targets, values, calldatas);
|
|
252
|
+
const descriptionHash = computeDescHash(args);
|
|
253
|
+
const data = iface.encodeFunctionData("cancel", [targets, values, calldatas, descriptionHash]);
|
|
254
|
+
return {
|
|
255
|
+
to: cfg.governorAddress,
|
|
256
|
+
value: "0",
|
|
257
|
+
data,
|
|
258
|
+
selector: data.slice(0, 10),
|
|
259
|
+
method: "cancel",
|
|
260
|
+
args: { targets, values: values.map(String), calldatas, descriptionHash },
|
|
261
|
+
family: "oz",
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
export function buildDelegate(cfg, delegatee) {
|
|
265
|
+
if (!isAddress(delegatee))
|
|
266
|
+
throw new Error(`delegate: invalid delegatee address ${delegatee}`);
|
|
267
|
+
const iface = new Interface(IVOTES_WRITE_ABI);
|
|
268
|
+
const data = iface.encodeFunctionData("delegate", [delegatee]);
|
|
269
|
+
return {
|
|
270
|
+
to: cfg.votingToken.address,
|
|
271
|
+
value: "0",
|
|
272
|
+
data,
|
|
273
|
+
selector: data.slice(0, 10),
|
|
274
|
+
method: "delegate",
|
|
275
|
+
args: { delegatee },
|
|
276
|
+
family: family(cfg),
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Round-trip helper exposed for tests: decode calldata back into named args
|
|
281
|
+
* for selector-validity + arg-roundtrip assertions.
|
|
282
|
+
*/
|
|
283
|
+
export function decodeGovernorWrite(cfg, data) {
|
|
284
|
+
const iface = governorIface(cfg);
|
|
285
|
+
const decoded = iface.parseTransaction({ data });
|
|
286
|
+
if (!decoded)
|
|
287
|
+
throw new Error(`decodeGovernorWrite: could not parse calldata for ${cfg.id}`);
|
|
288
|
+
return { method: decoded.name, args: decoded.args.toArray() };
|
|
289
|
+
}
|
|
290
|
+
//# sourceMappingURL=encoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoder.js","sourceRoot":"","sources":["../../src/governor/encoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAEtE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,gHAAgH;IAChH,wEAAwE;IACxE,iGAAiG;IACjG,mHAAmH;IACnH,6HAA6H;IAC7H,oHAAoH;IACpH,+HAA+H;CACvH,CAAC;AAEX,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,qIAAqI;IACrI,sDAAsD;IACtD,+EAA+E;IAC/E,oCAAoC;IACpC,8CAA8C;IAC9C,qCAAqC;CAC7B,CAAC;AAEX,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9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4
|
+
* External Governor MCP surface (research/06-execution-plan.md).
|
|
5
|
+
*
|
|
6
|
+
* Independent from DeXe Protocol tools — no dependency on DeXe contracts being
|
|
7
|
+
* deployed on the target chain (AC #11). Tools live under the `dexe_gov_*`
|
|
8
|
+
* namespace.
|
|
9
|
+
*/
|
|
10
|
+
export declare function registerGovernorTools(server: McpServer, config: DexeConfig): void;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/governor/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO/C;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAMjF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RpcProvider } from "../rpc.js";
|
|
2
|
+
import { registerGovernorReadTools } from "./tools/read.js";
|
|
3
|
+
import { registerGovernorBuildTools } from "./tools/build.js";
|
|
4
|
+
import { registerGovernorSimulateTools } from "./tools/simulate.js";
|
|
5
|
+
import { registerGovernorExtraTools } from "./tools/extras.js";
|
|
6
|
+
/**
|
|
7
|
+
* External Governor MCP surface (research/06-execution-plan.md).
|
|
8
|
+
*
|
|
9
|
+
* Independent from DeXe Protocol tools — no dependency on DeXe contracts being
|
|
10
|
+
* deployed on the target chain (AC #11). Tools live under the `dexe_gov_*`
|
|
11
|
+
* namespace.
|
|
12
|
+
*/
|
|
13
|
+
export function registerGovernorTools(server, config) {
|
|
14
|
+
const rpc = new RpcProvider(config);
|
|
15
|
+
registerGovernorReadTools(server, rpc);
|
|
16
|
+
registerGovernorBuildTools(server);
|
|
17
|
+
registerGovernorSimulateTools(server, rpc);
|
|
18
|
+
registerGovernorExtraTools(server, rpc);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/governor/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAiB,EAAE,MAAkB;IACzE,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,yBAAyB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,0BAA0B,CAAC,MAAM,CAAC,CAAC;IACnC,6BAA6B,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3C,0BAA0B,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-DAO Governor config. Source of truth lives in src/governor/configs/*.json
|
|
3
|
+
* and is imported here so `tsc` bundles the JSON into dist without an extra
|
|
4
|
+
* copy step. To add a new DAO: drop a JSON file in configs/, add an import
|
|
5
|
+
* line below, and append to ALL_CONFIGS.
|
|
6
|
+
*/
|
|
7
|
+
export interface GovernorConfig {
|
|
8
|
+
id: string;
|
|
9
|
+
chainId: number;
|
|
10
|
+
governorAddress: string;
|
|
11
|
+
governorVersion: "oz-v4" | "oz-v5" | "bravo-v3";
|
|
12
|
+
votingToken: {
|
|
13
|
+
type: "ERC20Votes" | "ERC20VotesComp";
|
|
14
|
+
address: string;
|
|
15
|
+
symbol: string;
|
|
16
|
+
decimals: number;
|
|
17
|
+
};
|
|
18
|
+
timelock?: {
|
|
19
|
+
address: string;
|
|
20
|
+
minDelay: number;
|
|
21
|
+
};
|
|
22
|
+
votingParams: {
|
|
23
|
+
votingDelay: number;
|
|
24
|
+
votingPeriod: number;
|
|
25
|
+
proposalThreshold?: string;
|
|
26
|
+
quorumNumerator: number;
|
|
27
|
+
quorumDenominator: number;
|
|
28
|
+
};
|
|
29
|
+
executor: {
|
|
30
|
+
type: "timelock" | "governor-self";
|
|
31
|
+
id?: string | null;
|
|
32
|
+
};
|
|
33
|
+
explorer?: {
|
|
34
|
+
etherscanBase?: string;
|
|
35
|
+
tallyOrgSlug?: string;
|
|
36
|
+
};
|
|
37
|
+
notes?: string;
|
|
38
|
+
}
|
|
39
|
+
export declare function validateGovernorConfig(raw: unknown, source: string): GovernorConfig;
|
|
40
|
+
export declare function loadGovernorConfigs(): Map<string, GovernorConfig>;
|
|
41
|
+
export declare function resolveGovernor(idOrAddress: string): GovernorConfig;
|
|
42
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/governor/loader.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,OAAO,GAAG,OAAO,GAAG,UAAU,CAAC;IAChD,WAAW,EAAE;QACX,IAAI,EAAE,YAAY,GAAG,gBAAgB,CAAC;QACtC,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,QAAQ,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,YAAY,EAAE;QACZ,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,eAAe,EAAE,MAAM,CAAC;QACxB,iBAAiB,EAAE,MAAM,CAAC;KAC3B,CAAC;IACF,QAAQ,EAAE;QAAE,IAAI,EAAE,UAAU,GAAG,eAAe,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IACrE,QAAQ,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAYD,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc,CAgEnF;AAID,wBAAgB,mBAAmB,IAAI,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAWjE;AAED,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,CAQnE"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import uniswap from "./configs/uniswap.json" with { type: "json" };
|
|
2
|
+
import compound from "./configs/compound.json" with { type: "json" };
|
|
3
|
+
import optimism from "./configs/optimism.json" with { type: "json" };
|
|
4
|
+
const RAW_CONFIGS = [uniswap, compound, optimism];
|
|
5
|
+
const ADDR_RE = /^0x[a-fA-F0-9]{40}$/;
|
|
6
|
+
function assertAddress(label, v) {
|
|
7
|
+
if (typeof v !== "string" || !ADDR_RE.test(v)) {
|
|
8
|
+
throw new Error(`governor config: ${label} must be a 0x-prefixed 20-byte address, got ${String(v)}`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function validateGovernorConfig(raw, source) {
|
|
12
|
+
if (!raw || typeof raw !== "object") {
|
|
13
|
+
throw new Error(`governor config ${source}: root must be an object`);
|
|
14
|
+
}
|
|
15
|
+
const o = raw;
|
|
16
|
+
if (typeof o.id !== "string" || !/^[a-z0-9-]+$/.test(o.id)) {
|
|
17
|
+
throw new Error(`governor config ${source}: id must match /^[a-z0-9-]+$/`);
|
|
18
|
+
}
|
|
19
|
+
if (typeof o.chainId !== "number" || o.chainId < 1) {
|
|
20
|
+
throw new Error(`governor config ${source}: chainId must be a positive integer`);
|
|
21
|
+
}
|
|
22
|
+
assertAddress(`${source}.governorAddress`, o.governorAddress);
|
|
23
|
+
const version = o.governorVersion ?? "oz-v4";
|
|
24
|
+
if (!["oz-v4", "oz-v5", "bravo-v3"].includes(version)) {
|
|
25
|
+
throw new Error(`governor config ${source}: governorVersion must be oz-v4|oz-v5|bravo-v3`);
|
|
26
|
+
}
|
|
27
|
+
const vt = o.votingToken;
|
|
28
|
+
if (!vt || typeof vt !== "object")
|
|
29
|
+
throw new Error(`${source}: votingToken missing`);
|
|
30
|
+
assertAddress(`${source}.votingToken.address`, vt.address);
|
|
31
|
+
if (!["ERC20Votes", "ERC20VotesComp"].includes(vt.type)) {
|
|
32
|
+
throw new Error(`${source}: votingToken.type must be ERC20Votes|ERC20VotesComp`);
|
|
33
|
+
}
|
|
34
|
+
if (typeof vt.symbol !== "string")
|
|
35
|
+
throw new Error(`${source}: votingToken.symbol missing`);
|
|
36
|
+
const decimals = typeof vt.decimals === "number" ? vt.decimals : 18;
|
|
37
|
+
if (o.timelock !== undefined) {
|
|
38
|
+
assertAddress(`${source}.timelock.address`, o.timelock?.address);
|
|
39
|
+
if (typeof o.timelock?.minDelay !== "number") {
|
|
40
|
+
throw new Error(`${source}: timelock.minDelay must be a number (seconds)`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const vp = o.votingParams;
|
|
44
|
+
if (!vp || typeof vp !== "object")
|
|
45
|
+
throw new Error(`${source}: votingParams missing`);
|
|
46
|
+
if (typeof vp.votingDelay !== "number")
|
|
47
|
+
throw new Error(`${source}: votingParams.votingDelay missing`);
|
|
48
|
+
if (typeof vp.votingPeriod !== "number")
|
|
49
|
+
throw new Error(`${source}: votingParams.votingPeriod missing`);
|
|
50
|
+
if (typeof vp.quorumNumerator !== "number") {
|
|
51
|
+
throw new Error(`${source}: votingParams.quorumNumerator missing`);
|
|
52
|
+
}
|
|
53
|
+
const ex = o.executor;
|
|
54
|
+
if (!ex || typeof ex !== "object")
|
|
55
|
+
throw new Error(`${source}: executor missing`);
|
|
56
|
+
if (!["timelock", "governor-self"].includes(ex.type)) {
|
|
57
|
+
throw new Error(`${source}: executor.type must be timelock|governor-self`);
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
id: o.id,
|
|
61
|
+
chainId: o.chainId,
|
|
62
|
+
governorAddress: o.governorAddress,
|
|
63
|
+
governorVersion: version,
|
|
64
|
+
votingToken: { type: vt.type, address: vt.address, symbol: vt.symbol, decimals },
|
|
65
|
+
timelock: o.timelock,
|
|
66
|
+
votingParams: {
|
|
67
|
+
votingDelay: vp.votingDelay,
|
|
68
|
+
votingPeriod: vp.votingPeriod,
|
|
69
|
+
proposalThreshold: vp.proposalThreshold,
|
|
70
|
+
quorumNumerator: vp.quorumNumerator,
|
|
71
|
+
quorumDenominator: typeof vp.quorumDenominator === "number" ? vp.quorumDenominator : 100,
|
|
72
|
+
},
|
|
73
|
+
executor: { type: ex.type, id: ex.id ?? null },
|
|
74
|
+
explorer: o.explorer,
|
|
75
|
+
notes: o.notes,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
let cache = null;
|
|
79
|
+
export function loadGovernorConfigs() {
|
|
80
|
+
if (cache)
|
|
81
|
+
return cache;
|
|
82
|
+
const out = new Map();
|
|
83
|
+
for (const raw of RAW_CONFIGS) {
|
|
84
|
+
const id = typeof raw?.id === "string" ? raw.id : "<anonymous>";
|
|
85
|
+
const cfg = validateGovernorConfig(raw, `configs/${id}.json`);
|
|
86
|
+
if (out.has(cfg.id))
|
|
87
|
+
throw new Error(`governor config: duplicate id "${cfg.id}"`);
|
|
88
|
+
out.set(cfg.id, cfg);
|
|
89
|
+
}
|
|
90
|
+
cache = out;
|
|
91
|
+
return cache;
|
|
92
|
+
}
|
|
93
|
+
export function resolveGovernor(idOrAddress) {
|
|
94
|
+
const configs = loadGovernorConfigs();
|
|
95
|
+
const lower = idOrAddress.toLowerCase();
|
|
96
|
+
for (const cfg of configs.values()) {
|
|
97
|
+
if (cfg.id === idOrAddress || cfg.governorAddress.toLowerCase() === lower)
|
|
98
|
+
return cfg;
|
|
99
|
+
}
|
|
100
|
+
const known = [...configs.keys()].join(", ") || "(none)";
|
|
101
|
+
throw new Error(`unknown governor "${idOrAddress}"; known ids: [${known}]`);
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/governor/loader.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,wBAAwB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACnE,OAAO,QAAQ,MAAM,yBAAyB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACrE,OAAO,QAAQ,MAAM,yBAAyB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAgCrE,MAAM,WAAW,GAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAE7D,MAAM,OAAO,GAAG,qBAAqB,CAAC;AAEtC,SAAS,aAAa,CAAC,KAAa,EAAE,CAAU;IAC9C,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,oBAAoB,KAAK,+CAA+C,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACvG,CAAC;AACH,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,GAAY,EAAE,MAAc;IACjE,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;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