dexe-mcp 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -0
- package/dist/tools/inbox.d.ts +4 -0
- package/dist/tools/inbox.d.ts.map +1 -0
- package/dist/tools/inbox.js +251 -0
- package/dist/tools/inbox.js.map +1 -0
- 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/otc.d.ts.map +1 -1
- package/dist/tools/otc.js +29 -6
- package/dist/tools/otc.js.map +1 -1
- package/dist/tools/predict.d.ts +4 -0
- package/dist/tools/predict.d.ts.map +1 -0
- package/dist/tools/predict.js +209 -0
- package/dist/tools/predict.js.map +1 -0
- package/dist/tools/simulate.d.ts +27 -0
- package/dist/tools/simulate.d.ts.map +1 -0
- package/dist/tools/simulate.js +278 -0
- package/dist/tools/simulate.js.map +1 -0
- package/dist/tools/subgraph.d.ts.map +1 -1
- package/dist/tools/subgraph.js +303 -163
- package/dist/tools/subgraph.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Interface, isAddress } from "ethers";
|
|
3
|
+
import { RpcProvider } from "../rpc.js";
|
|
4
|
+
import { multicall } from "../lib/multicall.js";
|
|
5
|
+
import { gqlRequest } from "../lib/subgraph.js";
|
|
6
|
+
import { proposalStateLabel } from "../lib/govEnums.js";
|
|
7
|
+
/**
|
|
8
|
+
* dexe_proposal_forecast — predictive pass-rate based on historical proposals.
|
|
9
|
+
*
|
|
10
|
+
* Reads the latest 10 proposals on the DAO via getProposals + their final
|
|
11
|
+
* states, computes pass-rate + average For-vote weight, and returns a
|
|
12
|
+
* recommendation. Mainnet only — testnet has no subgraph and historical
|
|
13
|
+
* data is too sparse to forecast usefully.
|
|
14
|
+
*
|
|
15
|
+
* The "subgraph" requirement here is loose: this tool primarily runs over
|
|
16
|
+
* RPC (multicall on getProposals) so it actually works on testnet too, but
|
|
17
|
+
* we keep the documented mainnet-only contract. To opt-in on testnet, call
|
|
18
|
+
* with `forceRpcOnly: true`.
|
|
19
|
+
*/
|
|
20
|
+
const GOV_POOL_ABI = new Interface([
|
|
21
|
+
"function getHelperContracts() view returns (address settings, address userKeeper, address validators, address poolRegistry, address votePower)",
|
|
22
|
+
"function getProposals(uint256 offset, uint256 limit) view returns (tuple(tuple(tuple(bool earlyCompletion, bool delegatedVotingAllowed, bool validatorsVote, uint64 duration, uint64 durationValidators, uint64 executionDelay, uint128 quorum, uint128 quorumValidators, uint256 minVotesForVoting, uint256 minVotesForCreating, tuple(address rewardToken, uint256 creationReward, uint256 executionReward, uint256 voteRewardsCoefficient) rewardsInfo, string executorDescription) settings, uint64 voteEnd, uint64 executeAfter, bool executed, uint256 votesFor, uint256 votesAgainst, uint256 rawVotesFor, uint256 rawVotesAgainst, uint256 givenRewards) core, string descriptionURL, tuple(address executor, uint256 value, bytes data)[] actionsOnFor, tuple(address executor, uint256 value, bytes data)[] actionsOnAgainst)[] proposals, tuple(uint256 proposalId, uint256 executeAfter, uint256 quorum, uint256 rawVotesFor, uint256 rawVotesAgainst, bool executed, tuple(bool earlyCompletion, bool delegatedVotingAllowed, bool validatorsVote, uint64 duration, uint64 durationValidators, uint64 executionDelay, uint128 quorum, uint128 quorumValidators, uint256 minVotesForVoting, uint256 minVotesForCreating, tuple(address rewardToken, uint256 creationReward, uint256 executionReward, uint256 voteRewardsCoefficient) rewardsInfo, string executorDescription) settings)[] validatorProposals, uint8[] proposalStates, uint256[] requiredQuorums, uint256[] requiredValidatorsQuorums)",
|
|
23
|
+
]);
|
|
24
|
+
const GOV_SETTINGS_ABI = new Interface([
|
|
25
|
+
"function getDefaultSettings() view returns (tuple(bool earlyCompletion, bool delegatedVotingAllowed, bool validatorsVote, uint64 duration, uint64 durationValidators, uint64 executionDelay, uint128 quorum, uint128 quorumValidators, uint256 minVotesForVoting, uint256 minVotesForCreating, tuple(address rewardToken, uint256 creationReward, uint256 executionReward, uint256 voteRewardsCoefficient) rewardsInfo, string executorDescription))",
|
|
26
|
+
]);
|
|
27
|
+
// Subgraph fallback for daos with proposalCount > on-chain getProposals
|
|
28
|
+
// reasonable cap. Same shape as the pools subgraph proposals entity.
|
|
29
|
+
const RECENT_PROPOSALS_QUERY = /* GraphQL */ `
|
|
30
|
+
query RecentProposals($pool: String!, $first: Int!) {
|
|
31
|
+
proposals(
|
|
32
|
+
where: { pool: $pool }
|
|
33
|
+
first: $first
|
|
34
|
+
orderBy: creationTimestamp
|
|
35
|
+
orderDirection: desc
|
|
36
|
+
) {
|
|
37
|
+
id
|
|
38
|
+
proposalId
|
|
39
|
+
executed
|
|
40
|
+
voters
|
|
41
|
+
currentRawVotesFor
|
|
42
|
+
currentRawVotesAgainst
|
|
43
|
+
quorumReached
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
function err(message) {
|
|
48
|
+
return { content: [{ type: "text", text: message }], isError: true };
|
|
49
|
+
}
|
|
50
|
+
function ok(data) {
|
|
51
|
+
return {
|
|
52
|
+
content: [
|
|
53
|
+
{
|
|
54
|
+
type: "text",
|
|
55
|
+
text: JSON.stringify(data, (_k, v) => (typeof v === "bigint" ? v.toString() : v), 2),
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export function registerPredictTools(server, ctx) {
|
|
61
|
+
const rpc = new RpcProvider(ctx.config);
|
|
62
|
+
server.registerTool("dexe_proposal_forecast", {
|
|
63
|
+
title: "Predictive proposal pass-rate forecaster",
|
|
64
|
+
description: "Reads the latest 10 proposals on a DAO + their final states, computes the historical " +
|
|
65
|
+
"pass-rate and average For-vote weight, and returns a forecast. " +
|
|
66
|
+
"When `draft.actionsOnFor` is supplied the projection is annotated with the caller's vote weight. " +
|
|
67
|
+
"Mainnet only by default — pass `forceRpcOnly: true` to run on testnet using on-chain reads alone.",
|
|
68
|
+
inputSchema: {
|
|
69
|
+
govPool: z.string().describe("GovPool address"),
|
|
70
|
+
draft: z
|
|
71
|
+
.object({
|
|
72
|
+
actionsOnFor: z.array(z.unknown()).default([]),
|
|
73
|
+
voteAmount: z.string().optional(),
|
|
74
|
+
})
|
|
75
|
+
.optional()
|
|
76
|
+
.describe("Optional draft proposal — voteAmount is added to projectedFor"),
|
|
77
|
+
forceRpcOnly: z
|
|
78
|
+
.boolean()
|
|
79
|
+
.default(false)
|
|
80
|
+
.describe("Bypass mainnet-only guard; forecast purely from on-chain getProposals"),
|
|
81
|
+
},
|
|
82
|
+
}, async ({ govPool, draft, forceRpcOnly = false }) => {
|
|
83
|
+
if (!isAddress(govPool))
|
|
84
|
+
return err(`Invalid govPool: ${govPool}`);
|
|
85
|
+
const isMainnet = ctx.config.chainId === 56;
|
|
86
|
+
if (!isMainnet && !forceRpcOnly) {
|
|
87
|
+
return ok({
|
|
88
|
+
error: "subgraph required",
|
|
89
|
+
hint: "Mainnet only by default. Pass forceRpcOnly: true to run from on-chain getProposals on this chain.",
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const provider = rpc.requireProvider();
|
|
93
|
+
// Step 1: helpers + recent 10 proposals.
|
|
94
|
+
const [helpersR, proposalsR] = await multicall(provider, [
|
|
95
|
+
{ target: govPool, iface: GOV_POOL_ABI, method: "getHelperContracts", args: [], allowFailure: true },
|
|
96
|
+
{ target: govPool, iface: GOV_POOL_ABI, method: "getProposals", args: [0n, 10n], allowFailure: true },
|
|
97
|
+
]);
|
|
98
|
+
if (!helpersR?.success)
|
|
99
|
+
return err("getHelperContracts reverted");
|
|
100
|
+
const helpers = helpersR.value;
|
|
101
|
+
// Step 2: required quorum from default settings.
|
|
102
|
+
const [settingsR] = await multicall(provider, [
|
|
103
|
+
{
|
|
104
|
+
target: helpers.settings,
|
|
105
|
+
iface: GOV_SETTINGS_ABI,
|
|
106
|
+
method: "getDefaultSettings",
|
|
107
|
+
args: [],
|
|
108
|
+
allowFailure: true,
|
|
109
|
+
},
|
|
110
|
+
]);
|
|
111
|
+
let requiredQuorum = 0n;
|
|
112
|
+
if (settingsR?.success) {
|
|
113
|
+
const s = settingsR.value;
|
|
114
|
+
requiredQuorum = s.quorum;
|
|
115
|
+
}
|
|
116
|
+
// Step 3: walk historical proposals.
|
|
117
|
+
let proposals = [];
|
|
118
|
+
if (proposalsR?.success) {
|
|
119
|
+
const raw = proposalsR.value;
|
|
120
|
+
proposals = raw.proposals.map((p, i) => {
|
|
121
|
+
const idx = Number(raw.proposalStates[i] ?? 9);
|
|
122
|
+
return {
|
|
123
|
+
proposalId: String(i + 1),
|
|
124
|
+
state: proposalStateLabel(idx),
|
|
125
|
+
executed: p.core.executed,
|
|
126
|
+
votesFor: p.core.votesFor,
|
|
127
|
+
votesAgainst: p.core.votesAgainst,
|
|
128
|
+
};
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
// Step 4: optional subgraph cross-check for richer history (mainnet only).
|
|
132
|
+
const subgraphUrl = ctx.config.subgraphPoolsUrl;
|
|
133
|
+
let subgraphHistory = null;
|
|
134
|
+
if (subgraphUrl && isMainnet) {
|
|
135
|
+
try {
|
|
136
|
+
const data = await gqlRequest(subgraphUrl, RECENT_PROPOSALS_QUERY, {
|
|
137
|
+
pool: govPool.toLowerCase(),
|
|
138
|
+
first: 10,
|
|
139
|
+
});
|
|
140
|
+
subgraphHistory = data.proposals;
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
// soft-fail — on-chain data is enough
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// Stats: pass-rate + average For weight.
|
|
147
|
+
const total = proposals.length;
|
|
148
|
+
const passed = proposals.filter((p) => p.state === "ExecutedFor" || p.state === "SucceededFor").length;
|
|
149
|
+
const passRate = total > 0 ? passed / total : 0;
|
|
150
|
+
const avgFor = total > 0
|
|
151
|
+
? proposals.reduce((acc, p) => acc + p.votesFor, 0n) / BigInt(total)
|
|
152
|
+
: 0n;
|
|
153
|
+
// Projection: average + caller's draft voteAmount.
|
|
154
|
+
let projectedFor = avgFor;
|
|
155
|
+
if (draft?.voteAmount) {
|
|
156
|
+
try {
|
|
157
|
+
projectedFor += BigInt(draft.voteAmount);
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
// ignore malformed amount
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const projectedPct = requiredQuorum > 0n
|
|
164
|
+
? Number((projectedFor * 10000n) / requiredQuorum) / 100
|
|
165
|
+
: 0;
|
|
166
|
+
const hitProbability = Math.min(1, Math.max(0, projectedPct / 100));
|
|
167
|
+
// Risks heuristic.
|
|
168
|
+
const risks = [];
|
|
169
|
+
if (passRate < 0.4 && total > 0)
|
|
170
|
+
risks.push("voterApathy");
|
|
171
|
+
if ((draft?.actionsOnFor?.length ?? 0) > 5)
|
|
172
|
+
risks.push("complexityRisk");
|
|
173
|
+
if (requiredQuorum > 0n && projectedFor < requiredQuorum)
|
|
174
|
+
risks.push("quorumGap");
|
|
175
|
+
let recommendation;
|
|
176
|
+
if (hitProbability >= 0.8)
|
|
177
|
+
recommendation = "likelyPass";
|
|
178
|
+
else if (hitProbability >= 0.5)
|
|
179
|
+
recommendation = "borderline";
|
|
180
|
+
else
|
|
181
|
+
recommendation = "likelyFail";
|
|
182
|
+
return ok({
|
|
183
|
+
govPool,
|
|
184
|
+
chain: ctx.config.chainId,
|
|
185
|
+
quorum: {
|
|
186
|
+
required: requiredQuorum.toString(),
|
|
187
|
+
projectedFor: projectedFor.toString(),
|
|
188
|
+
projectedPct,
|
|
189
|
+
hitProbability,
|
|
190
|
+
},
|
|
191
|
+
historicalPassRate: {
|
|
192
|
+
last10: passed,
|
|
193
|
+
total,
|
|
194
|
+
ratio: passRate,
|
|
195
|
+
},
|
|
196
|
+
history: proposals.map((p) => ({
|
|
197
|
+
proposalId: p.proposalId,
|
|
198
|
+
state: p.state,
|
|
199
|
+
executed: p.executed,
|
|
200
|
+
votesFor: p.votesFor.toString(),
|
|
201
|
+
votesAgainst: p.votesAgainst.toString(),
|
|
202
|
+
})),
|
|
203
|
+
subgraphHistory,
|
|
204
|
+
risks,
|
|
205
|
+
recommendation,
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=predict.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"predict.js","sourceRoot":"","sources":["../../src/tools/predict.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAG9C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD;;;;;;;;;;;;GAYG;AAEH,MAAM,YAAY,GAAG,IAAI,SAAS,CAAC;IACjC,gJAAgJ;IAChJ,m7CAAm7C;CACp7C,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAAG,IAAI,SAAS,CAAC;IACrC,sbAAsb;CACvb,CAAC,CAAC;AAEH,wEAAwE;AACxE,qEAAqE;AACrE,MAAM,sBAAsB,GAAG,aAAa,CAAC;;;;;;;;;;;;;;;;;CAiB5C,CAAC;AAEF,SAAS,GAAG,CAAC,OAAe;IAC1B,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAChF,CAAC;AAED,SAAS,EAAE,CAAC,IAA6B;IACvC,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,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,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAElF,IAAI,cAA0D,CAAC;QAC/D,IAAI,cAAc,IAAI,GAAG;YAAE,cAAc,GAAG,YAAY,CAAC;aACpD,IAAI,cAAc,IAAI,GAAG;YAAE,cAAc,GAAG,YAAY,CAAC;;YACzD,cAAc,GAAG,YAAY,CAAC;QAEnC,OAAO,EAAE,CAAC;YACR,OAAO;YACP,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,OAAO;YACzB,MAAM,EAAE;gBACN,QAAQ,EAAE,cAAc,CAAC,QAAQ,EAAE;gBACnC,YAAY,EAAE,YAAY,CAAC,QAAQ,EAAE;gBACrC,YAAY;gBACZ,cAAc;aACf;YACD,kBAAkB,EAAE;gBAClB,MAAM,EAAE,MAAM;gBACd,KAAK;gBACL,KAAK,EAAE,QAAQ;aAChB;YACD,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC7B,UAAU,EAAE,CAAC,CAAC,UAAU;gBACxB,KAAK,EAAE,CAAC,CAAC,KAAK;gBACd,QAAQ,EAAE,CAAC,CAAC,QAAQ;gBACpB,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE;gBAC/B,YAAY,EAAE,CAAC,CAAC,YAAY,CAAC,QAAQ,EAAE;aACxC,CAAC,CAAC;YACH,eAAe;YACf,KAAK;YACL,cAAc;SACf,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { ToolContext } from "./context.js";
|
|
3
|
+
import { SignerManager } from "../lib/signer.js";
|
|
4
|
+
import { RpcProvider } from "../rpc.js";
|
|
5
|
+
/** Pull the revert reason out of an ethers v6 CallException-shaped error. */
|
|
6
|
+
declare function decodeRevert(error: unknown): {
|
|
7
|
+
revertReason: string;
|
|
8
|
+
returnData?: string;
|
|
9
|
+
};
|
|
10
|
+
interface SimCalldataInput {
|
|
11
|
+
to: string;
|
|
12
|
+
data: string;
|
|
13
|
+
value?: string;
|
|
14
|
+
from?: string;
|
|
15
|
+
blockTag?: string | number;
|
|
16
|
+
}
|
|
17
|
+
interface SimCalldataResult {
|
|
18
|
+
success: boolean;
|
|
19
|
+
revertReason?: string;
|
|
20
|
+
returnData?: string;
|
|
21
|
+
gasEstimate?: string;
|
|
22
|
+
}
|
|
23
|
+
declare function simulateCalldata(rpc: RpcProvider, input: SimCalldataInput): Promise<SimCalldataResult>;
|
|
24
|
+
export declare function registerSimulateTools(server: McpServer, ctx: ToolContext, signer: SignerManager): void;
|
|
25
|
+
export { simulateCalldata, decodeRevert };
|
|
26
|
+
export type { SimCalldataInput, SimCalldataResult };
|
|
27
|
+
//# sourceMappingURL=simulate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simulate.d.ts","sourceRoot":"","sources":["../../src/tools/simulate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAkDxC,6EAA6E;AAC7E,iBAAS,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAuCA;AAID,UAAU,gBAAgB;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC5B;AAED,UAAU,iBAAiB;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,iBAAe,gBAAgB,CAC7B,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,gBAAgB,GACtB,OAAO,CAAC,iBAAiB,CAAC,CAkC5B;AAID,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,EACjB,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,aAAa,GACpB,IAAI,CAiMN;AAID,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,CAAC;AAC1C,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Interface, ZeroAddress, isAddress, getAddress } from "ethers";
|
|
3
|
+
import { RpcProvider } from "../rpc.js";
|
|
4
|
+
// ---------- ABI fragments ----------
|
|
5
|
+
const ERROR_STRING_SELECTOR = "0x08c379a0"; // Error(string)
|
|
6
|
+
const PANIC_SELECTOR = "0x4e487b71"; // Panic(uint256)
|
|
7
|
+
const GOV_POOL_ABI = new Interface([
|
|
8
|
+
"function getProposalState(uint256 proposalId) view returns (uint8)",
|
|
9
|
+
"function execute(uint256 proposalId)",
|
|
10
|
+
]);
|
|
11
|
+
const TOKEN_SALE_ABI = new Interface([
|
|
12
|
+
"function buy(uint256 tierId, address tokenToBuyWith, uint256 amount, bytes32[] proof) payable",
|
|
13
|
+
]);
|
|
14
|
+
const ERC20_ABI = new Interface([
|
|
15
|
+
"function allowance(address owner, address spender) view returns (uint256)",
|
|
16
|
+
]);
|
|
17
|
+
// Source of truth for proposal states; index 4 is SucceededFor (executable).
|
|
18
|
+
const PROPOSAL_STATES = [
|
|
19
|
+
"Voting",
|
|
20
|
+
"WaitingForVotingTransfer",
|
|
21
|
+
"ValidatorVoting",
|
|
22
|
+
"Defeated",
|
|
23
|
+
"SucceededFor",
|
|
24
|
+
"SucceededAgainst",
|
|
25
|
+
"Locked",
|
|
26
|
+
"ExecutedFor",
|
|
27
|
+
"ExecutedAgainst",
|
|
28
|
+
"Undefined",
|
|
29
|
+
];
|
|
30
|
+
// ---------- helpers ----------
|
|
31
|
+
function err(message) {
|
|
32
|
+
return { content: [{ type: "text", text: message }], isError: true };
|
|
33
|
+
}
|
|
34
|
+
function ok(data) {
|
|
35
|
+
return {
|
|
36
|
+
content: [{ type: "text", text: JSON.stringify(data, bigintReplacer, 2) }],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function bigintReplacer(_k, v) {
|
|
40
|
+
return typeof v === "bigint" ? v.toString() : v;
|
|
41
|
+
}
|
|
42
|
+
/** Pull the revert reason out of an ethers v6 CallException-shaped error. */
|
|
43
|
+
function decodeRevert(error) {
|
|
44
|
+
const e = error;
|
|
45
|
+
// Try common shapes for the raw return data.
|
|
46
|
+
const data = e?.data ?? e?.info?.error?.data ?? e?.error?.data;
|
|
47
|
+
if (typeof data === "string" && data.startsWith(ERROR_STRING_SELECTOR)) {
|
|
48
|
+
try {
|
|
49
|
+
const decoded = new Interface([
|
|
50
|
+
"function Error(string)",
|
|
51
|
+
]).decodeFunctionData("Error", data);
|
|
52
|
+
return { revertReason: String(decoded[0]), returnData: data };
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// fall through to message-based decode
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (typeof data === "string" && data.startsWith(PANIC_SELECTOR)) {
|
|
59
|
+
try {
|
|
60
|
+
const decoded = new Interface([
|
|
61
|
+
"function Panic(uint256)",
|
|
62
|
+
]).decodeFunctionData("Panic", data);
|
|
63
|
+
return {
|
|
64
|
+
revertReason: `Panic(0x${BigInt(decoded[0]).toString(16)})`,
|
|
65
|
+
returnData: data,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// fall through
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const msg = e?.shortMessage ?? e?.reason ?? e?.message ?? String(error);
|
|
73
|
+
return { revertReason: msg, ...(data ? { returnData: data } : {}) };
|
|
74
|
+
}
|
|
75
|
+
async function simulateCalldata(rpc, input) {
|
|
76
|
+
const provider = rpc.requireProvider();
|
|
77
|
+
const blockTag = input.blockTag ?? "latest";
|
|
78
|
+
const tx = {
|
|
79
|
+
to: input.to,
|
|
80
|
+
data: input.data,
|
|
81
|
+
...(input.value ? { value: BigInt(input.value) } : {}),
|
|
82
|
+
...(input.from ? { from: input.from } : {}),
|
|
83
|
+
blockTag,
|
|
84
|
+
};
|
|
85
|
+
const result = { success: false };
|
|
86
|
+
try {
|
|
87
|
+
const returnData = await provider.call(tx);
|
|
88
|
+
result.success = true;
|
|
89
|
+
result.returnData = returnData;
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
const decoded = decodeRevert(e);
|
|
93
|
+
result.revertReason = decoded.revertReason;
|
|
94
|
+
if (decoded.returnData)
|
|
95
|
+
result.returnData = decoded.returnData;
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
// Only run estimateGas if the call succeeded — otherwise it'd just re-revert.
|
|
99
|
+
try {
|
|
100
|
+
const gas = await provider.estimateGas(tx);
|
|
101
|
+
result.gasEstimate = gas.toString();
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// estimateGas can fail even when call succeeds (e.g. balance issues for
|
|
105
|
+
// value-bearing tx with from=0x0). Leave undefined.
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
// ---------- register ----------
|
|
110
|
+
export function registerSimulateTools(server, ctx, signer) {
|
|
111
|
+
const rpc = new RpcProvider(ctx.config);
|
|
112
|
+
// =============================================
|
|
113
|
+
// dexe_sim_calldata
|
|
114
|
+
// =============================================
|
|
115
|
+
server.tool("dexe_sim_calldata", "Preflight any tx via eth_call against live state with optional caller override. " +
|
|
116
|
+
"Returns success/revertReason/gasEstimate without spending gas. Decodes Error(string) " +
|
|
117
|
+
"and Panic(uint256) revert payloads when the node returns them.", {
|
|
118
|
+
to: z.string(),
|
|
119
|
+
data: z.string(),
|
|
120
|
+
value: z.string().optional().describe("wei, decimal string"),
|
|
121
|
+
from: z
|
|
122
|
+
.string()
|
|
123
|
+
.optional()
|
|
124
|
+
.describe("Caller address override; defaults to active signer or zero address."),
|
|
125
|
+
blockTag: z
|
|
126
|
+
.union([z.string(), z.number()])
|
|
127
|
+
.optional()
|
|
128
|
+
.describe("Block tag for eth_call (default: 'latest')."),
|
|
129
|
+
}, async (input) => {
|
|
130
|
+
try {
|
|
131
|
+
if (!isAddress(input.to))
|
|
132
|
+
return err(`Invalid to: ${input.to}`);
|
|
133
|
+
const fromResolved = input.from ??
|
|
134
|
+
(signer.hasSigner() ? signer.getAddress() : ZeroAddress);
|
|
135
|
+
const result = await simulateCalldata(rpc, {
|
|
136
|
+
to: getAddress(input.to),
|
|
137
|
+
data: input.data,
|
|
138
|
+
value: input.value,
|
|
139
|
+
from: fromResolved,
|
|
140
|
+
blockTag: input.blockTag,
|
|
141
|
+
});
|
|
142
|
+
return ok({ ...result, from: fromResolved });
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
return err(e instanceof Error ? e.message : String(e));
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
// =============================================
|
|
149
|
+
// dexe_sim_proposal
|
|
150
|
+
// =============================================
|
|
151
|
+
server.tool("dexe_sim_proposal", "Simulate GovPool.execute(proposalId) against live state. Reads the proposal state " +
|
|
152
|
+
"first; refuses to sim unless it is `SucceededFor` (idx 4). Useful before paying gas " +
|
|
153
|
+
"to find out the underlying action would revert.", {
|
|
154
|
+
govPool: z.string(),
|
|
155
|
+
proposalId: z.string(),
|
|
156
|
+
from: z.string().optional(),
|
|
157
|
+
}, async (input) => {
|
|
158
|
+
try {
|
|
159
|
+
if (!isAddress(input.govPool))
|
|
160
|
+
return err(`Invalid govPool: ${input.govPool}`);
|
|
161
|
+
const provider = rpc.requireProvider();
|
|
162
|
+
const govAddr = getAddress(input.govPool);
|
|
163
|
+
const proposalIdBn = BigInt(input.proposalId);
|
|
164
|
+
// Read current state.
|
|
165
|
+
const stateData = GOV_POOL_ABI.encodeFunctionData("getProposalState", [
|
|
166
|
+
proposalIdBn,
|
|
167
|
+
]);
|
|
168
|
+
let stateIndex;
|
|
169
|
+
try {
|
|
170
|
+
const ret = await provider.call({ to: govAddr, data: stateData });
|
|
171
|
+
stateIndex = Number(GOV_POOL_ABI.decodeFunctionResult("getProposalState", ret)[0]);
|
|
172
|
+
}
|
|
173
|
+
catch (e) {
|
|
174
|
+
const decoded = decodeRevert(e);
|
|
175
|
+
return err(`getProposalState reverted: ${decoded.revertReason}. Proposal may not exist on this GovPool.`);
|
|
176
|
+
}
|
|
177
|
+
const proposalState = PROPOSAL_STATES[stateIndex] ?? `Unknown(${stateIndex})`;
|
|
178
|
+
if (stateIndex !== 4) {
|
|
179
|
+
return ok({
|
|
180
|
+
success: false,
|
|
181
|
+
revertReason: `Proposal state is '${proposalState}' (idx ${stateIndex}); execute() requires 'SucceededFor' (idx 4).`,
|
|
182
|
+
proposalState,
|
|
183
|
+
proposalStateIndex: stateIndex,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
const fromResolved = input.from ??
|
|
187
|
+
(signer.hasSigner() ? signer.getAddress() : ZeroAddress);
|
|
188
|
+
const data = GOV_POOL_ABI.encodeFunctionData("execute", [proposalIdBn]);
|
|
189
|
+
const result = await simulateCalldata(rpc, {
|
|
190
|
+
to: govAddr,
|
|
191
|
+
data,
|
|
192
|
+
from: fromResolved,
|
|
193
|
+
});
|
|
194
|
+
return ok({
|
|
195
|
+
...result,
|
|
196
|
+
proposalState,
|
|
197
|
+
proposalStateIndex: stateIndex,
|
|
198
|
+
from: fromResolved,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
catch (e) {
|
|
202
|
+
return err(e instanceof Error ? e.message : String(e));
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
// =============================================
|
|
206
|
+
// dexe_sim_buy
|
|
207
|
+
// =============================================
|
|
208
|
+
server.tool("dexe_sim_buy", "Simulate TokenSaleProposal.buy(tierId, paymentToken, amount, proof) against live state. " +
|
|
209
|
+
"Native path (paymentToken == 0x0) sets value = amount. ERC20 path also reads the caller's " +
|
|
210
|
+
"current allowance and reports `willNeedApprove: true` when allowance < amount, so callers " +
|
|
211
|
+
"know the broadcast will need an approve prepended.", {
|
|
212
|
+
tokenSaleProposal: z.string(),
|
|
213
|
+
tierId: z.string(),
|
|
214
|
+
tokenToBuyWith: z.string().describe("Payment token; 0x0 sentinel for native BNB"),
|
|
215
|
+
amount: z.string().describe("amount in wei"),
|
|
216
|
+
proof: z.array(z.string()).default([]),
|
|
217
|
+
from: z.string().optional(),
|
|
218
|
+
}, async (input) => {
|
|
219
|
+
try {
|
|
220
|
+
if (!isAddress(input.tokenSaleProposal))
|
|
221
|
+
return err(`Invalid tokenSaleProposal`);
|
|
222
|
+
if (!isAddress(input.tokenToBuyWith))
|
|
223
|
+
return err(`Invalid tokenToBuyWith`);
|
|
224
|
+
const tspAddr = getAddress(input.tokenSaleProposal);
|
|
225
|
+
const paymentAddr = getAddress(input.tokenToBuyWith);
|
|
226
|
+
const native = paymentAddr.toLowerCase() === ZeroAddress.toLowerCase();
|
|
227
|
+
const tierIdBn = BigInt(input.tierId);
|
|
228
|
+
const amountBn = BigInt(input.amount);
|
|
229
|
+
const fromResolved = input.from ??
|
|
230
|
+
(signer.hasSigner() ? signer.getAddress() : ZeroAddress);
|
|
231
|
+
// ERC20 path — read current allowance to flag approve-needed.
|
|
232
|
+
let willNeedApprove;
|
|
233
|
+
if (!native) {
|
|
234
|
+
try {
|
|
235
|
+
const provider = rpc.requireProvider();
|
|
236
|
+
const allowanceData = ERC20_ABI.encodeFunctionData("allowance", [
|
|
237
|
+
fromResolved,
|
|
238
|
+
tspAddr,
|
|
239
|
+
]);
|
|
240
|
+
const ret = await provider.call({
|
|
241
|
+
to: paymentAddr,
|
|
242
|
+
data: allowanceData,
|
|
243
|
+
});
|
|
244
|
+
const allowance = BigInt(ERC20_ABI.decodeFunctionResult("allowance", ret)[0]);
|
|
245
|
+
willNeedApprove = allowance < amountBn;
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
// Non-ERC20 token or RPC blip — leave undefined, don't fail the sim.
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const data = TOKEN_SALE_ABI.encodeFunctionData("buy", [
|
|
252
|
+
tierIdBn,
|
|
253
|
+
paymentAddr,
|
|
254
|
+
amountBn,
|
|
255
|
+
input.proof,
|
|
256
|
+
]);
|
|
257
|
+
const result = await simulateCalldata(rpc, {
|
|
258
|
+
to: tspAddr,
|
|
259
|
+
data,
|
|
260
|
+
value: native ? amountBn.toString() : undefined,
|
|
261
|
+
from: fromResolved,
|
|
262
|
+
});
|
|
263
|
+
return ok({
|
|
264
|
+
...result,
|
|
265
|
+
native,
|
|
266
|
+
...(willNeedApprove !== undefined ? { willNeedApprove } : {}),
|
|
267
|
+
from: fromResolved,
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
catch (e) {
|
|
271
|
+
return err(e instanceof Error ? e.message : String(e));
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
// Export the core for reuse by other tools (e.g. dexe_otc_buyer_buy
|
|
276
|
+
// `simulateFirst` flag).
|
|
277
|
+
export { simulateCalldata, decodeRevert };
|
|
278
|
+
//# sourceMappingURL=simulate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simulate.js","sourceRoot":"","sources":["../../src/tools/simulate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,QAAQ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C,EAAE,EAAE,OAAO;gBACX,IAAI;gBACJ,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS;gBAC/C,IAAI,EAAE,YAAY;aACnB,CAAC,CAAC;YAEH,OAAO,EAAE,CAAC;gBACR,GAAG,MAAM;gBACT,MAAM;gBACN,GAAG,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC7D,IAAI,EAAE,YAAY;aACnB,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,GAAG,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACzD,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC;AAED,oEAAoE;AACpE,yBAAyB;AACzB,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subgraph.d.ts","sourceRoot":"","sources":["../../src/tools/subgraph.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"subgraph.d.ts","sourceRoot":"","sources":["../../src/tools/subgraph.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAoNhD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI,CAQ/E"}
|