@continuumdao/ctm-mpc-defi 0.2.50 → 0.2.51

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 +770 -28
  2. package/dist/agent/catalog.cjs.map +1 -1
  3. package/dist/agent/catalog.d.ts +6 -1
  4. package/dist/agent/catalog.js +770 -28
  5. package/dist/agent/catalog.js.map +1 -1
  6. package/dist/agent/skills/continuum-dao/SKILL.md +2 -0
  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 +2274 -59
  20. package/dist/protocols/evm/continuum-dao/index.cjs.map +1 -1
  21. package/dist/protocols/evm/continuum-dao/index.d.ts +690 -2
  22. package/dist/protocols/evm/continuum-dao/index.js +2218 -61
  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
@@ -924,12 +936,12 @@ async function continuumDaoForumSignInEligible(args) {
924
936
  };
925
937
  }
926
938
  async function continuumDaoForumSignInNonce(args) {
927
- const qs = new URLSearchParams({
939
+ const qs2 = new URLSearchParams({
928
940
  address: args.address,
929
941
  nodeKey: args.nodeKey || "",
930
942
  username: args.username || ""
931
943
  });
932
- return forumFetch(`/api/continuum/eip712/nonce?${qs}`, { forumUrl: args.forumUrl });
944
+ return forumFetch(`/api/continuum/eip712/nonce?${qs2}`, { forumUrl: args.forumUrl });
933
945
  }
934
946
  async function buildEvmMultisignBodyContinuumDaoForumSignIn(args) {
935
947
  const owner = getAddress(args.executorAddress);
@@ -2293,9 +2305,9 @@ function parseBackendProposal(raw) {
2293
2305
  committeeProposer: proposer ? isContinuumDaoCommitteeProposer(proposer) : void 0
2294
2306
  };
2295
2307
  }
2296
- function isLegacyContinuumDaoGovernor(addr) {
2297
- if (!addr || !isConfiguredAddress(addr)) return false;
2298
- return getAddress(addr) === CONTINUUM_DAO_LINEA_GOVERNOR_LEGACY_ADDRESS;
2308
+ function isLegacyContinuumDaoGovernor(addr2) {
2309
+ if (!addr2 || !isConfiguredAddress(addr2)) return false;
2310
+ return getAddress(addr2) === CONTINUUM_DAO_LINEA_GOVERNOR_LEGACY_ADDRESS;
2299
2311
  }
2300
2312
  function summarizeLiveProposals(result) {
2301
2313
  if (result.overlay === "backend-only") {
@@ -2472,6 +2484,45 @@ function registerProtocolModule(mod) {
2472
2484
 
2473
2485
  // src/protocols/evm/continuum-dao/index.ts
2474
2486
  init_constants();
2487
+
2488
+ // src/protocols/evm/continuum-dao/marketplaceModule.ts
2489
+ init_constants();
2490
+ var common = ["keyGen", "purposeText", "useCustomGas"];
2491
+ var continuumDaoMarketplaceProtocolModule = {
2492
+ id: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID,
2493
+ chainCategory: "evm",
2494
+ isChainSupported(ctx) {
2495
+ if (ctx.chainCategory !== "evm") return false;
2496
+ const n = typeof ctx.chainId === "number" ? ctx.chainId : Number.parseInt(String(ctx.chainId), 10);
2497
+ return n === CONTINUUM_DAO_LINEA_CHAIN_ID;
2498
+ },
2499
+ isTokenSupported(token) {
2500
+ return token.category === "evm" && (token.kind === "erc20" || token.kind === "erc721");
2501
+ },
2502
+ actions: [
2503
+ { id: "continuum-dao-marketplace.fetch-config", protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID, chainCategory: "evm", description: "Marketplace payment tokens, durations, and fees", commonParams: [], params: {} },
2504
+ { 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: {} },
2505
+ { 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: {} },
2506
+ { 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: {} },
2507
+ { 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: {} },
2508
+ { 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: {} },
2509
+ { 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" } } },
2510
+ { 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" } } },
2511
+ { 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: {} },
2512
+ { 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" } } },
2513
+ { 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" } } },
2514
+ { 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" } } },
2515
+ { 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" } } },
2516
+ { 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" } } },
2517
+ { 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" } } },
2518
+ { 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" } } },
2519
+ { 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" } } },
2520
+ { 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" } } },
2521
+ { 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" } } }
2522
+ ]
2523
+ };
2524
+
2525
+ // src/protocols/evm/continuum-dao/index.ts
2475
2526
  init_constants();
2476
2527
 
2477
2528
  // src/protocols/evm/continuum-dao/escrowRules.ts
@@ -2767,13 +2818,13 @@ async function readVeCtmLockState(args) {
2767
2818
  let attached = false;
2768
2819
  if (isConfiguredAddress(nodeProperties)) {
2769
2820
  try {
2770
- const attachedKey = await client.readContract({
2821
+ const attachedKey2 = await client.readContract({
2771
2822
  address: getAddress(nodeProperties),
2772
2823
  abi: nodePropsAbi,
2773
2824
  functionName: "attachedKeyGen",
2774
2825
  args: [args.tokenId]
2775
2826
  });
2776
- attached = attachedKey !== zeroAddress;
2827
+ attached = attachedKey2 !== zeroAddress;
2777
2828
  } catch {
2778
2829
  attached = false;
2779
2830
  }
@@ -2941,7 +2992,7 @@ async function preflightAttachVeCtm(args) {
2941
2992
  }
2942
2993
  if (isConfiguredAddress(nodeProperties)) {
2943
2994
  const np = getAddress(nodeProperties);
2944
- const [attachedKey, attachedForKey] = await Promise.all([
2995
+ const [attachedKey2, attachedForKey] = await Promise.all([
2945
2996
  client.readContract({
2946
2997
  address: np,
2947
2998
  abi: nodePropsAbi,
@@ -2955,7 +3006,7 @@ async function preflightAttachVeCtm(args) {
2955
3006
  args: [executor]
2956
3007
  })
2957
3008
  ]);
2958
- if (attachedKey !== zeroAddress) {
3009
+ if (attachedKey2 !== zeroAddress) {
2959
3010
  throw new Error(`veCTM #${args.tokenId} is already attached. You cannot replace an attached NFT.`);
2960
3011
  }
2961
3012
  if (attachedForKey !== 0n) {
@@ -2972,7 +3023,7 @@ async function preflightAttachVeCtm(args) {
2972
3023
  }
2973
3024
  async function preflightRequestDetach(args) {
2974
3025
  const client = publicClient(args.rpcUrl, args.chainId);
2975
- const [attachedKey, alreadyRequested] = await Promise.all([
3026
+ const [attachedKey2, alreadyRequested] = await Promise.all([
2976
3027
  client.readContract({
2977
3028
  address: args.nodeProperties,
2978
3029
  abi: nodePropsAbi,
@@ -2986,7 +3037,7 @@ async function preflightRequestDetach(args) {
2986
3037
  args: [args.tokenId]
2987
3038
  })
2988
3039
  ]);
2989
- if (attachedKey === zeroAddress) {
3040
+ if (attachedKey2 === zeroAddress) {
2990
3041
  throw new Error(`veCTM #${args.tokenId} is not attached to a node.`);
2991
3042
  }
2992
3043
  if (alreadyRequested) {
@@ -2994,9 +3045,9 @@ async function preflightRequestDetach(args) {
2994
3045
  `Detach already requested for veCTM #${args.tokenId}. The NFT stays attached until governance executes detach.`
2995
3046
  );
2996
3047
  }
2997
- if (getAddress(attachedKey) !== getAddress(args.owner)) {
3048
+ if (getAddress(attachedKey2) !== getAddress(args.owner)) {
2998
3049
  throw new Error(
2999
- `Request detach from the attached KeyGen (${getAddress(attachedKey)}).`
3050
+ `Request detach from the attached KeyGen (${getAddress(attachedKey2)}).`
3000
3051
  );
3001
3052
  }
3002
3053
  }
@@ -3850,8 +3901,8 @@ function extractAbiFromSourcifyFiles(data) {
3850
3901
  if (!label.includes("metadata.json") && f.name !== "metadata.json") continue;
3851
3902
  if (typeof f.content !== "string") continue;
3852
3903
  try {
3853
- const meta3 = JSON.parse(f.content);
3854
- const abi = extractAbiFromUnknown(meta3);
3904
+ const meta4 = JSON.parse(f.content);
3905
+ const abi = extractAbiFromUnknown(meta4);
3855
3906
  if (abi) return abi;
3856
3907
  } catch {
3857
3908
  continue;
@@ -4711,6 +4762,2112 @@ async function continuumDaoFetchProposalVotes(args, deps) {
4711
4762
 
4712
4763
  // src/protocols/evm/continuum-dao/index.ts
4713
4764
  init_forum();
4765
+
4766
+ // src/protocols/evm/continuum-dao/marketplaceTypes.ts
4767
+ var MARKET_ORDER_STATUS = [
4768
+ "NonExistent",
4769
+ "Open",
4770
+ "Fulfilled",
4771
+ "Expired",
4772
+ "DelistedOrRescinded",
4773
+ "LockAmountDecreased",
4774
+ "LockEndIncreased",
4775
+ "TokenApprovalRequired",
4776
+ "PaymentApprovalRequired",
4777
+ "KeyGenAttached"
4778
+ ];
4779
+ var AUCTION_STATUS = [
4780
+ "NonExistent",
4781
+ "Pending",
4782
+ "Active",
4783
+ "Complete",
4784
+ "Sold",
4785
+ "Canceled",
4786
+ "Expired"
4787
+ ];
4788
+ var FEE_TIER_NAMES = ["Black", "Gold", "Silver", "Bronze", "Blue"];
4789
+ function orderStatusName(code) {
4790
+ return MARKET_ORDER_STATUS[code] ?? "NonExistent";
4791
+ }
4792
+ function auctionStatusName(code) {
4793
+ return AUCTION_STATUS[code] ?? "NonExistent";
4794
+ }
4795
+ function addr(value) {
4796
+ try {
4797
+ return getAddress(value);
4798
+ } catch {
4799
+ return value;
4800
+ }
4801
+ }
4802
+ function same(a, b) {
4803
+ return a.toLowerCase() === b.toLowerCase();
4804
+ }
4805
+ function deadlineAt(unix) {
4806
+ const n = Number(unix);
4807
+ if (!Number.isFinite(n) || n <= 0) return "";
4808
+ return new Date(n * 1e3).toISOString();
4809
+ }
4810
+ function blankOrder(kind, tokenId, creator, index) {
4811
+ return {
4812
+ kind,
4813
+ tokenId,
4814
+ onchainIndex: index,
4815
+ creator: addr(creator),
4816
+ paymentToken: zeroAddress,
4817
+ price: "0",
4818
+ deadlineUnix: "0",
4819
+ deadlineAt: "",
4820
+ snapshotAmount: "0",
4821
+ snapshotEnd: "0",
4822
+ storedStatus: "Open",
4823
+ protocolStatus: "Open"
4824
+ };
4825
+ }
4826
+ function blankAuction(tokenId, seller, index) {
4827
+ return {
4828
+ tokenId,
4829
+ onchainIndex: index,
4830
+ seller: addr(seller),
4831
+ paymentToken: zeroAddress,
4832
+ reservePrice: "0",
4833
+ minimumBidIncrement: "0",
4834
+ highestBid: "0",
4835
+ highestBidder: null,
4836
+ deadlineUnix: "0",
4837
+ deadlineAt: "",
4838
+ storedStatus: "Pending",
4839
+ derivedStatus: "Pending",
4840
+ needsSettle: false,
4841
+ bids: []
4842
+ };
4843
+ }
4844
+ function latestOpenOrder(rows, kind, tokenId, creator) {
4845
+ for (let i = rows.length - 1; i >= 0; i--) {
4846
+ const row = rows[i];
4847
+ if (row.kind === kind && row.tokenId === tokenId && same(row.creator, creator) && row.storedStatus === "Open") {
4848
+ return row;
4849
+ }
4850
+ }
4851
+ return void 0;
4852
+ }
4853
+ function latestAuction(rows, tokenId, seller) {
4854
+ for (let i = rows.length - 1; i >= 0; i--) {
4855
+ const row = rows[i];
4856
+ if (row.tokenId === tokenId && same(row.seller, seller)) return row;
4857
+ }
4858
+ return void 0;
4859
+ }
4860
+ function applyMarketplaceEvent(book, ev) {
4861
+ const listingSeq = book.listings.reduce((max, row) => Math.max(max, Number(row.onchainIndex) || 0), 0);
4862
+ const offeringSeq = book.offerings.reduce((max, row) => Math.max(max, Number(row.onchainIndex) || 0), 0);
4863
+ const auctionSeq = book.auctions.reduce((max, row) => Math.max(max, Number(row.onchainIndex) || 0), 0);
4864
+ const next = (seq) => String(seq + 1);
4865
+ if (ev.name === "ListingCreated" || ev.name === "OfferingCreated") {
4866
+ const kind = ev.name === "ListingCreated" ? "Listing" : "Offering";
4867
+ const rows = kind === "Listing" ? book.listings : book.offerings;
4868
+ const prev = latestOpenOrder(rows, kind, ev.tokenId, ev.actor);
4869
+ if (prev) {
4870
+ prev.storedStatus = "DelistedOrRescinded";
4871
+ prev.protocolStatus = "DelistedOrRescinded";
4872
+ prev.closedTx = ev.tx;
4873
+ prev.closedBlock = ev.block;
4874
+ }
4875
+ const row = blankOrder(kind, ev.tokenId, ev.actor, next(kind === "Listing" ? listingSeq : offeringSeq));
4876
+ row.paymentToken = addr(ev.paymentToken);
4877
+ row.price = ev.amount;
4878
+ row.deadlineUnix = ev.deadline;
4879
+ row.deadlineAt = deadlineAt(ev.deadline);
4880
+ row.createdTx = ev.tx;
4881
+ row.createdBlock = ev.block;
4882
+ if (kind === "Listing") row.seller = addr(ev.actor);
4883
+ else row.buyer = addr(ev.actor);
4884
+ rows.push(row);
4885
+ return;
4886
+ }
4887
+ if (ev.name === "Delisted" || ev.name === "Rescinded") {
4888
+ const kind = ev.name === "Delisted" ? "Listing" : "Offering";
4889
+ const row = latestOpenOrder(kind === "Listing" ? book.listings : book.offerings, kind, ev.tokenId, ev.actor);
4890
+ if (row) {
4891
+ row.storedStatus = "DelistedOrRescinded";
4892
+ row.protocolStatus = "DelistedOrRescinded";
4893
+ row.closedTx = ev.tx;
4894
+ row.closedBlock = ev.block;
4895
+ }
4896
+ return;
4897
+ }
4898
+ if (ev.name === "ListingFulfilled" || ev.name === "OfferingFulfilled") {
4899
+ const kind = ev.name === "ListingFulfilled" ? "Listing" : "Offering";
4900
+ const actor = kind === "Listing" ? ev.seller : ev.buyer;
4901
+ const row = latestOpenOrder(kind === "Listing" ? book.listings : book.offerings, kind, ev.tokenId, actor);
4902
+ if (row) {
4903
+ row.storedStatus = "Fulfilled";
4904
+ row.protocolStatus = "Fulfilled";
4905
+ row.counterparty = addr(kind === "Listing" ? ev.buyer : ev.seller);
4906
+ row.seller = addr(ev.seller);
4907
+ row.buyer = addr(ev.buyer);
4908
+ row.fee = ev.fee;
4909
+ row.net = ev.net;
4910
+ row.closedTx = ev.tx;
4911
+ row.closedBlock = ev.block;
4912
+ }
4913
+ return;
4914
+ }
4915
+ if (ev.name === "AuctionCreated") {
4916
+ const prev = latestAuction(book.auctions, ev.tokenId, ev.actor);
4917
+ if (prev && (prev.storedStatus === "Pending" || prev.storedStatus === "Active")) {
4918
+ prev.storedStatus = "Canceled";
4919
+ prev.derivedStatus = "Canceled";
4920
+ prev.closedTx = ev.tx;
4921
+ prev.closedBlock = ev.block;
4922
+ }
4923
+ const row = blankAuction(ev.tokenId, ev.actor, next(auctionSeq));
4924
+ row.paymentToken = addr(ev.paymentToken);
4925
+ row.reservePrice = ev.amount;
4926
+ row.minimumBidIncrement = ev.minIncrement;
4927
+ row.deadlineUnix = ev.deadline;
4928
+ row.deadlineAt = deadlineAt(ev.deadline);
4929
+ row.createdTx = ev.tx;
4930
+ row.createdBlock = ev.block;
4931
+ book.auctions.push(row);
4932
+ return;
4933
+ }
4934
+ if (ev.name === "AuctionCanceled") {
4935
+ const row = latestAuction(book.auctions, ev.tokenId, ev.actor);
4936
+ if (row && row.storedStatus === "Pending") {
4937
+ row.storedStatus = "Canceled";
4938
+ row.derivedStatus = "Canceled";
4939
+ row.closedTx = ev.tx;
4940
+ row.closedBlock = ev.block;
4941
+ }
4942
+ return;
4943
+ }
4944
+ if (ev.name === "AuctionBid") {
4945
+ const row = latestAuction(book.auctions, ev.tokenId, ev.seller);
4946
+ if (!row || row.storedStatus !== "Pending" && row.storedStatus !== "Active") return;
4947
+ row.bids = [
4948
+ ...row.bids,
4949
+ {
4950
+ bidder: addr(ev.buyer),
4951
+ price: ev.price,
4952
+ tx: ev.tx,
4953
+ timestamp: ev.timestamp ?? "0",
4954
+ logIndex: String(ev.logIndex),
4955
+ block: ev.block
4956
+ }
4957
+ ];
4958
+ row.highestBid = ev.price;
4959
+ row.highestBidder = addr(ev.buyer);
4960
+ row.storedStatus = "Active";
4961
+ row.derivedStatus = "Active";
4962
+ return;
4963
+ }
4964
+ if (ev.name === "AuctionSettled") {
4965
+ const row = latestAuction(book.auctions, ev.tokenId, ev.seller);
4966
+ if (!row) return;
4967
+ const name = auctionStatusName(ev.finalStatus);
4968
+ row.storedStatus = name;
4969
+ row.derivedStatus = name;
4970
+ row.needsSettle = false;
4971
+ row.closedTx = ev.tx;
4972
+ row.closedBlock = ev.block;
4973
+ return;
4974
+ }
4975
+ if (ev.name === "AuctionSuccessful") {
4976
+ const row = latestAuction(book.auctions, ev.tokenId, ev.seller);
4977
+ if (!row) return;
4978
+ row.storedStatus = "Sold";
4979
+ row.derivedStatus = "Sold";
4980
+ row.buyer = addr(ev.buyer);
4981
+ row.highestBidder = addr(ev.buyer);
4982
+ row.highestBid = ev.price;
4983
+ row.fee = ev.fee;
4984
+ row.net = ev.net;
4985
+ row.needsSettle = false;
4986
+ row.closedTx = ev.tx;
4987
+ row.closedBlock = ev.block;
4988
+ }
4989
+ }
4990
+ function foldMarketplaceEvents(events, initial) {
4991
+ const book = {
4992
+ listings: [...initial?.listings ?? []],
4993
+ offerings: [...initial?.offerings ?? []],
4994
+ auctions: (initial?.auctions ?? []).map((row) => ({ ...row, bids: [...row.bids] }))
4995
+ };
4996
+ for (const ev of events) applyMarketplaceEvent(book, ev);
4997
+ return book;
4998
+ }
4999
+ function deriveAuctionStatus(auction, nowUnix) {
5000
+ const deadline = Number(auction.deadlineUnix);
5001
+ if (auction.storedStatus === "Pending" && Number.isFinite(deadline) && nowUnix >= deadline) return "Expired";
5002
+ if (auction.storedStatus === "Active" && Number.isFinite(deadline) && nowUnix >= deadline) return "Complete";
5003
+ return auction.derivedStatus || auction.storedStatus;
5004
+ }
5005
+ function applyDerivedStatuses(book, nowUnix) {
5006
+ return {
5007
+ listings: book.listings.map((row) => {
5008
+ const deadline = Number(row.deadlineUnix);
5009
+ if (row.storedStatus === "Open" && Number.isFinite(deadline) && nowUnix >= deadline) {
5010
+ return { ...row, protocolStatus: "Expired" };
5011
+ }
5012
+ return row;
5013
+ }),
5014
+ offerings: book.offerings.map((row) => {
5015
+ const deadline = Number(row.deadlineUnix);
5016
+ if (row.storedStatus === "Open" && Number.isFinite(deadline) && nowUnix >= deadline) {
5017
+ return { ...row, protocolStatus: "Expired" };
5018
+ }
5019
+ return row;
5020
+ }),
5021
+ auctions: book.auctions.map((row) => {
5022
+ const derived = deriveAuctionStatus(row, nowUnix);
5023
+ const needsSettle = derived === "Complete" || derived === "Expired";
5024
+ return { ...row, derivedStatus: derived, needsSettle };
5025
+ })
5026
+ };
5027
+ }
5028
+ function isLiveAuctionStatus(status) {
5029
+ return status === "Pending" || status === "Active" || status === "Complete";
5030
+ }
5031
+ function isOpenOrder(row) {
5032
+ return row.storedStatus === "Open" && row.protocolStatus === "Open";
5033
+ }
5034
+ var marketplaceAbi = parseAbi([
5035
+ "function weth() view returns (address)",
5036
+ "function ve() view returns (address)",
5037
+ "function np() view returns (address)",
5038
+ "function gov() view returns (address)",
5039
+ "function minimumDuration() view returns (uint256)",
5040
+ "function maximumDuration() view returns (uint256)",
5041
+ "function isValidPaymentToken(address) view returns (bool)",
5042
+ "function feeLimitByTier(uint8) view returns (uint256)",
5043
+ "function feeRateByTier(uint8) view returns (uint256)",
5044
+ "function listingIndexByTokenSeller(uint256,address) view returns (uint256)",
5045
+ "function listingsByToken(uint256,uint256) view returns (uint256 price, uint256 deadline, uint256 snapshotAmount, uint256 snapshotEnd, address creator, address paymentToken, uint8 status, uint8 kind)",
5046
+ "function offeringIndexByTokenBuyer(uint256,address) view returns (uint256)",
5047
+ "function offeringsByToken(uint256,uint256) view returns (uint256 price, uint256 deadline, uint256 snapshotAmount, uint256 snapshotEnd, address creator, address paymentToken, uint8 status, uint8 kind)",
5048
+ "function auctionIndexByTokenSeller(uint256,address) view returns (uint256)",
5049
+ "function auctionsByToken(uint256,uint256) view returns (uint256 reservePrice, uint256 minimumBidIncrement, uint256 deadline, address seller, address paymentToken, address highestBidder, uint256 highestBid, uint8 status)",
5050
+ "function marketOrderStatus((uint256,uint256,uint256,uint256,address,address,uint8,uint8),uint256,uint256,address,uint256) view returns (uint8)",
5051
+ "function auctionStatus((uint256,uint256,uint256,address,address,address,uint256,uint8)) view returns (uint8)",
5052
+ "function createListing(uint256,address,uint256,uint256)",
5053
+ "function delist(uint256)",
5054
+ "function fulfillListing(uint256,address,address,uint256) payable",
5055
+ "function createOffering(uint256,address,uint256,uint256) payable",
5056
+ "function rescind(uint256)",
5057
+ "function fulfillOffering(uint256,address,address,uint256)",
5058
+ "function createAuction(uint256,address,uint256,uint256,uint256)",
5059
+ "function cancelAuction(uint256)",
5060
+ "function auctionBid(uint256,address,uint256) payable",
5061
+ "function settleAuction(uint256,address)",
5062
+ "event ListingCreated(uint256 indexed _tokenId, address indexed _listedBy, address indexed _paymentToken, uint256 _ask, uint256 _deadline)",
5063
+ "event ListingFulfilled(uint256 indexed _tokenId, address indexed _buyer, address indexed _seller, uint256 _ask, uint256 _netPrice, uint256 _fee)",
5064
+ "event Delisted(uint256 indexed _tokenId, address indexed _seller)",
5065
+ "event OfferingCreated(uint256 indexed _tokenId, address indexed _offeredBy, address indexed _paymentToken, uint256 _bid, uint256 _deadline)",
5066
+ "event OfferingFulfilled(uint256 indexed _tokenId, address indexed _buyer, address indexed _seller, uint256 _bid, uint256 _netPrice, uint256 _fee)",
5067
+ "event Rescinded(uint256 indexed _tokenId, address indexed _buyer)",
5068
+ "event AuctionCreated(uint256 indexed _tokenId, address indexed _createdBy, address indexed _paymentToken, uint256 _reservePrice, uint256 _minimumBidIncrement, uint256 _deadline)",
5069
+ "event AuctionCanceled(uint256 indexed _tokenId, address indexed _seller)",
5070
+ "event AuctionBid(uint256 indexed _tokenId, address indexed _seller, address indexed _buyer, uint256 _price)",
5071
+ "event AuctionSettled(uint256 indexed _tokenId, address indexed _seller, uint8 indexed _finalStatus)",
5072
+ "event AuctionSuccessful(uint256 indexed _tokenId, address indexed _seller, address indexed _buyer, uint256 _price, uint256 _fee, uint256 _net)"
5073
+ ]);
5074
+ var marketplaceReadAbi = parseAbi([
5075
+ "function ownerOf(uint256) view returns (address)",
5076
+ "function getApproved(uint256) view returns (address)",
5077
+ "function isApprovedForAll(address,address) view returns (bool)",
5078
+ "function approve(address,uint256)",
5079
+ "function locked(uint256) view returns (int128 amount, uint256 end)",
5080
+ "function allowance(address,address) view returns (uint256)",
5081
+ "function decimals() view returns (uint8)",
5082
+ "function symbol() view returns (string)",
5083
+ "function attachedKeyGen(uint256) view returns (address)"
5084
+ ]);
5085
+
5086
+ // src/protocols/evm/continuum-dao/marketplacePlan.ts
5087
+ var MARKETPLACE_APPROVE_FALLBACK = 80000n;
5088
+ var MARKETPLACE_LISTING_FALLBACK = 280000n;
5089
+ var MARKETPLACE_FULFILL_FALLBACK = 450000n;
5090
+ var MARKETPLACE_OFFERING_FALLBACK = 320000n;
5091
+ var MARKETPLACE_AUCTION_CREATE_FALLBACK = 380000n;
5092
+ var MARKETPLACE_BID_FALLBACK = 280000n;
5093
+ var MARKETPLACE_SETTLE_FALLBACK = 400000n;
5094
+ function same2(a, b) {
5095
+ try {
5096
+ return getAddress(a) === getAddress(b);
5097
+ } catch {
5098
+ return a.toLowerCase() === b.toLowerCase();
5099
+ }
5100
+ }
5101
+ function isWeth(snap, token) {
5102
+ return same2(token, snap.weth);
5103
+ }
5104
+ function keyGenOwnsVeCtm(snap, seller) {
5105
+ if (same2(snap.owner, snap.executor)) return true;
5106
+ if (seller && same2(seller, snap.executor)) return true;
5107
+ if (snap.executorOpenListing && same2(snap.owner, snap.executor)) return true;
5108
+ if (snap.executorLiveAuction) return true;
5109
+ return false;
5110
+ }
5111
+ function assertNotOwn(snap, seller, tokenId) {
5112
+ if (same2(snap.owner, snap.executor) || seller && same2(seller, snap.executor) || snap.executorLiveAuction) {
5113
+ throw new Error(`This KeyGen already owns veCTM #${tokenId.toString()} and cannot buy or bid on it.`);
5114
+ }
5115
+ }
5116
+ function assertDeadline(snap, deadline) {
5117
+ const min = snap.now + snap.minimumDuration;
5118
+ const max = snap.now + snap.maximumDuration;
5119
+ if (deadline < min || deadline > max) {
5120
+ throw new Error(`Deadline must be between ${min.toString()} and ${max.toString()} (unix seconds).`);
5121
+ }
5122
+ }
5123
+ function assertPayment(snap) {
5124
+ if (!snap.paymentTokenValid) throw new Error("This payment token is not accepted by the marketplace.");
5125
+ }
5126
+ function assertNotAttached(snap, tokenId) {
5127
+ if (snap.attachedKeyGen !== zeroAddress) {
5128
+ throw new Error(`veCTM #${tokenId.toString()} has a KeyGen attached.`);
5129
+ }
5130
+ }
5131
+ function nftApproveStep(snap, tokenId) {
5132
+ if (snap.nftApproved) return null;
5133
+ return {
5134
+ to: snap.votingEscrow,
5135
+ data: encodeFunctionData({
5136
+ abi: marketplaceReadAbi,
5137
+ functionName: "approve",
5138
+ args: [snap.marketplace, tokenId]
5139
+ }),
5140
+ value: 0n,
5141
+ fallbackGas: MARKETPLACE_APPROVE_FALLBACK,
5142
+ evmType: "continuum_dao_marketplace_nft_approve",
5143
+ name: "VotingEscrow.approve",
5144
+ extra: { tokenId: tokenId.toString(), operator: snap.marketplace }
5145
+ };
5146
+ }
5147
+ function parseApproveAbi() {
5148
+ return [
5149
+ {
5150
+ type: "function",
5151
+ name: "approve",
5152
+ stateMutability: "nonpayable",
5153
+ inputs: [
5154
+ { name: "spender", type: "address" },
5155
+ { name: "amount", type: "uint256" }
5156
+ ],
5157
+ outputs: [{ name: "", type: "bool" }]
5158
+ }
5159
+ ];
5160
+ }
5161
+ function erc20Approve(snap, token, amount) {
5162
+ if (snap.allowance >= amount) return null;
5163
+ return {
5164
+ to: token,
5165
+ data: encodeFunctionData({
5166
+ abi: parseApproveAbi(),
5167
+ functionName: "approve",
5168
+ args: [snap.marketplace, amount]
5169
+ }),
5170
+ value: 0n,
5171
+ fallbackGas: MARKETPLACE_APPROVE_FALLBACK,
5172
+ evmType: "continuum_dao_marketplace_approve",
5173
+ name: "ERC20.approve",
5174
+ extra: { spender: snap.marketplace, amountWei: amount.toString(), token }
5175
+ };
5176
+ }
5177
+ function withApprovals(steps) {
5178
+ return steps.filter((s) => s != null);
5179
+ }
5180
+ function planMarketplaceSteps(input, snap) {
5181
+ const m = snap.marketplace;
5182
+ switch (input.action) {
5183
+ case "createListing": {
5184
+ assertPayment(snap);
5185
+ assertDeadline(snap, input.deadline);
5186
+ if (!same2(snap.owner, snap.executor)) throw new Error("Only the veCTM owner can create a listing.");
5187
+ return withApprovals([
5188
+ nftApproveStep(snap, input.tokenId),
5189
+ {
5190
+ to: m,
5191
+ data: encodeFunctionData({
5192
+ abi: marketplaceAbi,
5193
+ functionName: "createListing",
5194
+ args: [input.tokenId, input.paymentToken, input.askWei, input.deadline]
5195
+ }),
5196
+ value: 0n,
5197
+ fallbackGas: MARKETPLACE_LISTING_FALLBACK,
5198
+ evmType: "continuum_dao_marketplace_create_listing",
5199
+ name: "VotingEscrowMarketplace.createListing",
5200
+ extra: {
5201
+ tokenId: input.tokenId.toString(),
5202
+ paymentToken: input.paymentToken,
5203
+ askWei: input.askWei.toString(),
5204
+ deadline: input.deadline.toString()
5205
+ }
5206
+ }
5207
+ ]);
5208
+ }
5209
+ case "delist": {
5210
+ if (!snap.listing || snap.listing.status !== 1) throw new Error("No open listing for this KeyGen.");
5211
+ return [
5212
+ {
5213
+ to: m,
5214
+ data: encodeFunctionData({ abi: marketplaceAbi, functionName: "delist", args: [input.tokenId] }),
5215
+ value: 0n,
5216
+ fallbackGas: MARKETPLACE_LISTING_FALLBACK,
5217
+ evmType: "continuum_dao_marketplace_delist",
5218
+ name: "VotingEscrowMarketplace.delist",
5219
+ extra: { tokenId: input.tokenId.toString() }
5220
+ }
5221
+ ];
5222
+ }
5223
+ case "fulfillListing": {
5224
+ assertNotOwn(snap, input.seller, input.tokenId);
5225
+ const listing = snap.listing;
5226
+ if (!listing || !same2(listing.creator, input.seller)) throw new Error("No open listing for this seller.");
5227
+ if (!same2(listing.paymentToken, input.paymentToken) || listing.price !== input.priceWei) {
5228
+ throw new Error("Listing price or payment token changed. Refresh and try again.");
5229
+ }
5230
+ const weth = isWeth(snap, listing.paymentToken);
5231
+ return withApprovals([
5232
+ weth ? null : erc20Approve(snap, listing.paymentToken, listing.price),
5233
+ {
5234
+ to: m,
5235
+ data: encodeFunctionData({
5236
+ abi: marketplaceAbi,
5237
+ functionName: "fulfillListing",
5238
+ args: [input.tokenId, input.seller, listing.paymentToken, listing.price]
5239
+ }),
5240
+ value: weth ? listing.price : 0n,
5241
+ fallbackGas: MARKETPLACE_FULFILL_FALLBACK,
5242
+ evmType: "continuum_dao_marketplace_fulfill_listing",
5243
+ name: "VotingEscrowMarketplace.fulfillListing",
5244
+ extra: {
5245
+ tokenId: input.tokenId.toString(),
5246
+ seller: input.seller,
5247
+ paymentToken: listing.paymentToken,
5248
+ priceWei: listing.price.toString(),
5249
+ recipient: snap.executor
5250
+ }
5251
+ }
5252
+ ]);
5253
+ }
5254
+ case "createOffering": {
5255
+ assertNotOwn(snap, void 0, input.tokenId);
5256
+ assertPayment(snap);
5257
+ assertDeadline(snap, input.deadline);
5258
+ const weth = isWeth(snap, input.paymentToken);
5259
+ return withApprovals([
5260
+ erc20Approve(snap, input.paymentToken, input.bidWei),
5261
+ {
5262
+ to: m,
5263
+ data: encodeFunctionData({
5264
+ abi: marketplaceAbi,
5265
+ functionName: "createOffering",
5266
+ args: [input.tokenId, input.paymentToken, input.bidWei, input.deadline]
5267
+ }),
5268
+ value: weth ? input.bidWei : 0n,
5269
+ fallbackGas: MARKETPLACE_OFFERING_FALLBACK,
5270
+ evmType: "continuum_dao_marketplace_create_offering",
5271
+ name: "VotingEscrowMarketplace.createOffering",
5272
+ extra: {
5273
+ tokenId: input.tokenId.toString(),
5274
+ paymentToken: input.paymentToken,
5275
+ bidWei: input.bidWei.toString(),
5276
+ deadline: input.deadline.toString()
5277
+ }
5278
+ }
5279
+ ]);
5280
+ }
5281
+ case "rescind": {
5282
+ if (!snap.offering || snap.offering.status !== 1) throw new Error("No open offering for this KeyGen.");
5283
+ return [
5284
+ {
5285
+ to: m,
5286
+ data: encodeFunctionData({ abi: marketplaceAbi, functionName: "rescind", args: [input.tokenId] }),
5287
+ value: 0n,
5288
+ fallbackGas: MARKETPLACE_OFFERING_FALLBACK,
5289
+ evmType: "continuum_dao_marketplace_rescind",
5290
+ name: "VotingEscrowMarketplace.rescind",
5291
+ extra: { tokenId: input.tokenId.toString() }
5292
+ }
5293
+ ];
5294
+ }
5295
+ case "fulfillOffering": {
5296
+ assertNotAttached(snap, input.tokenId);
5297
+ if (!same2(snap.owner, snap.executor)) throw new Error("Only the veCTM owner can accept an offering.");
5298
+ const offering = snap.offering;
5299
+ if (!offering || !same2(offering.creator, input.buyer)) throw new Error("No open offering for this buyer.");
5300
+ if (!same2(offering.paymentToken, input.paymentToken) || offering.price !== input.priceWei) {
5301
+ throw new Error("Offering price or payment token changed. Refresh and try again.");
5302
+ }
5303
+ return withApprovals([
5304
+ nftApproveStep(snap, input.tokenId),
5305
+ {
5306
+ to: m,
5307
+ data: encodeFunctionData({
5308
+ abi: marketplaceAbi,
5309
+ functionName: "fulfillOffering",
5310
+ args: [input.tokenId, input.buyer, offering.paymentToken, offering.price]
5311
+ }),
5312
+ value: 0n,
5313
+ fallbackGas: MARKETPLACE_FULFILL_FALLBACK,
5314
+ evmType: "continuum_dao_marketplace_fulfill_offering",
5315
+ name: "VotingEscrowMarketplace.fulfillOffering",
5316
+ extra: {
5317
+ tokenId: input.tokenId.toString(),
5318
+ buyer: input.buyer,
5319
+ paymentToken: offering.paymentToken,
5320
+ priceWei: offering.price.toString()
5321
+ }
5322
+ }
5323
+ ]);
5324
+ }
5325
+ case "createAuction": {
5326
+ assertNotAttached(snap, input.tokenId);
5327
+ assertPayment(snap);
5328
+ assertDeadline(snap, input.deadline);
5329
+ if (input.reserveWei <= 0n) throw new Error("Reserve price must be greater than zero.");
5330
+ if (!same2(snap.owner, snap.executor)) throw new Error("Only the veCTM owner can start an auction.");
5331
+ if (snap.executorLiveAuction) throw new Error("A live auction already exists for this token.");
5332
+ return withApprovals([
5333
+ nftApproveStep(snap, input.tokenId),
5334
+ {
5335
+ to: m,
5336
+ data: encodeFunctionData({
5337
+ abi: marketplaceAbi,
5338
+ functionName: "createAuction",
5339
+ args: [input.tokenId, input.paymentToken, input.deadline, input.reserveWei, input.minIncrementWei]
5340
+ }),
5341
+ value: 0n,
5342
+ fallbackGas: MARKETPLACE_AUCTION_CREATE_FALLBACK,
5343
+ evmType: "continuum_dao_marketplace_create_auction",
5344
+ name: "VotingEscrowMarketplace.createAuction",
5345
+ extra: {
5346
+ tokenId: input.tokenId.toString(),
5347
+ paymentToken: input.paymentToken,
5348
+ reserveWei: input.reserveWei.toString(),
5349
+ minIncrementWei: input.minIncrementWei.toString(),
5350
+ deadline: input.deadline.toString()
5351
+ }
5352
+ }
5353
+ ]);
5354
+ }
5355
+ case "cancelAuction": {
5356
+ const auction = snap.auction;
5357
+ if (!auction || !same2(auction.seller, snap.executor)) throw new Error("No auction for this KeyGen.");
5358
+ if (auction.status !== 1) throw new Error("Only a pending auction with no bids can be canceled.");
5359
+ return [
5360
+ {
5361
+ to: m,
5362
+ data: encodeFunctionData({ abi: marketplaceAbi, functionName: "cancelAuction", args: [input.tokenId] }),
5363
+ value: 0n,
5364
+ fallbackGas: MARKETPLACE_AUCTION_CREATE_FALLBACK,
5365
+ evmType: "continuum_dao_marketplace_cancel_auction",
5366
+ name: "VotingEscrowMarketplace.cancelAuction",
5367
+ extra: { tokenId: input.tokenId.toString(), recipient: snap.executor }
5368
+ }
5369
+ ];
5370
+ }
5371
+ case "auctionBid": {
5372
+ assertNotOwn(snap, input.seller, input.tokenId);
5373
+ const auction = snap.auction;
5374
+ if (!auction || !same2(auction.seller, input.seller)) throw new Error("No live auction for this seller.");
5375
+ if (auction.status !== 1 && auction.status !== 2) throw new Error("This auction is not accepting bids.");
5376
+ if (input.priceWei < auction.reservePrice) throw new Error("Bid is below the reserve price.");
5377
+ if (auction.highestBidder !== zeroAddress && input.priceWei < auction.highestBid + auction.minimumBidIncrement) {
5378
+ throw new Error("Bid is below the highest bid plus the minimum increment.");
5379
+ }
5380
+ const weth = isWeth(snap, auction.paymentToken);
5381
+ return withApprovals([
5382
+ weth ? null : erc20Approve(snap, auction.paymentToken, input.priceWei),
5383
+ {
5384
+ to: m,
5385
+ data: encodeFunctionData({
5386
+ abi: marketplaceAbi,
5387
+ functionName: "auctionBid",
5388
+ args: [input.tokenId, input.seller, input.priceWei]
5389
+ }),
5390
+ value: weth ? input.priceWei : 0n,
5391
+ fallbackGas: MARKETPLACE_BID_FALLBACK,
5392
+ evmType: "continuum_dao_marketplace_auction_bid",
5393
+ name: "VotingEscrowMarketplace.auctionBid",
5394
+ extra: {
5395
+ tokenId: input.tokenId.toString(),
5396
+ seller: input.seller,
5397
+ priceWei: input.priceWei.toString(),
5398
+ paymentToken: auction.paymentToken
5399
+ }
5400
+ }
5401
+ ]);
5402
+ }
5403
+ case "settleAuction": {
5404
+ const auction = snap.auction;
5405
+ if (!auction || !same2(auction.seller, input.seller)) throw new Error("Auction not found.");
5406
+ const derived = auction.status === 2 && snap.now >= auction.deadline ? 3 : auction.status === 1 && snap.now >= auction.deadline ? 6 : auction.status;
5407
+ if (derived !== 3 && derived !== 6) throw new Error("This auction is not ready to settle.");
5408
+ const winner = auction.highestBidder;
5409
+ return [
5410
+ {
5411
+ to: m,
5412
+ data: encodeFunctionData({
5413
+ abi: marketplaceAbi,
5414
+ functionName: "settleAuction",
5415
+ args: [input.tokenId, input.seller]
5416
+ }),
5417
+ value: 0n,
5418
+ fallbackGas: MARKETPLACE_SETTLE_FALLBACK,
5419
+ evmType: "continuum_dao_marketplace_settle_auction",
5420
+ name: "VotingEscrowMarketplace.settleAuction",
5421
+ extra: {
5422
+ tokenId: input.tokenId.toString(),
5423
+ seller: input.seller,
5424
+ highestBidder: winner,
5425
+ recipient: derived === 3 ? winner : input.seller
5426
+ }
5427
+ }
5428
+ ];
5429
+ }
5430
+ default:
5431
+ throw new Error("Unknown marketplace action.");
5432
+ }
5433
+ }
5434
+
5435
+ // src/protocols/evm/continuum-dao/marketplaceChain.ts
5436
+ init_defiEvmClient();
5437
+ init_constants();
5438
+ function marketplacePublicClient(chainId, rpcUrl) {
5439
+ const ch = defineChain({
5440
+ id: chainId,
5441
+ name: "Linea",
5442
+ nativeCurrency: { decimals: 18, name: "Ether", symbol: "ETH" },
5443
+ rpcUrls: { default: { http: [rpcUrl] } }
5444
+ });
5445
+ return createPublicClient({ chain: ch, transport: defiEvmTransport(rpcUrl) });
5446
+ }
5447
+ var KNOWN_PAYMENT_TOKENS = [
5448
+ { address: getAddress(CTM_TOKEN_ADDRESS), symbol: "CTM", decimals: 18 },
5449
+ { address: MARKETPLACE_WETH_LINEA_ADDRESS, symbol: "WETH", decimals: 18 },
5450
+ { address: MARKETPLACE_USDC_LINEA_ADDRESS, symbol: "USDC", decimals: 6 }
5451
+ ];
5452
+ function calculateMarketplaceFee(price, lockedAmount, limits, rates) {
5453
+ for (let i = 0; i < 5; i++) {
5454
+ const limit = limits[i] ?? 0n;
5455
+ if (lockedAmount >= limit) {
5456
+ const rateBps = rates[i] ?? 0n;
5457
+ const fee = price * rateBps / 10000n;
5458
+ return {
5459
+ tier: FEE_TIER_NAMES[i] ?? "Blue",
5460
+ tierIndex: i,
5461
+ limit,
5462
+ rateBps,
5463
+ fee,
5464
+ net: price - fee
5465
+ };
5466
+ }
5467
+ }
5468
+ return null;
5469
+ }
5470
+ async function readMarketplaceConfigFromChain(args) {
5471
+ const marketplace = args.marketplace ?? VOTING_ESCROW_MARKETPLACE_LINEA_ADDRESS;
5472
+ const client = marketplacePublicClient(args.chainId, args.rpcUrl);
5473
+ const [weth, ve, gov, np, minimumDuration, maximumDuration] = await Promise.all([
5474
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "weth" }),
5475
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "ve" }),
5476
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "gov" }),
5477
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "np" }),
5478
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "minimumDuration" }),
5479
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "maximumDuration" })
5480
+ ]);
5481
+ const feeLimits = [];
5482
+ const feeRates = [];
5483
+ for (let i = 0; i < 5; i++) {
5484
+ const [limit, rate] = await Promise.all([
5485
+ client.readContract({
5486
+ address: marketplace,
5487
+ abi: marketplaceAbi,
5488
+ functionName: "feeLimitByTier",
5489
+ args: [i]
5490
+ }),
5491
+ client.readContract({
5492
+ address: marketplace,
5493
+ abi: marketplaceAbi,
5494
+ functionName: "feeRateByTier",
5495
+ args: [i]
5496
+ })
5497
+ ]);
5498
+ feeLimits.push(limit);
5499
+ feeRates.push(rate);
5500
+ }
5501
+ const paymentTokens = [];
5502
+ for (const token of KNOWN_PAYMENT_TOKENS) {
5503
+ let isValid = false;
5504
+ try {
5505
+ isValid = await client.readContract({
5506
+ address: marketplace,
5507
+ abi: marketplaceAbi,
5508
+ functionName: "isValidPaymentToken",
5509
+ args: [token.address]
5510
+ });
5511
+ } catch {
5512
+ isValid = false;
5513
+ }
5514
+ if (isValid) paymentTokens.push({ ...token, address: token.address, isValid: true });
5515
+ }
5516
+ return {
5517
+ chainId: args.chainId,
5518
+ marketplace,
5519
+ ve,
5520
+ gov,
5521
+ np,
5522
+ weth,
5523
+ minimumDuration: minimumDuration.toString(),
5524
+ maximumDuration: maximumDuration.toString(),
5525
+ feeLimits: feeLimits.map((n) => n.toString()),
5526
+ feeRates: feeRates.map((n) => n.toString()),
5527
+ feeTiers: FEE_TIER_NAMES.map((name, index) => ({
5528
+ name,
5529
+ index,
5530
+ limit: feeLimits[index].toString(),
5531
+ rateBps: feeRates[index].toString()
5532
+ })),
5533
+ paymentTokens,
5534
+ source: "logs"
5535
+ };
5536
+ }
5537
+ async function readMarketplaceFeePreviewFromChain(args) {
5538
+ const marketplace = args.marketplace ?? VOTING_ESCROW_MARKETPLACE_LINEA_ADDRESS;
5539
+ const ve = args.votingEscrow ?? VOTING_ESCROW_LINEA_ADDRESS;
5540
+ const client = marketplacePublicClient(args.chainId, args.rpcUrl);
5541
+ const locked = await client.readContract({
5542
+ address: ve,
5543
+ abi: marketplaceReadAbi,
5544
+ functionName: "locked",
5545
+ args: [args.tokenId]
5546
+ });
5547
+ const lockedAmount = BigInt(locked[0]);
5548
+ const limits = [];
5549
+ const rates = [];
5550
+ for (let i = 0; i < 5; i++) {
5551
+ limits.push(
5552
+ await client.readContract({
5553
+ address: marketplace,
5554
+ abi: marketplaceAbi,
5555
+ functionName: "feeLimitByTier",
5556
+ args: [i]
5557
+ })
5558
+ );
5559
+ rates.push(
5560
+ await client.readContract({
5561
+ address: marketplace,
5562
+ abi: marketplaceAbi,
5563
+ functionName: "feeRateByTier",
5564
+ args: [i]
5565
+ })
5566
+ );
5567
+ }
5568
+ const fee = calculateMarketplaceFee(args.price, lockedAmount < 0n ? 0n : lockedAmount, limits, rates);
5569
+ if (!fee) throw new Error("Locked CTM is below the minimum fee tier.");
5570
+ return {
5571
+ tokenId: args.tokenId.toString(),
5572
+ lockedAmount: (lockedAmount < 0n ? 0n : lockedAmount).toString(),
5573
+ tier: fee.tier,
5574
+ tierIndex: fee.tierIndex,
5575
+ limit: fee.limit.toString(),
5576
+ rateBps: fee.rateBps.toString(),
5577
+ price: args.price.toString(),
5578
+ fee: fee.fee.toString(),
5579
+ net: fee.net.toString(),
5580
+ source: "logs"
5581
+ };
5582
+ }
5583
+ async function readOrder(client, marketplace, tokenId, index, kind) {
5584
+ if (index === 0n) return null;
5585
+ const row = kind === "listing" ? await client.readContract({
5586
+ address: marketplace,
5587
+ abi: marketplaceAbi,
5588
+ functionName: "listingsByToken",
5589
+ args: [tokenId, index]
5590
+ }) : await client.readContract({
5591
+ address: marketplace,
5592
+ abi: marketplaceAbi,
5593
+ functionName: "offeringsByToken",
5594
+ args: [tokenId, index]
5595
+ });
5596
+ return {
5597
+ price: row[0],
5598
+ deadline: row[1],
5599
+ snapshotAmount: row[2],
5600
+ snapshotEnd: row[3],
5601
+ creator: row[4],
5602
+ paymentToken: row[5],
5603
+ status: Number(row[6])
5604
+ };
5605
+ }
5606
+ async function readAuction(client, marketplace, tokenId, index) {
5607
+ if (index === 0n) return null;
5608
+ const row = await client.readContract({
5609
+ address: marketplace,
5610
+ abi: marketplaceAbi,
5611
+ functionName: "auctionsByToken",
5612
+ args: [tokenId, index]
5613
+ });
5614
+ return {
5615
+ reservePrice: row[0],
5616
+ minimumBidIncrement: row[1],
5617
+ deadline: row[2],
5618
+ seller: row[3],
5619
+ paymentToken: row[4],
5620
+ highestBidder: row[5],
5621
+ highestBid: row[6],
5622
+ status: Number(row[7])
5623
+ };
5624
+ }
5625
+ async function loadMarketplacePlanSnapshot(args) {
5626
+ const marketplace = VOTING_ESCROW_MARKETPLACE_LINEA_ADDRESS;
5627
+ const client = marketplacePublicClient(args.chainId, args.rpcUrl);
5628
+ const [weth, ve, np, minimumDuration, maximumDuration, block] = await Promise.all([
5629
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "weth" }),
5630
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "ve" }),
5631
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "np" }),
5632
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "minimumDuration" }),
5633
+ client.readContract({ address: marketplace, abi: marketplaceAbi, functionName: "maximumDuration" }),
5634
+ client.getBlock({ blockTag: "latest" })
5635
+ ]);
5636
+ let owner = zeroAddress;
5637
+ try {
5638
+ owner = await client.readContract({
5639
+ address: ve,
5640
+ abi: marketplaceReadAbi,
5641
+ functionName: "ownerOf",
5642
+ args: [args.tokenId]
5643
+ });
5644
+ } catch {
5645
+ owner = zeroAddress;
5646
+ }
5647
+ const [approved, approvedForAll, attachedKeyGen, listingIndex, offeringIndex, auctionIndex] = await Promise.all([
5648
+ client.readContract({ address: ve, abi: marketplaceReadAbi, functionName: "getApproved", args: [args.tokenId] }).catch(() => zeroAddress),
5649
+ owner === zeroAddress ? Promise.resolve(false) : client.readContract({
5650
+ address: ve,
5651
+ abi: marketplaceReadAbi,
5652
+ functionName: "isApprovedForAll",
5653
+ args: [owner, marketplace]
5654
+ }).catch(() => false),
5655
+ client.readContract({ address: np, abi: marketplaceReadAbi, functionName: "attachedKeyGen", args: [args.tokenId] }).catch(() => zeroAddress),
5656
+ client.readContract({
5657
+ address: marketplace,
5658
+ abi: marketplaceAbi,
5659
+ functionName: "listingIndexByTokenSeller",
5660
+ args: [args.tokenId, args.seller ?? args.executor]
5661
+ }),
5662
+ client.readContract({
5663
+ address: marketplace,
5664
+ abi: marketplaceAbi,
5665
+ functionName: "offeringIndexByTokenBuyer",
5666
+ args: [args.tokenId, args.buyer ?? args.executor]
5667
+ }),
5668
+ client.readContract({
5669
+ address: marketplace,
5670
+ abi: marketplaceAbi,
5671
+ functionName: "auctionIndexByTokenSeller",
5672
+ args: [args.tokenId, args.seller ?? args.executor]
5673
+ })
5674
+ ]);
5675
+ const [listing, offering, auction, executorListingIndex, executorAuctionIndex] = await Promise.all([
5676
+ readOrder(client, marketplace, args.tokenId, listingIndex, "listing"),
5677
+ readOrder(client, marketplace, args.tokenId, offeringIndex, "offering"),
5678
+ readAuction(client, marketplace, args.tokenId, auctionIndex),
5679
+ args.seller && args.seller !== args.executor ? client.readContract({
5680
+ address: marketplace,
5681
+ abi: marketplaceAbi,
5682
+ functionName: "listingIndexByTokenSeller",
5683
+ args: [args.tokenId, args.executor]
5684
+ }) : Promise.resolve(0n),
5685
+ args.seller && args.seller !== args.executor ? client.readContract({
5686
+ address: marketplace,
5687
+ abi: marketplaceAbi,
5688
+ functionName: "auctionIndexByTokenSeller",
5689
+ args: [args.tokenId, args.executor]
5690
+ }) : Promise.resolve(auctionIndex)
5691
+ ]);
5692
+ const executorAuction = executorAuctionIndex === auctionIndex ? auction : await readAuction(client, marketplace, args.tokenId, executorAuctionIndex);
5693
+ const liveAuction = executorAuction != null && (executorAuction.status === 1 || executorAuction.status === 2 || executorAuction.status === 3) && executorAuction.seller.toLowerCase() === args.executor.toLowerCase();
5694
+ let executorOpenListing = false;
5695
+ if (executorListingIndex > 0n) {
5696
+ const row = await readOrder(client, marketplace, args.tokenId, executorListingIndex, "listing");
5697
+ executorOpenListing = row?.status === 1;
5698
+ } else if (!args.seller || args.seller === args.executor) {
5699
+ executorOpenListing = listing?.status === 1 && listing.creator.toLowerCase() === args.executor.toLowerCase();
5700
+ }
5701
+ const paymentToken = args.paymentToken ?? listing?.paymentToken ?? offering?.paymentToken ?? auction?.paymentToken;
5702
+ let paymentTokenValid = true;
5703
+ if (paymentToken) {
5704
+ paymentTokenValid = await client.readContract({
5705
+ address: marketplace,
5706
+ abi: marketplaceAbi,
5707
+ functionName: "isValidPaymentToken",
5708
+ args: [paymentToken]
5709
+ });
5710
+ }
5711
+ const spendToken = paymentToken ?? zeroAddress;
5712
+ const spendFrom = args.buyer && args.buyer !== args.executor ? args.buyer : args.executor;
5713
+ let allowance = 0n;
5714
+ if (spendToken !== zeroAddress && spendToken.toLowerCase() !== weth.toLowerCase()) {
5715
+ allowance = await client.readContract({
5716
+ address: spendToken,
5717
+ abi: marketplaceReadAbi,
5718
+ functionName: "allowance",
5719
+ args: [spendFrom, marketplace]
5720
+ }).catch(() => 0n);
5721
+ } else if (spendToken.toLowerCase() === weth.toLowerCase()) {
5722
+ allowance = await client.readContract({
5723
+ address: spendToken,
5724
+ abi: marketplaceReadAbi,
5725
+ functionName: "allowance",
5726
+ args: [args.executor, marketplace]
5727
+ }).catch(() => 0n);
5728
+ }
5729
+ return {
5730
+ marketplace,
5731
+ votingEscrow: ve,
5732
+ weth,
5733
+ now: block.timestamp,
5734
+ minimumDuration,
5735
+ maximumDuration,
5736
+ executor: args.executor,
5737
+ owner,
5738
+ nftApproved: approvedForAll || approved !== zeroAddress && approved.toLowerCase() === marketplace.toLowerCase(),
5739
+ allowance,
5740
+ attachedKeyGen,
5741
+ paymentTokenValid,
5742
+ executorOpenListing,
5743
+ executorLiveAuction: liveAuction,
5744
+ listing: listing && listing.status === 1 ? listing : listing,
5745
+ offering: offering && offering.status === 1 ? offering : offering,
5746
+ auction
5747
+ };
5748
+ }
5749
+ init_constants();
5750
+ var memoryCache = /* @__PURE__ */ new Map();
5751
+ function emptyMarketplaceIndexCache() {
5752
+ return { lastScannedBlock: "0", listings: [], offerings: [], auctions: [] };
5753
+ }
5754
+ function getMarketplaceIndexMemoryCache(chainId) {
5755
+ return memoryCache.get(chainId) ?? null;
5756
+ }
5757
+ function setMarketplaceIndexMemoryCache(chainId, cache) {
5758
+ memoryCache.set(chainId, cache);
5759
+ }
5760
+ function arg(args, key, index) {
5761
+ const value = args[key] ?? args[index];
5762
+ if (typeof value === "bigint") return value.toString();
5763
+ return String(value ?? "");
5764
+ }
5765
+ function toFoldEvent(log, timestamp) {
5766
+ try {
5767
+ const decoded = decodeEventLog({
5768
+ abi: marketplaceAbi,
5769
+ data: log.data,
5770
+ topics: log.topics
5771
+ });
5772
+ const args = decoded.args;
5773
+ const ref = {
5774
+ tx: log.transactionHash ?? "",
5775
+ block: log.blockNumber != null ? log.blockNumber.toString() : "0",
5776
+ logIndex: log.logIndex ?? 0,
5777
+ timestamp
5778
+ };
5779
+ switch (decoded.eventName) {
5780
+ case "ListingCreated":
5781
+ return {
5782
+ name: "ListingCreated",
5783
+ tokenId: arg(args, "_tokenId", 0),
5784
+ actor: arg(args, "_listedBy", 1),
5785
+ paymentToken: arg(args, "_paymentToken", 2),
5786
+ amount: arg(args, "_ask", 3),
5787
+ deadline: arg(args, "_deadline", 4),
5788
+ ...ref
5789
+ };
5790
+ case "OfferingCreated":
5791
+ return {
5792
+ name: "OfferingCreated",
5793
+ tokenId: arg(args, "_tokenId", 0),
5794
+ actor: arg(args, "_offeredBy", 1),
5795
+ paymentToken: arg(args, "_paymentToken", 2),
5796
+ amount: arg(args, "_bid", 3),
5797
+ deadline: arg(args, "_deadline", 4),
5798
+ ...ref
5799
+ };
5800
+ case "ListingFulfilled":
5801
+ return {
5802
+ name: "ListingFulfilled",
5803
+ tokenId: arg(args, "_tokenId", 0),
5804
+ buyer: arg(args, "_buyer", 1),
5805
+ seller: arg(args, "_seller", 2),
5806
+ price: arg(args, "_ask", 3),
5807
+ net: arg(args, "_netPrice", 4),
5808
+ fee: arg(args, "_fee", 5),
5809
+ ...ref
5810
+ };
5811
+ case "OfferingFulfilled":
5812
+ return {
5813
+ name: "OfferingFulfilled",
5814
+ tokenId: arg(args, "_tokenId", 0),
5815
+ buyer: arg(args, "_buyer", 1),
5816
+ seller: arg(args, "_seller", 2),
5817
+ price: arg(args, "_bid", 3),
5818
+ net: arg(args, "_netPrice", 4),
5819
+ fee: arg(args, "_fee", 5),
5820
+ ...ref
5821
+ };
5822
+ case "Delisted":
5823
+ return { name: "Delisted", tokenId: arg(args, "_tokenId", 0), actor: arg(args, "_seller", 1), ...ref };
5824
+ case "Rescinded":
5825
+ return { name: "Rescinded", tokenId: arg(args, "_tokenId", 0), actor: arg(args, "_buyer", 1), ...ref };
5826
+ case "AuctionCreated":
5827
+ return {
5828
+ name: "AuctionCreated",
5829
+ tokenId: arg(args, "_tokenId", 0),
5830
+ actor: arg(args, "_createdBy", 1),
5831
+ paymentToken: arg(args, "_paymentToken", 2),
5832
+ amount: arg(args, "_reservePrice", 3),
5833
+ minIncrement: arg(args, "_minimumBidIncrement", 4),
5834
+ deadline: arg(args, "_deadline", 5),
5835
+ ...ref
5836
+ };
5837
+ case "AuctionCanceled":
5838
+ return { name: "AuctionCanceled", tokenId: arg(args, "_tokenId", 0), actor: arg(args, "_seller", 1), ...ref };
5839
+ case "AuctionBid":
5840
+ return {
5841
+ name: "AuctionBid",
5842
+ tokenId: arg(args, "_tokenId", 0),
5843
+ seller: arg(args, "_seller", 1),
5844
+ buyer: arg(args, "_buyer", 2),
5845
+ price: arg(args, "_price", 3),
5846
+ ...ref
5847
+ };
5848
+ case "AuctionSettled":
5849
+ return {
5850
+ name: "AuctionSettled",
5851
+ tokenId: arg(args, "_tokenId", 0),
5852
+ seller: arg(args, "_seller", 1),
5853
+ finalStatus: Number(args._finalStatus ?? args[2] ?? 0),
5854
+ ...ref
5855
+ };
5856
+ case "AuctionSuccessful":
5857
+ return {
5858
+ name: "AuctionSuccessful",
5859
+ tokenId: arg(args, "_tokenId", 0),
5860
+ seller: arg(args, "_seller", 1),
5861
+ buyer: arg(args, "_buyer", 2),
5862
+ price: arg(args, "_price", 3),
5863
+ fee: arg(args, "_fee", 4),
5864
+ net: arg(args, "_net", 5),
5865
+ ...ref
5866
+ };
5867
+ default:
5868
+ return null;
5869
+ }
5870
+ } catch {
5871
+ return null;
5872
+ }
5873
+ }
5874
+ async function getLogsChunked(args) {
5875
+ const logs = [];
5876
+ let chunk = 5000n;
5877
+ let start = args.fromBlock;
5878
+ while (start <= args.toBlock) {
5879
+ const end = start + chunk - 1n > args.toBlock ? args.toBlock : start + chunk - 1n;
5880
+ try {
5881
+ const part = await args.client.getLogs({
5882
+ address: args.address,
5883
+ fromBlock: start,
5884
+ toBlock: end
5885
+ });
5886
+ logs.push(...part);
5887
+ args.onProgress?.(end, args.toBlock);
5888
+ start = end + 1n;
5889
+ } catch (err) {
5890
+ if (chunk <= 200n) throw err;
5891
+ chunk = chunk / 2n < 200n ? 200n : chunk / 2n;
5892
+ }
5893
+ }
5894
+ return logs;
5895
+ }
5896
+ async function scanMarketplaceLogs(args) {
5897
+ const client = marketplacePublicClient(args.chainId, args.rpcUrl);
5898
+ const head = await client.getBlockNumber();
5899
+ const prior = args.cache ?? getMarketplaceIndexMemoryCache(args.chainId) ?? emptyMarketplaceIndexCache();
5900
+ const scanned = BigInt(prior.lastScannedBlock || "0");
5901
+ const fromBlock = scanned > 0n ? scanned + 1n : VOTING_ESCROW_MARKETPLACE_START_BLOCK;
5902
+ if (fromBlock > head) {
5903
+ const now2 = Number((await client.getBlock({ blockTag: "latest" })).timestamp);
5904
+ const derived2 = applyDerivedStatuses(
5905
+ { listings: prior.listings, offerings: prior.offerings, auctions: prior.auctions },
5906
+ now2
5907
+ );
5908
+ const cache2 = { lastScannedBlock: head.toString(), ...derived2 };
5909
+ setMarketplaceIndexMemoryCache(args.chainId, cache2);
5910
+ return cache2;
5911
+ }
5912
+ const logs = await getLogsChunked({
5913
+ client,
5914
+ address: VOTING_ESCROW_MARKETPLACE_LINEA_ADDRESS,
5915
+ fromBlock,
5916
+ toBlock: head,
5917
+ onProgress: args.onProgress
5918
+ });
5919
+ const events = logs.map((log) => toFoldEvent(log)).filter((ev) => ev != null);
5920
+ const folded = foldMarketplaceEvents(events, {
5921
+ listings: prior.listings,
5922
+ offerings: prior.offerings,
5923
+ auctions: prior.auctions
5924
+ });
5925
+ const now = Number((await client.getBlock({ blockTag: "latest" })).timestamp);
5926
+ const derived = applyDerivedStatuses(folded, now);
5927
+ const cache = { lastScannedBlock: head.toString(), ...derived };
5928
+ setMarketplaceIndexMemoryCache(args.chainId, cache);
5929
+ return cache;
5930
+ }
5931
+
5932
+ // src/protocols/evm/continuum-dao/marketplaceCatalog.ts
5933
+ init_constants();
5934
+ function apiBase(args) {
5935
+ return (args.apiBase ?? CONTINUUM_DAO_MARKETPLACE_API).replace(/\/$/, "");
5936
+ }
5937
+ function isOffline(status) {
5938
+ if (status == null || status === 0 || status >= 500) return true;
5939
+ return false;
5940
+ }
5941
+ async function getJson(url) {
5942
+ try {
5943
+ const res = await fetch(url);
5944
+ if (!res.ok) {
5945
+ const text = await res.text().catch(() => "");
5946
+ return { ok: false, status: res.status, error: new Error(`${url}: ${res.status} ${text}`.trim()) };
5947
+ }
5948
+ return { ok: true, body: await res.json() };
5949
+ } catch (err) {
5950
+ return { ok: false, status: 0, error: err instanceof Error ? err : new Error(String(err)) };
5951
+ }
5952
+ }
5953
+ function qs(params) {
5954
+ const search = new URLSearchParams();
5955
+ for (const [key, value] of Object.entries(params)) {
5956
+ if (value === void 0 || value === "") continue;
5957
+ search.set(key, String(value));
5958
+ }
5959
+ const encoded = search.toString();
5960
+ return encoded ? `?${encoded}` : "";
5961
+ }
5962
+ async function logsBook(args) {
5963
+ if (!args.rpcUrl?.trim()) throw new Error("Linea RPC is required to index the marketplace while the API is offline.");
5964
+ return scanMarketplaceLogs({
5965
+ chainId: args.chainId ?? CONTINUUM_DAO_LINEA_CHAIN_ID,
5966
+ rpcUrl: args.rpcUrl.trim(),
5967
+ cache: args.cache,
5968
+ onProgress: args.onProgress
5969
+ });
5970
+ }
5971
+ function matchOrder(row, args, includeInactive) {
5972
+ if (!includeInactive && !isOpenOrder(row)) return false;
5973
+ if (args.tokenId && row.tokenId !== args.tokenId) return false;
5974
+ if (args.paymentToken && row.paymentToken.toLowerCase() !== args.paymentToken.toLowerCase()) return false;
5975
+ if (args.creator && row.creator.toLowerCase() !== args.creator.toLowerCase()) return false;
5976
+ if (args.seller && (row.seller ?? row.creator).toLowerCase() !== args.seller.toLowerCase()) return false;
5977
+ return true;
5978
+ }
5979
+ function matchAuction(row, args, includeInactive) {
5980
+ if (!includeInactive && !isLiveAuctionStatus(row.derivedStatus)) return false;
5981
+ if (args.tokenId && row.tokenId !== args.tokenId) return false;
5982
+ if (args.paymentToken && row.paymentToken.toLowerCase() !== args.paymentToken.toLowerCase()) return false;
5983
+ if (args.seller && row.seller.toLowerCase() !== args.seller.toLowerCase()) return false;
5984
+ return true;
5985
+ }
5986
+ function listFrom(items, source) {
5987
+ return { items, nextCursor: null, source };
5988
+ }
5989
+ async function fetchContinuumDaoMarketplaceConfig(args = {}) {
5990
+ const url = `${apiBase(args)}/marketplace/config`;
5991
+ const res = await getJson(url);
5992
+ if (res.ok && res.body && typeof res.body === "object") {
5993
+ return { ...res.body, source: "api" };
5994
+ }
5995
+ if (!res.ok && !isOffline(res.status)) throw res.error;
5996
+ return readMarketplaceConfigFromChain({
5997
+ chainId: args.chainId ?? CONTINUUM_DAO_LINEA_CHAIN_ID,
5998
+ rpcUrl: args.rpcUrl ?? ""
5999
+ });
6000
+ }
6001
+ async function fetchContinuumDaoMarketplaceListings(args = {}) {
6002
+ const includeInactive = Boolean(args.includeInactive);
6003
+ const url = `${apiBase(args)}/marketplace/listings${qs({
6004
+ includeInactive,
6005
+ paymentToken: args.paymentToken,
6006
+ tokenId: args.tokenId,
6007
+ creator: args.creator,
6008
+ limit: args.limit ?? 100,
6009
+ cursor: args.cursor,
6010
+ viewer: args.viewer
6011
+ })}`;
6012
+ const res = await getJson(url);
6013
+ if (res.ok) {
6014
+ const body = res.body;
6015
+ return { items: body.items ?? [], nextCursor: body.nextCursor ?? null, source: "api" };
6016
+ }
6017
+ if (args.cursor || !isOffline(res.status)) throw res.error;
6018
+ const book = await logsBook(args);
6019
+ return listFrom(book.listings.filter((row) => matchOrder(row, args, includeInactive)), "logs");
6020
+ }
6021
+ async function fetchContinuumDaoMarketplaceOfferings(args = {}) {
6022
+ const includeInactive = Boolean(args.includeInactive);
6023
+ const url = `${apiBase(args)}/marketplace/offerings${qs({
6024
+ includeInactive,
6025
+ paymentToken: args.paymentToken,
6026
+ tokenId: args.tokenId,
6027
+ creator: args.creator,
6028
+ limit: args.limit ?? 100,
6029
+ cursor: args.cursor,
6030
+ viewer: args.viewer
6031
+ })}`;
6032
+ const res = await getJson(url);
6033
+ if (res.ok) {
6034
+ const body = res.body;
6035
+ return { items: body.items ?? [], nextCursor: body.nextCursor ?? null, source: "api" };
6036
+ }
6037
+ if (args.cursor || !isOffline(res.status)) throw res.error;
6038
+ const book = await logsBook(args);
6039
+ return listFrom(book.offerings.filter((row) => matchOrder(row, args, includeInactive)), "logs");
6040
+ }
6041
+ async function fetchContinuumDaoMarketplaceAuctions(args = {}) {
6042
+ const includeInactive = Boolean(args.includeInactive);
6043
+ const url = `${apiBase(args)}/marketplace/auctions${qs({
6044
+ includeInactive,
6045
+ paymentToken: args.paymentToken,
6046
+ tokenId: args.tokenId,
6047
+ seller: args.seller,
6048
+ limit: args.limit ?? 100,
6049
+ cursor: args.cursor,
6050
+ viewer: args.viewer
6051
+ })}`;
6052
+ const res = await getJson(url);
6053
+ if (res.ok) {
6054
+ const body = res.body;
6055
+ return {
6056
+ items: (body.items ?? []).map((row) => ({ ...row, bids: row.bids ?? [] })),
6057
+ nextCursor: body.nextCursor ?? null,
6058
+ source: "api"
6059
+ };
6060
+ }
6061
+ if (args.cursor || !isOffline(res.status)) throw res.error;
6062
+ const book = await logsBook(args);
6063
+ return listFrom(book.auctions.filter((row) => matchAuction(row, args, includeInactive)), "logs");
6064
+ }
6065
+ async function fetchContinuumDaoMarketplaceToken(args) {
6066
+ const url = `${apiBase(args)}/marketplace/tokens/${encodeURIComponent(args.tokenId)}${qs({ viewer: args.viewer })}`;
6067
+ const res = await getJson(url);
6068
+ if (res.ok && res.body && typeof res.body === "object") {
6069
+ return { ...res.body, source: "api" };
6070
+ }
6071
+ if (!res.ok && !isOffline(res.status)) throw res.error;
6072
+ const book = await logsBook(args);
6073
+ const listings = book.listings.filter((row) => row.tokenId === args.tokenId);
6074
+ const offerings = book.offerings.filter((row) => row.tokenId === args.tokenId);
6075
+ const auctions = book.auctions.filter((row) => row.tokenId === args.tokenId);
6076
+ return {
6077
+ token: { tokenId: args.tokenId },
6078
+ listing: listings.find((row) => isOpenOrder(row)) ?? null,
6079
+ offerings: offerings.filter((row) => isOpenOrder(row)),
6080
+ auction: auctions.find((row) => isLiveAuctionStatus(row.derivedStatus)) ?? null,
6081
+ history: {
6082
+ listings: listings.filter((row) => !isOpenOrder(row)),
6083
+ offerings: offerings.filter((row) => !isOpenOrder(row)),
6084
+ auctions: auctions.filter((row) => !isLiveAuctionStatus(row.derivedStatus))
6085
+ },
6086
+ source: "logs"
6087
+ };
6088
+ }
6089
+ async function fetchContinuumDaoMarketplaceFeePreview(args) {
6090
+ const url = `${apiBase(args)}/marketplace/fee-preview${qs({ tokenId: args.tokenId, price: args.price })}`;
6091
+ const res = await getJson(url);
6092
+ if (res.ok && res.body && typeof res.body === "object") {
6093
+ return { ...res.body, source: "api" };
6094
+ }
6095
+ if (!res.ok && !isOffline(res.status)) throw res.error;
6096
+ return readMarketplaceFeePreviewFromChain({
6097
+ chainId: args.chainId ?? CONTINUUM_DAO_LINEA_CHAIN_ID,
6098
+ rpcUrl: args.rpcUrl ?? "",
6099
+ tokenId: BigInt(args.tokenId),
6100
+ price: BigInt(args.price)
6101
+ });
6102
+ }
6103
+ async function fetchContinuumDaoMarketplaceActivity(args) {
6104
+ const url = `${apiBase(args)}/marketplace/users/${encodeURIComponent(args.address)}/activity${qs({ limit: args.limit ?? 50 })}`;
6105
+ const res = await getJson(url);
6106
+ if (res.ok && res.body && typeof res.body === "object") {
6107
+ const body = res.body;
6108
+ return {
6109
+ address: args.address,
6110
+ orders: body.orders ?? [],
6111
+ auctions: (body.auctions ?? []).map((row) => ({ ...row, bids: row.bids ?? [] })),
6112
+ source: "api"
6113
+ };
6114
+ }
6115
+ if (!res.ok && !isOffline(res.status)) throw res.error;
6116
+ const book = await logsBook(args);
6117
+ const address = args.address.toLowerCase();
6118
+ const orders = [...book.listings, ...book.offerings].filter((row) => {
6119
+ return row.creator.toLowerCase() === address || (row.counterparty ?? "").toLowerCase() === address || (row.seller ?? "").toLowerCase() === address || (row.buyer ?? "").toLowerCase() === address;
6120
+ });
6121
+ const auctions = book.auctions.filter((row) => {
6122
+ return row.seller.toLowerCase() === address || (row.buyer ?? "").toLowerCase() === address || (row.highestBidder ?? "").toLowerCase() === address || row.bids.some((bid) => bid.bidder.toLowerCase() === address);
6123
+ });
6124
+ return { address: args.address, orders, auctions, source: "logs" };
6125
+ }
6126
+
6127
+ // src/protocols/evm/continuum-dao/marketplaceSearch.ts
6128
+ init_constants();
6129
+ var LOCKED_ABI = [parseAbiItem("function locked(uint256 tokenId) view returns (int128 amount, uint256 end)")];
6130
+ var MONTH_SECONDS = 30 * 24 * 60 * 60;
6131
+ var PAGE_SIZE = 100;
6132
+ var MAX_PAGES = 20;
6133
+ var DEFAULT_LIMIT = 10;
6134
+ var MAX_LIMIT = 25;
6135
+ var DEFAULT_DIRECTION = {
6136
+ pricePerLockedCtm: "asc",
6137
+ price: "asc",
6138
+ locked: "desc",
6139
+ unlock: "asc",
6140
+ deadline: "asc"
6141
+ };
6142
+ function same3(a, b) {
6143
+ if (!a || !b) return false;
6144
+ try {
6145
+ return getAddress(a) === getAddress(b);
6146
+ } catch {
6147
+ return a.toLowerCase() === b.toLowerCase();
6148
+ }
6149
+ }
6150
+ function attachedKey(keygen, protocolStatus) {
6151
+ if (protocolStatus === "KeyGenAttached") return true;
6152
+ const value = (keygen ?? "").trim().toLowerCase();
6153
+ return Boolean(value && value !== "0" && !/^0x0+$/.test(value));
6154
+ }
6155
+ function asBig(value) {
6156
+ try {
6157
+ return BigInt(value || "0");
6158
+ } catch {
6159
+ return 0n;
6160
+ }
6161
+ }
6162
+ function parseCtm(raw) {
6163
+ const trimmed = raw?.trim();
6164
+ if (!trimmed) return null;
6165
+ return parseUnits(trimmed, 18);
6166
+ }
6167
+ function parseTime(raw) {
6168
+ const trimmed = raw?.trim();
6169
+ if (!trimmed) return null;
6170
+ if (/^\d+$/.test(trimmed)) {
6171
+ const n = Number(trimmed);
6172
+ if (!Number.isFinite(n)) throw new Error("Unlock bound must be an ISO date or unix seconds.");
6173
+ return n > 1e12 ? Math.floor(n / 1e3) : n;
6174
+ }
6175
+ const ms = Date.parse(trimmed);
6176
+ if (Number.isNaN(ms)) throw new Error("Unlock bound must be an ISO date or unix seconds.");
6177
+ return Math.floor(ms / 1e3);
6178
+ }
6179
+ function paymentMeta(address) {
6180
+ const lower = address.toLowerCase();
6181
+ if (lower === MARKETPLACE_USDC_LINEA_ADDRESS.toLowerCase()) return { symbol: "USDC", decimals: 6 };
6182
+ if (lower === MARKETPLACE_WETH_LINEA_ADDRESS.toLowerCase()) return { symbol: "WETH", decimals: 18 };
6183
+ if (lower === CTM_TOKEN_ADDRESS.toLowerCase()) return { symbol: "CTM", decimals: 18 };
6184
+ return { symbol: "token", decimals: 18 };
6185
+ }
6186
+ function trimDecimal(value) {
6187
+ return value.replace(/(\.\d*?[1-9])0+$/, "$1").replace(/\.0+$/, "");
6188
+ }
6189
+ function humanAmount(wei, decimals) {
6190
+ return trimDecimal(formatUnits(wei, decimals));
6191
+ }
6192
+ function positive(value) {
6193
+ const trimmed = (value ?? "").trim();
6194
+ return trimmed && trimmed !== "0" ? trimmed : "";
6195
+ }
6196
+ function unlockUnixFrom(row) {
6197
+ const iso2 = positive(row.unlockTimeAt);
6198
+ if (iso2) {
6199
+ const ms = Date.parse(iso2);
6200
+ if (!Number.isNaN(ms)) return Math.floor(ms / 1e3);
6201
+ }
6202
+ const unix = positive(row.unlockTime) || positive(row.snapshotEnd);
6203
+ return unix ? Number(unix) : 0;
6204
+ }
6205
+ function lockedFrom(row) {
6206
+ return asBig(positive(row.lockedCTM) || positive(row.currentLockedAmount) || positive(row.snapshotAmount));
6207
+ }
6208
+ function listingCandidate(row) {
6209
+ const attached = attachedKey(row.keygen, row.protocolStatus);
6210
+ const open = row.protocolStatus === "Open" || row.storedStatus === "Open";
6211
+ return {
6212
+ kind: "listing",
6213
+ tokenId: row.tokenId,
6214
+ onchainIndex: row.onchainIndex,
6215
+ seller: row.seller ?? row.creator,
6216
+ paymentToken: row.paymentToken,
6217
+ price: asBig(row.price),
6218
+ priceBasis: "ask",
6219
+ locked: lockedFrom(row),
6220
+ unlockUnix: unlockUnixFrom(row),
6221
+ deadlineUnix: Number(row.deadlineUnix || "0") || 0,
6222
+ attached,
6223
+ fillable: open && !attached,
6224
+ protocolStatus: row.protocolStatus,
6225
+ storedStatus: row.storedStatus,
6226
+ keygen: row.keygen
6227
+ };
6228
+ }
6229
+ function auctionCandidate(row) {
6230
+ const attached = attachedKey(row.keygen, row.storedStatus);
6231
+ const bid = asBig(row.highestBid);
6232
+ const reserve = asBig(row.reservePrice);
6233
+ const live = row.derivedStatus === "Pending" || row.derivedStatus === "Active";
6234
+ return {
6235
+ kind: "auction",
6236
+ tokenId: row.tokenId,
6237
+ onchainIndex: row.onchainIndex,
6238
+ seller: row.seller,
6239
+ paymentToken: row.paymentToken,
6240
+ price: bid > 0n ? bid : reserve,
6241
+ priceBasis: bid > 0n ? "highestBid" : "reserve",
6242
+ locked: lockedFrom(row),
6243
+ unlockUnix: unlockUnixFrom(row),
6244
+ deadlineUnix: Number(row.deadlineUnix || "0") || 0,
6245
+ attached,
6246
+ fillable: live && !attached,
6247
+ protocolStatus: row.derivedStatus,
6248
+ storedStatus: row.storedStatus,
6249
+ keygen: row.keygen
6250
+ };
6251
+ }
6252
+ function applyLock(row, lock) {
6253
+ if (row.locked > 0n && row.unlockUnix > 0) return row;
6254
+ if (!lock) return row;
6255
+ return {
6256
+ ...row,
6257
+ locked: row.locked > 0n ? row.locked : lock.amount,
6258
+ unlockUnix: row.unlockUnix > 0 ? row.unlockUnix : lock.end
6259
+ };
6260
+ }
6261
+ function rankMarketplaceSearchHits(rows, query, nowUnix = Math.floor(Date.now() / 1e3)) {
6262
+ const sort = query.sort ?? "pricePerLockedCtm";
6263
+ const direction = query.sortDirection ?? DEFAULT_DIRECTION[sort];
6264
+ const minLocked = parseCtm(query.minLockedCtm);
6265
+ const maxLocked = parseCtm(query.maxLockedCtm);
6266
+ const unlockAfter = parseTime(query.unlockAfter);
6267
+ const unlockBefore = parseTime(query.unlockBefore);
6268
+ const monthCap = query.maxUnlockMonths != null && Number.isFinite(query.maxUnlockMonths) ? nowUnix + Math.floor(query.maxUnlockMonths * MONTH_SECONDS) : null;
6269
+ const executor = query.executor?.trim();
6270
+ const excludeOwned = query.excludeOwned !== false && Boolean(executor);
6271
+ let matched = rows.filter((row) => {
6272
+ if (query.paymentToken && !same3(row.paymentToken, query.paymentToken)) return false;
6273
+ if (excludeOwned && same3(row.seller, executor)) return false;
6274
+ if (minLocked != null && row.locked < minLocked) return false;
6275
+ if (maxLocked != null && row.locked > maxLocked) return false;
6276
+ if (unlockAfter != null && row.unlockUnix < unlockAfter) return false;
6277
+ if (unlockBefore != null && (row.unlockUnix <= 0 || row.unlockUnix > unlockBefore)) return false;
6278
+ if (monthCap != null && (row.unlockUnix <= nowUnix || row.unlockUnix > monthCap)) return false;
6279
+ return true;
6280
+ });
6281
+ const priceSort = sort === "price" || sort === "pricePerLockedCtm";
6282
+ if (priceSort && !query.paymentToken) {
6283
+ const tokens = new Set(matched.map((row) => row.paymentToken.toLowerCase()));
6284
+ if (tokens.size > 1) {
6285
+ const symbols = [...tokens].map((token) => paymentMeta(token).symbol).join(", ");
6286
+ throw new Error(`Pass paymentToken to rank by price. These rows use ${symbols}.`);
6287
+ }
6288
+ }
6289
+ const asc = direction === "asc";
6290
+ const key = (row) => {
6291
+ if (sort === "locked") return row.locked;
6292
+ if (sort === "unlock") return BigInt(row.unlockUnix || 0);
6293
+ if (sort === "deadline") return BigInt(row.deadlineUnix || 0);
6294
+ if (sort === "pricePerLockedCtm") return row.locked > 0n ? row.price * 10n ** 18n / row.locked : 2n ** 255n - 1n;
6295
+ return row.price;
6296
+ };
6297
+ matched = [...matched].sort((a, b) => {
6298
+ if (a.fillable !== b.fillable) return a.fillable ? -1 : 1;
6299
+ if (sort === "pricePerLockedCtm" && a.locked <= 0n !== b.locked <= 0n) return a.locked <= 0n ? 1 : -1;
6300
+ const cmp = key(a) === key(b) ? 0 : key(a) < key(b) ? -1 : 1;
6301
+ if (cmp !== 0) return asc ? cmp : -cmp;
6302
+ return a.tokenId.localeCompare(b.tokenId);
6303
+ });
6304
+ const limit = Math.min(MAX_LIMIT, Math.max(1, query.limit ?? DEFAULT_LIMIT));
6305
+ return matched.slice(0, limit).map((row) => toHit(row, nowUnix));
6306
+ }
6307
+ function toHit(row, nowUnix) {
6308
+ const meta4 = paymentMeta(row.paymentToken);
6309
+ const perCtm = row.locked > 0n ? row.price * 10n ** 18n / row.locked : 0n;
6310
+ const months = row.unlockUnix > nowUnix ? ((row.unlockUnix - nowUnix) / MONTH_SECONDS).toFixed(1) : row.unlockUnix > 0 ? "0" : "";
6311
+ return {
6312
+ kind: row.kind,
6313
+ tokenId: row.tokenId,
6314
+ onchainIndex: row.onchainIndex,
6315
+ seller: row.seller,
6316
+ paymentToken: row.paymentToken,
6317
+ paymentSymbol: meta4.symbol,
6318
+ price: row.price.toString(),
6319
+ priceHuman: humanAmount(row.price, meta4.decimals),
6320
+ priceBasis: row.priceBasis,
6321
+ lockedCtm: row.locked.toString(),
6322
+ lockedCtmHuman: humanAmount(row.locked, 18),
6323
+ unlockAt: row.unlockUnix > 0 ? new Date(row.unlockUnix * 1e3).toISOString() : "",
6324
+ monthsToUnlock: months,
6325
+ pricePerLockedCtm: row.locked > 0n ? humanAmount(perCtm, meta4.decimals) : "",
6326
+ deadlineAt: row.deadlineUnix > 0 ? new Date(row.deadlineUnix * 1e3).toISOString() : "",
6327
+ attached: row.attached,
6328
+ fillable: row.fillable
6329
+ };
6330
+ }
6331
+ async function fillMissingLocks(rows, rpcUrl, chainId) {
6332
+ const missing = [...new Set(rows.filter((row) => row.locked <= 0n || row.unlockUnix <= 0).map((row) => row.tokenId))];
6333
+ if (missing.length === 0 || !rpcUrl?.trim()) return rows;
6334
+ const client = marketplacePublicClient(chainId, rpcUrl.trim());
6335
+ const locks = /* @__PURE__ */ new Map();
6336
+ for (let i = 0; i < missing.length; i += 40) {
6337
+ const chunk = missing.slice(i, i + 40);
6338
+ const results = await client.multicall({
6339
+ contracts: chunk.map((id) => ({
6340
+ address: VOTING_ESCROW_LINEA_ADDRESS,
6341
+ abi: LOCKED_ABI,
6342
+ functionName: "locked",
6343
+ args: [BigInt(id)]
6344
+ })),
6345
+ allowFailure: true
6346
+ });
6347
+ results.forEach((result, index) => {
6348
+ if (result.status !== "success" || !result.result) return;
6349
+ const [amount, end] = result.result;
6350
+ const id = chunk[index];
6351
+ if (!id) return;
6352
+ locks.set(id, { amount: amount < 0n ? 0n : amount, end: Number(end) });
6353
+ });
6354
+ }
6355
+ return rows.map((row) => applyLock(row, locks.get(row.tokenId)));
6356
+ }
6357
+ async function collectKind(kind, args) {
6358
+ const rows = [];
6359
+ let cursor;
6360
+ let scanned = 0;
6361
+ let source = "api";
6362
+ let truncated = false;
6363
+ for (let page = 0; page < MAX_PAGES; page += 1) {
6364
+ const query = { ...args, includeInactive: false, limit: PAGE_SIZE, cursor };
6365
+ const res = kind === "listing" ? await fetchContinuumDaoMarketplaceListings(query) : await fetchContinuumDaoMarketplaceAuctions(query);
6366
+ source = res.source;
6367
+ scanned += res.items.length;
6368
+ for (const item of res.items) {
6369
+ rows.push(kind === "listing" ? listingCandidate(item) : auctionCandidate(item));
6370
+ }
6371
+ if (res.source === "logs" || !res.nextCursor) return { rows, scanned, truncated, source };
6372
+ cursor = res.nextCursor;
6373
+ }
6374
+ truncated = true;
6375
+ return { rows, scanned, truncated, source };
6376
+ }
6377
+ async function searchContinuumDaoMarketplace(args = {}) {
6378
+ const kind = args.kind ?? "listing";
6379
+ const chainId = args.chainId ?? CONTINUUM_DAO_LINEA_CHAIN_ID;
6380
+ const parts = await Promise.all([
6381
+ kind !== "auction" ? collectKind("listing", args) : Promise.resolve(null),
6382
+ kind !== "listing" ? collectKind("auction", args) : Promise.resolve(null)
6383
+ ]);
6384
+ const collected = parts.flatMap((part) => part?.rows ?? []);
6385
+ const withLocks = await fillMissingLocks(collected, args.rpcUrl, chainId);
6386
+ const sort = args.sort ?? "pricePerLockedCtm";
6387
+ const items = rankMarketplaceSearchHits(withLocks, args);
6388
+ return {
6389
+ sort,
6390
+ sortDirection: args.sortDirection ?? DEFAULT_DIRECTION[sort],
6391
+ paymentToken: args.paymentToken ?? null,
6392
+ scanned: parts.reduce((sum, part) => sum + (part?.scanned ?? 0), 0),
6393
+ truncated: parts.some((part) => part?.truncated),
6394
+ items,
6395
+ source: parts.some((part) => part?.source === "logs") ? "logs" : "api"
6396
+ };
6397
+ }
6398
+
6399
+ // src/protocols/evm/continuum-dao/marketplaceFeeAlternative.ts
6400
+ init_constants();
6401
+ var PAGE_SIZE2 = 100;
6402
+ var MAX_PAGES2 = 20;
6403
+ var feeAbi = parseAbi([
6404
+ "function veCtmThresholdPower() view returns (uint256)",
6405
+ "function getActiveRates() view returns (uint256 monthlyFee, uint256 freeSignaturesPerMonth, uint256 overageFeePerSignature)",
6406
+ "function FEE_TOKEN() view returns (address)",
6407
+ "function ctmPerFeeToken() view returns (uint256)",
6408
+ "function locked(uint256 tokenId) view returns (int128 amount, uint256 end)",
6409
+ "function balanceOfNFT(uint256 tokenId) view returns (uint256)"
6410
+ ]);
6411
+ function trimDecimal2(value) {
6412
+ return value.replace(/(\.\d*?[1-9])0+$/, "$1").replace(/\.0+$/, "");
6413
+ }
6414
+ function human(wei, decimals) {
6415
+ return trimDecimal2(formatUnits(wei, decimals));
6416
+ }
6417
+ function paymentMeta2(address) {
6418
+ const lower = address.toLowerCase();
6419
+ if (lower === MARKETPLACE_USDC_LINEA_ADDRESS.toLowerCase()) return { symbol: "USDC", decimals: 6 };
6420
+ if (lower === MARKETPLACE_WETH_LINEA_ADDRESS.toLowerCase()) return { symbol: "WETH", decimals: 18 };
6421
+ if (lower === CTM_TOKEN_ADDRESS.toLowerCase()) return { symbol: "CTM", decimals: 18 };
6422
+ return { symbol: "token", decimals: 18 };
6423
+ }
6424
+ function monthsOfFees(price, monthly) {
6425
+ if (monthly <= 0n || price < 0n) return null;
6426
+ const tenths = price * 10n / monthly;
6427
+ const whole = tenths / 10n;
6428
+ const frac = tenths % 10n;
6429
+ return frac === 0n ? whole.toString() : `${whole}.${frac}`;
6430
+ }
6431
+ function votingPowerAboveUntil(args) {
6432
+ if (args.votingPower <= args.threshold) return null;
6433
+ if (args.unlockUnix <= args.nowUnix) return null;
6434
+ if (args.threshold <= 0n) return args.unlockUnix;
6435
+ const remaining = BigInt(args.unlockUnix - args.nowUnix);
6436
+ const drop = remaining * args.threshold / args.votingPower;
6437
+ return args.unlockUnix - Number(drop);
6438
+ }
6439
+ function pickFeeAlternativeExample(rows, preferredToken) {
6440
+ const fillable = rows.filter((row) => row.fillable && row.locked > 0n && row.votingPower > 0n);
6441
+ const preferred = preferredToken ? fillable.filter((row) => row.paymentToken.toLowerCase() === preferredToken.toLowerCase()) : [];
6442
+ const pool = preferred.length > 0 ? preferred : fillable;
6443
+ const perCtm = (row) => row.price * 10n ** 18n / row.locked;
6444
+ return [...pool].sort((a, b) => {
6445
+ const left = perCtm(a);
6446
+ const right = perCtm(b);
6447
+ if (left === right) return a.tokenId.localeCompare(b.tokenId);
6448
+ return left < right ? -1 : 1;
6449
+ })[0] ?? null;
6450
+ }
6451
+ function iso(unix) {
6452
+ return unix > 0 ? new Date(unix * 1e3).toISOString() : "";
6453
+ }
6454
+ function buildFeeAlternativeSummary(args) {
6455
+ const fee = `${args.monthlyFeeHuman} ${args.monthlyFeeSymbol}`;
6456
+ const year = `${args.annualFeeHuman} ${args.monthlyFeeSymbol} (${args.annualFeeCtmHuman} CTM)`;
6457
+ 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.`;
6458
+ if (!args.example) {
6459
+ return `${lead} No live direct listing is above that threshold right now.`;
6460
+ }
6461
+ const row = args.example;
6462
+ 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.`;
6463
+ 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}`;
6464
+ }
6465
+ async function readFeeSide(rpcUrl, chainId) {
6466
+ const client = marketplacePublicClient(chainId, rpcUrl);
6467
+ const wallet = MULTISIGN_AGENT_WALLET_LINEA_ADDRESS;
6468
+ const [threshold, rates, feeToken, ctmPerFeeToken] = await Promise.all([
6469
+ client.readContract({ address: wallet, abi: feeAbi, functionName: "veCtmThresholdPower" }),
6470
+ client.readContract({ address: wallet, abi: feeAbi, functionName: "getActiveRates" }),
6471
+ client.readContract({ address: wallet, abi: feeAbi, functionName: "FEE_TOKEN" }),
6472
+ client.readContract({ address: wallet, abi: feeAbi, functionName: "ctmPerFeeToken" })
6473
+ ]);
6474
+ const monthlyFee = rates[0];
6475
+ const monthlyFeeCtm = ctmPerFeeToken > 0n ? monthlyFee * ctmPerFeeToken / CTM_FEE_RATE_SCALE : 0n;
6476
+ return { threshold, monthlyFee, monthlyFeeCtm, feeToken: getAddress(feeToken) };
6477
+ }
6478
+ async function collectListings(args) {
6479
+ const rows = [];
6480
+ let cursor;
6481
+ let scanned = 0;
6482
+ let source = "api";
6483
+ let truncated = false;
6484
+ for (let page = 0; page < MAX_PAGES2; page += 1) {
6485
+ const res = await fetchContinuumDaoMarketplaceListings({ ...args, includeInactive: false, limit: PAGE_SIZE2, cursor });
6486
+ source = res.source;
6487
+ scanned += res.items.length;
6488
+ rows.push(...res.items.map(listingCandidate));
6489
+ if (res.source === "logs" || !res.nextCursor) return { rows, scanned, truncated, source };
6490
+ cursor = res.nextCursor;
6491
+ }
6492
+ return { rows, scanned, truncated: true, source };
6493
+ }
6494
+ async function fillLocks(rows, rpcUrl, chainId) {
6495
+ const missing = [...new Set(rows.filter((row) => row.locked <= 0n || row.unlockUnix <= 0).map((row) => row.tokenId))];
6496
+ if (missing.length === 0) return rows;
6497
+ const client = marketplacePublicClient(chainId, rpcUrl);
6498
+ const locks = /* @__PURE__ */ new Map();
6499
+ for (let i = 0; i < missing.length; i += 40) {
6500
+ const chunk = missing.slice(i, i + 40);
6501
+ const results = await client.multicall({
6502
+ contracts: chunk.map((id) => ({
6503
+ address: VOTING_ESCROW_LINEA_ADDRESS,
6504
+ abi: feeAbi,
6505
+ functionName: "locked",
6506
+ args: [BigInt(id)]
6507
+ })),
6508
+ allowFailure: true
6509
+ });
6510
+ results.forEach((result, index) => {
6511
+ if (result.status !== "success" || !result.result) return;
6512
+ const id = chunk[index];
6513
+ if (!id) return;
6514
+ const [amount, end] = result.result;
6515
+ locks.set(id, { amount: amount < 0n ? 0n : amount, end: Number(end) });
6516
+ });
6517
+ }
6518
+ return rows.map((row) => {
6519
+ const lock = locks.get(row.tokenId);
6520
+ if (!lock) return row;
6521
+ return { ...row, locked: row.locked > 0n ? row.locked : lock.amount, unlockUnix: row.unlockUnix > 0 ? row.unlockUnix : lock.end };
6522
+ });
6523
+ }
6524
+ async function readVotingPower(tokenIds, rpcUrl, chainId) {
6525
+ const client = marketplacePublicClient(chainId, rpcUrl);
6526
+ const power = /* @__PURE__ */ new Map();
6527
+ for (let i = 0; i < tokenIds.length; i += 40) {
6528
+ const chunk = tokenIds.slice(i, i + 40);
6529
+ const results = await client.multicall({
6530
+ contracts: chunk.map((id) => ({
6531
+ address: VOTING_ESCROW_LINEA_ADDRESS,
6532
+ abi: feeAbi,
6533
+ functionName: "balanceOfNFT",
6534
+ args: [BigInt(id)]
6535
+ })),
6536
+ allowFailure: true
6537
+ });
6538
+ results.forEach((result, index) => {
6539
+ const id = chunk[index];
6540
+ if (!id || result.status !== "success") return;
6541
+ power.set(id, result.result);
6542
+ });
6543
+ }
6544
+ return power;
6545
+ }
6546
+ async function quoteContinuumDaoMarketplaceFeeAlternative(args) {
6547
+ const rpcUrl = args.rpcUrl?.trim();
6548
+ if (!rpcUrl) throw new Error("Linea RPC is required to read the monthly fee and veCTM threshold.");
6549
+ const chainId = args.chainId ?? CONTINUUM_DAO_LINEA_CHAIN_ID;
6550
+ const payment = args.payment ?? "fee";
6551
+ const nowUnix = Math.floor(Date.now() / 1e3);
6552
+ const fee = await readFeeSide(rpcUrl, chainId);
6553
+ const collected = await collectListings(args);
6554
+ const withLocks = await fillLocks(collected.rows, rpcUrl, chainId);
6555
+ const executor = args.executor?.trim();
6556
+ const visible = executor ? withLocks.filter((row) => {
6557
+ try {
6558
+ return getAddress(row.seller) !== getAddress(executor);
6559
+ } catch {
6560
+ return row.seller.toLowerCase() !== executor.toLowerCase();
6561
+ }
6562
+ }) : withLocks;
6563
+ const aboveLock = visible.filter((row) => row.fillable && row.locked > fee.threshold);
6564
+ const power = await readVotingPower(aboveLock.map((row) => row.tokenId), rpcUrl, chainId);
6565
+ const qualified = aboveLock.flatMap((row) => {
6566
+ const votingPower = power.get(row.tokenId);
6567
+ if (votingPower == null || votingPower <= fee.threshold) return [];
6568
+ return [
6569
+ {
6570
+ tokenId: row.tokenId,
6571
+ paymentToken: row.paymentToken,
6572
+ price: row.price,
6573
+ locked: row.locked,
6574
+ unlockUnix: row.unlockUnix,
6575
+ votingPower,
6576
+ fillable: row.fillable
6577
+ }
6578
+ ];
6579
+ });
6580
+ const preferred = payment === "ctm" ? CTM_TOKEN_ADDRESS : fee.feeToken;
6581
+ const picked = pickFeeAlternativeExample(qualified, preferred);
6582
+ const feeMeta = paymentMeta2(fee.feeToken);
6583
+ const example = picked ? toExample(picked, fee, payment, preferred, nowUnix) : null;
6584
+ const quoteBase = {
6585
+ payment,
6586
+ threshold: fee.threshold.toString(),
6587
+ thresholdHuman: human(fee.threshold, 18),
6588
+ monthlyFee: fee.monthlyFee.toString(),
6589
+ monthlyFeeHuman: human(fee.monthlyFee, feeMeta.decimals),
6590
+ monthlyFeeSymbol: feeMeta.symbol,
6591
+ annualFee: (fee.monthlyFee * 12n).toString(),
6592
+ annualFeeHuman: human(fee.monthlyFee * 12n, feeMeta.decimals),
6593
+ monthlyFeeCtm: fee.monthlyFeeCtm.toString(),
6594
+ monthlyFeeCtmHuman: human(fee.monthlyFeeCtm, 18),
6595
+ annualFeeCtm: (fee.monthlyFeeCtm * 12n).toString(),
6596
+ annualFeeCtmHuman: human(fee.monthlyFeeCtm * 12n, 18),
6597
+ feeToken: fee.feeToken,
6598
+ example,
6599
+ scanned: collected.scanned,
6600
+ truncated: collected.truncated,
6601
+ source: collected.source
6602
+ };
6603
+ return {
6604
+ ...quoteBase,
6605
+ summary: buildFeeAlternativeSummary({
6606
+ thresholdHuman: quoteBase.thresholdHuman,
6607
+ monthlyFeeHuman: quoteBase.monthlyFeeHuman,
6608
+ monthlyFeeSymbol: quoteBase.monthlyFeeSymbol,
6609
+ annualFeeHuman: quoteBase.annualFeeHuman,
6610
+ annualFeeCtmHuman: quoteBase.annualFeeCtmHuman,
6611
+ example
6612
+ })
6613
+ };
6614
+ }
6615
+ function toExample(row, fee, payment, preferred, nowUnix) {
6616
+ const meta4 = paymentMeta2(row.paymentToken);
6617
+ const same5 = row.paymentToken.toLowerCase() === preferred.toLowerCase();
6618
+ const monthly = payment === "ctm" ? fee.monthlyFeeCtm : fee.monthlyFee;
6619
+ const until = votingPowerAboveUntil({
6620
+ votingPower: row.votingPower,
6621
+ threshold: fee.threshold,
6622
+ nowUnix,
6623
+ unlockUnix: row.unlockUnix
6624
+ });
6625
+ const perCtm = row.price * 10n ** 18n / row.locked;
6626
+ return {
6627
+ tokenId: row.tokenId,
6628
+ price: row.price.toString(),
6629
+ priceHuman: human(row.price, meta4.decimals),
6630
+ paymentToken: row.paymentToken,
6631
+ paymentSymbol: meta4.symbol,
6632
+ lockedCtm: row.locked.toString(),
6633
+ lockedCtmHuman: human(row.locked, 18),
6634
+ unlockAt: iso(row.unlockUnix),
6635
+ votingPower: row.votingPower.toString(),
6636
+ votingPowerHuman: human(row.votingPower, 18),
6637
+ staysAboveThresholdUntil: iso(until ?? 0),
6638
+ pricePerLockedCtm: human(perCtm, meta4.decimals),
6639
+ monthsOfFees: same5 ? monthsOfFees(row.price, monthly) : null,
6640
+ comparedTo: same5 ? payment : null,
6641
+ fillable: row.fillable
6642
+ };
6643
+ }
6644
+
6645
+ // src/protocols/evm/continuum-dao/marketplaceMultisign.ts
6646
+ init_buildBatch();
6647
+ init_constants();
6648
+ function parseWei(raw, label) {
6649
+ const value = typeof raw === "bigint" ? raw : BigInt(String(raw).trim());
6650
+ if (value < 0n) throw new Error(`${label} must be zero or greater.`);
6651
+ return value;
6652
+ }
6653
+ function parseTokenId2(raw) {
6654
+ const id = typeof raw === "bigint" ? raw : BigInt(String(raw).trim());
6655
+ if (id <= 0n) throw new Error("veCTM token id must be greater than zero.");
6656
+ return id;
6657
+ }
6658
+ function requireLinea(chainId) {
6659
+ if (chainId !== CONTINUUM_DAO_LINEA_CHAIN_ID) {
6660
+ throw new Error("veCTM marketplace actions are Linea mainnet only.");
6661
+ }
6662
+ }
6663
+ function meta3(step, chainId, gasLimit) {
6664
+ return {
6665
+ destinationAddress: step.to,
6666
+ signatureText: continuumDaoSignatureText({ name: step.name, ...step.extra }, chainId),
6667
+ evm: {
6668
+ type: step.evmType,
6669
+ version: 1,
6670
+ chainId: String(chainId),
6671
+ protocolId: CONTINUUM_DAO_MARKETPLACE_PROTOCOL_ID
6672
+ },
6673
+ continuumDaoMarketplace: { ...step.extra, name: step.name, gas: { baseGasUnits: gasLimit.toString() } }
6674
+ };
6675
+ }
6676
+ async function finalize2(steps, args, purposeSuffix) {
6677
+ const evmSteps = steps.map((s) => ({
6678
+ to: s.to,
6679
+ data: s.data,
6680
+ value: s.value,
6681
+ fallbackGas: s.fallbackGas
6682
+ }));
6683
+ const firstDataNo0x = evmSteps[0].data.startsWith("0x") ? evmSteps[0].data.slice(2) : evmSteps[0].data;
6684
+ return buildEvmMultisignBatch({
6685
+ context: {
6686
+ chainCategory: "evm",
6687
+ keyGen: args.keyGen,
6688
+ purposeText: args.purposeText,
6689
+ chainId: args.chainId,
6690
+ rpcUrl: args.rpcUrl.trim(),
6691
+ executorAddress: args.executorAddress,
6692
+ chainDetail: args.chainDetail,
6693
+ useCustomGas: args.useCustomGas,
6694
+ customGasChainDetails: args.customGasChainDetails
6695
+ },
6696
+ steps: evmSteps,
6697
+ purposeSuffix,
6698
+ firstMsgRawNo0x: firstDataNo0x,
6699
+ destinationAddress: steps[0].to,
6700
+ buildBatchMeta: ({ index, gasLimit }) => meta3(steps[index], args.chainId, gasLimit)
6701
+ });
6702
+ }
6703
+ async function build(args, input, purposeSuffix, snapshotArgs) {
6704
+ requireLinea(args.chainId);
6705
+ const executor = getAddress(args.executorAddress);
6706
+ const tokenId = "tokenId" in input ? input.tokenId : 0n;
6707
+ const snap = await loadMarketplacePlanSnapshot({
6708
+ chainId: args.chainId,
6709
+ rpcUrl: args.rpcUrl,
6710
+ executor,
6711
+ tokenId,
6712
+ ...snapshotArgs
6713
+ });
6714
+ const steps = planMarketplaceSteps(input, snap);
6715
+ return finalize2(steps, args, purposeSuffix);
6716
+ }
6717
+ async function buildEvmMultisignBodyContinuumDaoMarketplaceCreateListing(args) {
6718
+ const tokenId = parseTokenId2(args.tokenId);
6719
+ const paymentToken = getAddress(args.paymentToken);
6720
+ const askWei = parseWei(args.askWei, "Ask");
6721
+ const deadline = parseWei(args.deadline, "Deadline");
6722
+ return build(
6723
+ args,
6724
+ { action: "createListing", tokenId, paymentToken, askWei, deadline },
6725
+ `ContinuumDAO marketplace: list veCTM #${tokenId.toString()}.`,
6726
+ { paymentToken }
6727
+ );
6728
+ }
6729
+ async function buildEvmMultisignBodyContinuumDaoMarketplaceDelist(args) {
6730
+ const tokenId = parseTokenId2(args.tokenId);
6731
+ return build(args, { action: "delist", tokenId }, `ContinuumDAO marketplace: delist veCTM #${tokenId.toString()}.`, {});
6732
+ }
6733
+ async function buildEvmMultisignBodyContinuumDaoMarketplaceFulfillListing(args) {
6734
+ const tokenId = parseTokenId2(args.tokenId);
6735
+ const seller = getAddress(args.seller);
6736
+ const paymentToken = getAddress(args.paymentToken);
6737
+ const priceWei = parseWei(args.priceWei, "Price");
6738
+ return build(
6739
+ args,
6740
+ { action: "fulfillListing", tokenId, seller, paymentToken, priceWei },
6741
+ `ContinuumDAO marketplace: buy veCTM #${tokenId.toString()}.`,
6742
+ { seller, paymentToken }
6743
+ );
6744
+ }
6745
+ async function buildEvmMultisignBodyContinuumDaoMarketplaceCreateOffering(args) {
6746
+ const tokenId = parseTokenId2(args.tokenId);
6747
+ const paymentToken = getAddress(args.paymentToken);
6748
+ const bidWei = parseWei(args.bidWei, "Bid");
6749
+ const deadline = parseWei(args.deadline, "Deadline");
6750
+ return build(
6751
+ args,
6752
+ { action: "createOffering", tokenId, paymentToken, bidWei, deadline },
6753
+ `ContinuumDAO marketplace: offer on veCTM #${tokenId.toString()}.`,
6754
+ { paymentToken }
6755
+ );
6756
+ }
6757
+ async function buildEvmMultisignBodyContinuumDaoMarketplaceRescind(args) {
6758
+ const tokenId = parseTokenId2(args.tokenId);
6759
+ return build(
6760
+ args,
6761
+ { action: "rescind", tokenId },
6762
+ `ContinuumDAO marketplace: rescind offer on veCTM #${tokenId.toString()}.`,
6763
+ {}
6764
+ );
6765
+ }
6766
+ async function buildEvmMultisignBodyContinuumDaoMarketplaceFulfillOffering(args) {
6767
+ const tokenId = parseTokenId2(args.tokenId);
6768
+ const buyer = getAddress(args.buyer);
6769
+ const paymentToken = getAddress(args.paymentToken);
6770
+ const priceWei = parseWei(args.priceWei, "Price");
6771
+ return build(
6772
+ args,
6773
+ { action: "fulfillOffering", tokenId, buyer, paymentToken, priceWei },
6774
+ `ContinuumDAO marketplace: accept offer on veCTM #${tokenId.toString()}.`,
6775
+ { buyer, paymentToken }
6776
+ );
6777
+ }
6778
+ async function buildEvmMultisignBodyContinuumDaoMarketplaceCreateAuction(args) {
6779
+ const tokenId = parseTokenId2(args.tokenId);
6780
+ const paymentToken = getAddress(args.paymentToken);
6781
+ const deadline = parseWei(args.deadline, "Deadline");
6782
+ const reserveWei = parseWei(args.reserveWei, "Reserve");
6783
+ const minIncrementWei = parseWei(args.minIncrementWei, "Minimum increment");
6784
+ return build(
6785
+ args,
6786
+ { action: "createAuction", tokenId, paymentToken, deadline, reserveWei, minIncrementWei },
6787
+ `ContinuumDAO marketplace: auction veCTM #${tokenId.toString()}.`,
6788
+ { paymentToken }
6789
+ );
6790
+ }
6791
+ async function buildEvmMultisignBodyContinuumDaoMarketplaceCancelAuction(args) {
6792
+ const tokenId = parseTokenId2(args.tokenId);
6793
+ return build(
6794
+ args,
6795
+ { action: "cancelAuction", tokenId },
6796
+ `ContinuumDAO marketplace: cancel auction for veCTM #${tokenId.toString()}.`,
6797
+ {}
6798
+ );
6799
+ }
6800
+ async function buildEvmMultisignBodyContinuumDaoMarketplaceAuctionBid(args) {
6801
+ const tokenId = parseTokenId2(args.tokenId);
6802
+ const seller = getAddress(args.seller);
6803
+ const priceWei = parseWei(args.priceWei, "Bid");
6804
+ return build(
6805
+ args,
6806
+ { action: "auctionBid", tokenId, seller, priceWei },
6807
+ `ContinuumDAO marketplace: bid on veCTM #${tokenId.toString()}.`,
6808
+ { seller }
6809
+ );
6810
+ }
6811
+ async function buildEvmMultisignBodyContinuumDaoMarketplaceSettleAuction(args) {
6812
+ const tokenId = parseTokenId2(args.tokenId);
6813
+ const seller = getAddress(args.seller);
6814
+ return build(
6815
+ args,
6816
+ { action: "settleAuction", tokenId, seller },
6817
+ `ContinuumDAO marketplace: settle auction for veCTM #${tokenId.toString()}.`,
6818
+ { seller }
6819
+ );
6820
+ }
6821
+ function parseExtra(detail) {
6822
+ const raw = detail?.ExtraJSON ?? detail?.extraJSON;
6823
+ if (raw == null) return null;
6824
+ if (typeof raw === "object" && !Array.isArray(raw)) return raw;
6825
+ if (typeof raw === "string" && raw.trim()) {
6826
+ try {
6827
+ const parsed = JSON.parse(raw);
6828
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) return parsed;
6829
+ } catch {
6830
+ return null;
6831
+ }
6832
+ }
6833
+ return null;
6834
+ }
6835
+ function same4(a, b) {
6836
+ try {
6837
+ return getAddress(a) === getAddress(b);
6838
+ } catch {
6839
+ return a.toLowerCase() === b.toLowerCase();
6840
+ }
6841
+ }
6842
+ function marketplaceVeCtmReceivedBy(detail, executor) {
6843
+ const extra = parseExtra(detail);
6844
+ const batch = extra?.batchMeta;
6845
+ if (!Array.isArray(batch) || !executor.trim()) return null;
6846
+ for (const entry of batch) {
6847
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
6848
+ const row = entry;
6849
+ const evm = row.evm;
6850
+ const type = evm && typeof evm === "object" ? String(evm.type ?? "") : "";
6851
+ const meta4 = row.continuumDaoMarketplace;
6852
+ if (!meta4 || typeof meta4 !== "object" || Array.isArray(meta4)) continue;
6853
+ const info = meta4;
6854
+ const tokenId = String(info.tokenId ?? "").trim();
6855
+ if (!tokenId) continue;
6856
+ if (type === "continuum_dao_marketplace_fulfill_listing") {
6857
+ const recipient = String(info.recipient ?? "");
6858
+ if (!recipient || same4(recipient, executor)) return { tokenId };
6859
+ }
6860
+ if (type === "continuum_dao_marketplace_settle_auction") {
6861
+ const highest = String(info.highestBidder ?? "");
6862
+ const recipient = String(info.recipient ?? "");
6863
+ if (highest && same4(highest, executor) && same4(recipient, executor)) return { tokenId };
6864
+ }
6865
+ }
6866
+ return null;
6867
+ }
6868
+
6869
+ // src/protocols/evm/continuum-dao/index.ts
6870
+ registerProtocolModule(continuumDaoMarketplaceProtocolModule);
4714
6871
  var continuumDaoProtocolModule = {
4715
6872
  id: CONTINUUM_DAO_PROTOCOL_ID,
4716
6873
  chainCategory: "evm",
@@ -4762,6 +6919,6 @@ var continuumDaoProtocolModule = {
4762
6919
  };
4763
6920
  registerProtocolModule(continuumDaoProtocolModule);
4764
6921
 
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 };
6922
+ 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
6923
  //# sourceMappingURL=index.js.map
4767
6924
  //# sourceMappingURL=index.js.map