dexe-mcp 0.3.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 +262 -136
- package/dist/lib/merkleTree.d.ts +38 -0
- package/dist/lib/merkleTree.d.ts.map +1 -0
- package/dist/lib/merkleTree.js +83 -0
- package/dist/lib/merkleTree.js.map +1 -0
- package/dist/tools/flow.d.ts +57 -0
- package/dist/tools/flow.d.ts.map +1 -1
- package/dist/tools/flow.js +204 -176
- package/dist/tools/flow.js.map +1 -1
- 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 +10 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/merkle.d.ts +4 -0
- package/dist/tools/merkle.d.ts.map +1 -0
- package/dist/tools/merkle.js +174 -0
- package/dist/tools/merkle.js.map +1 -0
- package/dist/tools/otc.d.ts +5 -0
- package/dist/tools/otc.d.ts.map +1 -0
- package/dist/tools/otc.js +504 -0
- package/dist/tools/otc.js.map +1 -0
- 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/proposalBuildComplex.d.ts +222 -0
- package/dist/tools/proposalBuildComplex.d.ts.map +1 -1
- package/dist/tools/proposalBuildComplex.js +373 -66
- package/dist/tools/proposalBuildComplex.js.map +1 -1
- package/dist/tools/read.js +2 -2
- package/dist/tools/read.js.map +1 -1
- 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 +84 -83
|
@@ -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;I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Q,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"}
|
|
@@ -1,4 +1,226 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
1
2
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
3
|
import type { ToolContext } from "./context.js";
|
|
4
|
+
export declare const TOKEN_SALE_PROPOSAL_ABI: readonly ["function createTiers(tuple(tuple(string name, string description) metadata, uint256 totalTokenProvided, uint64 saleStartTime, uint64 saleEndTime, uint64 claimLockDuration, address saleTokenAddress, address[] purchaseTokenAddresses, uint256[] exchangeRates, uint256 minAllocationPerUser, uint256 maxAllocationPerUser, tuple(uint256 vestingPercentage, uint64 vestingDuration, uint64 cliffPeriod, uint64 unlockStep) vestingSettings, tuple(uint8 participationType, bytes data)[] participationDetails)[] tiers)", "function addToWhitelist(tuple(uint256 tierId, address[] users, string uri)[] requests)", "function recover(uint256[] tierIds)"];
|
|
5
|
+
type Action = {
|
|
6
|
+
executor: string;
|
|
7
|
+
value: string;
|
|
8
|
+
data: string;
|
|
9
|
+
};
|
|
3
10
|
export declare function registerProposalBuildComplexTools(server: McpServer, _ctx: ToolContext): void;
|
|
11
|
+
export declare const tierSchema: z.ZodObject<{
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
description: z.ZodDefault<z.ZodString>;
|
|
14
|
+
totalTokenProvided: z.ZodString;
|
|
15
|
+
saleStartTime: z.ZodString;
|
|
16
|
+
saleEndTime: z.ZodString;
|
|
17
|
+
claimLockDuration: z.ZodDefault<z.ZodString>;
|
|
18
|
+
saleTokenAddress: z.ZodString;
|
|
19
|
+
purchaseTokenAddresses: z.ZodArray<z.ZodString, "many">;
|
|
20
|
+
exchangeRates: z.ZodArray<z.ZodString, "many">;
|
|
21
|
+
minAllocationPerUser: z.ZodDefault<z.ZodString>;
|
|
22
|
+
maxAllocationPerUser: z.ZodDefault<z.ZodString>;
|
|
23
|
+
vestingSettings: z.ZodDefault<z.ZodObject<{
|
|
24
|
+
vestingPercentage: z.ZodDefault<z.ZodString>;
|
|
25
|
+
vestingDuration: z.ZodDefault<z.ZodString>;
|
|
26
|
+
cliffPeriod: z.ZodDefault<z.ZodString>;
|
|
27
|
+
unlockStep: z.ZodDefault<z.ZodString>;
|
|
28
|
+
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
vestingPercentage: string;
|
|
30
|
+
vestingDuration: string;
|
|
31
|
+
cliffPeriod: string;
|
|
32
|
+
unlockStep: string;
|
|
33
|
+
}, {
|
|
34
|
+
vestingPercentage?: string | undefined;
|
|
35
|
+
vestingDuration?: string | undefined;
|
|
36
|
+
cliffPeriod?: string | undefined;
|
|
37
|
+
unlockStep?: string | undefined;
|
|
38
|
+
}>>;
|
|
39
|
+
participation: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
40
|
+
type: z.ZodLiteral<"DAOVotes">;
|
|
41
|
+
requiredVotes: z.ZodString;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
type: "DAOVotes";
|
|
44
|
+
requiredVotes: string;
|
|
45
|
+
}, {
|
|
46
|
+
type: "DAOVotes";
|
|
47
|
+
requiredVotes: string;
|
|
48
|
+
}>, z.ZodObject<{
|
|
49
|
+
type: z.ZodLiteral<"Whitelist">;
|
|
50
|
+
users: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
51
|
+
uri: z.ZodDefault<z.ZodString>;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
type: "Whitelist";
|
|
54
|
+
uri: string;
|
|
55
|
+
users: string[];
|
|
56
|
+
}, {
|
|
57
|
+
type: "Whitelist";
|
|
58
|
+
uri?: string | undefined;
|
|
59
|
+
users?: string[] | undefined;
|
|
60
|
+
}>, z.ZodObject<{
|
|
61
|
+
type: z.ZodLiteral<"BABT">;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
type: "BABT";
|
|
64
|
+
}, {
|
|
65
|
+
type: "BABT";
|
|
66
|
+
}>, z.ZodObject<{
|
|
67
|
+
type: z.ZodLiteral<"TokenLock">;
|
|
68
|
+
token: z.ZodString;
|
|
69
|
+
amount: z.ZodString;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
type: "TokenLock";
|
|
72
|
+
token: string;
|
|
73
|
+
amount: string;
|
|
74
|
+
}, {
|
|
75
|
+
type: "TokenLock";
|
|
76
|
+
token: string;
|
|
77
|
+
amount: string;
|
|
78
|
+
}>, z.ZodObject<{
|
|
79
|
+
type: z.ZodLiteral<"NftLock">;
|
|
80
|
+
nft: z.ZodString;
|
|
81
|
+
amount: z.ZodString;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
type: "NftLock";
|
|
84
|
+
amount: string;
|
|
85
|
+
nft: string;
|
|
86
|
+
}, {
|
|
87
|
+
type: "NftLock";
|
|
88
|
+
amount: string;
|
|
89
|
+
nft: string;
|
|
90
|
+
}>, z.ZodObject<{
|
|
91
|
+
type: z.ZodLiteral<"MerkleWhitelist">;
|
|
92
|
+
users: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
93
|
+
uri: z.ZodDefault<z.ZodString>;
|
|
94
|
+
root: z.ZodOptional<z.ZodString>;
|
|
95
|
+
}, "strip", z.ZodTypeAny, {
|
|
96
|
+
type: "MerkleWhitelist";
|
|
97
|
+
uri: string;
|
|
98
|
+
users: string[];
|
|
99
|
+
root?: string | undefined;
|
|
100
|
+
}, {
|
|
101
|
+
type: "MerkleWhitelist";
|
|
102
|
+
uri?: string | undefined;
|
|
103
|
+
root?: string | undefined;
|
|
104
|
+
users?: string[] | undefined;
|
|
105
|
+
}>]>, "many">>;
|
|
106
|
+
}, "strip", z.ZodTypeAny, {
|
|
107
|
+
name: string;
|
|
108
|
+
description: string;
|
|
109
|
+
totalTokenProvided: string;
|
|
110
|
+
saleStartTime: string;
|
|
111
|
+
saleEndTime: string;
|
|
112
|
+
claimLockDuration: string;
|
|
113
|
+
saleTokenAddress: string;
|
|
114
|
+
purchaseTokenAddresses: string[];
|
|
115
|
+
exchangeRates: string[];
|
|
116
|
+
minAllocationPerUser: string;
|
|
117
|
+
maxAllocationPerUser: string;
|
|
118
|
+
vestingSettings: {
|
|
119
|
+
vestingPercentage: string;
|
|
120
|
+
vestingDuration: string;
|
|
121
|
+
cliffPeriod: string;
|
|
122
|
+
unlockStep: string;
|
|
123
|
+
};
|
|
124
|
+
participation: ({
|
|
125
|
+
type: "DAOVotes";
|
|
126
|
+
requiredVotes: string;
|
|
127
|
+
} | {
|
|
128
|
+
type: "Whitelist";
|
|
129
|
+
uri: string;
|
|
130
|
+
users: string[];
|
|
131
|
+
} | {
|
|
132
|
+
type: "BABT";
|
|
133
|
+
} | {
|
|
134
|
+
type: "TokenLock";
|
|
135
|
+
token: string;
|
|
136
|
+
amount: string;
|
|
137
|
+
} | {
|
|
138
|
+
type: "NftLock";
|
|
139
|
+
amount: string;
|
|
140
|
+
nft: string;
|
|
141
|
+
} | {
|
|
142
|
+
type: "MerkleWhitelist";
|
|
143
|
+
uri: string;
|
|
144
|
+
users: string[];
|
|
145
|
+
root?: string | undefined;
|
|
146
|
+
})[];
|
|
147
|
+
}, {
|
|
148
|
+
name: string;
|
|
149
|
+
totalTokenProvided: string;
|
|
150
|
+
saleStartTime: string;
|
|
151
|
+
saleEndTime: string;
|
|
152
|
+
saleTokenAddress: string;
|
|
153
|
+
purchaseTokenAddresses: string[];
|
|
154
|
+
exchangeRates: string[];
|
|
155
|
+
description?: string | undefined;
|
|
156
|
+
claimLockDuration?: string | undefined;
|
|
157
|
+
minAllocationPerUser?: string | undefined;
|
|
158
|
+
maxAllocationPerUser?: string | undefined;
|
|
159
|
+
vestingSettings?: {
|
|
160
|
+
vestingPercentage?: string | undefined;
|
|
161
|
+
vestingDuration?: string | undefined;
|
|
162
|
+
cliffPeriod?: string | undefined;
|
|
163
|
+
unlockStep?: string | undefined;
|
|
164
|
+
} | undefined;
|
|
165
|
+
participation?: ({
|
|
166
|
+
type: "DAOVotes";
|
|
167
|
+
requiredVotes: string;
|
|
168
|
+
} | {
|
|
169
|
+
type: "Whitelist";
|
|
170
|
+
uri?: string | undefined;
|
|
171
|
+
users?: string[] | undefined;
|
|
172
|
+
} | {
|
|
173
|
+
type: "BABT";
|
|
174
|
+
} | {
|
|
175
|
+
type: "TokenLock";
|
|
176
|
+
token: string;
|
|
177
|
+
amount: string;
|
|
178
|
+
} | {
|
|
179
|
+
type: "NftLock";
|
|
180
|
+
amount: string;
|
|
181
|
+
nft: string;
|
|
182
|
+
} | {
|
|
183
|
+
type: "MerkleWhitelist";
|
|
184
|
+
uri?: string | undefined;
|
|
185
|
+
root?: string | undefined;
|
|
186
|
+
users?: string[] | undefined;
|
|
187
|
+
})[] | undefined;
|
|
188
|
+
}>;
|
|
189
|
+
export type TierSpec = z.infer<typeof tierSchema>;
|
|
190
|
+
export declare function buildTierTuple(tier: TierSpec): {
|
|
191
|
+
tuple: unknown[];
|
|
192
|
+
whitelistUsers: string[];
|
|
193
|
+
whitelistUri: string;
|
|
194
|
+
derivedRoots: {
|
|
195
|
+
root: string;
|
|
196
|
+
users: string[];
|
|
197
|
+
}[];
|
|
198
|
+
};
|
|
199
|
+
export declare function buildSaleApprovals(tiers: readonly TierSpec[], tokenSaleProposal: string): Action[];
|
|
200
|
+
/**
|
|
201
|
+
* Pure builder for a multi-tier Token Sale proposal envelope. Used by both
|
|
202
|
+
* the `dexe_proposal_build_token_sale_multi` registrar and the OTC composite
|
|
203
|
+
* tools in `src/tools/otc.ts`.
|
|
204
|
+
*/
|
|
205
|
+
export declare function buildTokenSaleMultiActions(input: {
|
|
206
|
+
tokenSaleProposal: string;
|
|
207
|
+
tiers: readonly TierSpec[];
|
|
208
|
+
latestTierId?: string;
|
|
209
|
+
proposalName?: string;
|
|
210
|
+
proposalDescription?: string;
|
|
211
|
+
}): {
|
|
212
|
+
metadata: Record<string, unknown>;
|
|
213
|
+
actions: Action[];
|
|
214
|
+
derivedMerkleRoots: {
|
|
215
|
+
root: string;
|
|
216
|
+
users: string[];
|
|
217
|
+
}[];
|
|
218
|
+
whitelistRequests: {
|
|
219
|
+
tierId: string;
|
|
220
|
+
users: string[];
|
|
221
|
+
uri: string;
|
|
222
|
+
}[];
|
|
223
|
+
tierNames: string;
|
|
224
|
+
};
|
|
225
|
+
export {};
|
|
4
226
|
//# sourceMappingURL=proposalBuildComplex.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proposalBuildComplex.d.ts","sourceRoot":"","sources":["../../src/tools/proposalBuildComplex.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"proposalBuildComplex.d.ts","sourceRoot":"","sources":["../../src/tools/proposalBuildComplex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAyBhD,eAAO,MAAM,uBAAuB,yoBAI1B,CAAC;AAmFX,KAAK,MAAM,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAqChE,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,WAAW,GAChB,IAAI,CAaN;AA8FD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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