@continuumdao/ctm-mpc-defi 0.2.50 → 0.2.52

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.
Files changed (38) hide show
  1. package/dist/agent/catalog.cjs +829 -55
  2. package/dist/agent/catalog.cjs.map +1 -1
  3. package/dist/agent/catalog.d.ts +93 -22
  4. package/dist/agent/catalog.js +829 -55
  5. package/dist/agent/catalog.js.map +1 -1
  6. package/dist/agent/skills/continuum-dao/SKILL.md +9 -6
  7. package/dist/agent/skills/continuum-dao-marketplace/SKILL.md +58 -0
  8. package/dist/agent/skills/hyperliquidOutcome/SKILL.md +47 -0
  9. package/dist/core/index.cjs +2 -1
  10. package/dist/core/index.cjs.map +1 -1
  11. package/dist/core/index.js +2 -1
  12. package/dist/core/index.js.map +1 -1
  13. package/dist/index.cjs +2 -1
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.js +2 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/protocols/evm/aerodrome/index.cjs.map +1 -1
  18. package/dist/protocols/evm/aerodrome/index.js.map +1 -1
  19. package/dist/protocols/evm/continuum-dao/index.cjs +2311 -62
  20. package/dist/protocols/evm/continuum-dao/index.cjs.map +1 -1
  21. package/dist/protocols/evm/continuum-dao/index.d.ts +697 -2
  22. package/dist/protocols/evm/continuum-dao/index.js +2255 -64
  23. package/dist/protocols/evm/continuum-dao/index.js.map +1 -1
  24. package/dist/protocols/evm/hyperliquidOutcome/index.cjs +1294 -0
  25. package/dist/protocols/evm/hyperliquidOutcome/index.cjs.map +1 -0
  26. package/dist/protocols/evm/hyperliquidOutcome/index.d.ts +465 -0
  27. package/dist/protocols/evm/hyperliquidOutcome/index.js +1247 -0
  28. package/dist/protocols/evm/hyperliquidOutcome/index.js.map +1 -0
  29. package/dist/protocols/evm/pendle/index.cjs +2 -1
  30. package/dist/protocols/evm/pendle/index.cjs.map +1 -1
  31. package/dist/protocols/evm/pendle/index.js +2 -1
  32. package/dist/protocols/evm/pendle/index.js.map +1 -1
  33. package/dist/protocols/evm/trueo/index.cjs +569 -9
  34. package/dist/protocols/evm/trueo/index.cjs.map +1 -1
  35. package/dist/protocols/evm/trueo/index.d.ts +42 -1
  36. package/dist/protocols/evm/trueo/index.js +569 -9
  37. package/dist/protocols/evm/trueo/index.js.map +1 -1
  38. package/package.json +6 -1
@@ -1,4 +1,4 @@
1
- import { parseAbi, parseAbiItem, getAddress, zeroAddress, encodeFunctionData, keccak256, encodePacked, padHex, toHex, createPublicClient, defineChain, parseUnits, isAddress, formatUnits, hashTypedData, http, stringToHex, parseGwei, serializeTransaction } from 'viem';
1
+ import { parseAbi, parseAbiItem, getAddress, zeroAddress, encodeFunctionData, keccak256, encodePacked, padHex, toHex, createPublicClient, defineChain, parseUnits, isAddress, formatUnits, hashTypedData, http, decodeEventLog, stringToHex, parseGwei, serializeTransaction } from 'viem';
2
2
  import { getClientIdFromKeyGenResult, fetchChainFeeParams, gasLimitFromEstimateAndChainConfig, gweiToDecimalString, proposalTxParamsToFeeSnapshot, alignEip1559FeesWithLatestBase } from '@continuumdao/continuum-node-sdk';
3
3
 
4
4
  var __defProp = Object.defineProperty;
@@ -38,19 +38,19 @@ var init_chainIdParse = __esm({
38
38
  "src/chains/evm/chainIdParse.ts"() {
39
39
  }
40
40
  });
41
- function isContinuumDaoCommitteeProposer(addr) {
42
- if (!addr || !isConfiguredAddress(addr)) return false;
41
+ function isContinuumDaoCommitteeProposer(addr2) {
42
+ if (!addr2 || !isConfiguredAddress(addr2)) return false;
43
43
  try {
44
- const a = getAddress(addr);
44
+ const a = getAddress(addr2);
45
45
  return CONTINUUM_DAO_COMMITTEE_PROPOSERS.some((c) => c === a);
46
46
  } catch {
47
47
  return false;
48
48
  }
49
49
  }
50
- function isConfiguredAddress(addr) {
51
- if (!addr?.trim()) return false;
50
+ function isConfiguredAddress(addr2) {
51
+ if (!addr2?.trim()) return false;
52
52
  try {
53
- return getAddress(addr) !== zeroAddress;
53
+ return getAddress(addr2) !== zeroAddress;
54
54
  } catch {
55
55
  return false;
56
56
  }
@@ -72,6 +72,10 @@ function votingEscrowAddressOnEvmChain(chainId) {
72
72
  const ve = continuumDaoDeployment(chainId)?.votingEscrow;
73
73
  return ve && isConfiguredAddress(ve) ? getAddress(ve) : null;
74
74
  }
75
+ function votingEscrowMarketplaceAddressOnEvmChain(chainId) {
76
+ if (chainId !== CONTINUUM_DAO_LINEA_CHAIN_ID) return null;
77
+ return VOTING_ESCROW_MARKETPLACE_LINEA_ADDRESS;
78
+ }
75
79
  function governorAddressOnEvmChain(chainId) {
76
80
  const gov = continuumDaoDeployment(chainId)?.governor;
77
81
  return gov && isConfiguredAddress(gov) ? getAddress(gov) : null;
@@ -134,7 +138,7 @@ function listContinuumDaoDefaultAssets() {
134
138
  }
135
139
  return out;
136
140
  }
137
- var CONTINUUM_DAO_PROTOCOL_ID, CONTINUUM_DAO_ETHEREUM_CHAIN_ID, CONTINUUM_DAO_LINEA_CHAIN_ID, CONTINUUM_DAO_LINEA_SEPOLIA_CHAIN_ID, CTM_TOKEN_NAME, CTM_TOKEN_SYMBOL, VECTM_TOKEN_NAME, VECTM_TOKEN_SYMBOL, CTM_TOKEN_DECIMALS, WEEK_SECONDS, MAXTIME_SECONDS, VECTM_MAX_LOCK_WEEKS, VECTM_DEFAULT_MINIMUM_LOCK_WEI, VECTM_LIQ_MIN_LOCKED_WEI, VECTM_LIQ_PENALTY_NUM, VECTM_LIQ_PENALTY_DEN, UNSET, CTM_TOKEN_ADDRESS, VOTING_ESCROW_LINEA_ADDRESS, CONTINUUM_DAO_LINEA_GOVERNOR_ADDRESS, CONTINUUM_DAO_LINEA_GOVERNOR_LEGACY_ADDRESS, CONTINUUM_DAO_COMMITTEE_PROPOSERS, CONTINUUM_DAO_DEPLOYMENTS, CONTINUUM_DAO_GOVERNANCE_API;
141
+ var CONTINUUM_DAO_PROTOCOL_ID, CONTINUUM_DAO_ETHEREUM_CHAIN_ID, CONTINUUM_DAO_LINEA_CHAIN_ID, CONTINUUM_DAO_LINEA_SEPOLIA_CHAIN_ID, CTM_TOKEN_NAME, CTM_TOKEN_SYMBOL, VECTM_TOKEN_NAME, VECTM_TOKEN_SYMBOL, CTM_TOKEN_DECIMALS, WEEK_SECONDS, MAXTIME_SECONDS, VECTM_MAX_LOCK_WEEKS, VECTM_DEFAULT_MINIMUM_LOCK_WEI, VECTM_LIQ_MIN_LOCKED_WEI, VECTM_LIQ_PENALTY_NUM, VECTM_LIQ_PENALTY_DEN, UNSET, CTM_TOKEN_ADDRESS, VOTING_ESCROW_LINEA_ADDRESS, MULTISIGN_AGENT_WALLET_LINEA_ADDRESS, CTM_FEE_RATE_SCALE, VOTING_ESCROW_MARKETPLACE_LINEA_ADDRESS, VOTING_ESCROW_MARKETPLACE_START_BLOCK, MARKETPLACE_WETH_LINEA_ADDRESS, MARKETPLACE_USDC_LINEA_ADDRESS, CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, CONTINUUM_DAO_LINEA_GOVERNOR_ADDRESS, CONTINUUM_DAO_LINEA_GOVERNOR_LEGACY_ADDRESS, CONTINUUM_DAO_COMMITTEE_PROPOSERS, CONTINUUM_DAO_DEPLOYMENTS, CONTINUUM_DAO_GOVERNANCE_API, CONTINUUM_DAO_MARKETPLACE_API;
138
142
  var init_constants = __esm({
139
143
  "src/protocols/evm/continuum-dao/constants.ts"() {
140
144
  init_chainIdParse();
@@ -163,6 +167,13 @@ var init_constants = __esm({
163
167
  };
164
168
  CTM_TOKEN_ADDRESS = getAddress("0x2026027054F5beBCEB650aBD62dC623e327658e7");
165
169
  VOTING_ESCROW_LINEA_ADDRESS = getAddress("0x221EC90B3B083A8501A37bdeb7035CeaedF3C31f");
170
+ MULTISIGN_AGENT_WALLET_LINEA_ADDRESS = getAddress("0x4ebd7cCBe32a51d1638cFE90E8eD1c4BdF42f729");
171
+ CTM_FEE_RATE_SCALE = 1000n;
172
+ VOTING_ESCROW_MARKETPLACE_LINEA_ADDRESS = getAddress("0x92557d38beAe4658d3c03A02F349FFB60c3bfFA5");
173
+ VOTING_ESCROW_MARKETPLACE_START_BLOCK = 32100001n;
174
+ MARKETPLACE_WETH_LINEA_ADDRESS = getAddress("0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f");
175
+ MARKETPLACE_USDC_LINEA_ADDRESS = getAddress("0x176211869cA2b568f2A7D4EE941E073a821EE1ff");
176
+ CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID = "continuum-dao-marketplace";
166
177
  CONTINUUM_DAO_LINEA_GOVERNOR_ADDRESS = getAddress("0x76FF2CB03175900F1D83328C82D27EA9aeaF2355");
167
178
  CONTINUUM_DAO_LINEA_GOVERNOR_LEGACY_ADDRESS = getAddress("0x4800F9f1dC1b6daCA841B71E0531F547D374168E");
168
179
  CONTINUUM_DAO_COMMITTEE_PROPOSERS = [
@@ -183,6 +194,7 @@ var init_constants = __esm({
183
194
  }
184
195
  };
185
196
  CONTINUUM_DAO_GOVERNANCE_API = "https://app-api.continuumdao.org";
197
+ CONTINUUM_DAO_MARKETPLACE_API = CONTINUUM_DAO_GOVERNANCE_API;
186
198
  }
187
199
  });
188
200
  function defiEvmTransport(rpcUrl, opts) {
@@ -604,25 +616,25 @@ async function forumFetch(path, init = {}) {
604
616
  return body;
605
617
  }
606
618
  async function continuumDaoForumResolve(args) {
607
- const qs = new URLSearchParams();
608
- if (args.url) qs.set("url", String(args.url));
609
- if (args.tid != null) qs.set("tid", String(args.tid));
610
- return forumFetch(`/api/continuum/forum/resolve?${qs}`, { forumUrl: args.forumUrl });
619
+ const qs2 = new URLSearchParams();
620
+ if (args.url) qs2.set("url", String(args.url));
621
+ if (args.tid != null) qs2.set("tid", String(args.tid));
622
+ return forumFetch(`/api/continuum/forum/resolve?${qs2}`, { forumUrl: args.forumUrl });
611
623
  }
612
624
  async function continuumDaoForumFetchThread(args) {
613
- const qs = new URLSearchParams();
614
- if (args.url) qs.set("url", String(args.url));
615
- if (args.tid != null) qs.set("tid", String(args.tid));
616
- if (args.index != null) qs.set("index", String(args.index));
617
- if (args.start != null) qs.set("start", String(args.start));
618
- if (args.limit != null) qs.set("limit", String(args.limit));
619
- return forumFetch(`/api/continuum/forum/thread?${qs}`, { forumUrl: args.forumUrl });
625
+ const qs2 = new URLSearchParams();
626
+ if (args.url) qs2.set("url", String(args.url));
627
+ if (args.tid != null) qs2.set("tid", String(args.tid));
628
+ if (args.index != null) qs2.set("index", String(args.index));
629
+ if (args.start != null) qs2.set("start", String(args.start));
630
+ if (args.limit != null) qs2.set("limit", String(args.limit));
631
+ return forumFetch(`/api/continuum/forum/thread?${qs2}`, { forumUrl: args.forumUrl });
620
632
  }
621
633
  async function continuumDaoForumReplyCount(args) {
622
- const qs = new URLSearchParams();
623
- if (args.url) qs.set("url", String(args.url));
624
- if (args.tid != null) qs.set("tid", String(args.tid));
625
- return forumFetch(`/api/continuum/forum/thread/replies?${qs}`, { forumUrl: args.forumUrl });
634
+ const qs2 = new URLSearchParams();
635
+ if (args.url) qs2.set("url", String(args.url));
636
+ if (args.tid != null) qs2.set("tid", String(args.tid));
637
+ return forumFetch(`/api/continuum/forum/thread/replies?${qs2}`, { forumUrl: args.forumUrl });
626
638
  }
627
639
  async function continuumDaoForumFetchPost(args) {
628
640
  return forumFetch(`/api/continuum/forum/post?pid=${encodeURIComponent(String(args.pid))}`, {
@@ -648,22 +660,22 @@ function assertContinuumDaoForumRecentInput(args) {
648
660
  }
649
661
  async function continuumDaoForumSearch(args) {
650
662
  assertContinuumDaoForumSearchInput(args);
651
- const qs = new URLSearchParams();
652
- if (args.query?.trim()) qs.set("query", args.query.trim());
653
- if (args.hours != null) qs.set("hours", String(args.hours));
654
- if (args.since?.trim()) qs.set("since", args.since.trim());
655
- if (args.start != null) qs.set("start", String(args.start));
656
- if (args.limit != null) qs.set("limit", String(args.limit));
657
- return forumFetch(`/api/continuum/forum/search?${qs}`, { forumUrl: args.forumUrl });
663
+ const qs2 = new URLSearchParams();
664
+ if (args.query?.trim()) qs2.set("query", args.query.trim());
665
+ if (args.hours != null) qs2.set("hours", String(args.hours));
666
+ if (args.since?.trim()) qs2.set("since", args.since.trim());
667
+ if (args.start != null) qs2.set("start", String(args.start));
668
+ if (args.limit != null) qs2.set("limit", String(args.limit));
669
+ return forumFetch(`/api/continuum/forum/search?${qs2}`, { forumUrl: args.forumUrl });
658
670
  }
659
671
  async function continuumDaoForumRecent(args) {
660
672
  assertContinuumDaoForumRecentInput(args);
661
- const qs = new URLSearchParams();
662
- if (args.hours != null) qs.set("hours", String(args.hours));
663
- if (args.since?.trim()) qs.set("since", args.since.trim());
664
- if (args.start != null) qs.set("start", String(args.start));
665
- if (args.limit != null) qs.set("limit", String(args.limit));
666
- return forumFetch(`/api/continuum/forum/recent?${qs}`, {
673
+ const qs2 = new URLSearchParams();
674
+ if (args.hours != null) qs2.set("hours", String(args.hours));
675
+ if (args.since?.trim()) qs2.set("since", args.since.trim());
676
+ if (args.start != null) qs2.set("start", String(args.start));
677
+ if (args.limit != null) qs2.set("limit", String(args.limit));
678
+ return forumFetch(`/api/continuum/forum/recent?${qs2}`, {
667
679
  forumUrl: args.forumUrl,
668
680
  ticket: args.ticket
669
681
  });
@@ -697,10 +709,10 @@ async function continuumDaoForumDelete(args) {
697
709
  });
698
710
  }
699
711
  async function continuumDaoForumUserPostIds(args) {
700
- const qs = new URLSearchParams({ username: args.username });
701
- if (args.start != null) qs.set("start", String(args.start));
702
- if (args.limit != null) qs.set("limit", String(args.limit));
703
- return forumFetch(`/api/continuum/forum/user/posts?${qs}`, { forumUrl: args.forumUrl });
712
+ const qs2 = new URLSearchParams({ username: args.username });
713
+ if (args.start != null) qs2.set("start", String(args.start));
714
+ if (args.limit != null) qs2.set("limit", String(args.limit));
715
+ return forumFetch(`/api/continuum/forum/user/posts?${qs2}`, { forumUrl: args.forumUrl });
704
716
  }
705
717
  async function continuumDaoForumReply(args) {
706
718
  return forumFetch("/api/continuum/forum/reply", {
@@ -771,11 +783,11 @@ async function continuumDaoForumUnread(args) {
771
783
  if (!args.ticket?.trim()) {
772
784
  throw new Error("ticket is required to list unread forum topics");
773
785
  }
774
- const qs = new URLSearchParams();
775
- if (args.filter?.trim()) qs.set("filter", args.filter.trim());
776
- if (args.start != null) qs.set("start", String(args.start));
777
- if (args.limit != null) qs.set("limit", String(args.limit));
778
- const suffix = qs.toString() ? `?${qs}` : "";
786
+ const qs2 = new URLSearchParams();
787
+ if (args.filter?.trim()) qs2.set("filter", args.filter.trim());
788
+ if (args.start != null) qs2.set("start", String(args.start));
789
+ if (args.limit != null) qs2.set("limit", String(args.limit));
790
+ const suffix = qs2.toString() ? `?${qs2}` : "";
779
791
  return forumFetch(`/api/continuum/forum/unread${suffix}`, {
780
792
  forumUrl: args.forumUrl,
781
793
  ticket: args.ticket
@@ -916,20 +928,52 @@ async function continuumDaoForumSignInEligible(args) {
916
928
  const st = body.status && typeof body.status === "object" ? body.status : null;
917
929
  const reason = typeof body.reason === "string" && body.reason || st && typeof st.message === "string" && st.message || void 0;
918
930
  const ok = res.ok && Boolean(body.ok ?? body.eligible);
931
+ const votingPower = typeof body.votingPower === "string" ? body.votingPower : void 0;
932
+ const threshold = typeof body.threshold === "string" ? body.threshold : void 0;
933
+ const tokenId = typeof body.tokenId === "string" ? body.tokenId : void 0;
919
934
  return {
920
935
  ok,
921
936
  eligible: ok,
922
937
  address: typeof body.address === "string" ? body.address : address,
923
- reason: ok ? void 0 : reason || "Address does not meet the veCTM threshold"
938
+ reason: ok ? void 0 : reason || "Address does not meet the veCTM threshold",
939
+ votingPower,
940
+ threshold,
941
+ tokenId
924
942
  };
925
943
  }
944
+ function assertForumSignInUsernameChoice(args) {
945
+ const nodeKey = args.nodeKey?.trim() || "";
946
+ const username = args.username?.trim() || "";
947
+ if (username && !FORUM_USERNAME_RE.test(username)) {
948
+ throw new Error(
949
+ "Ask the operator for a forum username of 2\u201316 letters, numbers, periods, underscores, or hyphens. If they want the node-key name, call again with useNodeKeyUsername true and nodeKey set."
950
+ );
951
+ }
952
+ if (!username && !(args.useNodeKeyUsername && nodeKey)) {
953
+ throw new Error(
954
+ "Ask the operator for a custom forum username (2\u201316 letters, numbers, . _ -). If they want the default, call again with useNodeKeyUsername true and nodeKey set. The username will be the first 16 characters of the node key."
955
+ );
956
+ }
957
+ }
926
958
  async function continuumDaoForumSignInNonce(args) {
927
- const qs = new URLSearchParams({
959
+ const qs2 = new URLSearchParams({
928
960
  address: args.address,
929
961
  nodeKey: args.nodeKey || "",
930
962
  username: args.username || ""
931
963
  });
932
- return forumFetch(`/api/continuum/eip712/nonce?${qs}`, { forumUrl: args.forumUrl });
964
+ return forumFetch(`/api/continuum/eip712/nonce?${qs2}`, { forumUrl: args.forumUrl });
965
+ }
966
+ function forumSignInTypedExpiryUnix(message) {
967
+ const raw = message.expiresAt;
968
+ const n = typeof raw === "number" ? raw : typeof raw === "string" && raw.trim() !== "" ? Number(raw) : NaN;
969
+ if (!Number.isFinite(n) || n <= 0) return void 0;
970
+ return Math.floor(n > 1e12 ? n / 1e3 : n);
971
+ }
972
+ function forumSignInRequestExpiryUnix(message, explicit) {
973
+ const typed = forumSignInTypedExpiryUnix(message);
974
+ const caller = explicit != null && explicit > 0 ? Math.floor(explicit) : void 0;
975
+ if (typed != null && caller != null) return Math.min(typed, caller);
976
+ return typed ?? caller;
933
977
  }
934
978
  async function buildEvmMultisignBodyContinuumDaoForumSignIn(args) {
935
979
  const owner = getAddress(args.executorAddress);
@@ -939,6 +983,7 @@ async function buildEvmMultisignBodyContinuumDaoForumSignIn(args) {
939
983
  `${gate.reason || "Address does not meet the veCTM threshold"}. Do not start a multi-sign request.`
940
984
  );
941
985
  }
986
+ assertForumSignInUsernameChoice(args);
942
987
  const typed = await continuumDaoForumSignInNonce({
943
988
  address: owner,
944
989
  nodeKey: args.nodeKey,
@@ -967,10 +1012,10 @@ async function buildEvmMultisignBodyContinuumDaoForumSignIn(args) {
967
1012
  }
968
1013
  }
969
1014
  ],
970
- expiryDate: args.expiryDate
1015
+ expiryDate: forumSignInRequestExpiryUnix(typed.message, args.expiryDate)
971
1016
  });
972
1017
  }
973
- var DEFAULT_FORUM_URL, FORUM_GOVERNANCE_SECTIONS, FORUM_IDEA_SECTION, PROPOSAL_TYPE_TO_FORUM_SECTION, IDEA_SECTION_ALIASES, FORUM_LOGIN_DELIVERY_KIND;
1018
+ var DEFAULT_FORUM_URL, FORUM_GOVERNANCE_SECTIONS, FORUM_IDEA_SECTION, PROPOSAL_TYPE_TO_FORUM_SECTION, IDEA_SECTION_ALIASES, FORUM_LOGIN_DELIVERY_KIND, FORUM_USERNAME_RE;
974
1019
  var init_forum = __esm({
975
1020
  "src/protocols/evm/continuum-dao/forum.ts"() {
976
1021
  init_eip712Multisign();
@@ -992,6 +1037,7 @@ var init_forum = __esm({
992
1037
  };
993
1038
  IDEA_SECTION_ALIASES = /* @__PURE__ */ new Set(["ideas", "ideas-suggestions", "suggestions"]);
994
1039
  FORUM_LOGIN_DELIVERY_KIND = "forumLogin";
1040
+ FORUM_USERNAME_RE = /^[A-Za-z0-9._-]{2,16}$/;
995
1041
  }
996
1042
  });
997
1043
 
@@ -2293,9 +2339,9 @@ function parseBackendProposal(raw) {
2293
2339
  committeeProposer: proposer ? isContinuumDaoCommitteeProposer(proposer) : void 0
2294
2340
  };
2295
2341
  }
2296
- function isLegacyContinuumDaoGovernor(addr) {
2297
- if (!addr || !isConfiguredAddress(addr)) return false;
2298
- return getAddress(addr) === CONTINUUM_DAO_LINEA_GOVERNOR_LEGACY_ADDRESS;
2342
+ function isLegacyContinuumDaoGovernor(addr2) {
2343
+ if (!addr2 || !isConfiguredAddress(addr2)) return false;
2344
+ return getAddress(addr2) === CONTINUUM_DAO_LINEA_GOVERNOR_LEGACY_ADDRESS;
2299
2345
  }
2300
2346
  function summarizeLiveProposals(result) {
2301
2347
  if (result.overlay === "backend-only") {
@@ -2472,6 +2518,45 @@ function registerProtocolModule(mod) {
2472
2518
 
2473
2519
  // src/protocols/evm/continuum-dao/index.ts
2474
2520
  init_constants();
2521
+
2522
+ // src/protocols/evm/continuum-dao/marketplaceModule.ts
2523
+ init_constants();
2524
+ var common = ["keyGen", "purposeText", "useCustomGas"];
2525
+ var continuumDaoMarketplaceProtocolModule = {
2526
+ id: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID,
2527
+ chainCategory: "evm",
2528
+ isChainSupported(ctx) {
2529
+ if (ctx.chainCategory !== "evm") return false;
2530
+ const n = typeof ctx.chainId === "number" ? ctx.chainId : Number.parseInt(String(ctx.chainId), 10);
2531
+ return n === CONTINUUM_DAO_LINEA_CHAIN_ID;
2532
+ },
2533
+ isTokenSupported(token) {
2534
+ return token.category === "evm" && (token.kind === "erc20" || token.kind === "erc721");
2535
+ },
2536
+ actions: [
2537
+ { id: "continuum-dao-marketplace.fetch-config", protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, chainCategory: "evm", description: "Marketplace payment tokens, durations, and fees", commonParams: [], params: {} },
2538
+ { id: "continuum-dao-marketplace.search", protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, chainCategory: "evm", description: "Rank veCTMs for sale by price, locked CTM, or unlock time", commonParams: [], params: {} },
2539
+ { id: "continuum-dao-marketplace.fee-alternative", protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, chainCategory: "evm", description: "One qualifying direct listing beside 12 times the KeyGen monthly fee", commonParams: [], params: {} },
2540
+ { id: "continuum-dao-marketplace.fetch-listings", protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, chainCategory: "evm", description: "Open listings, or past sales when includeInactive is set", commonParams: [], params: {} },
2541
+ { id: "continuum-dao-marketplace.fetch-offerings", protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, chainCategory: "evm", description: "Open offerings, or closed offers when includeInactive is set", commonParams: [], params: {} },
2542
+ { id: "continuum-dao-marketplace.fetch-auctions", protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, chainCategory: "evm", description: "Live auctions, or settled auctions when includeInactive is set. Each row includes bids.", commonParams: [], params: {} },
2543
+ { id: "continuum-dao-marketplace.fetch-token", protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, chainCategory: "evm", description: "One veCTM: live orders plus history of sales and auctions", commonParams: [], params: { tokenId: { type: "string", required: true, description: "veCTM token id" } } },
2544
+ { id: "continuum-dao-marketplace.fetch-activity", protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, chainCategory: "evm", description: "An address\u2019s sales, buys, and auctions including bids", commonParams: [], params: { address: { type: "string", required: true, description: "KeyGen or wallet" } } },
2545
+ { id: "continuum-dao-marketplace.fetch-fee-preview", protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, chainCategory: "evm", description: "Protocol fee for a price and veCTM", commonParams: [], params: {} },
2546
+ { id: "continuum-dao-marketplace.create-listing", protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, chainCategory: "evm", description: "Approve veCTM if needed and create a listing", commonParams: [...common], params: { tokenId: { type: "string", required: true, description: "veCTM token id" }, askWei: { type: "string", required: true, description: "Ask in payment-token wei" } } },
2547
+ { id: "continuum-dao-marketplace.delist", protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, chainCategory: "evm", description: "Delist an open listing", commonParams: [...common], params: { tokenId: { type: "string", required: true, description: "veCTM token id" } } },
2548
+ { id: "continuum-dao-marketplace.fulfill-listing", protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, chainCategory: "evm", description: "Buy a listed veCTM", commonParams: [...common], params: { tokenId: { type: "string", required: true, description: "veCTM token id" } } },
2549
+ { id: "continuum-dao-marketplace.create-offering", protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, chainCategory: "evm", description: "Make an offering on a veCTM", commonParams: [...common], params: { tokenId: { type: "string", required: true, description: "veCTM token id" } } },
2550
+ { id: "continuum-dao-marketplace.rescind", protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, chainCategory: "evm", description: "Rescind an open offering", commonParams: [...common], params: { tokenId: { type: "string", required: true, description: "veCTM token id" } } },
2551
+ { id: "continuum-dao-marketplace.fulfill-offering", protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, chainCategory: "evm", description: "Accept an offering on a veCTM you own", commonParams: [...common], params: { tokenId: { type: "string", required: true, description: "veCTM token id" } } },
2552
+ { id: "continuum-dao-marketplace.create-auction", protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, chainCategory: "evm", description: "Escrow a veCTM into an auction", commonParams: [...common], params: { tokenId: { type: "string", required: true, description: "veCTM token id" } } },
2553
+ { id: "continuum-dao-marketplace.cancel-auction", protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, chainCategory: "evm", description: "Cancel a pending auction with no bids", commonParams: [...common], params: { tokenId: { type: "string", required: true, description: "veCTM token id" } } },
2554
+ { id: "continuum-dao-marketplace.auction-bid", protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, chainCategory: "evm", description: "Bid on a live auction", commonParams: [...common], params: { tokenId: { type: "string", required: true, description: "veCTM token id" } } },
2555
+ { id: "continuum-dao-marketplace.settle-auction", protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, chainCategory: "evm", description: "Settle a completed or expired auction", commonParams: [...common], params: { tokenId: { type: "string", required: true, description: "veCTM token id" } } }
2556
+ ]
2557
+ };
2558
+
2559
+ // src/protocols/evm/continuum-dao/index.ts
2475
2560
  init_constants();
2476
2561
 
2477
2562
  // src/protocols/evm/continuum-dao/escrowRules.ts
@@ -2767,13 +2852,13 @@ async function readVeCtmLockState(args) {
2767
2852
  let attached = false;
2768
2853
  if (isConfiguredAddress(nodeProperties)) {
2769
2854
  try {
2770
- const attachedKey = await client.readContract({
2855
+ const attachedKey2 = await client.readContract({
2771
2856
  address: getAddress(nodeProperties),
2772
2857
  abi: nodePropsAbi,
2773
2858
  functionName: "attachedKeyGen",
2774
2859
  args: [args.tokenId]
2775
2860
  });
2776
- attached = attachedKey !== zeroAddress;
2861
+ attached = attachedKey2 !== zeroAddress;
2777
2862
  } catch {
2778
2863
  attached = false;
2779
2864
  }
@@ -2941,7 +3026,7 @@ async function preflightAttachVeCtm(args) {
2941
3026
  }
2942
3027
  if (isConfiguredAddress(nodeProperties)) {
2943
3028
  const np = getAddress(nodeProperties);
2944
- const [attachedKey, attachedForKey] = await Promise.all([
3029
+ const [attachedKey2, attachedForKey] = await Promise.all([
2945
3030
  client.readContract({
2946
3031
  address: np,
2947
3032
  abi: nodePropsAbi,
@@ -2955,7 +3040,7 @@ async function preflightAttachVeCtm(args) {
2955
3040
  args: [executor]
2956
3041
  })
2957
3042
  ]);
2958
- if (attachedKey !== zeroAddress) {
3043
+ if (attachedKey2 !== zeroAddress) {
2959
3044
  throw new Error(`veCTM #${args.tokenId} is already attached. You cannot replace an attached NFT.`);
2960
3045
  }
2961
3046
  if (attachedForKey !== 0n) {
@@ -2972,7 +3057,7 @@ async function preflightAttachVeCtm(args) {
2972
3057
  }
2973
3058
  async function preflightRequestDetach(args) {
2974
3059
  const client = publicClient(args.rpcUrl, args.chainId);
2975
- const [attachedKey, alreadyRequested] = await Promise.all([
3060
+ const [attachedKey2, alreadyRequested] = await Promise.all([
2976
3061
  client.readContract({
2977
3062
  address: args.nodeProperties,
2978
3063
  abi: nodePropsAbi,
@@ -2986,7 +3071,7 @@ async function preflightRequestDetach(args) {
2986
3071
  args: [args.tokenId]
2987
3072
  })
2988
3073
  ]);
2989
- if (attachedKey === zeroAddress) {
3074
+ if (attachedKey2 === zeroAddress) {
2990
3075
  throw new Error(`veCTM #${args.tokenId} is not attached to a node.`);
2991
3076
  }
2992
3077
  if (alreadyRequested) {
@@ -2994,9 +3079,9 @@ async function preflightRequestDetach(args) {
2994
3079
  `Detach already requested for veCTM #${args.tokenId}. The NFT stays attached until governance executes detach.`
2995
3080
  );
2996
3081
  }
2997
- if (getAddress(attachedKey) !== getAddress(args.owner)) {
3082
+ if (getAddress(attachedKey2) !== getAddress(args.owner)) {
2998
3083
  throw new Error(
2999
- `Request detach from the attached KeyGen (${getAddress(attachedKey)}).`
3084
+ `Request detach from the attached KeyGen (${getAddress(attachedKey2)}).`
3000
3085
  );
3001
3086
  }
3002
3087
  }
@@ -3850,8 +3935,8 @@ function extractAbiFromSourcifyFiles(data) {
3850
3935
  if (!label.includes("metadata.json") && f.name !== "metadata.json") continue;
3851
3936
  if (typeof f.content !== "string") continue;
3852
3937
  try {
3853
- const meta3 = JSON.parse(f.content);
3854
- const abi = extractAbiFromUnknown(meta3);
3938
+ const meta4 = JSON.parse(f.content);
3939
+ const abi = extractAbiFromUnknown(meta4);
3855
3940
  if (abi) return abi;
3856
3941
  } catch {
3857
3942
  continue;
@@ -4711,6 +4796,2112 @@ async function continuumDaoFetchProposalVotes(args, deps) {
4711
4796
 
4712
4797
  // src/protocols/evm/continuum-dao/index.ts
4713
4798
  init_forum();
4799
+
4800
+ // src/protocols/evm/continuum-dao/marketplaceTypes.ts
4801
+ var MARKET_ORDER_STATUS = [
4802
+ "NonExistent",
4803
+ "Open",
4804
+ "Fulfilled",
4805
+ "Expired",
4806
+ "DelistedOrRescinded",
4807
+ "LockAmountDecreased",
4808
+ "LockEndIncreased",
4809
+ "TokenApprovalRequired",
4810
+ "PaymentApprovalRequired",
4811
+ "KeyGenAttached"
4812
+ ];
4813
+ var AUCTION_STATUS = [
4814
+ "NonExistent",
4815
+ "Pending",
4816
+ "Active",
4817
+ "Complete",
4818
+ "Sold",
4819
+ "Canceled",
4820
+ "Expired"
4821
+ ];
4822
+ var FEE_TIER_NAMES = ["Black", "Gold", "Silver", "Bronze", "Blue"];
4823
+ function orderStatusName(code) {
4824
+ return MARKET_ORDER_STATUS[code] ?? "NonExistent";
4825
+ }
4826
+ function auctionStatusName(code) {
4827
+ return AUCTION_STATUS[code] ?? "NonExistent";
4828
+ }
4829
+ function addr(value) {
4830
+ try {
4831
+ return getAddress(value);
4832
+ } catch {
4833
+ return value;
4834
+ }
4835
+ }
4836
+ function same(a, b) {
4837
+ return a.toLowerCase() === b.toLowerCase();
4838
+ }
4839
+ function deadlineAt(unix) {
4840
+ const n = Number(unix);
4841
+ if (!Number.isFinite(n) || n <= 0) return "";
4842
+ return new Date(n * 1e3).toISOString();
4843
+ }
4844
+ function blankOrder(kind, tokenId, creator, index) {
4845
+ return {
4846
+ kind,
4847
+ tokenId,
4848
+ onchainIndex: index,
4849
+ creator: addr(creator),
4850
+ paymentToken: zeroAddress,
4851
+ price: "0",
4852
+ deadlineUnix: "0",
4853
+ deadlineAt: "",
4854
+ snapshotAmount: "0",
4855
+ snapshotEnd: "0",
4856
+ storedStatus: "Open",
4857
+ protocolStatus: "Open"
4858
+ };
4859
+ }
4860
+ function blankAuction(tokenId, seller, index) {
4861
+ return {
4862
+ tokenId,
4863
+ onchainIndex: index,
4864
+ seller: addr(seller),
4865
+ paymentToken: zeroAddress,
4866
+ reservePrice: "0",
4867
+ minimumBidIncrement: "0",
4868
+ highestBid: "0",
4869
+ highestBidder: null,
4870
+ deadlineUnix: "0",
4871
+ deadlineAt: "",
4872
+ storedStatus: "Pending",
4873
+ derivedStatus: "Pending",
4874
+ needsSettle: false,
4875
+ bids: []
4876
+ };
4877
+ }
4878
+ function latestOpenOrder(rows, kind, tokenId, creator) {
4879
+ for (let i = rows.length - 1; i >= 0; i--) {
4880
+ const row = rows[i];
4881
+ if (row.kind === kind && row.tokenId === tokenId && same(row.creator, creator) && row.storedStatus === "Open") {
4882
+ return row;
4883
+ }
4884
+ }
4885
+ return void 0;
4886
+ }
4887
+ function latestAuction(rows, tokenId, seller) {
4888
+ for (let i = rows.length - 1; i >= 0; i--) {
4889
+ const row = rows[i];
4890
+ if (row.tokenId === tokenId && same(row.seller, seller)) return row;
4891
+ }
4892
+ return void 0;
4893
+ }
4894
+ function applyMarketplaceEvent(book, ev) {
4895
+ const listingSeq = book.listings.reduce((max, row) => Math.max(max, Number(row.onchainIndex) || 0), 0);
4896
+ const offeringSeq = book.offerings.reduce((max, row) => Math.max(max, Number(row.onchainIndex) || 0), 0);
4897
+ const auctionSeq = book.auctions.reduce((max, row) => Math.max(max, Number(row.onchainIndex) || 0), 0);
4898
+ const next = (seq) => String(seq + 1);
4899
+ if (ev.name === "ListingCreated" || ev.name === "OfferingCreated") {
4900
+ const kind = ev.name === "ListingCreated" ? "Listing" : "Offering";
4901
+ const rows = kind === "Listing" ? book.listings : book.offerings;
4902
+ const prev = latestOpenOrder(rows, kind, ev.tokenId, ev.actor);
4903
+ if (prev) {
4904
+ prev.storedStatus = "DelistedOrRescinded";
4905
+ prev.protocolStatus = "DelistedOrRescinded";
4906
+ prev.closedTx = ev.tx;
4907
+ prev.closedBlock = ev.block;
4908
+ }
4909
+ const row = blankOrder(kind, ev.tokenId, ev.actor, next(kind === "Listing" ? listingSeq : offeringSeq));
4910
+ row.paymentToken = addr(ev.paymentToken);
4911
+ row.price = ev.amount;
4912
+ row.deadlineUnix = ev.deadline;
4913
+ row.deadlineAt = deadlineAt(ev.deadline);
4914
+ row.createdTx = ev.tx;
4915
+ row.createdBlock = ev.block;
4916
+ if (kind === "Listing") row.seller = addr(ev.actor);
4917
+ else row.buyer = addr(ev.actor);
4918
+ rows.push(row);
4919
+ return;
4920
+ }
4921
+ if (ev.name === "Delisted" || ev.name === "Rescinded") {
4922
+ const kind = ev.name === "Delisted" ? "Listing" : "Offering";
4923
+ const row = latestOpenOrder(kind === "Listing" ? book.listings : book.offerings, kind, ev.tokenId, ev.actor);
4924
+ if (row) {
4925
+ row.storedStatus = "DelistedOrRescinded";
4926
+ row.protocolStatus = "DelistedOrRescinded";
4927
+ row.closedTx = ev.tx;
4928
+ row.closedBlock = ev.block;
4929
+ }
4930
+ return;
4931
+ }
4932
+ if (ev.name === "ListingFulfilled" || ev.name === "OfferingFulfilled") {
4933
+ const kind = ev.name === "ListingFulfilled" ? "Listing" : "Offering";
4934
+ const actor = kind === "Listing" ? ev.seller : ev.buyer;
4935
+ const row = latestOpenOrder(kind === "Listing" ? book.listings : book.offerings, kind, ev.tokenId, actor);
4936
+ if (row) {
4937
+ row.storedStatus = "Fulfilled";
4938
+ row.protocolStatus = "Fulfilled";
4939
+ row.counterparty = addr(kind === "Listing" ? ev.buyer : ev.seller);
4940
+ row.seller = addr(ev.seller);
4941
+ row.buyer = addr(ev.buyer);
4942
+ row.fee = ev.fee;
4943
+ row.net = ev.net;
4944
+ row.closedTx = ev.tx;
4945
+ row.closedBlock = ev.block;
4946
+ }
4947
+ return;
4948
+ }
4949
+ if (ev.name === "AuctionCreated") {
4950
+ const prev = latestAuction(book.auctions, ev.tokenId, ev.actor);
4951
+ if (prev && (prev.storedStatus === "Pending" || prev.storedStatus === "Active")) {
4952
+ prev.storedStatus = "Canceled";
4953
+ prev.derivedStatus = "Canceled";
4954
+ prev.closedTx = ev.tx;
4955
+ prev.closedBlock = ev.block;
4956
+ }
4957
+ const row = blankAuction(ev.tokenId, ev.actor, next(auctionSeq));
4958
+ row.paymentToken = addr(ev.paymentToken);
4959
+ row.reservePrice = ev.amount;
4960
+ row.minimumBidIncrement = ev.minIncrement;
4961
+ row.deadlineUnix = ev.deadline;
4962
+ row.deadlineAt = deadlineAt(ev.deadline);
4963
+ row.createdTx = ev.tx;
4964
+ row.createdBlock = ev.block;
4965
+ book.auctions.push(row);
4966
+ return;
4967
+ }
4968
+ if (ev.name === "AuctionCanceled") {
4969
+ const row = latestAuction(book.auctions, ev.tokenId, ev.actor);
4970
+ if (row && row.storedStatus === "Pending") {
4971
+ row.storedStatus = "Canceled";
4972
+ row.derivedStatus = "Canceled";
4973
+ row.closedTx = ev.tx;
4974
+ row.closedBlock = ev.block;
4975
+ }
4976
+ return;
4977
+ }
4978
+ if (ev.name === "AuctionBid") {
4979
+ const row = latestAuction(book.auctions, ev.tokenId, ev.seller);
4980
+ if (!row || row.storedStatus !== "Pending" && row.storedStatus !== "Active") return;
4981
+ row.bids = [
4982
+ ...row.bids,
4983
+ {
4984
+ bidder: addr(ev.buyer),
4985
+ price: ev.price,
4986
+ tx: ev.tx,
4987
+ timestamp: ev.timestamp ?? "0",
4988
+ logIndex: String(ev.logIndex),
4989
+ block: ev.block
4990
+ }
4991
+ ];
4992
+ row.highestBid = ev.price;
4993
+ row.highestBidder = addr(ev.buyer);
4994
+ row.storedStatus = "Active";
4995
+ row.derivedStatus = "Active";
4996
+ return;
4997
+ }
4998
+ if (ev.name === "AuctionSettled") {
4999
+ const row = latestAuction(book.auctions, ev.tokenId, ev.seller);
5000
+ if (!row) return;
5001
+ const name = auctionStatusName(ev.finalStatus);
5002
+ row.storedStatus = name;
5003
+ row.derivedStatus = name;
5004
+ row.needsSettle = false;
5005
+ row.closedTx = ev.tx;
5006
+ row.closedBlock = ev.block;
5007
+ return;
5008
+ }
5009
+ if (ev.name === "AuctionSuccessful") {
5010
+ const row = latestAuction(book.auctions, ev.tokenId, ev.seller);
5011
+ if (!row) return;
5012
+ row.storedStatus = "Sold";
5013
+ row.derivedStatus = "Sold";
5014
+ row.buyer = addr(ev.buyer);
5015
+ row.highestBidder = addr(ev.buyer);
5016
+ row.highestBid = ev.price;
5017
+ row.fee = ev.fee;
5018
+ row.net = ev.net;
5019
+ row.needsSettle = false;
5020
+ row.closedTx = ev.tx;
5021
+ row.closedBlock = ev.block;
5022
+ }
5023
+ }
5024
+ function foldMarketplaceEvents(events, initial) {
5025
+ const book = {
5026
+ listings: [...initial?.listings ?? []],
5027
+ offerings: [...initial?.offerings ?? []],
5028
+ auctions: (initial?.auctions ?? []).map((row) => ({ ...row, bids: [...row.bids] }))
5029
+ };
5030
+ for (const ev of events) applyMarketplaceEvent(book, ev);
5031
+ return book;
5032
+ }
5033
+ function deriveAuctionStatus(auction, nowUnix) {
5034
+ const deadline = Number(auction.deadlineUnix);
5035
+ if (auction.storedStatus === "Pending" && Number.isFinite(deadline) && nowUnix >= deadline) return "Expired";
5036
+ if (auction.storedStatus === "Active" && Number.isFinite(deadline) && nowUnix >= deadline) return "Complete";
5037
+ return auction.derivedStatus || auction.storedStatus;
5038
+ }
5039
+ function applyDerivedStatuses(book, nowUnix) {
5040
+ return {
5041
+ listings: book.listings.map((row) => {
5042
+ const deadline = Number(row.deadlineUnix);
5043
+ if (row.storedStatus === "Open" && Number.isFinite(deadline) && nowUnix >= deadline) {
5044
+ return { ...row, protocolStatus: "Expired" };
5045
+ }
5046
+ return row;
5047
+ }),
5048
+ offerings: book.offerings.map((row) => {
5049
+ const deadline = Number(row.deadlineUnix);
5050
+ if (row.storedStatus === "Open" && Number.isFinite(deadline) && nowUnix >= deadline) {
5051
+ return { ...row, protocolStatus: "Expired" };
5052
+ }
5053
+ return row;
5054
+ }),
5055
+ auctions: book.auctions.map((row) => {
5056
+ const derived = deriveAuctionStatus(row, nowUnix);
5057
+ const needsSettle = derived === "Complete" || derived === "Expired";
5058
+ return { ...row, derivedStatus: derived, needsSettle };
5059
+ })
5060
+ };
5061
+ }
5062
+ function isLiveAuctionStatus(status) {
5063
+ return status === "Pending" || status === "Active" || status === "Complete";
5064
+ }
5065
+ function isOpenOrder(row) {
5066
+ return row.storedStatus === "Open" && row.protocolStatus === "Open";
5067
+ }
5068
+ var marketplaceAbi = parseAbi([
5069
+ "function weth() view returns (address)",
5070
+ "function ve() view returns (address)",
5071
+ "function np() view returns (address)",
5072
+ "function gov() view returns (address)",
5073
+ "function minimumDuration() view returns (uint256)",
5074
+ "function maximumDuration() view returns (uint256)",
5075
+ "function isValidPaymentToken(address) view returns (bool)",
5076
+ "function feeLimitByTier(uint8) view returns (uint256)",
5077
+ "function feeRateByTier(uint8) view returns (uint256)",
5078
+ "function listingIndexByTokenSeller(uint256,address) view returns (uint256)",
5079
+ "function listingsByToken(uint256,uint256) view returns (uint256 price, uint256 deadline, uint256 snapshotAmount, uint256 snapshotEnd, address creator, address paymentToken, uint8 status, uint8 kind)",
5080
+ "function offeringIndexByTokenBuyer(uint256,address) view returns (uint256)",
5081
+ "function offeringsByToken(uint256,uint256) view returns (uint256 price, uint256 deadline, uint256 snapshotAmount, uint256 snapshotEnd, address creator, address paymentToken, uint8 status, uint8 kind)",
5082
+ "function auctionIndexByTokenSeller(uint256,address) view returns (uint256)",
5083
+ "function auctionsByToken(uint256,uint256) view returns (uint256 reservePrice, uint256 minimumBidIncrement, uint256 deadline, address seller, address paymentToken, address highestBidder, uint256 highestBid, uint8 status)",
5084
+ "function marketOrderStatus((uint256,uint256,uint256,uint256,address,address,uint8,uint8),uint256,uint256,address,uint256) view returns (uint8)",
5085
+ "function auctionStatus((uint256,uint256,uint256,address,address,address,uint256,uint8)) view returns (uint8)",
5086
+ "function createListing(uint256,address,uint256,uint256)",
5087
+ "function delist(uint256)",
5088
+ "function fulfillListing(uint256,address,address,uint256) payable",
5089
+ "function createOffering(uint256,address,uint256,uint256) payable",
5090
+ "function rescind(uint256)",
5091
+ "function fulfillOffering(uint256,address,address,uint256)",
5092
+ "function createAuction(uint256,address,uint256,uint256,uint256)",
5093
+ "function cancelAuction(uint256)",
5094
+ "function auctionBid(uint256,address,uint256) payable",
5095
+ "function settleAuction(uint256,address)",
5096
+ "event ListingCreated(uint256 indexed _tokenId, address indexed _listedBy, address indexed _paymentToken, uint256 _ask, uint256 _deadline)",
5097
+ "event ListingFulfilled(uint256 indexed _tokenId, address indexed _buyer, address indexed _seller, uint256 _ask, uint256 _netPrice, uint256 _fee)",
5098
+ "event Delisted(uint256 indexed _tokenId, address indexed _seller)",
5099
+ "event OfferingCreated(uint256 indexed _tokenId, address indexed _offeredBy, address indexed _paymentToken, uint256 _bid, uint256 _deadline)",
5100
+ "event OfferingFulfilled(uint256 indexed _tokenId, address indexed _buyer, address indexed _seller, uint256 _bid, uint256 _netPrice, uint256 _fee)",
5101
+ "event Rescinded(uint256 indexed _tokenId, address indexed _buyer)",
5102
+ "event AuctionCreated(uint256 indexed _tokenId, address indexed _createdBy, address indexed _paymentToken, uint256 _reservePrice, uint256 _minimumBidIncrement, uint256 _deadline)",
5103
+ "event AuctionCanceled(uint256 indexed _tokenId, address indexed _seller)",
5104
+ "event AuctionBid(uint256 indexed _tokenId, address indexed _seller, address indexed _buyer, uint256 _price)",
5105
+ "event AuctionSettled(uint256 indexed _tokenId, address indexed _seller, uint8 indexed _finalStatus)",
5106
+ "event AuctionSuccessful(uint256 indexed _tokenId, address indexed _seller, address indexed _buyer, uint256 _price, uint256 _fee, uint256 _net)"
5107
+ ]);
5108
+ var marketplaceReadAbi = parseAbi([
5109
+ "function ownerOf(uint256) view returns (address)",
5110
+ "function getApproved(uint256) view returns (address)",
5111
+ "function isApprovedForAll(address,address) view returns (bool)",
5112
+ "function approve(address,uint256)",
5113
+ "function locked(uint256) view returns (int128 amount, uint256 end)",
5114
+ "function allowance(address,address) view returns (uint256)",
5115
+ "function decimals() view returns (uint8)",
5116
+ "function symbol() view returns (string)",
5117
+ "function attachedKeyGen(uint256) view returns (address)"
5118
+ ]);
5119
+
5120
+ // src/protocols/evm/continuum-dao/marketplacePlan.ts
5121
+ var MARKETPLACE_APPROVE_FALLBACK = 80000n;
5122
+ var MARKETPLACE_LISTING_FALLBACK = 280000n;
5123
+ var MARKETPLACE_FULFILL_FALLBACK = 450000n;
5124
+ var MARKETPLACE_OFFERING_FALLBACK = 320000n;
5125
+ var MARKETPLACE_AUCTION_CREATE_FALLBACK = 380000n;
5126
+ var MARKETPLACE_BID_FALLBACK = 280000n;
5127
+ var MARKETPLACE_SETTLE_FALLBACK = 400000n;
5128
+ function same2(a, b) {
5129
+ try {
5130
+ return getAddress(a) === getAddress(b);
5131
+ } catch {
5132
+ return a.toLowerCase() === b.toLowerCase();
5133
+ }
5134
+ }
5135
+ function isWeth(snap, token) {
5136
+ return same2(token, snap.weth);
5137
+ }
5138
+ function keyGenOwnsVeCtm(snap, seller) {
5139
+ if (same2(snap.owner, snap.executor)) return true;
5140
+ if (seller && same2(seller, snap.executor)) return true;
5141
+ if (snap.executorOpenListing && same2(snap.owner, snap.executor)) return true;
5142
+ if (snap.executorLiveAuction) return true;
5143
+ return false;
5144
+ }
5145
+ function assertNotOwn(snap, seller, tokenId) {
5146
+ if (same2(snap.owner, snap.executor) || seller && same2(seller, snap.executor) || snap.executorLiveAuction) {
5147
+ throw new Error(`This KeyGen already owns veCTM #${tokenId.toString()} and cannot buy or bid on it.`);
5148
+ }
5149
+ }
5150
+ function assertDeadline(snap, deadline) {
5151
+ const min = snap.now + snap.minimumDuration;
5152
+ const max = snap.now + snap.maximumDuration;
5153
+ if (deadline < min || deadline > max) {
5154
+ throw new Error(`Deadline must be between ${min.toString()} and ${max.toString()} (unix seconds).`);
5155
+ }
5156
+ }
5157
+ function assertPayment(snap) {
5158
+ if (!snap.paymentTokenValid) throw new Error("This payment token is not accepted by the marketplace.");
5159
+ }
5160
+ function assertNotAttached(snap, tokenId) {
5161
+ if (snap.attachedKeyGen !== zeroAddress) {
5162
+ throw new Error(`veCTM #${tokenId.toString()} has a KeyGen attached.`);
5163
+ }
5164
+ }
5165
+ function nftApproveStep(snap, tokenId) {
5166
+ if (snap.nftApproved) return null;
5167
+ return {
5168
+ to: snap.votingEscrow,
5169
+ data: encodeFunctionData({
5170
+ abi: marketplaceReadAbi,
5171
+ functionName: "approve",
5172
+ args: [snap.marketplace, tokenId]
5173
+ }),
5174
+ value: 0n,
5175
+ fallbackGas: MARKETPLACE_APPROVE_FALLBACK,
5176
+ evmType: "continuum_dao_marketplace_nft_approve",
5177
+ name: "VotingEscrow.approve",
5178
+ extra: { tokenId: tokenId.toString(), operator: snap.marketplace }
5179
+ };
5180
+ }
5181
+ function parseApproveAbi() {
5182
+ return [
5183
+ {
5184
+ type: "function",
5185
+ name: "approve",
5186
+ stateMutability: "nonpayable",
5187
+ inputs: [
5188
+ { name: "spender", type: "address" },
5189
+ { name: "amount", type: "uint256" }
5190
+ ],
5191
+ outputs: [{ name: "", type: "bool" }]
5192
+ }
5193
+ ];
5194
+ }
5195
+ function erc20Approve(snap, token, amount) {
5196
+ if (snap.allowance >= amount) return null;
5197
+ return {
5198
+ to: token,
5199
+ data: encodeFunctionData({
5200
+ abi: parseApproveAbi(),
5201
+ functionName: "approve",
5202
+ args: [snap.marketplace, amount]
5203
+ }),
5204
+ value: 0n,
5205
+ fallbackGas: MARKETPLACE_APPROVE_FALLBACK,
5206
+ evmType: "continuum_dao_marketplace_approve",
5207
+ name: "ERC20.approve",
5208
+ extra: { spender: snap.marketplace, amountWei: amount.toString(), token }
5209
+ };
5210
+ }
5211
+ function withApprovals(steps) {
5212
+ return steps.filter((s) => s != null);
5213
+ }
5214
+ function planMarketplaceSteps(input, snap) {
5215
+ const m = snap.marketplace;
5216
+ switch (input.action) {
5217
+ case "createListing": {
5218
+ assertPayment(snap);
5219
+ assertDeadline(snap, input.deadline);
5220
+ if (!same2(snap.owner, snap.executor)) throw new Error("Only the veCTM owner can create a listing.");
5221
+ return withApprovals([
5222
+ nftApproveStep(snap, input.tokenId),
5223
+ {
5224
+ to: m,
5225
+ data: encodeFunctionData({
5226
+ abi: marketplaceAbi,
5227
+ functionName: "createListing",
5228
+ args: [input.tokenId, input.paymentToken, input.askWei, input.deadline]
5229
+ }),
5230
+ value: 0n,
5231
+ fallbackGas: MARKETPLACE_LISTING_FALLBACK,
5232
+ evmType: "continuum_dao_marketplace_create_listing",
5233
+ name: "VotingEscrowMarketplace.createListing",
5234
+ extra: {
5235
+ tokenId: input.tokenId.toString(),
5236
+ paymentToken: input.paymentToken,
5237
+ askWei: input.askWei.toString(),
5238
+ deadline: input.deadline.toString()
5239
+ }
5240
+ }
5241
+ ]);
5242
+ }
5243
+ case "delist": {
5244
+ if (!snap.listing || snap.listing.status !== 1) throw new Error("No open listing for this KeyGen.");
5245
+ return [
5246
+ {
5247
+ to: m,
5248
+ data: encodeFunctionData({ abi: marketplaceAbi, functionName: "delist", args: [input.tokenId] }),
5249
+ value: 0n,
5250
+ fallbackGas: MARKETPLACE_LISTING_FALLBACK,
5251
+ evmType: "continuum_dao_marketplace_delist",
5252
+ name: "VotingEscrowMarketplace.delist",
5253
+ extra: { tokenId: input.tokenId.toString() }
5254
+ }
5255
+ ];
5256
+ }
5257
+ case "fulfillListing": {
5258
+ assertNotOwn(snap, input.seller, input.tokenId);
5259
+ const listing = snap.listing;
5260
+ if (!listing || !same2(listing.creator, input.seller)) throw new Error("No open listing for this seller.");
5261
+ if (!same2(listing.paymentToken, input.paymentToken) || listing.price !== input.priceWei) {
5262
+ throw new Error("Listing price or payment token changed. Refresh and try again.");
5263
+ }
5264
+ const weth = isWeth(snap, listing.paymentToken);
5265
+ return withApprovals([
5266
+ weth ? null : erc20Approve(snap, listing.paymentToken, listing.price),
5267
+ {
5268
+ to: m,
5269
+ data: encodeFunctionData({
5270
+ abi: marketplaceAbi,
5271
+ functionName: "fulfillListing",
5272
+ args: [input.tokenId, input.seller, listing.paymentToken, listing.price]
5273
+ }),
5274
+ value: weth ? listing.price : 0n,
5275
+ fallbackGas: MARKETPLACE_FULFILL_FALLBACK,
5276
+ evmType: "continuum_dao_marketplace_fulfill_listing",
5277
+ name: "VotingEscrowMarketplace.fulfillListing",
5278
+ extra: {
5279
+ tokenId: input.tokenId.toString(),
5280
+ seller: input.seller,
5281
+ paymentToken: listing.paymentToken,
5282
+ priceWei: listing.price.toString(),
5283
+ recipient: snap.executor
5284
+ }
5285
+ }
5286
+ ]);
5287
+ }
5288
+ case "createOffering": {
5289
+ assertNotOwn(snap, void 0, input.tokenId);
5290
+ assertPayment(snap);
5291
+ assertDeadline(snap, input.deadline);
5292
+ const weth = isWeth(snap, input.paymentToken);
5293
+ return withApprovals([
5294
+ erc20Approve(snap, input.paymentToken, input.bidWei),
5295
+ {
5296
+ to: m,
5297
+ data: encodeFunctionData({
5298
+ abi: marketplaceAbi,
5299
+ functionName: "createOffering",
5300
+ args: [input.tokenId, input.paymentToken, input.bidWei, input.deadline]
5301
+ }),
5302
+ value: weth ? input.bidWei : 0n,
5303
+ fallbackGas: MARKETPLACE_OFFERING_FALLBACK,
5304
+ evmType: "continuum_dao_marketplace_create_offering",
5305
+ name: "VotingEscrowMarketplace.createOffering",
5306
+ extra: {
5307
+ tokenId: input.tokenId.toString(),
5308
+ paymentToken: input.paymentToken,
5309
+ bidWei: input.bidWei.toString(),
5310
+ deadline: input.deadline.toString()
5311
+ }
5312
+ }
5313
+ ]);
5314
+ }
5315
+ case "rescind": {
5316
+ if (!snap.offering || snap.offering.status !== 1) throw new Error("No open offering for this KeyGen.");
5317
+ return [
5318
+ {
5319
+ to: m,
5320
+ data: encodeFunctionData({ abi: marketplaceAbi, functionName: "rescind", args: [input.tokenId] }),
5321
+ value: 0n,
5322
+ fallbackGas: MARKETPLACE_OFFERING_FALLBACK,
5323
+ evmType: "continuum_dao_marketplace_rescind",
5324
+ name: "VotingEscrowMarketplace.rescind",
5325
+ extra: { tokenId: input.tokenId.toString() }
5326
+ }
5327
+ ];
5328
+ }
5329
+ case "fulfillOffering": {
5330
+ assertNotAttached(snap, input.tokenId);
5331
+ if (!same2(snap.owner, snap.executor)) throw new Error("Only the veCTM owner can accept an offering.");
5332
+ const offering = snap.offering;
5333
+ if (!offering || !same2(offering.creator, input.buyer)) throw new Error("No open offering for this buyer.");
5334
+ if (!same2(offering.paymentToken, input.paymentToken) || offering.price !== input.priceWei) {
5335
+ throw new Error("Offering price or payment token changed. Refresh and try again.");
5336
+ }
5337
+ return withApprovals([
5338
+ nftApproveStep(snap, input.tokenId),
5339
+ {
5340
+ to: m,
5341
+ data: encodeFunctionData({
5342
+ abi: marketplaceAbi,
5343
+ functionName: "fulfillOffering",
5344
+ args: [input.tokenId, input.buyer, offering.paymentToken, offering.price]
5345
+ }),
5346
+ value: 0n,
5347
+ fallbackGas: MARKETPLACE_FULFILL_FALLBACK,
5348
+ evmType: "continuum_dao_marketplace_fulfill_offering",
5349
+ name: "VotingEscrowMarketplace.fulfillOffering",
5350
+ extra: {
5351
+ tokenId: input.tokenId.toString(),
5352
+ buyer: input.buyer,
5353
+ paymentToken: offering.paymentToken,
5354
+ priceWei: offering.price.toString()
5355
+ }
5356
+ }
5357
+ ]);
5358
+ }
5359
+ case "createAuction": {
5360
+ assertNotAttached(snap, input.tokenId);
5361
+ assertPayment(snap);
5362
+ assertDeadline(snap, input.deadline);
5363
+ if (input.reserveWei <= 0n) throw new Error("Reserve price must be greater than zero.");
5364
+ if (!same2(snap.owner, snap.executor)) throw new Error("Only the veCTM owner can start an auction.");
5365
+ if (snap.executorLiveAuction) throw new Error("A live auction already exists for this token.");
5366
+ return withApprovals([
5367
+ nftApproveStep(snap, input.tokenId),
5368
+ {
5369
+ to: m,
5370
+ data: encodeFunctionData({
5371
+ abi: marketplaceAbi,
5372
+ functionName: "createAuction",
5373
+ args: [input.tokenId, input.paymentToken, input.deadline, input.reserveWei, input.minIncrementWei]
5374
+ }),
5375
+ value: 0n,
5376
+ fallbackGas: MARKETPLACE_AUCTION_CREATE_FALLBACK,
5377
+ evmType: "continuum_dao_marketplace_create_auction",
5378
+ name: "VotingEscrowMarketplace.createAuction",
5379
+ extra: {
5380
+ tokenId: input.tokenId.toString(),
5381
+ paymentToken: input.paymentToken,
5382
+ reserveWei: input.reserveWei.toString(),
5383
+ minIncrementWei: input.minIncrementWei.toString(),
5384
+ deadline: input.deadline.toString()
5385
+ }
5386
+ }
5387
+ ]);
5388
+ }
5389
+ case "cancelAuction": {
5390
+ const auction = snap.auction;
5391
+ if (!auction || !same2(auction.seller, snap.executor)) throw new Error("No auction for this KeyGen.");
5392
+ if (auction.status !== 1) throw new Error("Only a pending auction with no bids can be canceled.");
5393
+ return [
5394
+ {
5395
+ to: m,
5396
+ data: encodeFunctionData({ abi: marketplaceAbi, functionName: "cancelAuction", args: [input.tokenId] }),
5397
+ value: 0n,
5398
+ fallbackGas: MARKETPLACE_AUCTION_CREATE_FALLBACK,
5399
+ evmType: "continuum_dao_marketplace_cancel_auction",
5400
+ name: "VotingEscrowMarketplace.cancelAuction",
5401
+ extra: { tokenId: input.tokenId.toString(), recipient: snap.executor }
5402
+ }
5403
+ ];
5404
+ }
5405
+ case "auctionBid": {
5406
+ assertNotOwn(snap, input.seller, input.tokenId);
5407
+ const auction = snap.auction;
5408
+ if (!auction || !same2(auction.seller, input.seller)) throw new Error("No live auction for this seller.");
5409
+ if (auction.status !== 1 && auction.status !== 2) throw new Error("This auction is not accepting bids.");
5410
+ if (input.priceWei < auction.reservePrice) throw new Error("Bid is below the reserve price.");
5411
+ if (auction.highestBidder !== zeroAddress && input.priceWei < auction.highestBid + auction.minimumBidIncrement) {
5412
+ throw new Error("Bid is below the highest bid plus the minimum increment.");
5413
+ }
5414
+ const weth = isWeth(snap, auction.paymentToken);
5415
+ return withApprovals([
5416
+ weth ? null : erc20Approve(snap, auction.paymentToken, input.priceWei),
5417
+ {
5418
+ to: m,
5419
+ data: encodeFunctionData({
5420
+ abi: marketplaceAbi,
5421
+ functionName: "auctionBid",
5422
+ args: [input.tokenId, input.seller, input.priceWei]
5423
+ }),
5424
+ value: weth ? input.priceWei : 0n,
5425
+ fallbackGas: MARKETPLACE_BID_FALLBACK,
5426
+ evmType: "continuum_dao_marketplace_auction_bid",
5427
+ name: "VotingEscrowMarketplace.auctionBid",
5428
+ extra: {
5429
+ tokenId: input.tokenId.toString(),
5430
+ seller: input.seller,
5431
+ priceWei: input.priceWei.toString(),
5432
+ paymentToken: auction.paymentToken
5433
+ }
5434
+ }
5435
+ ]);
5436
+ }
5437
+ case "settleAuction": {
5438
+ const auction = snap.auction;
5439
+ if (!auction || !same2(auction.seller, input.seller)) throw new Error("Auction not found.");
5440
+ const derived = auction.status === 2 && snap.now >= auction.deadline ? 3 : auction.status === 1 && snap.now >= auction.deadline ? 6 : auction.status;
5441
+ if (derived !== 3 && derived !== 6) throw new Error("This auction is not ready to settle.");
5442
+ const winner = auction.highestBidder;
5443
+ return [
5444
+ {
5445
+ to: m,
5446
+ data: encodeFunctionData({
5447
+ abi: marketplaceAbi,
5448
+ functionName: "settleAuction",
5449
+ args: [input.tokenId, input.seller]
5450
+ }),
5451
+ value: 0n,
5452
+ fallbackGas: MARKETPLACE_SETTLE_FALLBACK,
5453
+ evmType: "continuum_dao_marketplace_settle_auction",
5454
+ name: "VotingEscrowMarketplace.settleAuction",
5455
+ extra: {
5456
+ tokenId: input.tokenId.toString(),
5457
+ seller: input.seller,
5458
+ highestBidder: winner,
5459
+ recipient: derived === 3 ? winner : input.seller
5460
+ }
5461
+ }
5462
+ ];
5463
+ }
5464
+ default:
5465
+ throw new Error("Unknown marketplace action.");
5466
+ }
5467
+ }
5468
+
5469
+ // src/protocols/evm/continuum-dao/marketplaceChain.ts
5470
+ init_defiEvmClient();
5471
+ init_constants();
5472
+ function marketplacePublicClient(chainId, rpcUrl) {
5473
+ const ch = defineChain({
5474
+ id: chainId,
5475
+ name: "Linea",
5476
+ nativeCurrency: { decimals: 18, name: "Ether", symbol: "ETH" },
5477
+ rpcUrls: { default: { http: [rpcUrl] } }
5478
+ });
5479
+ return createPublicClient({ chain: ch, transport: defiEvmTransport(rpcUrl) });
5480
+ }
5481
+ var KNOWN_PAYMENT_TOKENS = [
5482
+ { address: getAddress(CTM_TOKEN_ADDRESS), symbol: "CTM", decimals: 18 },
5483
+ { address: MARKETPLACE_WETH_LINEA_ADDRESS, symbol: "WETH", decimals: 18 },
5484
+ { address: MARKETPLACE_USDC_LINEA_ADDRESS, symbol: "USDC", decimals: 6 }
5485
+ ];
5486
+ function calculateMarketplaceFee(price, lockedAmount, limits, rates) {
5487
+ for (let i = 0; i < 5; i++) {
5488
+ const limit = limits[i] ?? 0n;
5489
+ if (lockedAmount >= limit) {
5490
+ const rateBps = rates[i] ?? 0n;
5491
+ const fee = price * rateBps / 10000n;
5492
+ return {
5493
+ tier: FEE_TIER_NAMES[i] ?? "Blue",
5494
+ tierIndex: i,
5495
+ limit,
5496
+ rateBps,
5497
+ fee,
5498
+ net: price - fee
5499
+ };
5500
+ }
5501
+ }
5502
+ return null;
5503
+ }
5504
+ async function readMarketplaceConfigFromChain(args) {
5505
+ const marketplace = args.marketplace ?? VOTING_ESCROW_MARKETPLACE_LINEA_ADDRESS;
5506
+ const client = marketplacePublicClient(args.chainId, args.rpcUrl);
5507
+ const [weth, ve, gov, np, minimumDuration, maximumDuration] = await Promise.all([
5508
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "weth" }),
5509
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "ve" }),
5510
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "gov" }),
5511
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "np" }),
5512
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "minimumDuration" }),
5513
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "maximumDuration" })
5514
+ ]);
5515
+ const feeLimits = [];
5516
+ const feeRates = [];
5517
+ for (let i = 0; i < 5; i++) {
5518
+ const [limit, rate] = await Promise.all([
5519
+ client.readContract({
5520
+ address: marketplace,
5521
+ abi: marketplaceAbi,
5522
+ functionName: "feeLimitByTier",
5523
+ args: [i]
5524
+ }),
5525
+ client.readContract({
5526
+ address: marketplace,
5527
+ abi: marketplaceAbi,
5528
+ functionName: "feeRateByTier",
5529
+ args: [i]
5530
+ })
5531
+ ]);
5532
+ feeLimits.push(limit);
5533
+ feeRates.push(rate);
5534
+ }
5535
+ const paymentTokens = [];
5536
+ for (const token of KNOWN_PAYMENT_TOKENS) {
5537
+ let isValid = false;
5538
+ try {
5539
+ isValid = await client.readContract({
5540
+ address: marketplace,
5541
+ abi: marketplaceAbi,
5542
+ functionName: "isValidPaymentToken",
5543
+ args: [token.address]
5544
+ });
5545
+ } catch {
5546
+ isValid = false;
5547
+ }
5548
+ if (isValid) paymentTokens.push({ ...token, address: token.address, isValid: true });
5549
+ }
5550
+ return {
5551
+ chainId: args.chainId,
5552
+ marketplace,
5553
+ ve,
5554
+ gov,
5555
+ np,
5556
+ weth,
5557
+ minimumDuration: minimumDuration.toString(),
5558
+ maximumDuration: maximumDuration.toString(),
5559
+ feeLimits: feeLimits.map((n) => n.toString()),
5560
+ feeRates: feeRates.map((n) => n.toString()),
5561
+ feeTiers: FEE_TIER_NAMES.map((name, index) => ({
5562
+ name,
5563
+ index,
5564
+ limit: feeLimits[index].toString(),
5565
+ rateBps: feeRates[index].toString()
5566
+ })),
5567
+ paymentTokens,
5568
+ source: "logs"
5569
+ };
5570
+ }
5571
+ async function readMarketplaceFeePreviewFromChain(args) {
5572
+ const marketplace = args.marketplace ?? VOTING_ESCROW_MARKETPLACE_LINEA_ADDRESS;
5573
+ const ve = args.votingEscrow ?? VOTING_ESCROW_LINEA_ADDRESS;
5574
+ const client = marketplacePublicClient(args.chainId, args.rpcUrl);
5575
+ const locked = await client.readContract({
5576
+ address: ve,
5577
+ abi: marketplaceReadAbi,
5578
+ functionName: "locked",
5579
+ args: [args.tokenId]
5580
+ });
5581
+ const lockedAmount = BigInt(locked[0]);
5582
+ const limits = [];
5583
+ const rates = [];
5584
+ for (let i = 0; i < 5; i++) {
5585
+ limits.push(
5586
+ await client.readContract({
5587
+ address: marketplace,
5588
+ abi: marketplaceAbi,
5589
+ functionName: "feeLimitByTier",
5590
+ args: [i]
5591
+ })
5592
+ );
5593
+ rates.push(
5594
+ await client.readContract({
5595
+ address: marketplace,
5596
+ abi: marketplaceAbi,
5597
+ functionName: "feeRateByTier",
5598
+ args: [i]
5599
+ })
5600
+ );
5601
+ }
5602
+ const fee = calculateMarketplaceFee(args.price, lockedAmount < 0n ? 0n : lockedAmount, limits, rates);
5603
+ if (!fee) throw new Error("Locked CTM is below the minimum fee tier.");
5604
+ return {
5605
+ tokenId: args.tokenId.toString(),
5606
+ lockedAmount: (lockedAmount < 0n ? 0n : lockedAmount).toString(),
5607
+ tier: fee.tier,
5608
+ tierIndex: fee.tierIndex,
5609
+ limit: fee.limit.toString(),
5610
+ rateBps: fee.rateBps.toString(),
5611
+ price: args.price.toString(),
5612
+ fee: fee.fee.toString(),
5613
+ net: fee.net.toString(),
5614
+ source: "logs"
5615
+ };
5616
+ }
5617
+ async function readOrder(client, marketplace, tokenId, index, kind) {
5618
+ if (index === 0n) return null;
5619
+ const row = kind === "listing" ? await client.readContract({
5620
+ address: marketplace,
5621
+ abi: marketplaceAbi,
5622
+ functionName: "listingsByToken",
5623
+ args: [tokenId, index]
5624
+ }) : await client.readContract({
5625
+ address: marketplace,
5626
+ abi: marketplaceAbi,
5627
+ functionName: "offeringsByToken",
5628
+ args: [tokenId, index]
5629
+ });
5630
+ return {
5631
+ price: row[0],
5632
+ deadline: row[1],
5633
+ snapshotAmount: row[2],
5634
+ snapshotEnd: row[3],
5635
+ creator: row[4],
5636
+ paymentToken: row[5],
5637
+ status: Number(row[6])
5638
+ };
5639
+ }
5640
+ async function readAuction(client, marketplace, tokenId, index) {
5641
+ if (index === 0n) return null;
5642
+ const row = await client.readContract({
5643
+ address: marketplace,
5644
+ abi: marketplaceAbi,
5645
+ functionName: "auctionsByToken",
5646
+ args: [tokenId, index]
5647
+ });
5648
+ return {
5649
+ reservePrice: row[0],
5650
+ minimumBidIncrement: row[1],
5651
+ deadline: row[2],
5652
+ seller: row[3],
5653
+ paymentToken: row[4],
5654
+ highestBidder: row[5],
5655
+ highestBid: row[6],
5656
+ status: Number(row[7])
5657
+ };
5658
+ }
5659
+ async function loadMarketplacePlanSnapshot(args) {
5660
+ const marketplace = VOTING_ESCROW_MARKETPLACE_LINEA_ADDRESS;
5661
+ const client = marketplacePublicClient(args.chainId, args.rpcUrl);
5662
+ const [weth, ve, np, minimumDuration, maximumDuration, block] = await Promise.all([
5663
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "weth" }),
5664
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "ve" }),
5665
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "np" }),
5666
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "minimumDuration" }),
5667
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "maximumDuration" }),
5668
+ client.getBlock({ blockTag: "latest" })
5669
+ ]);
5670
+ let owner = zeroAddress;
5671
+ try {
5672
+ owner = await client.readContract({
5673
+ address: ve,
5674
+ abi: marketplaceReadAbi,
5675
+ functionName: "ownerOf",
5676
+ args: [args.tokenId]
5677
+ });
5678
+ } catch {
5679
+ owner = zeroAddress;
5680
+ }
5681
+ const [approved, approvedForAll, attachedKeyGen, listingIndex, offeringIndex, auctionIndex] = await Promise.all([
5682
+ client.readContract({ address: ve, abi: marketplaceReadAbi, functionName: "getApproved", args: [args.tokenId] }).catch(() => zeroAddress),
5683
+ owner === zeroAddress ? Promise.resolve(false) : client.readContract({
5684
+ address: ve,
5685
+ abi: marketplaceReadAbi,
5686
+ functionName: "isApprovedForAll",
5687
+ args: [owner, marketplace]
5688
+ }).catch(() => false),
5689
+ client.readContract({ address: np, abi: marketplaceReadAbi, functionName: "attachedKeyGen", args: [args.tokenId] }).catch(() => zeroAddress),
5690
+ client.readContract({
5691
+ address: marketplace,
5692
+ abi: marketplaceAbi,
5693
+ functionName: "listingIndexByTokenSeller",
5694
+ args: [args.tokenId, args.seller ?? args.executor]
5695
+ }),
5696
+ client.readContract({
5697
+ address: marketplace,
5698
+ abi: marketplaceAbi,
5699
+ functionName: "offeringIndexByTokenBuyer",
5700
+ args: [args.tokenId, args.buyer ?? args.executor]
5701
+ }),
5702
+ client.readContract({
5703
+ address: marketplace,
5704
+ abi: marketplaceAbi,
5705
+ functionName: "auctionIndexByTokenSeller",
5706
+ args: [args.tokenId, args.seller ?? args.executor]
5707
+ })
5708
+ ]);
5709
+ const [listing, offering, auction, executorListingIndex, executorAuctionIndex] = await Promise.all([
5710
+ readOrder(client, marketplace, args.tokenId, listingIndex, "listing"),
5711
+ readOrder(client, marketplace, args.tokenId, offeringIndex, "offering"),
5712
+ readAuction(client, marketplace, args.tokenId, auctionIndex),
5713
+ args.seller && args.seller !== args.executor ? client.readContract({
5714
+ address: marketplace,
5715
+ abi: marketplaceAbi,
5716
+ functionName: "listingIndexByTokenSeller",
5717
+ args: [args.tokenId, args.executor]
5718
+ }) : Promise.resolve(0n),
5719
+ args.seller && args.seller !== args.executor ? client.readContract({
5720
+ address: marketplace,
5721
+ abi: marketplaceAbi,
5722
+ functionName: "auctionIndexByTokenSeller",
5723
+ args: [args.tokenId, args.executor]
5724
+ }) : Promise.resolve(auctionIndex)
5725
+ ]);
5726
+ const executorAuction = executorAuctionIndex === auctionIndex ? auction : await readAuction(client, marketplace, args.tokenId, executorAuctionIndex);
5727
+ const liveAuction = executorAuction != null && (executorAuction.status === 1 || executorAuction.status === 2 || executorAuction.status === 3) && executorAuction.seller.toLowerCase() === args.executor.toLowerCase();
5728
+ let executorOpenListing = false;
5729
+ if (executorListingIndex > 0n) {
5730
+ const row = await readOrder(client, marketplace, args.tokenId, executorListingIndex, "listing");
5731
+ executorOpenListing = row?.status === 1;
5732
+ } else if (!args.seller || args.seller === args.executor) {
5733
+ executorOpenListing = listing?.status === 1 && listing.creator.toLowerCase() === args.executor.toLowerCase();
5734
+ }
5735
+ const paymentToken = args.paymentToken ?? listing?.paymentToken ?? offering?.paymentToken ?? auction?.paymentToken;
5736
+ let paymentTokenValid = true;
5737
+ if (paymentToken) {
5738
+ paymentTokenValid = await client.readContract({
5739
+ address: marketplace,
5740
+ abi: marketplaceAbi,
5741
+ functionName: "isValidPaymentToken",
5742
+ args: [paymentToken]
5743
+ });
5744
+ }
5745
+ const spendToken = paymentToken ?? zeroAddress;
5746
+ const spendFrom = args.buyer && args.buyer !== args.executor ? args.buyer : args.executor;
5747
+ let allowance = 0n;
5748
+ if (spendToken !== zeroAddress && spendToken.toLowerCase() !== weth.toLowerCase()) {
5749
+ allowance = await client.readContract({
5750
+ address: spendToken,
5751
+ abi: marketplaceReadAbi,
5752
+ functionName: "allowance",
5753
+ args: [spendFrom, marketplace]
5754
+ }).catch(() => 0n);
5755
+ } else if (spendToken.toLowerCase() === weth.toLowerCase()) {
5756
+ allowance = await client.readContract({
5757
+ address: spendToken,
5758
+ abi: marketplaceReadAbi,
5759
+ functionName: "allowance",
5760
+ args: [args.executor, marketplace]
5761
+ }).catch(() => 0n);
5762
+ }
5763
+ return {
5764
+ marketplace,
5765
+ votingEscrow: ve,
5766
+ weth,
5767
+ now: block.timestamp,
5768
+ minimumDuration,
5769
+ maximumDuration,
5770
+ executor: args.executor,
5771
+ owner,
5772
+ nftApproved: approvedForAll || approved !== zeroAddress && approved.toLowerCase() === marketplace.toLowerCase(),
5773
+ allowance,
5774
+ attachedKeyGen,
5775
+ paymentTokenValid,
5776
+ executorOpenListing,
5777
+ executorLiveAuction: liveAuction,
5778
+ listing: listing && listing.status === 1 ? listing : listing,
5779
+ offering: offering && offering.status === 1 ? offering : offering,
5780
+ auction
5781
+ };
5782
+ }
5783
+ init_constants();
5784
+ var memoryCache = /* @__PURE__ */ new Map();
5785
+ function emptyMarketplaceIndexCache() {
5786
+ return { lastScannedBlock: "0", listings: [], offerings: [], auctions: [] };
5787
+ }
5788
+ function getMarketplaceIndexMemoryCache(chainId) {
5789
+ return memoryCache.get(chainId) ?? null;
5790
+ }
5791
+ function setMarketplaceIndexMemoryCache(chainId, cache) {
5792
+ memoryCache.set(chainId, cache);
5793
+ }
5794
+ function arg(args, key, index) {
5795
+ const value = args[key] ?? args[index];
5796
+ if (typeof value === "bigint") return value.toString();
5797
+ return String(value ?? "");
5798
+ }
5799
+ function toFoldEvent(log, timestamp) {
5800
+ try {
5801
+ const decoded = decodeEventLog({
5802
+ abi: marketplaceAbi,
5803
+ data: log.data,
5804
+ topics: log.topics
5805
+ });
5806
+ const args = decoded.args;
5807
+ const ref = {
5808
+ tx: log.transactionHash ?? "",
5809
+ block: log.blockNumber != null ? log.blockNumber.toString() : "0",
5810
+ logIndex: log.logIndex ?? 0,
5811
+ timestamp
5812
+ };
5813
+ switch (decoded.eventName) {
5814
+ case "ListingCreated":
5815
+ return {
5816
+ name: "ListingCreated",
5817
+ tokenId: arg(args, "_tokenId", 0),
5818
+ actor: arg(args, "_listedBy", 1),
5819
+ paymentToken: arg(args, "_paymentToken", 2),
5820
+ amount: arg(args, "_ask", 3),
5821
+ deadline: arg(args, "_deadline", 4),
5822
+ ...ref
5823
+ };
5824
+ case "OfferingCreated":
5825
+ return {
5826
+ name: "OfferingCreated",
5827
+ tokenId: arg(args, "_tokenId", 0),
5828
+ actor: arg(args, "_offeredBy", 1),
5829
+ paymentToken: arg(args, "_paymentToken", 2),
5830
+ amount: arg(args, "_bid", 3),
5831
+ deadline: arg(args, "_deadline", 4),
5832
+ ...ref
5833
+ };
5834
+ case "ListingFulfilled":
5835
+ return {
5836
+ name: "ListingFulfilled",
5837
+ tokenId: arg(args, "_tokenId", 0),
5838
+ buyer: arg(args, "_buyer", 1),
5839
+ seller: arg(args, "_seller", 2),
5840
+ price: arg(args, "_ask", 3),
5841
+ net: arg(args, "_netPrice", 4),
5842
+ fee: arg(args, "_fee", 5),
5843
+ ...ref
5844
+ };
5845
+ case "OfferingFulfilled":
5846
+ return {
5847
+ name: "OfferingFulfilled",
5848
+ tokenId: arg(args, "_tokenId", 0),
5849
+ buyer: arg(args, "_buyer", 1),
5850
+ seller: arg(args, "_seller", 2),
5851
+ price: arg(args, "_bid", 3),
5852
+ net: arg(args, "_netPrice", 4),
5853
+ fee: arg(args, "_fee", 5),
5854
+ ...ref
5855
+ };
5856
+ case "Delisted":
5857
+ return { name: "Delisted", tokenId: arg(args, "_tokenId", 0), actor: arg(args, "_seller", 1), ...ref };
5858
+ case "Rescinded":
5859
+ return { name: "Rescinded", tokenId: arg(args, "_tokenId", 0), actor: arg(args, "_buyer", 1), ...ref };
5860
+ case "AuctionCreated":
5861
+ return {
5862
+ name: "AuctionCreated",
5863
+ tokenId: arg(args, "_tokenId", 0),
5864
+ actor: arg(args, "_createdBy", 1),
5865
+ paymentToken: arg(args, "_paymentToken", 2),
5866
+ amount: arg(args, "_reservePrice", 3),
5867
+ minIncrement: arg(args, "_minimumBidIncrement", 4),
5868
+ deadline: arg(args, "_deadline", 5),
5869
+ ...ref
5870
+ };
5871
+ case "AuctionCanceled":
5872
+ return { name: "AuctionCanceled", tokenId: arg(args, "_tokenId", 0), actor: arg(args, "_seller", 1), ...ref };
5873
+ case "AuctionBid":
5874
+ return {
5875
+ name: "AuctionBid",
5876
+ tokenId: arg(args, "_tokenId", 0),
5877
+ seller: arg(args, "_seller", 1),
5878
+ buyer: arg(args, "_buyer", 2),
5879
+ price: arg(args, "_price", 3),
5880
+ ...ref
5881
+ };
5882
+ case "AuctionSettled":
5883
+ return {
5884
+ name: "AuctionSettled",
5885
+ tokenId: arg(args, "_tokenId", 0),
5886
+ seller: arg(args, "_seller", 1),
5887
+ finalStatus: Number(args._finalStatus ?? args[2] ?? 0),
5888
+ ...ref
5889
+ };
5890
+ case "AuctionSuccessful":
5891
+ return {
5892
+ name: "AuctionSuccessful",
5893
+ tokenId: arg(args, "_tokenId", 0),
5894
+ seller: arg(args, "_seller", 1),
5895
+ buyer: arg(args, "_buyer", 2),
5896
+ price: arg(args, "_price", 3),
5897
+ fee: arg(args, "_fee", 4),
5898
+ net: arg(args, "_net", 5),
5899
+ ...ref
5900
+ };
5901
+ default:
5902
+ return null;
5903
+ }
5904
+ } catch {
5905
+ return null;
5906
+ }
5907
+ }
5908
+ async function getLogsChunked(args) {
5909
+ const logs = [];
5910
+ let chunk = 5000n;
5911
+ let start = args.fromBlock;
5912
+ while (start <= args.toBlock) {
5913
+ const end = start + chunk - 1n > args.toBlock ? args.toBlock : start + chunk - 1n;
5914
+ try {
5915
+ const part = await args.client.getLogs({
5916
+ address: args.address,
5917
+ fromBlock: start,
5918
+ toBlock: end
5919
+ });
5920
+ logs.push(...part);
5921
+ args.onProgress?.(end, args.toBlock);
5922
+ start = end + 1n;
5923
+ } catch (err) {
5924
+ if (chunk <= 200n) throw err;
5925
+ chunk = chunk / 2n < 200n ? 200n : chunk / 2n;
5926
+ }
5927
+ }
5928
+ return logs;
5929
+ }
5930
+ async function scanMarketplaceLogs(args) {
5931
+ const client = marketplacePublicClient(args.chainId, args.rpcUrl);
5932
+ const head = await client.getBlockNumber();
5933
+ const prior = args.cache ?? getMarketplaceIndexMemoryCache(args.chainId) ?? emptyMarketplaceIndexCache();
5934
+ const scanned = BigInt(prior.lastScannedBlock || "0");
5935
+ const fromBlock = scanned > 0n ? scanned + 1n : VOTING_ESCROW_MARKETPLACE_START_BLOCK;
5936
+ if (fromBlock > head) {
5937
+ const now2 = Number((await client.getBlock({ blockTag: "latest" })).timestamp);
5938
+ const derived2 = applyDerivedStatuses(
5939
+ { listings: prior.listings, offerings: prior.offerings, auctions: prior.auctions },
5940
+ now2
5941
+ );
5942
+ const cache2 = { lastScannedBlock: head.toString(), ...derived2 };
5943
+ setMarketplaceIndexMemoryCache(args.chainId, cache2);
5944
+ return cache2;
5945
+ }
5946
+ const logs = await getLogsChunked({
5947
+ client,
5948
+ address: VOTING_ESCROW_MARKETPLACE_LINEA_ADDRESS,
5949
+ fromBlock,
5950
+ toBlock: head,
5951
+ onProgress: args.onProgress
5952
+ });
5953
+ const events = logs.map((log) => toFoldEvent(log)).filter((ev) => ev != null);
5954
+ const folded = foldMarketplaceEvents(events, {
5955
+ listings: prior.listings,
5956
+ offerings: prior.offerings,
5957
+ auctions: prior.auctions
5958
+ });
5959
+ const now = Number((await client.getBlock({ blockTag: "latest" })).timestamp);
5960
+ const derived = applyDerivedStatuses(folded, now);
5961
+ const cache = { lastScannedBlock: head.toString(), ...derived };
5962
+ setMarketplaceIndexMemoryCache(args.chainId, cache);
5963
+ return cache;
5964
+ }
5965
+
5966
+ // src/protocols/evm/continuum-dao/marketplaceCatalog.ts
5967
+ init_constants();
5968
+ function apiBase(args) {
5969
+ return (args.apiBase ?? CONTINUUM_DAO_MARKETPLACE_API).replace(/\/$/, "");
5970
+ }
5971
+ function isOffline(status) {
5972
+ if (status == null || status === 0 || status >= 500) return true;
5973
+ return false;
5974
+ }
5975
+ async function getJson(url) {
5976
+ try {
5977
+ const res = await fetch(url);
5978
+ if (!res.ok) {
5979
+ const text = await res.text().catch(() => "");
5980
+ return { ok: false, status: res.status, error: new Error(`${url}: ${res.status} ${text}`.trim()) };
5981
+ }
5982
+ return { ok: true, body: await res.json() };
5983
+ } catch (err) {
5984
+ return { ok: false, status: 0, error: err instanceof Error ? err : new Error(String(err)) };
5985
+ }
5986
+ }
5987
+ function qs(params) {
5988
+ const search = new URLSearchParams();
5989
+ for (const [key, value] of Object.entries(params)) {
5990
+ if (value === void 0 || value === "") continue;
5991
+ search.set(key, String(value));
5992
+ }
5993
+ const encoded = search.toString();
5994
+ return encoded ? `?${encoded}` : "";
5995
+ }
5996
+ async function logsBook(args) {
5997
+ if (!args.rpcUrl?.trim()) throw new Error("Linea RPC is required to index the marketplace while the API is offline.");
5998
+ return scanMarketplaceLogs({
5999
+ chainId: args.chainId ?? CONTINUUM_DAO_LINEA_CHAIN_ID,
6000
+ rpcUrl: args.rpcUrl.trim(),
6001
+ cache: args.cache,
6002
+ onProgress: args.onProgress
6003
+ });
6004
+ }
6005
+ function matchOrder(row, args, includeInactive) {
6006
+ if (!includeInactive && !isOpenOrder(row)) return false;
6007
+ if (args.tokenId && row.tokenId !== args.tokenId) return false;
6008
+ if (args.paymentToken && row.paymentToken.toLowerCase() !== args.paymentToken.toLowerCase()) return false;
6009
+ if (args.creator && row.creator.toLowerCase() !== args.creator.toLowerCase()) return false;
6010
+ if (args.seller && (row.seller ?? row.creator).toLowerCase() !== args.seller.toLowerCase()) return false;
6011
+ return true;
6012
+ }
6013
+ function matchAuction(row, args, includeInactive) {
6014
+ if (!includeInactive && !isLiveAuctionStatus(row.derivedStatus)) return false;
6015
+ if (args.tokenId && row.tokenId !== args.tokenId) return false;
6016
+ if (args.paymentToken && row.paymentToken.toLowerCase() !== args.paymentToken.toLowerCase()) return false;
6017
+ if (args.seller && row.seller.toLowerCase() !== args.seller.toLowerCase()) return false;
6018
+ return true;
6019
+ }
6020
+ function listFrom(items, source) {
6021
+ return { items, nextCursor: null, source };
6022
+ }
6023
+ async function fetchContinuumDaoMarketplaceConfig(args = {}) {
6024
+ const url = `${apiBase(args)}/marketplace/config`;
6025
+ const res = await getJson(url);
6026
+ if (res.ok && res.body && typeof res.body === "object") {
6027
+ return { ...res.body, source: "api" };
6028
+ }
6029
+ if (!res.ok && !isOffline(res.status)) throw res.error;
6030
+ return readMarketplaceConfigFromChain({
6031
+ chainId: args.chainId ?? CONTINUUM_DAO_LINEA_CHAIN_ID,
6032
+ rpcUrl: args.rpcUrl ?? ""
6033
+ });
6034
+ }
6035
+ async function fetchContinuumDaoMarketplaceListings(args = {}) {
6036
+ const includeInactive = Boolean(args.includeInactive);
6037
+ const url = `${apiBase(args)}/marketplace/listings${qs({
6038
+ includeInactive,
6039
+ paymentToken: args.paymentToken,
6040
+ tokenId: args.tokenId,
6041
+ creator: args.creator,
6042
+ limit: args.limit ?? 100,
6043
+ cursor: args.cursor,
6044
+ viewer: args.viewer
6045
+ })}`;
6046
+ const res = await getJson(url);
6047
+ if (res.ok) {
6048
+ const body = res.body;
6049
+ return { items: body.items ?? [], nextCursor: body.nextCursor ?? null, source: "api" };
6050
+ }
6051
+ if (args.cursor || !isOffline(res.status)) throw res.error;
6052
+ const book = await logsBook(args);
6053
+ return listFrom(book.listings.filter((row) => matchOrder(row, args, includeInactive)), "logs");
6054
+ }
6055
+ async function fetchContinuumDaoMarketplaceOfferings(args = {}) {
6056
+ const includeInactive = Boolean(args.includeInactive);
6057
+ const url = `${apiBase(args)}/marketplace/offerings${qs({
6058
+ includeInactive,
6059
+ paymentToken: args.paymentToken,
6060
+ tokenId: args.tokenId,
6061
+ creator: args.creator,
6062
+ limit: args.limit ?? 100,
6063
+ cursor: args.cursor,
6064
+ viewer: args.viewer
6065
+ })}`;
6066
+ const res = await getJson(url);
6067
+ if (res.ok) {
6068
+ const body = res.body;
6069
+ return { items: body.items ?? [], nextCursor: body.nextCursor ?? null, source: "api" };
6070
+ }
6071
+ if (args.cursor || !isOffline(res.status)) throw res.error;
6072
+ const book = await logsBook(args);
6073
+ return listFrom(book.offerings.filter((row) => matchOrder(row, args, includeInactive)), "logs");
6074
+ }
6075
+ async function fetchContinuumDaoMarketplaceAuctions(args = {}) {
6076
+ const includeInactive = Boolean(args.includeInactive);
6077
+ const url = `${apiBase(args)}/marketplace/auctions${qs({
6078
+ includeInactive,
6079
+ paymentToken: args.paymentToken,
6080
+ tokenId: args.tokenId,
6081
+ seller: args.seller,
6082
+ limit: args.limit ?? 100,
6083
+ cursor: args.cursor,
6084
+ viewer: args.viewer
6085
+ })}`;
6086
+ const res = await getJson(url);
6087
+ if (res.ok) {
6088
+ const body = res.body;
6089
+ return {
6090
+ items: (body.items ?? []).map((row) => ({ ...row, bids: row.bids ?? [] })),
6091
+ nextCursor: body.nextCursor ?? null,
6092
+ source: "api"
6093
+ };
6094
+ }
6095
+ if (args.cursor || !isOffline(res.status)) throw res.error;
6096
+ const book = await logsBook(args);
6097
+ return listFrom(book.auctions.filter((row) => matchAuction(row, args, includeInactive)), "logs");
6098
+ }
6099
+ async function fetchContinuumDaoMarketplaceToken(args) {
6100
+ const url = `${apiBase(args)}/marketplace/tokens/${encodeURIComponent(args.tokenId)}${qs({ viewer: args.viewer })}`;
6101
+ const res = await getJson(url);
6102
+ if (res.ok && res.body && typeof res.body === "object") {
6103
+ return { ...res.body, source: "api" };
6104
+ }
6105
+ if (!res.ok && !isOffline(res.status)) throw res.error;
6106
+ const book = await logsBook(args);
6107
+ const listings = book.listings.filter((row) => row.tokenId === args.tokenId);
6108
+ const offerings = book.offerings.filter((row) => row.tokenId === args.tokenId);
6109
+ const auctions = book.auctions.filter((row) => row.tokenId === args.tokenId);
6110
+ return {
6111
+ token: { tokenId: args.tokenId },
6112
+ listing: listings.find((row) => isOpenOrder(row)) ?? null,
6113
+ offerings: offerings.filter((row) => isOpenOrder(row)),
6114
+ auction: auctions.find((row) => isLiveAuctionStatus(row.derivedStatus)) ?? null,
6115
+ history: {
6116
+ listings: listings.filter((row) => !isOpenOrder(row)),
6117
+ offerings: offerings.filter((row) => !isOpenOrder(row)),
6118
+ auctions: auctions.filter((row) => !isLiveAuctionStatus(row.derivedStatus))
6119
+ },
6120
+ source: "logs"
6121
+ };
6122
+ }
6123
+ async function fetchContinuumDaoMarketplaceFeePreview(args) {
6124
+ const url = `${apiBase(args)}/marketplace/fee-preview${qs({ tokenId: args.tokenId, price: args.price })}`;
6125
+ const res = await getJson(url);
6126
+ if (res.ok && res.body && typeof res.body === "object") {
6127
+ return { ...res.body, source: "api" };
6128
+ }
6129
+ if (!res.ok && !isOffline(res.status)) throw res.error;
6130
+ return readMarketplaceFeePreviewFromChain({
6131
+ chainId: args.chainId ?? CONTINUUM_DAO_LINEA_CHAIN_ID,
6132
+ rpcUrl: args.rpcUrl ?? "",
6133
+ tokenId: BigInt(args.tokenId),
6134
+ price: BigInt(args.price)
6135
+ });
6136
+ }
6137
+ async function fetchContinuumDaoMarketplaceActivity(args) {
6138
+ const url = `${apiBase(args)}/marketplace/users/${encodeURIComponent(args.address)}/activity${qs({ limit: args.limit ?? 50 })}`;
6139
+ const res = await getJson(url);
6140
+ if (res.ok && res.body && typeof res.body === "object") {
6141
+ const body = res.body;
6142
+ return {
6143
+ address: args.address,
6144
+ orders: body.orders ?? [],
6145
+ auctions: (body.auctions ?? []).map((row) => ({ ...row, bids: row.bids ?? [] })),
6146
+ source: "api"
6147
+ };
6148
+ }
6149
+ if (!res.ok && !isOffline(res.status)) throw res.error;
6150
+ const book = await logsBook(args);
6151
+ const address = args.address.toLowerCase();
6152
+ const orders = [...book.listings, ...book.offerings].filter((row) => {
6153
+ return row.creator.toLowerCase() === address || (row.counterparty ?? "").toLowerCase() === address || (row.seller ?? "").toLowerCase() === address || (row.buyer ?? "").toLowerCase() === address;
6154
+ });
6155
+ const auctions = book.auctions.filter((row) => {
6156
+ return row.seller.toLowerCase() === address || (row.buyer ?? "").toLowerCase() === address || (row.highestBidder ?? "").toLowerCase() === address || row.bids.some((bid) => bid.bidder.toLowerCase() === address);
6157
+ });
6158
+ return { address: args.address, orders, auctions, source: "logs" };
6159
+ }
6160
+
6161
+ // src/protocols/evm/continuum-dao/marketplaceSearch.ts
6162
+ init_constants();
6163
+ var LOCKED_ABI = [parseAbiItem("function locked(uint256 tokenId) view returns (int128 amount, uint256 end)")];
6164
+ var MONTH_SECONDS = 30 * 24 * 60 * 60;
6165
+ var PAGE_SIZE = 100;
6166
+ var MAX_PAGES = 20;
6167
+ var DEFAULT_LIMIT = 10;
6168
+ var MAX_LIMIT = 25;
6169
+ var DEFAULT_DIRECTION = {
6170
+ pricePerLockedCtm: "asc",
6171
+ price: "asc",
6172
+ locked: "desc",
6173
+ unlock: "asc",
6174
+ deadline: "asc"
6175
+ };
6176
+ function same3(a, b) {
6177
+ if (!a || !b) return false;
6178
+ try {
6179
+ return getAddress(a) === getAddress(b);
6180
+ } catch {
6181
+ return a.toLowerCase() === b.toLowerCase();
6182
+ }
6183
+ }
6184
+ function attachedKey(keygen, protocolStatus) {
6185
+ if (protocolStatus === "KeyGenAttached") return true;
6186
+ const value = (keygen ?? "").trim().toLowerCase();
6187
+ return Boolean(value && value !== "0" && !/^0x0+$/.test(value));
6188
+ }
6189
+ function asBig(value) {
6190
+ try {
6191
+ return BigInt(value || "0");
6192
+ } catch {
6193
+ return 0n;
6194
+ }
6195
+ }
6196
+ function parseCtm(raw) {
6197
+ const trimmed = raw?.trim();
6198
+ if (!trimmed) return null;
6199
+ return parseUnits(trimmed, 18);
6200
+ }
6201
+ function parseTime(raw) {
6202
+ const trimmed = raw?.trim();
6203
+ if (!trimmed) return null;
6204
+ if (/^\d+$/.test(trimmed)) {
6205
+ const n = Number(trimmed);
6206
+ if (!Number.isFinite(n)) throw new Error("Unlock bound must be an ISO date or unix seconds.");
6207
+ return n > 1e12 ? Math.floor(n / 1e3) : n;
6208
+ }
6209
+ const ms = Date.parse(trimmed);
6210
+ if (Number.isNaN(ms)) throw new Error("Unlock bound must be an ISO date or unix seconds.");
6211
+ return Math.floor(ms / 1e3);
6212
+ }
6213
+ function paymentMeta(address) {
6214
+ const lower = address.toLowerCase();
6215
+ if (lower === MARKETPLACE_USDC_LINEA_ADDRESS.toLowerCase()) return { symbol: "USDC", decimals: 6 };
6216
+ if (lower === MARKETPLACE_WETH_LINEA_ADDRESS.toLowerCase()) return { symbol: "WETH", decimals: 18 };
6217
+ if (lower === CTM_TOKEN_ADDRESS.toLowerCase()) return { symbol: "CTM", decimals: 18 };
6218
+ return { symbol: "token", decimals: 18 };
6219
+ }
6220
+ function trimDecimal(value) {
6221
+ return value.replace(/(\.\d*?[1-9])0+$/, "$1").replace(/\.0+$/, "");
6222
+ }
6223
+ function humanAmount(wei, decimals) {
6224
+ return trimDecimal(formatUnits(wei, decimals));
6225
+ }
6226
+ function positive(value) {
6227
+ const trimmed = (value ?? "").trim();
6228
+ return trimmed && trimmed !== "0" ? trimmed : "";
6229
+ }
6230
+ function unlockUnixFrom(row) {
6231
+ const iso2 = positive(row.unlockTimeAt);
6232
+ if (iso2) {
6233
+ const ms = Date.parse(iso2);
6234
+ if (!Number.isNaN(ms)) return Math.floor(ms / 1e3);
6235
+ }
6236
+ const unix = positive(row.unlockTime) || positive(row.snapshotEnd);
6237
+ return unix ? Number(unix) : 0;
6238
+ }
6239
+ function lockedFrom(row) {
6240
+ return asBig(positive(row.lockedCTM) || positive(row.currentLockedAmount) || positive(row.snapshotAmount));
6241
+ }
6242
+ function listingCandidate(row) {
6243
+ const attached = attachedKey(row.keygen, row.protocolStatus);
6244
+ const open = row.protocolStatus === "Open" || row.storedStatus === "Open";
6245
+ return {
6246
+ kind: "listing",
6247
+ tokenId: row.tokenId,
6248
+ onchainIndex: row.onchainIndex,
6249
+ seller: row.seller ?? row.creator,
6250
+ paymentToken: row.paymentToken,
6251
+ price: asBig(row.price),
6252
+ priceBasis: "ask",
6253
+ locked: lockedFrom(row),
6254
+ unlockUnix: unlockUnixFrom(row),
6255
+ deadlineUnix: Number(row.deadlineUnix || "0") || 0,
6256
+ attached,
6257
+ fillable: open && !attached,
6258
+ protocolStatus: row.protocolStatus,
6259
+ storedStatus: row.storedStatus,
6260
+ keygen: row.keygen
6261
+ };
6262
+ }
6263
+ function auctionCandidate(row) {
6264
+ const attached = attachedKey(row.keygen, row.storedStatus);
6265
+ const bid = asBig(row.highestBid);
6266
+ const reserve = asBig(row.reservePrice);
6267
+ const live = row.derivedStatus === "Pending" || row.derivedStatus === "Active";
6268
+ return {
6269
+ kind: "auction",
6270
+ tokenId: row.tokenId,
6271
+ onchainIndex: row.onchainIndex,
6272
+ seller: row.seller,
6273
+ paymentToken: row.paymentToken,
6274
+ price: bid > 0n ? bid : reserve,
6275
+ priceBasis: bid > 0n ? "highestBid" : "reserve",
6276
+ locked: lockedFrom(row),
6277
+ unlockUnix: unlockUnixFrom(row),
6278
+ deadlineUnix: Number(row.deadlineUnix || "0") || 0,
6279
+ attached,
6280
+ fillable: live && !attached,
6281
+ protocolStatus: row.derivedStatus,
6282
+ storedStatus: row.storedStatus,
6283
+ keygen: row.keygen
6284
+ };
6285
+ }
6286
+ function applyLock(row, lock) {
6287
+ if (row.locked > 0n && row.unlockUnix > 0) return row;
6288
+ if (!lock) return row;
6289
+ return {
6290
+ ...row,
6291
+ locked: row.locked > 0n ? row.locked : lock.amount,
6292
+ unlockUnix: row.unlockUnix > 0 ? row.unlockUnix : lock.end
6293
+ };
6294
+ }
6295
+ function rankMarketplaceSearchHits(rows, query, nowUnix = Math.floor(Date.now() / 1e3)) {
6296
+ const sort = query.sort ?? "pricePerLockedCtm";
6297
+ const direction = query.sortDirection ?? DEFAULT_DIRECTION[sort];
6298
+ const minLocked = parseCtm(query.minLockedCtm);
6299
+ const maxLocked = parseCtm(query.maxLockedCtm);
6300
+ const unlockAfter = parseTime(query.unlockAfter);
6301
+ const unlockBefore = parseTime(query.unlockBefore);
6302
+ const monthCap = query.maxUnlockMonths != null && Number.isFinite(query.maxUnlockMonths) ? nowUnix + Math.floor(query.maxUnlockMonths * MONTH_SECONDS) : null;
6303
+ const executor = query.executor?.trim();
6304
+ const excludeOwned = query.excludeOwned !== false && Boolean(executor);
6305
+ let matched = rows.filter((row) => {
6306
+ if (query.paymentToken && !same3(row.paymentToken, query.paymentToken)) return false;
6307
+ if (excludeOwned && same3(row.seller, executor)) return false;
6308
+ if (minLocked != null && row.locked < minLocked) return false;
6309
+ if (maxLocked != null && row.locked > maxLocked) return false;
6310
+ if (unlockAfter != null && row.unlockUnix < unlockAfter) return false;
6311
+ if (unlockBefore != null && (row.unlockUnix <= 0 || row.unlockUnix > unlockBefore)) return false;
6312
+ if (monthCap != null && (row.unlockUnix <= nowUnix || row.unlockUnix > monthCap)) return false;
6313
+ return true;
6314
+ });
6315
+ const priceSort = sort === "price" || sort === "pricePerLockedCtm";
6316
+ if (priceSort && !query.paymentToken) {
6317
+ const tokens = new Set(matched.map((row) => row.paymentToken.toLowerCase()));
6318
+ if (tokens.size > 1) {
6319
+ const symbols = [...tokens].map((token) => paymentMeta(token).symbol).join(", ");
6320
+ throw new Error(`Pass paymentToken to rank by price. These rows use ${symbols}.`);
6321
+ }
6322
+ }
6323
+ const asc = direction === "asc";
6324
+ const key = (row) => {
6325
+ if (sort === "locked") return row.locked;
6326
+ if (sort === "unlock") return BigInt(row.unlockUnix || 0);
6327
+ if (sort === "deadline") return BigInt(row.deadlineUnix || 0);
6328
+ if (sort === "pricePerLockedCtm") return row.locked > 0n ? row.price * 10n ** 18n / row.locked : 2n ** 255n - 1n;
6329
+ return row.price;
6330
+ };
6331
+ matched = [...matched].sort((a, b) => {
6332
+ if (a.fillable !== b.fillable) return a.fillable ? -1 : 1;
6333
+ if (sort === "pricePerLockedCtm" && a.locked <= 0n !== b.locked <= 0n) return a.locked <= 0n ? 1 : -1;
6334
+ const cmp = key(a) === key(b) ? 0 : key(a) < key(b) ? -1 : 1;
6335
+ if (cmp !== 0) return asc ? cmp : -cmp;
6336
+ return a.tokenId.localeCompare(b.tokenId);
6337
+ });
6338
+ const limit = Math.min(MAX_LIMIT, Math.max(1, query.limit ?? DEFAULT_LIMIT));
6339
+ return matched.slice(0, limit).map((row) => toHit(row, nowUnix));
6340
+ }
6341
+ function toHit(row, nowUnix) {
6342
+ const meta4 = paymentMeta(row.paymentToken);
6343
+ const perCtm = row.locked > 0n ? row.price * 10n ** 18n / row.locked : 0n;
6344
+ const months = row.unlockUnix > nowUnix ? ((row.unlockUnix - nowUnix) / MONTH_SECONDS).toFixed(1) : row.unlockUnix > 0 ? "0" : "";
6345
+ return {
6346
+ kind: row.kind,
6347
+ tokenId: row.tokenId,
6348
+ onchainIndex: row.onchainIndex,
6349
+ seller: row.seller,
6350
+ paymentToken: row.paymentToken,
6351
+ paymentSymbol: meta4.symbol,
6352
+ price: row.price.toString(),
6353
+ priceHuman: humanAmount(row.price, meta4.decimals),
6354
+ priceBasis: row.priceBasis,
6355
+ lockedCtm: row.locked.toString(),
6356
+ lockedCtmHuman: humanAmount(row.locked, 18),
6357
+ unlockAt: row.unlockUnix > 0 ? new Date(row.unlockUnix * 1e3).toISOString() : "",
6358
+ monthsToUnlock: months,
6359
+ pricePerLockedCtm: row.locked > 0n ? humanAmount(perCtm, meta4.decimals) : "",
6360
+ deadlineAt: row.deadlineUnix > 0 ? new Date(row.deadlineUnix * 1e3).toISOString() : "",
6361
+ attached: row.attached,
6362
+ fillable: row.fillable
6363
+ };
6364
+ }
6365
+ async function fillMissingLocks(rows, rpcUrl, chainId) {
6366
+ const missing = [...new Set(rows.filter((row) => row.locked <= 0n || row.unlockUnix <= 0).map((row) => row.tokenId))];
6367
+ if (missing.length === 0 || !rpcUrl?.trim()) return rows;
6368
+ const client = marketplacePublicClient(chainId, rpcUrl.trim());
6369
+ const locks = /* @__PURE__ */ new Map();
6370
+ for (let i = 0; i < missing.length; i += 40) {
6371
+ const chunk = missing.slice(i, i + 40);
6372
+ const results = await client.multicall({
6373
+ contracts: chunk.map((id) => ({
6374
+ address: VOTING_ESCROW_LINEA_ADDRESS,
6375
+ abi: LOCKED_ABI,
6376
+ functionName: "locked",
6377
+ args: [BigInt(id)]
6378
+ })),
6379
+ allowFailure: true
6380
+ });
6381
+ results.forEach((result, index) => {
6382
+ if (result.status !== "success" || !result.result) return;
6383
+ const [amount, end] = result.result;
6384
+ const id = chunk[index];
6385
+ if (!id) return;
6386
+ locks.set(id, { amount: amount < 0n ? 0n : amount, end: Number(end) });
6387
+ });
6388
+ }
6389
+ return rows.map((row) => applyLock(row, locks.get(row.tokenId)));
6390
+ }
6391
+ async function collectKind(kind, args) {
6392
+ const rows = [];
6393
+ let cursor;
6394
+ let scanned = 0;
6395
+ let source = "api";
6396
+ let truncated = false;
6397
+ for (let page = 0; page < MAX_PAGES; page += 1) {
6398
+ const query = { ...args, includeInactive: false, limit: PAGE_SIZE, cursor };
6399
+ const res = kind === "listing" ? await fetchContinuumDaoMarketplaceListings(query) : await fetchContinuumDaoMarketplaceAuctions(query);
6400
+ source = res.source;
6401
+ scanned += res.items.length;
6402
+ for (const item of res.items) {
6403
+ rows.push(kind === "listing" ? listingCandidate(item) : auctionCandidate(item));
6404
+ }
6405
+ if (res.source === "logs" || !res.nextCursor) return { rows, scanned, truncated, source };
6406
+ cursor = res.nextCursor;
6407
+ }
6408
+ truncated = true;
6409
+ return { rows, scanned, truncated, source };
6410
+ }
6411
+ async function searchContinuumDaoMarketplace(args = {}) {
6412
+ const kind = args.kind ?? "listing";
6413
+ const chainId = args.chainId ?? CONTINUUM_DAO_LINEA_CHAIN_ID;
6414
+ const parts = await Promise.all([
6415
+ kind !== "auction" ? collectKind("listing", args) : Promise.resolve(null),
6416
+ kind !== "listing" ? collectKind("auction", args) : Promise.resolve(null)
6417
+ ]);
6418
+ const collected = parts.flatMap((part) => part?.rows ?? []);
6419
+ const withLocks = await fillMissingLocks(collected, args.rpcUrl, chainId);
6420
+ const sort = args.sort ?? "pricePerLockedCtm";
6421
+ const items = rankMarketplaceSearchHits(withLocks, args);
6422
+ return {
6423
+ sort,
6424
+ sortDirection: args.sortDirection ?? DEFAULT_DIRECTION[sort],
6425
+ paymentToken: args.paymentToken ?? null,
6426
+ scanned: parts.reduce((sum, part) => sum + (part?.scanned ?? 0), 0),
6427
+ truncated: parts.some((part) => part?.truncated),
6428
+ items,
6429
+ source: parts.some((part) => part?.source === "logs") ? "logs" : "api"
6430
+ };
6431
+ }
6432
+
6433
+ // src/protocols/evm/continuum-dao/marketplaceFeeAlternative.ts
6434
+ init_constants();
6435
+ var PAGE_SIZE2 = 100;
6436
+ var MAX_PAGES2 = 20;
6437
+ var feeAbi = parseAbi([
6438
+ "function veCtmThresholdPower() view returns (uint256)",
6439
+ "function getActiveRates() view returns (uint256 monthlyFee, uint256 freeSignaturesPerMonth, uint256 overageFeePerSignature)",
6440
+ "function FEE_TOKEN() view returns (address)",
6441
+ "function ctmPerFeeToken() view returns (uint256)",
6442
+ "function locked(uint256 tokenId) view returns (int128 amount, uint256 end)",
6443
+ "function balanceOfNFT(uint256 tokenId) view returns (uint256)"
6444
+ ]);
6445
+ function trimDecimal2(value) {
6446
+ return value.replace(/(\.\d*?[1-9])0+$/, "$1").replace(/\.0+$/, "");
6447
+ }
6448
+ function human(wei, decimals) {
6449
+ return trimDecimal2(formatUnits(wei, decimals));
6450
+ }
6451
+ function paymentMeta2(address) {
6452
+ const lower = address.toLowerCase();
6453
+ if (lower === MARKETPLACE_USDC_LINEA_ADDRESS.toLowerCase()) return { symbol: "USDC", decimals: 6 };
6454
+ if (lower === MARKETPLACE_WETH_LINEA_ADDRESS.toLowerCase()) return { symbol: "WETH", decimals: 18 };
6455
+ if (lower === CTM_TOKEN_ADDRESS.toLowerCase()) return { symbol: "CTM", decimals: 18 };
6456
+ return { symbol: "token", decimals: 18 };
6457
+ }
6458
+ function monthsOfFees(price, monthly) {
6459
+ if (monthly <= 0n || price < 0n) return null;
6460
+ const tenths = price * 10n / monthly;
6461
+ const whole = tenths / 10n;
6462
+ const frac = tenths % 10n;
6463
+ return frac === 0n ? whole.toString() : `${whole}.${frac}`;
6464
+ }
6465
+ function votingPowerAboveUntil(args) {
6466
+ if (args.votingPower <= args.threshold) return null;
6467
+ if (args.unlockUnix <= args.nowUnix) return null;
6468
+ if (args.threshold <= 0n) return args.unlockUnix;
6469
+ const remaining = BigInt(args.unlockUnix - args.nowUnix);
6470
+ const drop = remaining * args.threshold / args.votingPower;
6471
+ return args.unlockUnix - Number(drop);
6472
+ }
6473
+ function pickFeeAlternativeExample(rows, preferredToken) {
6474
+ const fillable = rows.filter((row) => row.fillable && row.locked > 0n && row.votingPower > 0n);
6475
+ const preferred = preferredToken ? fillable.filter((row) => row.paymentToken.toLowerCase() === preferredToken.toLowerCase()) : [];
6476
+ const pool = preferred.length > 0 ? preferred : fillable;
6477
+ const perCtm = (row) => row.price * 10n ** 18n / row.locked;
6478
+ return [...pool].sort((a, b) => {
6479
+ const left = perCtm(a);
6480
+ const right = perCtm(b);
6481
+ if (left === right) return a.tokenId.localeCompare(b.tokenId);
6482
+ return left < right ? -1 : 1;
6483
+ })[0] ?? null;
6484
+ }
6485
+ function iso(unix) {
6486
+ return unix > 0 ? new Date(unix * 1e3).toISOString() : "";
6487
+ }
6488
+ function buildFeeAlternativeSummary(args) {
6489
+ const fee = `${args.monthlyFeeHuman} ${args.monthlyFeeSymbol}`;
6490
+ const year = `${args.annualFeeHuman} ${args.monthlyFeeSymbol} (${args.annualFeeCtmHuman} CTM)`;
6491
+ const lead = `Paying this month is ${fee}. A year for one KeyGen is ${year}. As an alternative, buy a veCTM and attach it. Locked CTM and voting power both have to be above ${args.thresholdHuman}. One attached veCTM waives the monthly fee for KeyGens in that group, and VPN follows a qualifying group on the node. Voting power decays, so a lock sitting on the line can miss a later month.`;
6492
+ if (!args.example) {
6493
+ return `${lead} No live direct listing is above that threshold right now.`;
6494
+ }
6495
+ const row = args.example;
6496
+ const compare = row.monthsOfFees ? ` That ask is about ${row.monthsOfFees} months of fees. The ask buys a lock you still hold; the monthly fee is spent.` : ` The listing is priced in ${row.paymentSymbol}, which is a different token from the fee.`;
6497
+ return `${lead} Example direct listing #${row.tokenId}: ${row.priceHuman} ${row.paymentSymbol} for ${row.lockedCtmHuman} CTM, unlocks ${row.unlockAt}. Voting power stays above the threshold until ${row.staysAboveThresholdUntil}.${compare}`;
6498
+ }
6499
+ async function readFeeSide(rpcUrl, chainId) {
6500
+ const client = marketplacePublicClient(chainId, rpcUrl);
6501
+ const wallet = MULTISIGN_AGENT_WALLET_LINEA_ADDRESS;
6502
+ const [threshold, rates, feeToken, ctmPerFeeToken] = await Promise.all([
6503
+ client.readContract({ address: wallet, abi: feeAbi, functionName: "veCtmThresholdPower" }),
6504
+ client.readContract({ address: wallet, abi: feeAbi, functionName: "getActiveRates" }),
6505
+ client.readContract({ address: wallet, abi: feeAbi, functionName: "FEE_TOKEN" }),
6506
+ client.readContract({ address: wallet, abi: feeAbi, functionName: "ctmPerFeeToken" })
6507
+ ]);
6508
+ const monthlyFee = rates[0];
6509
+ const monthlyFeeCtm = ctmPerFeeToken > 0n ? monthlyFee * ctmPerFeeToken / CTM_FEE_RATE_SCALE : 0n;
6510
+ return { threshold, monthlyFee, monthlyFeeCtm, feeToken: getAddress(feeToken) };
6511
+ }
6512
+ async function collectListings(args) {
6513
+ const rows = [];
6514
+ let cursor;
6515
+ let scanned = 0;
6516
+ let source = "api";
6517
+ let truncated = false;
6518
+ for (let page = 0; page < MAX_PAGES2; page += 1) {
6519
+ const res = await fetchContinuumDaoMarketplaceListings({ ...args, includeInactive: false, limit: PAGE_SIZE2, cursor });
6520
+ source = res.source;
6521
+ scanned += res.items.length;
6522
+ rows.push(...res.items.map(listingCandidate));
6523
+ if (res.source === "logs" || !res.nextCursor) return { rows, scanned, truncated, source };
6524
+ cursor = res.nextCursor;
6525
+ }
6526
+ return { rows, scanned, truncated: true, source };
6527
+ }
6528
+ async function fillLocks(rows, rpcUrl, chainId) {
6529
+ const missing = [...new Set(rows.filter((row) => row.locked <= 0n || row.unlockUnix <= 0).map((row) => row.tokenId))];
6530
+ if (missing.length === 0) return rows;
6531
+ const client = marketplacePublicClient(chainId, rpcUrl);
6532
+ const locks = /* @__PURE__ */ new Map();
6533
+ for (let i = 0; i < missing.length; i += 40) {
6534
+ const chunk = missing.slice(i, i + 40);
6535
+ const results = await client.multicall({
6536
+ contracts: chunk.map((id) => ({
6537
+ address: VOTING_ESCROW_LINEA_ADDRESS,
6538
+ abi: feeAbi,
6539
+ functionName: "locked",
6540
+ args: [BigInt(id)]
6541
+ })),
6542
+ allowFailure: true
6543
+ });
6544
+ results.forEach((result, index) => {
6545
+ if (result.status !== "success" || !result.result) return;
6546
+ const id = chunk[index];
6547
+ if (!id) return;
6548
+ const [amount, end] = result.result;
6549
+ locks.set(id, { amount: amount < 0n ? 0n : amount, end: Number(end) });
6550
+ });
6551
+ }
6552
+ return rows.map((row) => {
6553
+ const lock = locks.get(row.tokenId);
6554
+ if (!lock) return row;
6555
+ return { ...row, locked: row.locked > 0n ? row.locked : lock.amount, unlockUnix: row.unlockUnix > 0 ? row.unlockUnix : lock.end };
6556
+ });
6557
+ }
6558
+ async function readVotingPower(tokenIds, rpcUrl, chainId) {
6559
+ const client = marketplacePublicClient(chainId, rpcUrl);
6560
+ const power = /* @__PURE__ */ new Map();
6561
+ for (let i = 0; i < tokenIds.length; i += 40) {
6562
+ const chunk = tokenIds.slice(i, i + 40);
6563
+ const results = await client.multicall({
6564
+ contracts: chunk.map((id) => ({
6565
+ address: VOTING_ESCROW_LINEA_ADDRESS,
6566
+ abi: feeAbi,
6567
+ functionName: "balanceOfNFT",
6568
+ args: [BigInt(id)]
6569
+ })),
6570
+ allowFailure: true
6571
+ });
6572
+ results.forEach((result, index) => {
6573
+ const id = chunk[index];
6574
+ if (!id || result.status !== "success") return;
6575
+ power.set(id, result.result);
6576
+ });
6577
+ }
6578
+ return power;
6579
+ }
6580
+ async function quoteContinuumDaoMarketplaceFeeAlternative(args) {
6581
+ const rpcUrl = args.rpcUrl?.trim();
6582
+ if (!rpcUrl) throw new Error("Linea RPC is required to read the monthly fee and veCTM threshold.");
6583
+ const chainId = args.chainId ?? CONTINUUM_DAO_LINEA_CHAIN_ID;
6584
+ const payment = args.payment ?? "fee";
6585
+ const nowUnix = Math.floor(Date.now() / 1e3);
6586
+ const fee = await readFeeSide(rpcUrl, chainId);
6587
+ const collected = await collectListings(args);
6588
+ const withLocks = await fillLocks(collected.rows, rpcUrl, chainId);
6589
+ const executor = args.executor?.trim();
6590
+ const visible = executor ? withLocks.filter((row) => {
6591
+ try {
6592
+ return getAddress(row.seller) !== getAddress(executor);
6593
+ } catch {
6594
+ return row.seller.toLowerCase() !== executor.toLowerCase();
6595
+ }
6596
+ }) : withLocks;
6597
+ const aboveLock = visible.filter((row) => row.fillable && row.locked > fee.threshold);
6598
+ const power = await readVotingPower(aboveLock.map((row) => row.tokenId), rpcUrl, chainId);
6599
+ const qualified = aboveLock.flatMap((row) => {
6600
+ const votingPower = power.get(row.tokenId);
6601
+ if (votingPower == null || votingPower <= fee.threshold) return [];
6602
+ return [
6603
+ {
6604
+ tokenId: row.tokenId,
6605
+ paymentToken: row.paymentToken,
6606
+ price: row.price,
6607
+ locked: row.locked,
6608
+ unlockUnix: row.unlockUnix,
6609
+ votingPower,
6610
+ fillable: row.fillable
6611
+ }
6612
+ ];
6613
+ });
6614
+ const preferred = payment === "ctm" ? CTM_TOKEN_ADDRESS : fee.feeToken;
6615
+ const picked = pickFeeAlternativeExample(qualified, preferred);
6616
+ const feeMeta = paymentMeta2(fee.feeToken);
6617
+ const example = picked ? toExample(picked, fee, payment, preferred, nowUnix) : null;
6618
+ const quoteBase = {
6619
+ payment,
6620
+ threshold: fee.threshold.toString(),
6621
+ thresholdHuman: human(fee.threshold, 18),
6622
+ monthlyFee: fee.monthlyFee.toString(),
6623
+ monthlyFeeHuman: human(fee.monthlyFee, feeMeta.decimals),
6624
+ monthlyFeeSymbol: feeMeta.symbol,
6625
+ annualFee: (fee.monthlyFee * 12n).toString(),
6626
+ annualFeeHuman: human(fee.monthlyFee * 12n, feeMeta.decimals),
6627
+ monthlyFeeCtm: fee.monthlyFeeCtm.toString(),
6628
+ monthlyFeeCtmHuman: human(fee.monthlyFeeCtm, 18),
6629
+ annualFeeCtm: (fee.monthlyFeeCtm * 12n).toString(),
6630
+ annualFeeCtmHuman: human(fee.monthlyFeeCtm * 12n, 18),
6631
+ feeToken: fee.feeToken,
6632
+ example,
6633
+ scanned: collected.scanned,
6634
+ truncated: collected.truncated,
6635
+ source: collected.source
6636
+ };
6637
+ return {
6638
+ ...quoteBase,
6639
+ summary: buildFeeAlternativeSummary({
6640
+ thresholdHuman: quoteBase.thresholdHuman,
6641
+ monthlyFeeHuman: quoteBase.monthlyFeeHuman,
6642
+ monthlyFeeSymbol: quoteBase.monthlyFeeSymbol,
6643
+ annualFeeHuman: quoteBase.annualFeeHuman,
6644
+ annualFeeCtmHuman: quoteBase.annualFeeCtmHuman,
6645
+ example
6646
+ })
6647
+ };
6648
+ }
6649
+ function toExample(row, fee, payment, preferred, nowUnix) {
6650
+ const meta4 = paymentMeta2(row.paymentToken);
6651
+ const same5 = row.paymentToken.toLowerCase() === preferred.toLowerCase();
6652
+ const monthly = payment === "ctm" ? fee.monthlyFeeCtm : fee.monthlyFee;
6653
+ const until = votingPowerAboveUntil({
6654
+ votingPower: row.votingPower,
6655
+ threshold: fee.threshold,
6656
+ nowUnix,
6657
+ unlockUnix: row.unlockUnix
6658
+ });
6659
+ const perCtm = row.price * 10n ** 18n / row.locked;
6660
+ return {
6661
+ tokenId: row.tokenId,
6662
+ price: row.price.toString(),
6663
+ priceHuman: human(row.price, meta4.decimals),
6664
+ paymentToken: row.paymentToken,
6665
+ paymentSymbol: meta4.symbol,
6666
+ lockedCtm: row.locked.toString(),
6667
+ lockedCtmHuman: human(row.locked, 18),
6668
+ unlockAt: iso(row.unlockUnix),
6669
+ votingPower: row.votingPower.toString(),
6670
+ votingPowerHuman: human(row.votingPower, 18),
6671
+ staysAboveThresholdUntil: iso(until ?? 0),
6672
+ pricePerLockedCtm: human(perCtm, meta4.decimals),
6673
+ monthsOfFees: same5 ? monthsOfFees(row.price, monthly) : null,
6674
+ comparedTo: same5 ? payment : null,
6675
+ fillable: row.fillable
6676
+ };
6677
+ }
6678
+
6679
+ // src/protocols/evm/continuum-dao/marketplaceMultisign.ts
6680
+ init_buildBatch();
6681
+ init_constants();
6682
+ function parseWei(raw, label) {
6683
+ const value = typeof raw === "bigint" ? raw : BigInt(String(raw).trim());
6684
+ if (value < 0n) throw new Error(`${label} must be zero or greater.`);
6685
+ return value;
6686
+ }
6687
+ function parseTokenId2(raw) {
6688
+ const id = typeof raw === "bigint" ? raw : BigInt(String(raw).trim());
6689
+ if (id <= 0n) throw new Error("veCTM token id must be greater than zero.");
6690
+ return id;
6691
+ }
6692
+ function requireLinea(chainId) {
6693
+ if (chainId !== CONTINUUM_DAO_LINEA_CHAIN_ID) {
6694
+ throw new Error("veCTM marketplace actions are Linea mainnet only.");
6695
+ }
6696
+ }
6697
+ function meta3(step, chainId, gasLimit) {
6698
+ return {
6699
+ destinationAddress: step.to,
6700
+ signatureText: continuumDaoSignatureText({ name: step.name, ...step.extra }, chainId),
6701
+ evm: {
6702
+ type: step.evmType,
6703
+ version: 1,
6704
+ chainId: String(chainId),
6705
+ protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID
6706
+ },
6707
+ continuumDaoMarketplace: { ...step.extra, name: step.name, gas: { baseGasUnits: gasLimit.toString() } }
6708
+ };
6709
+ }
6710
+ async function finalize2(steps, args, purposeSuffix) {
6711
+ const evmSteps = steps.map((s) => ({
6712
+ to: s.to,
6713
+ data: s.data,
6714
+ value: s.value,
6715
+ fallbackGas: s.fallbackGas
6716
+ }));
6717
+ const firstDataNo0x = evmSteps[0].data.startsWith("0x") ? evmSteps[0].data.slice(2) : evmSteps[0].data;
6718
+ return buildEvmMultisignBatch({
6719
+ context: {
6720
+ chainCategory: "evm",
6721
+ keyGen: args.keyGen,
6722
+ purposeText: args.purposeText,
6723
+ chainId: args.chainId,
6724
+ rpcUrl: args.rpcUrl.trim(),
6725
+ executorAddress: args.executorAddress,
6726
+ chainDetail: args.chainDetail,
6727
+ useCustomGas: args.useCustomGas,
6728
+ customGasChainDetails: args.customGasChainDetails
6729
+ },
6730
+ steps: evmSteps,
6731
+ purposeSuffix,
6732
+ firstMsgRawNo0x: firstDataNo0x,
6733
+ destinationAddress: steps[0].to,
6734
+ buildBatchMeta: ({ index, gasLimit }) => meta3(steps[index], args.chainId, gasLimit)
6735
+ });
6736
+ }
6737
+ async function build(args, input, purposeSuffix, snapshotArgs) {
6738
+ requireLinea(args.chainId);
6739
+ const executor = getAddress(args.executorAddress);
6740
+ const tokenId = "tokenId" in input ? input.tokenId : 0n;
6741
+ const snap = await loadMarketplacePlanSnapshot({
6742
+ chainId: args.chainId,
6743
+ rpcUrl: args.rpcUrl,
6744
+ executor,
6745
+ tokenId,
6746
+ ...snapshotArgs
6747
+ });
6748
+ const steps = planMarketplaceSteps(input, snap);
6749
+ return finalize2(steps, args, purposeSuffix);
6750
+ }
6751
+ async function buildEvmMultisignBodyContinuumDaoMarketplaceCreateListing(args) {
6752
+ const tokenId = parseTokenId2(args.tokenId);
6753
+ const paymentToken = getAddress(args.paymentToken);
6754
+ const askWei = parseWei(args.askWei, "Ask");
6755
+ const deadline = parseWei(args.deadline, "Deadline");
6756
+ return build(
6757
+ args,
6758
+ { action: "createListing", tokenId, paymentToken, askWei, deadline },
6759
+ `ContinuumDAO marketplace: list veCTM #${tokenId.toString()}.`,
6760
+ { paymentToken }
6761
+ );
6762
+ }
6763
+ async function buildEvmMultisignBodyContinuumDaoMarketplaceDelist(args) {
6764
+ const tokenId = parseTokenId2(args.tokenId);
6765
+ return build(args, { action: "delist", tokenId }, `ContinuumDAO marketplace: delist veCTM #${tokenId.toString()}.`, {});
6766
+ }
6767
+ async function buildEvmMultisignBodyContinuumDaoMarketplaceFulfillListing(args) {
6768
+ const tokenId = parseTokenId2(args.tokenId);
6769
+ const seller = getAddress(args.seller);
6770
+ const paymentToken = getAddress(args.paymentToken);
6771
+ const priceWei = parseWei(args.priceWei, "Price");
6772
+ return build(
6773
+ args,
6774
+ { action: "fulfillListing", tokenId, seller, paymentToken, priceWei },
6775
+ `ContinuumDAO marketplace: buy veCTM #${tokenId.toString()}.`,
6776
+ { seller, paymentToken }
6777
+ );
6778
+ }
6779
+ async function buildEvmMultisignBodyContinuumDaoMarketplaceCreateOffering(args) {
6780
+ const tokenId = parseTokenId2(args.tokenId);
6781
+ const paymentToken = getAddress(args.paymentToken);
6782
+ const bidWei = parseWei(args.bidWei, "Bid");
6783
+ const deadline = parseWei(args.deadline, "Deadline");
6784
+ return build(
6785
+ args,
6786
+ { action: "createOffering", tokenId, paymentToken, bidWei, deadline },
6787
+ `ContinuumDAO marketplace: offer on veCTM #${tokenId.toString()}.`,
6788
+ { paymentToken }
6789
+ );
6790
+ }
6791
+ async function buildEvmMultisignBodyContinuumDaoMarketplaceRescind(args) {
6792
+ const tokenId = parseTokenId2(args.tokenId);
6793
+ return build(
6794
+ args,
6795
+ { action: "rescind", tokenId },
6796
+ `ContinuumDAO marketplace: rescind offer on veCTM #${tokenId.toString()}.`,
6797
+ {}
6798
+ );
6799
+ }
6800
+ async function buildEvmMultisignBodyContinuumDaoMarketplaceFulfillOffering(args) {
6801
+ const tokenId = parseTokenId2(args.tokenId);
6802
+ const buyer = getAddress(args.buyer);
6803
+ const paymentToken = getAddress(args.paymentToken);
6804
+ const priceWei = parseWei(args.priceWei, "Price");
6805
+ return build(
6806
+ args,
6807
+ { action: "fulfillOffering", tokenId, buyer, paymentToken, priceWei },
6808
+ `ContinuumDAO marketplace: accept offer on veCTM #${tokenId.toString()}.`,
6809
+ { buyer, paymentToken }
6810
+ );
6811
+ }
6812
+ async function buildEvmMultisignBodyContinuumDaoMarketplaceCreateAuction(args) {
6813
+ const tokenId = parseTokenId2(args.tokenId);
6814
+ const paymentToken = getAddress(args.paymentToken);
6815
+ const deadline = parseWei(args.deadline, "Deadline");
6816
+ const reserveWei = parseWei(args.reserveWei, "Reserve");
6817
+ const minIncrementWei = parseWei(args.minIncrementWei, "Minimum increment");
6818
+ return build(
6819
+ args,
6820
+ { action: "createAuction", tokenId, paymentToken, deadline, reserveWei, minIncrementWei },
6821
+ `ContinuumDAO marketplace: auction veCTM #${tokenId.toString()}.`,
6822
+ { paymentToken }
6823
+ );
6824
+ }
6825
+ async function buildEvmMultisignBodyContinuumDaoMarketplaceCancelAuction(args) {
6826
+ const tokenId = parseTokenId2(args.tokenId);
6827
+ return build(
6828
+ args,
6829
+ { action: "cancelAuction", tokenId },
6830
+ `ContinuumDAO marketplace: cancel auction for veCTM #${tokenId.toString()}.`,
6831
+ {}
6832
+ );
6833
+ }
6834
+ async function buildEvmMultisignBodyContinuumDaoMarketplaceAuctionBid(args) {
6835
+ const tokenId = parseTokenId2(args.tokenId);
6836
+ const seller = getAddress(args.seller);
6837
+ const priceWei = parseWei(args.priceWei, "Bid");
6838
+ return build(
6839
+ args,
6840
+ { action: "auctionBid", tokenId, seller, priceWei },
6841
+ `ContinuumDAO marketplace: bid on veCTM #${tokenId.toString()}.`,
6842
+ { seller }
6843
+ );
6844
+ }
6845
+ async function buildEvmMultisignBodyContinuumDaoMarketplaceSettleAuction(args) {
6846
+ const tokenId = parseTokenId2(args.tokenId);
6847
+ const seller = getAddress(args.seller);
6848
+ return build(
6849
+ args,
6850
+ { action: "settleAuction", tokenId, seller },
6851
+ `ContinuumDAO marketplace: settle auction for veCTM #${tokenId.toString()}.`,
6852
+ { seller }
6853
+ );
6854
+ }
6855
+ function parseExtra(detail) {
6856
+ const raw = detail?.ExtraJSON ?? detail?.extraJSON;
6857
+ if (raw == null) return null;
6858
+ if (typeof raw === "object" && !Array.isArray(raw)) return raw;
6859
+ if (typeof raw === "string" && raw.trim()) {
6860
+ try {
6861
+ const parsed = JSON.parse(raw);
6862
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) return parsed;
6863
+ } catch {
6864
+ return null;
6865
+ }
6866
+ }
6867
+ return null;
6868
+ }
6869
+ function same4(a, b) {
6870
+ try {
6871
+ return getAddress(a) === getAddress(b);
6872
+ } catch {
6873
+ return a.toLowerCase() === b.toLowerCase();
6874
+ }
6875
+ }
6876
+ function marketplaceVeCtmReceivedBy(detail, executor) {
6877
+ const extra = parseExtra(detail);
6878
+ const batch = extra?.batchMeta;
6879
+ if (!Array.isArray(batch) || !executor.trim()) return null;
6880
+ for (const entry of batch) {
6881
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
6882
+ const row = entry;
6883
+ const evm = row.evm;
6884
+ const type = evm && typeof evm === "object" ? String(evm.type ?? "") : "";
6885
+ const meta4 = row.continuumDaoMarketplace;
6886
+ if (!meta4 || typeof meta4 !== "object" || Array.isArray(meta4)) continue;
6887
+ const info = meta4;
6888
+ const tokenId = String(info.tokenId ?? "").trim();
6889
+ if (!tokenId) continue;
6890
+ if (type === "continuum_dao_marketplace_fulfill_listing") {
6891
+ const recipient = String(info.recipient ?? "");
6892
+ if (!recipient || same4(recipient, executor)) return { tokenId };
6893
+ }
6894
+ if (type === "continuum_dao_marketplace_settle_auction") {
6895
+ const highest = String(info.highestBidder ?? "");
6896
+ const recipient = String(info.recipient ?? "");
6897
+ if (highest && same4(highest, executor) && same4(recipient, executor)) return { tokenId };
6898
+ }
6899
+ }
6900
+ return null;
6901
+ }
6902
+
6903
+ // src/protocols/evm/continuum-dao/index.ts
6904
+ registerProtocolModule(continuumDaoMarketplaceProtocolModule);
4714
6905
  var continuumDaoProtocolModule = {
4715
6906
  id: CONTINUUM_DAO_PROTOCOL_ID,
4716
6907
  chainCategory: "evm",
@@ -4762,6 +6953,6 @@ var continuumDaoProtocolModule = {
4762
6953
  };
4763
6954
  registerProtocolModule(continuumDaoProtocolModule);
4764
6955
 
4765
- export { ATTACH_VECTM_SIGNATURE, BRAVO_SUPPORT_LABELS, CONTINUUM_DAO_APPROVE_FALLBACK, CONTINUUM_DAO_ATTACH_FALLBACK, CONTINUUM_DAO_CANCEL_FALLBACK, CONTINUUM_DAO_COMMITTEE_PROPOSERS, CONTINUUM_DAO_CREATE_LOCK_FALLBACK, CONTINUUM_DAO_DELEGATE_FALLBACK, CONTINUUM_DAO_DEPLOYMENTS, CONTINUUM_DAO_DETACH_FALLBACK, CONTINUUM_DAO_ETHEREUM_CHAIN_ID, CONTINUUM_DAO_EVM_TYPES, CONTINUUM_DAO_EXECUTE_FALLBACK, CONTINUUM_DAO_GOVERNANCE_API, CONTINUUM_DAO_GOV_EVM_TYPES, CONTINUUM_DAO_INCREASE_AMOUNT_FALLBACK, CONTINUUM_DAO_INCREASE_UNLOCK_FALLBACK, CONTINUUM_DAO_LINEA_CHAIN_ID, CONTINUUM_DAO_LINEA_GOVERNOR_ADDRESS, CONTINUUM_DAO_LINEA_GOVERNOR_LEGACY_ADDRESS, CONTINUUM_DAO_LINEA_SEPOLIA_CHAIN_ID, CONTINUUM_DAO_LIQUIDATE_FALLBACK, CONTINUUM_DAO_MERGE_FALLBACK, CONTINUUM_DAO_PROPOSE_FALLBACK, CONTINUUM_DAO_PROTOCOL_ID, CONTINUUM_DAO_SPLIT_FALLBACK, CONTINUUM_DAO_TRANSFER_FALLBACK, CONTINUUM_DAO_VOTE_FALLBACK, CONTINUUM_DAO_WITHDRAW_FALLBACK, CTM_TOKEN_ADDRESS, CTM_TOKEN_DECIMALS, CTM_TOKEN_NAME, CTM_TOKEN_SYMBOL, FORUM_GOVERNANCE_SECTIONS, FORUM_IDEA_SECTION, FORUM_LOGIN_DELIVERY_KIND, FOUNDRY_PROPOSAL_REQUIRED_SERVERS, GOVERNOR_STATE, GOVERNOR_STATE_LABELS, INCREASE_UNLOCK_TIME_SIGNATURE, MAXTIME_SECONDS, PROPOSAL_TYPE_LABELS, PROPOSAL_TYPE_TO_FORUM_SECTION, VECTM_DEFAULT_MINIMUM_LOCK_WEI, VECTM_LIQ_MIN_LOCKED_WEI, VECTM_LIQ_PENALTY_DEN, VECTM_LIQ_PENALTY_NUM, VECTM_MAX_LOCK_WEEKS, VECTM_NODE_INFO_TUPLE, VECTM_TOKEN_NAME, VECTM_TOKEN_SYMBOL, VOTE_CAST_EVENT, VOTE_CAST_WITH_PARAMS_EVENT, VOTING_ESCROW_LINEA_ADDRESS, WEEK_SECONDS, applyForumSectionCheck, applyNodeAttachments, assertContinuumDaoForumDeleteInput, assertContinuumDaoForumMarkReadInput, assertContinuumDaoForumRecentInput, assertContinuumDaoForumSearchInput, assertContinuumDaoForumTopicKey, assertContinuumDaoProposalSimulation, assertCreateLockAmount, assertCtmAmountAtLeastMinimum, assertDelegatee, assertExecutorOwnsLock, assertIncreaseAmount, assertIncreaseUnlockTime, assertLiquidate, assertLockDurationSeconds, assertMerge, assertSplitExtracted, assertTransfer, assertUndelegateNotAlreadySelf, assertWithdraw, bravoSupportLabel, bucketGovernorState, buildBravoProposalArgs, buildDeltaProposalArgs, buildEvmMultisignBodyContinuumDaoAttachVeCtm, buildEvmMultisignBodyContinuumDaoAttachVeCtmFromMcp, buildEvmMultisignBodyContinuumDaoCancel, buildEvmMultisignBodyContinuumDaoCastVoteBravo, buildEvmMultisignBodyContinuumDaoCastVoteBravoFromMcp, buildEvmMultisignBodyContinuumDaoCastVoteDelta, buildEvmMultisignBodyContinuumDaoCreateLock, buildEvmMultisignBodyContinuumDaoDelegate, buildEvmMultisignBodyContinuumDaoExecute, buildEvmMultisignBodyContinuumDaoForumSignIn, buildEvmMultisignBodyContinuumDaoIncreaseAmount, buildEvmMultisignBodyContinuumDaoIncreaseUnlockTime, buildEvmMultisignBodyContinuumDaoLiquidate, buildEvmMultisignBodyContinuumDaoMerge, buildEvmMultisignBodyContinuumDaoProposeBravo, buildEvmMultisignBodyContinuumDaoProposeDelta, buildEvmMultisignBodyContinuumDaoProposeDeltaFromMcp, buildEvmMultisignBodyContinuumDaoRequestDetach, buildEvmMultisignBodyContinuumDaoSplit, buildEvmMultisignBodyContinuumDaoTransfer, buildEvmMultisignBodyContinuumDaoUndelegate, buildEvmMultisignBodyContinuumDaoWithdraw, buildFoundryProposalSimulatePlan, collectVotesFromLogs, computeLiquidationAmounts, continuumDaoComposeProposalAction, continuumDaoDeployment, continuumDaoExplainProposal, continuumDaoFetchDelegates, continuumDaoFetchLiveProposals, continuumDaoFetchProposal, continuumDaoFetchProposalCount, continuumDaoFetchProposalState, continuumDaoFetchProposalVoteEligibility, continuumDaoFetchProposalVotes, continuumDaoFetchProposals, continuumDaoFetchVotingPower, continuumDaoForumCreateIdea, continuumDaoForumCreateTopic, continuumDaoForumDelete, continuumDaoForumFetchPost, continuumDaoForumFetchThread, continuumDaoForumMarkRead, continuumDaoForumMarkUnread, continuumDaoForumMe, continuumDaoForumReact, continuumDaoForumRecent, continuumDaoForumReply, continuumDaoForumReplyCount, continuumDaoForumResolve, continuumDaoForumSearch, continuumDaoForumSections, continuumDaoForumSignInEligible, continuumDaoForumSignInNonce, continuumDaoForumSignOut, continuumDaoForumUnread, continuumDaoForumUrl, continuumDaoForumUserPostIds, continuumDaoHashProposal, continuumDaoMpaFlag, continuumDaoMpaListing, continuumDaoMpaMailboxList, continuumDaoMpaMailboxOpen, continuumDaoMpaMailboxSend, continuumDaoMpaRetract, continuumDaoProtocolModule, continuumDaoRegisterProposal, continuumDaoSignatureText, continuumDaoSimulateProposal, continuumDaoTechnocoreBind, ctmTokenAddressOnEvmChain, decodeDeltaVoteParams, encodeContinuumDaoNodeInfo, encodeDeltaMetadata, encodeDeltaVoteParams, encodeGovActionCalldata, estimateBlockAtTimestamp, executableGovBatches, expectedForumSectionForProposalType, explainGovAction, explainProposalRecord, explorerBase, floorUnlockTimeSeconds, formatProposalSimulationFailure, foundryPlanHasSequentialExecute, foundryScriptContainsCall, governorAddressOnEvmChain, governorWriteAbi, howVoted, isConfiguredAddress, isContinuumDaoCommitteeProposer, isContinuumDaoCtmOnAssetsChain, isContinuumDaoLockChain, isContinuumDaoSupportedChainId, isContinuumDaoVeCtmOnAssetsChain, isCtmTokenSymbol, isForumIdeaSection, isGovNoOpAction, isLegacyContinuumDaoGovernor, isLineaHomeNetwork, isRemoteC3Action, isVotingEscrowContinuumName, listContinuumDaoDefaultAssets, looksLikeProposalCatalogId, looksLikeUnixSeconds, maxLockDurationSeconds, normalizeGovConfiguration, normalizeNodeInfo, preflightAttachVeCtm, preflightCreateLock, preflightDelegate, preflightIncreaseAmount, preflightIncreaseUnlockTime, preflightLiquidate, preflightMerge, preflightRequestDetach, preflightSplit, preflightTransfer, preflightUndelegate, preflightWithdraw, proposalDescriptionHash, publicClient2 as publicClient, readCtmBalanceWei, readMinimumLockWei, readVeCtmLockState, requireGovernor, resolveAttachGroupId, resolveGovernorProposalRef, resolveProposalCatalogRange, summarizeLiveProposals, summarizeProposalVotes, throwIfProposalSimulationFailed, validateAbiParameter, votingEscrowAddressOnEvmChain, votingPowerRefuse, votingPowerWarning };
6956
+ export { ATTACH_VECTM_SIGNATURE, AUCTION_STATUS, BRAVO_SUPPORT_LABELS, CONTINUUM_DAO_APPROVE_FALLBACK, CONTINUUM_DAO_ATTACH_FALLBACK, CONTINUUM_DAO_CANCEL_FALLBACK, CONTINUUM_DAO_COMMITTEE_PROPOSERS, CONTINUUM_DAO_CREATE_LOCK_FALLBACK, CONTINUUM_DAO_DELEGATE_FALLBACK, CONTINUUM_DAO_DEPLOYMENTS, CONTINUUM_DAO_DETACH_FALLBACK, CONTINUUM_DAO_ETHEREUM_CHAIN_ID, CONTINUUM_DAO_EVM_TYPES, CONTINUUM_DAO_EXECUTE_FALLBACK, CONTINUUM_DAO_GOVERNANCE_API, CONTINUUM_DAO_GOV_EVM_TYPES, CONTINUUM_DAO_INCREASE_AMOUNT_FALLBACK, CONTINUUM_DAO_INCREASE_UNLOCK_FALLBACK, CONTINUUM_DAO_LINEA_CHAIN_ID, CONTINUUM_DAO_LINEA_GOVERNOR_ADDRESS, CONTINUUM_DAO_LINEA_GOVERNOR_LEGACY_ADDRESS, CONTINUUM_DAO_LINEA_SEPOLIA_CHAIN_ID, CONTINUUM_DAO_LIQUIDATE_FALLBACK, CONTINUUM_DAO_MARKETPLACE_API, CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, CONTINUUM_DAO_MERGE_FALLBACK, CONTINUUM_DAO_PROPOSE_FALLBACK, CONTINUUM_DAO_PROTOCOL_ID, CONTINUUM_DAO_SPLIT_FALLBACK, CONTINUUM_DAO_TRANSFER_FALLBACK, CONTINUUM_DAO_VOTE_FALLBACK, CONTINUUM_DAO_WITHDRAW_FALLBACK, CTM_FEE_RATE_SCALE, CTM_TOKEN_ADDRESS, CTM_TOKEN_DECIMALS, CTM_TOKEN_NAME, CTM_TOKEN_SYMBOL, FEE_TIER_NAMES, FORUM_GOVERNANCE_SECTIONS, FORUM_IDEA_SECTION, FORUM_LOGIN_DELIVERY_KIND, FOUNDRY_PROPOSAL_REQUIRED_SERVERS, GOVERNOR_STATE, GOVERNOR_STATE_LABELS, INCREASE_UNLOCK_TIME_SIGNATURE, MARKETPLACE_APPROVE_FALLBACK, MARKETPLACE_AUCTION_CREATE_FALLBACK, MARKETPLACE_BID_FALLBACK, MARKETPLACE_FULFILL_FALLBACK, MARKETPLACE_LISTING_FALLBACK, MARKETPLACE_OFFERING_FALLBACK, MARKETPLACE_SETTLE_FALLBACK, MARKETPLACE_USDC_LINEA_ADDRESS, MARKETPLACE_WETH_LINEA_ADDRESS, MARKET_ORDER_STATUS, MAXTIME_SECONDS, MULTISIGN_AGENT_WALLET_LINEA_ADDRESS, PROPOSAL_TYPE_LABELS, PROPOSAL_TYPE_TO_FORUM_SECTION, VECTM_DEFAULT_MINIMUM_LOCK_WEI, VECTM_LIQ_MIN_LOCKED_WEI, VECTM_LIQ_PENALTY_DEN, VECTM_LIQ_PENALTY_NUM, VECTM_MAX_LOCK_WEEKS, VECTM_NODE_INFO_TUPLE, VECTM_TOKEN_NAME, VECTM_TOKEN_SYMBOL, VOTE_CAST_EVENT, VOTE_CAST_WITH_PARAMS_EVENT, VOTING_ESCROW_LINEA_ADDRESS, VOTING_ESCROW_MARKETPLACE_LINEA_ADDRESS, VOTING_ESCROW_MARKETPLACE_START_BLOCK, WEEK_SECONDS, applyDerivedStatuses, applyForumSectionCheck, applyMarketplaceEvent, applyNodeAttachments, assertContinuumDaoForumDeleteInput, assertContinuumDaoForumMarkReadInput, assertContinuumDaoForumRecentInput, assertContinuumDaoForumSearchInput, assertContinuumDaoForumTopicKey, assertContinuumDaoProposalSimulation, assertCreateLockAmount, assertCtmAmountAtLeastMinimum, assertDelegatee, assertExecutorOwnsLock, assertIncreaseAmount, assertIncreaseUnlockTime, assertLiquidate, assertLockDurationSeconds, assertMerge, assertSplitExtracted, assertTransfer, assertUndelegateNotAlreadySelf, assertWithdraw, auctionCandidate, auctionStatusName, bravoSupportLabel, bucketGovernorState, buildBravoProposalArgs, buildDeltaProposalArgs, buildEvmMultisignBodyContinuumDaoAttachVeCtm, buildEvmMultisignBodyContinuumDaoAttachVeCtmFromMcp, buildEvmMultisignBodyContinuumDaoCancel, buildEvmMultisignBodyContinuumDaoCastVoteBravo, buildEvmMultisignBodyContinuumDaoCastVoteBravoFromMcp, buildEvmMultisignBodyContinuumDaoCastVoteDelta, buildEvmMultisignBodyContinuumDaoCreateLock, buildEvmMultisignBodyContinuumDaoDelegate, buildEvmMultisignBodyContinuumDaoExecute, buildEvmMultisignBodyContinuumDaoForumSignIn, buildEvmMultisignBodyContinuumDaoIncreaseAmount, buildEvmMultisignBodyContinuumDaoIncreaseUnlockTime, buildEvmMultisignBodyContinuumDaoLiquidate, buildEvmMultisignBodyContinuumDaoMarketplaceAuctionBid, buildEvmMultisignBodyContinuumDaoMarketplaceCancelAuction, buildEvmMultisignBodyContinuumDaoMarketplaceCreateAuction, buildEvmMultisignBodyContinuumDaoMarketplaceCreateListing, buildEvmMultisignBodyContinuumDaoMarketplaceCreateOffering, buildEvmMultisignBodyContinuumDaoMarketplaceDelist, buildEvmMultisignBodyContinuumDaoMarketplaceFulfillListing, buildEvmMultisignBodyContinuumDaoMarketplaceFulfillOffering, buildEvmMultisignBodyContinuumDaoMarketplaceRescind, buildEvmMultisignBodyContinuumDaoMarketplaceSettleAuction, buildEvmMultisignBodyContinuumDaoMerge, buildEvmMultisignBodyContinuumDaoProposeBravo, buildEvmMultisignBodyContinuumDaoProposeDelta, buildEvmMultisignBodyContinuumDaoProposeDeltaFromMcp, buildEvmMultisignBodyContinuumDaoRequestDetach, buildEvmMultisignBodyContinuumDaoSplit, buildEvmMultisignBodyContinuumDaoTransfer, buildEvmMultisignBodyContinuumDaoUndelegate, buildEvmMultisignBodyContinuumDaoWithdraw, buildFeeAlternativeSummary, buildFoundryProposalSimulatePlan, calculateMarketplaceFee, collectVotesFromLogs, computeLiquidationAmounts, continuumDaoComposeProposalAction, continuumDaoDeployment, continuumDaoExplainProposal, continuumDaoFetchDelegates, continuumDaoFetchLiveProposals, continuumDaoFetchProposal, continuumDaoFetchProposalCount, continuumDaoFetchProposalState, continuumDaoFetchProposalVoteEligibility, continuumDaoFetchProposalVotes, continuumDaoFetchProposals, continuumDaoFetchVotingPower, continuumDaoForumCreateIdea, continuumDaoForumCreateTopic, continuumDaoForumDelete, continuumDaoForumFetchPost, continuumDaoForumFetchThread, continuumDaoForumMarkRead, continuumDaoForumMarkUnread, continuumDaoForumMe, continuumDaoForumReact, continuumDaoForumRecent, continuumDaoForumReply, continuumDaoForumReplyCount, continuumDaoForumResolve, continuumDaoForumSearch, continuumDaoForumSections, continuumDaoForumSignInEligible, continuumDaoForumSignInNonce, continuumDaoForumSignOut, continuumDaoForumUnread, continuumDaoForumUrl, continuumDaoForumUserPostIds, continuumDaoHashProposal, continuumDaoMarketplaceProtocolModule, continuumDaoMpaFlag, continuumDaoMpaListing, continuumDaoMpaMailboxList, continuumDaoMpaMailboxOpen, continuumDaoMpaMailboxSend, continuumDaoMpaRetract, continuumDaoProtocolModule, continuumDaoRegisterProposal, continuumDaoSignatureText, continuumDaoSimulateProposal, continuumDaoTechnocoreBind, ctmTokenAddressOnEvmChain, decodeDeltaVoteParams, deriveAuctionStatus, emptyMarketplaceIndexCache, encodeContinuumDaoNodeInfo, encodeDeltaMetadata, encodeDeltaVoteParams, encodeGovActionCalldata, estimateBlockAtTimestamp, executableGovBatches, expectedForumSectionForProposalType, explainGovAction, explainProposalRecord, explorerBase, fetchContinuumDaoMarketplaceActivity, fetchContinuumDaoMarketplaceAuctions, fetchContinuumDaoMarketplaceConfig, fetchContinuumDaoMarketplaceFeePreview, fetchContinuumDaoMarketplaceListings, fetchContinuumDaoMarketplaceOfferings, fetchContinuumDaoMarketplaceToken, floorUnlockTimeSeconds, foldMarketplaceEvents, formatProposalSimulationFailure, foundryPlanHasSequentialExecute, foundryScriptContainsCall, getMarketplaceIndexMemoryCache, governorAddressOnEvmChain, governorWriteAbi, howVoted, isConfiguredAddress, isContinuumDaoCommitteeProposer, isContinuumDaoCtmOnAssetsChain, isContinuumDaoLockChain, isContinuumDaoSupportedChainId, isContinuumDaoVeCtmOnAssetsChain, isCtmTokenSymbol, isForumIdeaSection, isGovNoOpAction, isLegacyContinuumDaoGovernor, isLineaHomeNetwork, isLiveAuctionStatus, isOpenOrder, isRemoteC3Action, isVotingEscrowContinuumName, keyGenOwnsVeCtm, listContinuumDaoDefaultAssets, listingCandidate, loadMarketplacePlanSnapshot, looksLikeProposalCatalogId, looksLikeUnixSeconds, marketplacePublicClient, marketplaceVeCtmReceivedBy, maxLockDurationSeconds, monthsOfFees, normalizeGovConfiguration, normalizeNodeInfo, orderStatusName, pickFeeAlternativeExample, planMarketplaceSteps, preflightAttachVeCtm, preflightCreateLock, preflightDelegate, preflightIncreaseAmount, preflightIncreaseUnlockTime, preflightLiquidate, preflightMerge, preflightRequestDetach, preflightSplit, preflightTransfer, preflightUndelegate, preflightWithdraw, proposalDescriptionHash, publicClient2 as publicClient, quoteContinuumDaoMarketplaceFeeAlternative, rankMarketplaceSearchHits, readCtmBalanceWei, readMarketplaceConfigFromChain, readMarketplaceFeePreviewFromChain, readMinimumLockWei, readVeCtmLockState, requireGovernor, resolveAttachGroupId, resolveGovernorProposalRef, resolveProposalCatalogRange, scanMarketplaceLogs, searchContinuumDaoMarketplace, setMarketplaceIndexMemoryCache, summarizeLiveProposals, summarizeProposalVotes, throwIfProposalSimulationFailed, validateAbiParameter, votingEscrowAddressOnEvmChain, votingEscrowMarketplaceAddressOnEvmChain, votingPowerAboveUntil, votingPowerRefuse, votingPowerWarning };
4766
6957
  //# sourceMappingURL=index.js.map
4767
6958
  //# sourceMappingURL=index.js.map