@sage-protocol/sdk 0.2.6 → 0.2.9

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.
@@ -14,7 +14,7 @@ var require_package = __commonJS({
14
14
  "package.json"(exports2, module2) {
15
15
  module2.exports = {
16
16
  name: "@sage-protocol/sdk",
17
- version: "0.2.6",
17
+ version: "0.2.9",
18
18
  description: "Backend-agnostic SDK for interacting with the Sage Protocol (governance, SubDAOs, tokens).",
19
19
  main: "dist/index.cjs",
20
20
  module: "dist/index.mjs",
@@ -72,7 +72,6 @@ var require_package = __commonJS({
72
72
  },
73
73
  dependencies: {
74
74
  "@merit-systems/echo-typescript-sdk": "^1.0.17",
75
- "@whetstone-research/doppler-sdk": "^0.0.1-alpha.40",
76
75
  ai: "^5.0.52",
77
76
  axios: "^1.11.0",
78
77
  ethers: "^6.15.0",
@@ -140,7 +139,6 @@ var require_abi = __commonJS({
140
139
  // Core factory reads
141
140
  "function timelockMinDelay() view returns (uint256)",
142
141
  "function premiumPromptsAddress() view returns (address)",
143
- "function simpleKeyStoreAddress() view returns (address)",
144
142
  "function governanceConfigAddress() view returns (address)",
145
143
  "function libraryRegistryAddress() view returns (address)",
146
144
  // Canonical per‑SubDAO mapping
@@ -165,8 +163,14 @@ var require_abi = __commonJS({
165
163
  "function createSubDAOOperatorWithStableAdvanced(string name, string description, uint8 accessModel, uint256 minStakeAmount, address operatorExecutor, address operatorAdmin, bool anyoneExec, bool governorProposer, (uint256 value,uint256 deadline,uint8 v,bytes32 r,bytes32 s) permit) returns (address subDAO, address registry)",
166
164
  "function createSubDAOOperator(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount, address operatorExecutor, address operatorAdmin) returns (address subDAO, address registry)",
167
165
  "function createSubDAOOperatorAdvanced(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount, address operatorExecutor, address operatorAdmin, bool anyoneExec, bool governorProposer) returns (address subDAO, address registry)",
166
+ // Forking (legacy overloads forward with maxForkFee=type(uint256).max)
168
167
  "function createForkedSubDAO(string newName, string newDescription, string originalName, address originalSubDAO, address forker, bool copyLibrary) returns (address subDAO, address registry)",
169
- "function createForkedSubDAOWithStable(string newName, string newDescription, string originalName, address originalSubDAO, address forker, uint64 authorizationNonce, (uint256 value,uint256 deadline,uint8 v,bytes32 r,bytes32 s) permit, bool copyLibrary) returns (address subDAO, address registry)"
168
+ // Forking (preferred: explicit maxForkFee slippage cap)
169
+ "function createForkedSubDAO(string newName, string newDescription, string originalName, address originalSubDAO, address forker, uint256 maxForkFee, bool copyLibrary) returns (address subDAO, address registry)",
170
+ // Stable-fee forking (legacy overloads forward with maxForkFee=type(uint256).max)
171
+ "function createForkedSubDAOWithStable(string newName, string newDescription, string originalName, address originalSubDAO, address forker, uint64 authorizationNonce, (uint256 value,uint256 deadline,uint8 v,bytes32 r,bytes32 s) permit, bool copyLibrary) returns (address subDAO, address registry)",
172
+ // Stable-fee forking (preferred: explicit maxForkFee slippage cap)
173
+ "function createForkedSubDAOWithStable(string newName, string newDescription, string originalName, address originalSubDAO, address forker, uint64 authorizationNonce, (uint256 value,uint256 deadline,uint8 v,bytes32 r,bytes32 s) permit, uint256 maxForkFee, bool copyLibrary) returns (address subDAO, address registry)"
170
174
  ];
171
175
  var TemplateModule = [
172
176
  "function getActiveTemplates() view returns (uint256[])",
@@ -177,13 +181,11 @@ var require_abi = __commonJS({
177
181
  "function maxCreationBurn() view returns (uint256)"
178
182
  ];
179
183
  var LibraryRegistry = [
180
- "function libraryByDAO(address) view returns (string manifestCID, address lastUpdater, uint256 lastUpdated, string version, address forkedFromDAO, uint256 sxxxForkFee, uint256 nonce)",
184
+ "function libraryByDAO(address) view returns (string manifestCID, address lastUpdater, uint256 lastUpdated, string version, uint256 nonce)",
181
185
  "function daoTimelock(address) view returns (address)",
182
- "function getLibrary(address) view returns (tuple(string manifestCID, address lastUpdater, uint256 lastUpdated, string version, address forkedFromDAO, uint256 sxxxForkFee, uint256 nonce))",
186
+ "function getLibrary(address) view returns (tuple(string manifestCID, address lastUpdater, uint256 lastUpdated, string version, uint256 nonce))",
183
187
  "function getLibraryIds(address dao) view returns (bytes32[] memory)",
184
- "function getLibraryStream(address dao, string libraryId) view returns (tuple(string manifestCID, address lastUpdater, uint256 lastUpdated, string version, address forkedFromDAO, uint256 sxxxForkFee, uint256 nonce))",
185
- "function getLibraryForkFee(address dao) view returns (uint256)",
186
- "function setLibraryForkFee(address dao, uint256 fee)",
188
+ "function getLibraryStream(address dao, string libraryId) view returns (tuple(string manifestCID, address lastUpdater, uint256 lastUpdated, string version, uint256 nonce))",
187
189
  "function updateLibrary(address dao, string manifestCID, string version)",
188
190
  "function updateLibraryCAS(address dao, string manifestCID, string version, uint256 expectedNonce)",
189
191
  "function updateLibraryStream(address dao, string libraryId, string manifestCID, string version)",
@@ -302,9 +304,6 @@ var require_abi = __commonJS({
302
304
  "function getForkBurnDiscount(address) view returns (uint256)",
303
305
  "function totalBurned() view returns (uint256)"
304
306
  ];
305
- var PersonalLibraryFacet = [
306
- "function createPersonalRegistry(uint8 policy) returns (address)"
307
- ];
308
307
  var PersonalMarketplace = [
309
308
  "function setPrice(bytes32 key, uint256 price)",
310
309
  "function purchase(address creator, bytes32 key, uint256 expectedPrice, uint256 deadline)"
@@ -327,14 +326,28 @@ var require_abi = __commonJS({
327
326
  "event TokensSwept(address indexed token, address indexed to, uint256 amount)"
328
327
  ];
329
328
  var GovernanceBoostMerkle = [
330
- "function getProposalConfig(uint256) view returns (tuple(uint256 proposalId,address token,uint256 totalAmount,uint64 startTime,uint64 endTime,uint256 merkleRoot))",
331
- "function fund(uint256 proposalId, uint256 amount)",
332
- "function setRoot(uint256 proposalId, uint256 merkleRoot)"
329
+ "function createBoost(uint256 proposalId, uint256 totalPool)",
330
+ "function setMerkleRoot(uint256 proposalId, bytes32 root)",
331
+ "function finalize(uint256 proposalId)",
332
+ "function claim(uint256 proposalId, address account, uint256 amount, bytes32[] proof)",
333
+ "function getBoost(uint256 proposalId) view returns (uint256 totalPool, uint256 totalClaimed, bytes32 merkleRoot, uint256 expiresAt, bool active, bool finalized, address creator)",
334
+ "function claimed(uint256 proposalId, address account) view returns (bool)",
335
+ "event BoostCreated(uint256 indexed proposalId, address indexed creator, uint256 totalPool)",
336
+ "event MerkleRootSet(uint256 indexed proposalId, bytes32 merkleRoot)",
337
+ "event RewardClaimed(uint256 indexed proposalId, address indexed voter, uint256 amount)",
338
+ "event BoostFinalized(uint256 indexed proposalId, uint256 totalClaimed, uint256 refunded)"
333
339
  ];
334
340
  var GovernanceBoostDirect = [
335
- "function getDirectConfig(uint256) view returns (tuple(uint256 proposalId,address token,uint256 perVoter,uint256 maxVoters,uint64 startTime,uint64 endTime))",
336
- "function create(uint256 proposalId, address token, uint256 perVoter, uint256 maxVoters)",
337
- "function fund(uint256 proposalId, uint256 amount)"
341
+ "function createBoost((address governor,uint256 proposalId,uint256 perVoter,uint256 maxVoters,uint8 kind,address policy,uint96 minVotes,uint8 payoutMode,uint8 support,uint256 startAt,uint256 expiresAt) params)",
342
+ "function claim(uint256 proposalId, bytes data)",
343
+ "function finalize(uint256 proposalId)",
344
+ "function pause(uint256 proposalId, bool paused)",
345
+ "function setProtocolRake(uint96 rakeBps, address protocolTreasury)",
346
+ "function getBoost(uint256 proposalId) view returns (tuple(address creator, address governor, uint256 proposalId, uint256 snapshot, uint256 perVoter, uint256 maxVoters, uint256 votersPaid, uint96 minVotes, uint8 payoutMode, uint8 support, uint256 startAt, uint256 expiresAt, uint256 totalPool, uint256 totalPaid, uint8 kind, address policy, bool active, bool paused) boost)",
347
+ "function claimed(uint256 proposalId, address account) view returns (bool)",
348
+ "event BoostCreated(uint256 indexed proposalId, address indexed governor, uint256 perVoter, uint256 maxVoters, uint256 snapshot, uint8 kind, address policy, uint96 minVotes)",
349
+ "event BoostClaimed(uint256 indexed proposalId, address indexed claimer, uint256 amount, uint256 rake)",
350
+ "event BoostFinalized(uint256 indexed proposalId, uint256 paidCount, uint256 refund)"
338
351
  ];
339
352
  var VotingMultiplierNFT = [
340
353
  // Constants
@@ -342,6 +355,7 @@ var require_abi = __commonJS({
342
355
  "function MAX_NFTS_PER_ACCOUNT() view returns (uint256)",
343
356
  // Tier Management
344
357
  "function createTier(address dao, string name, uint256 multiplier, uint256 maxSupply, uint256 price) returns (uint256 tierId)",
358
+ "function createTierViaGovernance(address subdao, string name, uint256 multiplier, uint256 maxSupply, uint256 price) returns (uint256 tierId)",
345
359
  "function getTier(uint256 tierId) view returns (tuple(string name, uint256 multiplier, uint256 maxSupply, uint256 minted, uint256 price, address dao))",
346
360
  "function tierCount() view returns (uint256)",
347
361
  "function tiers(uint256) view returns (string name, uint256 multiplier, uint256 maxSupply, uint256 minted, uint256 price, address dao)",
@@ -414,7 +428,7 @@ var require_abi = __commonJS({
414
428
  "function weth() view returns (address)",
415
429
  "function timeBuffer() view returns (uint256)",
416
430
  "function reservePrice() view returns (uint256)",
417
- "function minBidIncrementPercentage() view returns (uint256)",
431
+ "function minBidIncrementBps() view returns (uint256)",
418
432
  "function duration() view returns (uint256)",
419
433
  "function mintTierId() view returns (uint256)",
420
434
  "function defaultTokenURI() view returns (string)",
@@ -424,7 +438,7 @@ var require_abi = __commonJS({
424
438
  "function paused() view returns (bool)",
425
439
  "function setTimeBuffer(uint256 _timeBuffer)",
426
440
  "function setReservePrice(uint256 _reservePrice)",
427
- "function setMinBidIncrementPercentage(uint256 _minBidIncrementPercentage)",
441
+ "function setMinBidIncrementBps(uint256 _minBidIncrementBps)",
428
442
  "function setDuration(uint256 _duration)",
429
443
  "function setMintTierId(uint256 _tierId)",
430
444
  "function setDefaultTokenURI(string _uri)",
@@ -437,7 +451,7 @@ var require_abi = __commonJS({
437
451
  "event AuctionSettled(uint256 indexed nftId, address winner, uint256 amount)",
438
452
  "event AuctionTimeBufferUpdated(uint256 timeBuffer)",
439
453
  "event AuctionReservePriceUpdated(uint256 reservePrice)",
440
- "event AuctionMinBidIncrementPercentageUpdated(uint256 minBidIncrementPercentage)",
454
+ "event AuctionMinBidIncrementBpsUpdated(uint256 minBidIncrementBps)",
441
455
  "event AuctionDurationUpdated(uint256 duration)"
442
456
  ];
443
457
  var SimpleBountySystem = [
@@ -447,10 +461,8 @@ var require_abi = __commonJS({
447
461
  // Bounty Creation
448
462
  "function createBounty(string title, string description, string ipfsCID, uint256 reward, uint256 deadline) returns (uint256)",
449
463
  "function createBountyAdvanced(string title, string description, string ipfsCID, uint256 reward, uint256 deadline, uint256 votingDuration, uint8 mode, uint8 libraryAction, address assignee, string libraryKey) returns (uint256)",
450
- // Submission & Claiming
451
- "function claimBounty(uint256 bountyId)",
464
+ // Submission
452
465
  "function submitEntry(uint256 bountyId, string promptIPFS, string deliverableIPFS) returns (uint256)",
453
- "function completeBounty(uint256 bountyId, string deliverableIPFS)",
454
466
  // Voting (COMPETITIVE mode)
455
467
  "function startVoting(uint256 bountyId)",
456
468
  "function vote(uint256 bountyId, uint256 submissionId)",
@@ -529,7 +541,6 @@ var require_abi = __commonJS({
529
541
  Timelock,
530
542
  ERC20Votes,
531
543
  SXXX,
532
- PersonalLibraryFacet,
533
544
  PersonalMarketplace,
534
545
  PersonalLicenseReceipt,
535
546
  TreasuryWrapper,
@@ -3864,15 +3875,17 @@ var require_library = __commonJS({
3864
3875
  return {
3865
3876
  manifestCID: info.manifestCID,
3866
3877
  previousCID: "",
3867
- // Not tracked on-chain in V4 (history is in events/subgraph)
3878
+ // Not tracked on-chain (history is in events/subgraph)
3868
3879
  timestamp: BigInt(info.lastUpdated.toString()),
3869
3880
  proposer: getAddress(info.lastUpdater),
3870
3881
  promptCount: 0,
3871
- // Not tracked on-chain in V4
3882
+ // Not tracked on-chain
3872
3883
  version: info.version,
3873
3884
  nonce: BigInt(info.nonce.toString()),
3874
- forkedFromDAO: info.forkedFromDAO && info.forkedFromDAO !== "0x0000000000000000000000000000000000000000" ? getAddress(info.forkedFromDAO) : null,
3875
- sxxxForkFee: BigInt(info.sxxxForkFee.toString())
3885
+ forkedFromDAO: null,
3886
+ // Removed from on-chain struct; use events/subgraph
3887
+ sxxxForkFee: 0n
3888
+ // Removed from on-chain struct
3876
3889
  };
3877
3890
  }
3878
3891
  async function getLibraryStreamInfo({ provider, registry, subdao, libraryId = "default" }) {
@@ -3892,8 +3905,10 @@ var require_library = __commonJS({
3892
3905
  promptCount: 0,
3893
3906
  version: info.version,
3894
3907
  nonce: BigInt(info.nonce.toString()),
3895
- forkedFromDAO: info.forkedFromDAO && info.forkedFromDAO !== "0x0000000000000000000000000000000000000000" ? getAddress(info.forkedFromDAO) : null,
3896
- sxxxForkFee: BigInt(info.sxxxForkFee.toString())
3908
+ forkedFromDAO: null,
3909
+ // Removed from on-chain struct; use events/subgraph
3910
+ sxxxForkFee: 0n
3911
+ // Removed from on-chain struct
3897
3912
  };
3898
3913
  }
3899
3914
  async function getLibraryIds({ provider, registry, subdao }) {
@@ -4549,8 +4564,8 @@ var require_governance = __commonJS({
4549
4564
  const reg = new Contract(
4550
4565
  targets[i],
4551
4566
  [
4552
- "function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,address forkedFromDAO,uint256 sxxxForkFee))",
4553
- "function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,address forkedFromDAO,uint256 sxxxForkFee,uint256 nonce))"
4567
+ "function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))",
4568
+ "function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))"
4554
4569
  ],
4555
4570
  provider
4556
4571
  );
@@ -4584,8 +4599,8 @@ var require_governance = __commonJS({
4584
4599
  const reg = new Contract(
4585
4600
  targets[i],
4586
4601
  [
4587
- "function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,address forkedFromDAO,uint256 sxxxForkFee))",
4588
- "function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,address forkedFromDAO,uint256 sxxxForkFee,uint256 nonce))"
4602
+ "function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))",
4603
+ "function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))"
4589
4604
  ],
4590
4605
  provider
4591
4606
  );
@@ -4619,8 +4634,8 @@ var require_governance = __commonJS({
4619
4634
  const reg = new Contract(
4620
4635
  targets[i],
4621
4636
  [
4622
- "function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,address forkedFromDAO,uint256 sxxxForkFee,uint256 nonce))",
4623
- "function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,address forkedFromDAO,uint256 sxxxForkFee))"
4637
+ "function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))",
4638
+ "function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))"
4624
4639
  ],
4625
4640
  provider
4626
4641
  );
@@ -4661,8 +4676,8 @@ var require_governance = __commonJS({
4661
4676
  const reg = new Contract(
4662
4677
  targets[i],
4663
4678
  [
4664
- "function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,address forkedFromDAO,uint256 sxxxForkFee,uint256 nonce))",
4665
- "function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,address forkedFromDAO,uint256 sxxxForkFee))"
4679
+ "function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))",
4680
+ "function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))"
4666
4681
  ],
4667
4682
  provider
4668
4683
  );
@@ -6925,6 +6940,7 @@ var require_factory = __commonJS({
6925
6940
  var { Contract, Interface, getAddress } = require("ethers");
6926
6941
  var ABI = require_abi();
6927
6942
  var { SageSDKError, CODES } = require_errors();
6943
+ var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
6928
6944
  function normalise(address, label) {
6929
6945
  if (!address) throw new SageSDKError(CODES.INVALID_ARGS, `${label} required`);
6930
6946
  try {
@@ -6933,6 +6949,14 @@ var require_factory = __commonJS({
6933
6949
  throw new SageSDKError(CODES.INVALID_ARGS, `invalid ${label}`, { cause: err });
6934
6950
  }
6935
6951
  }
6952
+ function normaliseNonZero(address, label) {
6953
+ const addr = normalise(address, label);
6954
+ if (addr === ZERO_ADDRESS) {
6955
+ const hint = label === "operatorAdmin" ? " (set it explicitly; it may be the same as operatorExecutor)" : "";
6956
+ throw new SageSDKError(CODES.INVALID_ARGS, `${label} cannot be zero address${hint}`);
6957
+ }
6958
+ return addr;
6959
+ }
6936
6960
  async function getFactoryConfig({ provider, factory }) {
6937
6961
  if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
6938
6962
  const addr = normalise(factory, "factory");
@@ -6946,7 +6970,6 @@ var require_factory = __commonJS({
6946
6970
  allowStableForkFee,
6947
6971
  timelockMinDelay,
6948
6972
  premiumPromptsAddress,
6949
- simpleKeyStoreAddress,
6950
6973
  governanceConfigAddress,
6951
6974
  libraryRegistryAddress,
6952
6975
  templateModule
@@ -6969,7 +6992,6 @@ var require_factory = __commonJS({
6969
6992
  contract.allowStableForkFee().catch(() => null),
6970
6993
  contract.timelockMinDelay().catch(() => null),
6971
6994
  contract.premiumPromptsAddress().catch(() => null),
6972
- contract.simpleKeyStoreAddress().catch(() => null),
6973
6995
  contract.governanceConfigAddress().catch(() => null),
6974
6996
  contract.libraryRegistryAddress().catch(() => null),
6975
6997
  contract.templateModule().catch(() => null)
@@ -6984,7 +7006,6 @@ var require_factory = __commonJS({
6984
7006
  allowStableForkFee,
6985
7007
  timelockMinDelay,
6986
7008
  premiumPromptsAddress: premiumPromptsAddress && premiumPromptsAddress !== "0x0000000000000000000000000000000000000000" ? getAddress(premiumPromptsAddress) : null,
6987
- simpleKeyStoreAddress: simpleKeyStoreAddress && simpleKeyStoreAddress !== "0x0000000000000000000000000000000000000000" ? getAddress(simpleKeyStoreAddress) : null,
6988
7009
  governanceConfigAddress: governanceConfigAddress && governanceConfigAddress !== "0x0000000000000000000000000000000000000000" ? getAddress(governanceConfigAddress) : null,
6989
7010
  libraryRegistryAddress: libraryRegistryAddress && libraryRegistryAddress !== "0x0000000000000000000000000000000000000000" ? getAddress(libraryRegistryAddress) : null,
6990
7011
  templateModule: templateModule ? getAddress(templateModule) : null
@@ -7102,18 +7123,45 @@ var require_factory = __commonJS({
7102
7123
  ]);
7103
7124
  return { to: addr, data: payload, value: 0n };
7104
7125
  }
7105
- function buildCreateForkedSubDAOTx({ factory, newName, newDescription, originalName, originalSubDAO, forker }) {
7126
+ function buildCreateForkedSubDAOTx({
7127
+ factory,
7128
+ newName,
7129
+ newDescription,
7130
+ originalName,
7131
+ originalSubDAO,
7132
+ forker,
7133
+ copyLibrary = false,
7134
+ maxForkFee
7135
+ }) {
7106
7136
  const addr = normalise(factory, "factory");
7107
- const payload = FactoryWriteInterface.encodeFunctionData("createForkedSubDAO", [
7137
+ const argsBase = [
7108
7138
  String(newName),
7109
7139
  String(newDescription),
7110
7140
  String(originalName),
7111
7141
  normalise(originalSubDAO, "originalSubDAO"),
7112
7142
  normalise(forker, "forker")
7113
- ]);
7143
+ ];
7144
+ const payload = maxForkFee === void 0 || maxForkFee === null ? FactoryWriteInterface.encodeFunctionData(
7145
+ "createForkedSubDAO(string,string,string,address,address,bool)",
7146
+ [...argsBase, Boolean(copyLibrary)]
7147
+ ) : FactoryWriteInterface.encodeFunctionData(
7148
+ "createForkedSubDAO(string,string,string,address,address,uint256,bool)",
7149
+ [...argsBase, BigInt(maxForkFee), Boolean(copyLibrary)]
7150
+ );
7114
7151
  return { to: addr, data: payload, value: 0n };
7115
7152
  }
7116
- function buildCreateForkedSubDAOWithStableTx({ factory, newName, newDescription, originalName, originalSubDAO, forker, authorizationNonce, permit }) {
7153
+ function buildCreateForkedSubDAOWithStableTx({
7154
+ factory,
7155
+ newName,
7156
+ newDescription,
7157
+ originalName,
7158
+ originalSubDAO,
7159
+ forker,
7160
+ authorizationNonce,
7161
+ permit,
7162
+ copyLibrary = false,
7163
+ maxForkFee
7164
+ }) {
7117
7165
  const addr = normalise(factory, "factory");
7118
7166
  if (!permit) throw new SageSDKError(CODES.INVALID_ARGS, "permit required for stable fork");
7119
7167
  const tuple = [
@@ -7123,7 +7171,7 @@ var require_factory = __commonJS({
7123
7171
  permit.r ?? "0x0000000000000000000000000000000000000000000000000000000000000000",
7124
7172
  permit.s ?? "0x0000000000000000000000000000000000000000000000000000000000000000"
7125
7173
  ];
7126
- const payload = FactoryWriteInterface.encodeFunctionData("createForkedSubDAOWithStable", [
7174
+ const argsBase = [
7127
7175
  String(newName),
7128
7176
  String(newDescription),
7129
7177
  String(originalName),
@@ -7131,7 +7179,14 @@ var require_factory = __commonJS({
7131
7179
  normalise(forker, "forker"),
7132
7180
  Number(authorizationNonce ?? 0),
7133
7181
  tuple
7134
- ]);
7182
+ ];
7183
+ const payload = maxForkFee === void 0 || maxForkFee === null ? FactoryWriteInterface.encodeFunctionData(
7184
+ "createForkedSubDAOWithStable(string,string,string,address,address,uint64,(uint256,uint256,uint8,bytes32,bytes32),bool)",
7185
+ [...argsBase, Boolean(copyLibrary)]
7186
+ ) : FactoryWriteInterface.encodeFunctionData(
7187
+ "createForkedSubDAOWithStable(string,string,string,address,address,uint64,(uint256,uint256,uint8,bytes32,bytes32),uint256,bool)",
7188
+ [...argsBase, BigInt(maxForkFee), Boolean(copyLibrary)]
7189
+ );
7135
7190
  return { to: addr, data: payload, value: 0n };
7136
7191
  }
7137
7192
  function buildCreateSubDAOWithParamsTx({
@@ -7198,7 +7253,7 @@ var require_factory = __commonJS({
7198
7253
  0n,
7199
7254
  // minStakeAmount deprecated
7200
7255
  normalise(operatorExecutor, "operatorExecutor"),
7201
- normalise(operatorAdmin, "operatorAdmin"),
7256
+ normaliseNonZero(operatorAdmin, "operatorAdmin"),
7202
7257
  tuple
7203
7258
  ]);
7204
7259
  return { to: addr, data: payload, value: 0n };
@@ -7230,7 +7285,7 @@ var require_factory = __commonJS({
7230
7285
  0n,
7231
7286
  // minStakeAmount deprecated
7232
7287
  normalise(operatorExecutor, "operatorExecutor"),
7233
- normalise(operatorAdmin, "operatorAdmin"),
7288
+ normaliseNonZero(operatorAdmin, "operatorAdmin"),
7234
7289
  Boolean(anyoneExec),
7235
7290
  Boolean(governorProposer),
7236
7291
  tuple
@@ -7332,10 +7387,8 @@ var require_lineage = __commonJS({
7332
7387
  var { Contract, getAddress } = require("ethers");
7333
7388
  var { SageSDKError, CODES } = require_errors();
7334
7389
  var LINEAGE_ABI = [
7335
- "function libraryByDAO(address) view returns (string manifestCID, address lastUpdater, uint256 lastUpdated, string version, address forkedFromDAO, uint256 sxxxForkFee)",
7336
- "function getLibraryForkFee(address) view returns (uint256)"
7390
+ "function libraryByDAO(address) view returns (string manifestCID, address lastUpdater, uint256 lastUpdated, string version, uint256 nonce)"
7337
7391
  ];
7338
- var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
7339
7392
  function normalise(address, label) {
7340
7393
  if (!address) throw new SageSDKError(CODES.INVALID_ARGS, `${label} required`);
7341
7394
  try {
@@ -7349,13 +7402,7 @@ var require_lineage = __commonJS({
7349
7402
  if (!registry) throw new SageSDKError(CODES.INVALID_ARGS, "registry required");
7350
7403
  if (!subdao) throw new SageSDKError(CODES.INVALID_ARGS, "subdao required");
7351
7404
  try {
7352
- const contract = new Contract(normalise(registry, "registry"), LINEAGE_ABI, provider);
7353
- const info = await contract.libraryByDAO(normalise(subdao, "subdao"));
7354
- const parent = info.forkedFromDAO;
7355
- if (!parent || parent === ZERO_ADDRESS) {
7356
- return null;
7357
- }
7358
- return getAddress(parent).toLowerCase();
7405
+ return null;
7359
7406
  } catch (err) {
7360
7407
  throw new SageSDKError(CODES.CONTRACT_ERROR, "Failed to fetch parent library", { cause: err });
7361
7408
  }
@@ -7365,25 +7412,11 @@ var require_lineage = __commonJS({
7365
7412
  if (!registry) throw new SageSDKError(CODES.INVALID_ARGS, "registry required");
7366
7413
  if (!subdao) throw new SageSDKError(CODES.INVALID_ARGS, "subdao required");
7367
7414
  try {
7368
- const contract = new Contract(normalise(registry, "registry"), LINEAGE_ABI, provider);
7369
- const chain = [];
7370
- let current = normalise(subdao, "subdao");
7371
- const MAX_DEPTH = 100;
7372
- let iterations = 0;
7373
- while (current && iterations < MAX_DEPTH) {
7374
- chain.unshift(getAddress(current).toLowerCase());
7375
- const info = await contract.libraryByDAO(current);
7376
- const parent = info.forkedFromDAO;
7377
- if (!parent || parent === ZERO_ADDRESS) {
7378
- break;
7379
- }
7380
- current = parent;
7381
- iterations++;
7382
- }
7415
+ const addr = getAddress(normalise(subdao, "subdao")).toLowerCase();
7383
7416
  return {
7384
- chain,
7385
- depth: chain.length - 1,
7386
- root: chain[0]
7417
+ chain: [addr],
7418
+ depth: 0,
7419
+ root: addr
7387
7420
  };
7388
7421
  } catch (err) {
7389
7422
  throw new SageSDKError(CODES.CONTRACT_ERROR, "Failed to fetch lineage chain", { cause: err });
@@ -7394,16 +7427,7 @@ var require_lineage = __commonJS({
7394
7427
  return parent !== null;
7395
7428
  }
7396
7429
  async function getLibraryForkFee({ provider, registry, subdao }) {
7397
- if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
7398
- if (!registry) throw new SageSDKError(CODES.INVALID_ARGS, "registry required");
7399
- if (!subdao) throw new SageSDKError(CODES.INVALID_ARGS, "subdao required");
7400
- try {
7401
- const contract = new Contract(normalise(registry, "registry"), LINEAGE_ABI, provider);
7402
- const fee = await contract.getLibraryForkFee(normalise(subdao, "subdao"));
7403
- return BigInt(fee.toString());
7404
- } catch (err) {
7405
- throw new SageSDKError(CODES.CONTRACT_ERROR, "Failed to fetch library fork fee", { cause: err });
7406
- }
7430
+ return 0n;
7407
7431
  }
7408
7432
  async function getLibraryInfo({ provider, registry, subdao }) {
7409
7433
  if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
@@ -7412,10 +7436,11 @@ var require_lineage = __commonJS({
7412
7436
  try {
7413
7437
  const contract = new Contract(normalise(registry, "registry"), LINEAGE_ABI, provider);
7414
7438
  const info = await contract.libraryByDAO(normalise(subdao, "subdao"));
7415
- const parent = info.forkedFromDAO;
7416
7439
  return {
7417
- parentDAO: !parent || parent === ZERO_ADDRESS ? null : getAddress(parent).toLowerCase(),
7418
- forkFee: BigInt(info.sxxxForkFee.toString()),
7440
+ parentDAO: null,
7441
+ // Fork lineage removed from on-chain struct
7442
+ forkFee: 0n,
7443
+ // Fork fees removed from on-chain struct
7419
7444
  manifestCID: info.manifestCID,
7420
7445
  version: info.version
7421
7446
  };
@@ -8611,12 +8636,6 @@ var require_personal = __commonJS({
8611
8636
  var { Interface } = require("ethers");
8612
8637
  var ABI = require_abi();
8613
8638
  var { normaliseAddress, toBytes32Key } = require_helpers();
8614
- function buildCreatePersonalRegistryTx({ factory, policy }) {
8615
- const to = normaliseAddress(factory, "factory");
8616
- const iface = new Interface(ABI.PersonalLibraryFacet);
8617
- const data = iface.encodeFunctionData("createPersonalRegistry", [policy >>> 0]);
8618
- return { to, data, value: 0n };
8619
- }
8620
8639
  function buildSetPriceTx({ marketplace, key, price }) {
8621
8640
  const to = normaliseAddress(marketplace, "marketplace");
8622
8641
  const k = toBytes32Key(key);
@@ -8636,7 +8655,6 @@ var require_personal = __commonJS({
8636
8655
  return { to, data, value: 0n };
8637
8656
  }
8638
8657
  module2.exports = {
8639
- buildCreatePersonalRegistryTx,
8640
8658
  buildSetPriceTx,
8641
8659
  buildBuyTx,
8642
8660
  ...require_receipt(),
@@ -8645,300 +8663,6 @@ var require_personal = __commonJS({
8645
8663
  }
8646
8664
  });
8647
8665
 
8648
- // src/premium/index.js
8649
- var require_premium = __commonJS({
8650
- "src/premium/index.js"(exports2, module2) {
8651
- var axios = require("axios");
8652
- var { getAddress } = require("ethers");
8653
- function safeGetAddress(value) {
8654
- try {
8655
- return getAddress(value);
8656
- } catch {
8657
- return null;
8658
- }
8659
- }
8660
- function mapSafe(list, mapper) {
8661
- const out = [];
8662
- for (const item of list || []) {
8663
- try {
8664
- const v = mapper(item);
8665
- if (v != null) out.push(v);
8666
- } catch {
8667
- }
8668
- }
8669
- return out;
8670
- }
8671
- async function query(url, document, variables) {
8672
- if (!url) throw new Error("subgraph url required");
8673
- const resp = await axios.post(url, { query: document, variables }, { timeout: 1e4 });
8674
- if (resp.data && resp.data.errors) {
8675
- throw new Error(resp.data.errors.map((e) => e.message).join("; "));
8676
- }
8677
- return resp.data.data;
8678
- }
8679
- async function listPremiumPrompts({ url, subdao = null, first = 50, skip = 0, orderBy = "blockTimestamp", orderDirection = "desc" }) {
8680
- const safeOrderBy = ["blockTimestamp", "price"].includes(orderBy) ? orderBy : "blockTimestamp";
8681
- const safeOrderDirection = orderDirection === "asc" ? "asc" : "desc";
8682
- let doc;
8683
- const variables = {
8684
- first: Math.min(Math.max(1, Number(first || 50)), 200),
8685
- skip: Number(skip || 0)
8686
- };
8687
- if (subdao) {
8688
- const addr = safeGetAddress(subdao);
8689
- if (!addr) throw new Error("invalid subdao address");
8690
- variables.subdao = addr.toLowerCase();
8691
- doc = `
8692
- query($subdao: Bytes!, $first: Int!, $skip: Int!) {
8693
- premiumPrompts(
8694
- where: { subdao: $subdao }
8695
- first: $first
8696
- skip: $skip
8697
- orderBy: ${safeOrderBy}
8698
- orderDirection: ${safeOrderDirection}
8699
- ) {
8700
- id
8701
- cidHash
8702
- subdao
8703
- price
8704
- manifestCID
8705
- blockNumber
8706
- blockTimestamp
8707
- transactionHash
8708
- }
8709
- }
8710
- `;
8711
- } else {
8712
- doc = `
8713
- query($first: Int!, $skip: Int!) {
8714
- premiumPrompts(
8715
- first: $first
8716
- skip: $skip
8717
- orderBy: ${safeOrderBy}
8718
- orderDirection: ${safeOrderDirection}
8719
- ) {
8720
- id
8721
- cidHash
8722
- subdao
8723
- price
8724
- manifestCID
8725
- blockNumber
8726
- blockTimestamp
8727
- transactionHash
8728
- }
8729
- }
8730
- `;
8731
- }
8732
- const data = await query(url, doc, variables);
8733
- return mapSafe(data?.premiumPrompts, (p) => {
8734
- const sub = safeGetAddress(p.subdao);
8735
- if (!sub) return null;
8736
- return {
8737
- id: String(p.id),
8738
- cidHash: String(p.cidHash),
8739
- subdao: sub,
8740
- price: BigInt(String(p.price || "0")),
8741
- manifestCID: p.manifestCID || null,
8742
- blockNumber: Number(p.blockNumber || 0),
8743
- blockTimestamp: Number(p.blockTimestamp || 0),
8744
- transactionHash: p.transactionHash || null
8745
- };
8746
- });
8747
- }
8748
- async function getPremiumPrompt({ url, cidHash }) {
8749
- const id2 = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
8750
- const doc = `
8751
- query($id: ID!) {
8752
- premiumPrompt(id: $id) {
8753
- id
8754
- cidHash
8755
- subdao
8756
- price
8757
- manifestCID
8758
- blockNumber
8759
- blockTimestamp
8760
- transactionHash
8761
- }
8762
- premiumPromptStats(id: $id) {
8763
- totalRevenue
8764
- purchaseCount
8765
- uniqueBuyers
8766
- currentHolders
8767
- }
8768
- }
8769
- `;
8770
- const data = await query(url, doc, { id: id2 });
8771
- const p = data?.premiumPrompt;
8772
- if (!p) return null;
8773
- const sub = safeGetAddress(p.subdao);
8774
- if (!sub) return null;
8775
- const stats = data?.premiumPromptStats || {};
8776
- return {
8777
- id: String(p.id),
8778
- cidHash: String(p.cidHash),
8779
- subdao: sub,
8780
- price: BigInt(String(p.price || "0")),
8781
- manifestCID: p.manifestCID || null,
8782
- blockNumber: Number(p.blockNumber || 0),
8783
- blockTimestamp: Number(p.blockTimestamp || 0),
8784
- transactionHash: p.transactionHash || null,
8785
- // Stats
8786
- totalRevenue: stats.totalRevenue ? BigInt(String(stats.totalRevenue)) : null,
8787
- purchaseCount: stats.purchaseCount ? BigInt(String(stats.purchaseCount)) : null,
8788
- uniqueBuyers: stats.uniqueBuyers ? BigInt(String(stats.uniqueBuyers)) : null,
8789
- currentHolders: stats.currentHolders ? BigInt(String(stats.currentHolders)) : null
8790
- };
8791
- }
8792
- async function listPremiumPurchases({ url, cidHash, first = 50, skip = 0 }) {
8793
- const normalizedCidHash = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
8794
- const doc = `
8795
- query($cidHash: Bytes!, $first: Int!, $skip: Int!) {
8796
- premiumPurchases(
8797
- where: { cidHash: $cidHash }
8798
- first: $first
8799
- skip: $skip
8800
- orderBy: blockTimestamp
8801
- orderDirection: desc
8802
- ) {
8803
- id
8804
- cidHash
8805
- buyer
8806
- price
8807
- treasury
8808
- blockNumber
8809
- blockTimestamp
8810
- transactionHash
8811
- }
8812
- }
8813
- `;
8814
- const data = await query(url, doc, {
8815
- cidHash: normalizedCidHash,
8816
- first: Math.min(Math.max(1, Number(first || 50)), 200),
8817
- skip: Number(skip || 0)
8818
- });
8819
- return mapSafe(data?.premiumPurchases, (p) => {
8820
- const buyer = safeGetAddress(p.buyer);
8821
- const treasury = safeGetAddress(p.treasury);
8822
- if (!buyer || !treasury) return null;
8823
- return {
8824
- id: String(p.id),
8825
- cidHash: String(p.cidHash),
8826
- buyer,
8827
- price: BigInt(String(p.price || "0")),
8828
- treasury,
8829
- blockNumber: Number(p.blockNumber || 0),
8830
- blockTimestamp: Number(p.blockTimestamp || 0),
8831
- transactionHash: p.transactionHash || null
8832
- };
8833
- });
8834
- }
8835
- async function hasPurchased({ url, cidHash, holder }) {
8836
- const normalizedCidHash = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
8837
- const normalizedHolder = holder.toLowerCase();
8838
- const id2 = `${normalizedCidHash}-${normalizedHolder}`;
8839
- const doc = `
8840
- query($id: ID!) {
8841
- premiumHolderBalance(id: $id) {
8842
- balance
8843
- }
8844
- }
8845
- `;
8846
- const data = await query(url, doc, { id: id2 });
8847
- const balance = data?.premiumHolderBalance?.balance;
8848
- return balance ? BigInt(String(balance)) > 0n : false;
8849
- }
8850
- async function getHolderBalance({ url, cidHash, holder }) {
8851
- const normalizedCidHash = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
8852
- const normalizedHolder = holder.toLowerCase();
8853
- const id2 = `${normalizedCidHash}-${normalizedHolder}`;
8854
- const doc = `
8855
- query($id: ID!) {
8856
- premiumHolderBalance(id: $id) {
8857
- balance
8858
- updatedAt
8859
- }
8860
- }
8861
- `;
8862
- const data = await query(url, doc, { id: id2 });
8863
- const row = data?.premiumHolderBalance;
8864
- if (!row) return 0n;
8865
- return BigInt(String(row.balance || "0"));
8866
- }
8867
- async function listHolders({ url, cidHash, first = 100, skip = 0 }) {
8868
- const normalizedCidHash = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
8869
- const doc = `
8870
- query($cidHash: Bytes!, $first: Int!, $skip: Int!) {
8871
- premiumHolderBalances(
8872
- where: { cidHash: $cidHash, balance_gt: "0" }
8873
- first: $first
8874
- skip: $skip
8875
- orderBy: balance
8876
- orderDirection: desc
8877
- ) {
8878
- id
8879
- cidHash
8880
- holder
8881
- balance
8882
- updatedAt
8883
- }
8884
- }
8885
- `;
8886
- const data = await query(url, doc, {
8887
- cidHash: normalizedCidHash,
8888
- first: Math.min(Math.max(1, Number(first || 100)), 500),
8889
- skip: Number(skip || 0)
8890
- });
8891
- return mapSafe(data?.premiumHolderBalances, (h) => {
8892
- const holder = safeGetAddress(h.holder);
8893
- if (!holder) return null;
8894
- return {
8895
- id: String(h.id),
8896
- cidHash: String(h.cidHash),
8897
- holder,
8898
- balance: BigInt(String(h.balance || "0")),
8899
- updatedAt: Number(h.updatedAt || 0)
8900
- };
8901
- });
8902
- }
8903
- async function getRevSplit({ url, subdao }) {
8904
- const addr = safeGetAddress(subdao);
8905
- if (!addr) throw new Error("invalid subdao address");
8906
- const doc = `
8907
- query($id: ID!) {
8908
- premiumRevSplit(id: $id) {
8909
- id
8910
- subdao
8911
- treasuryBps
8912
- protocolBps
8913
- creatorBps
8914
- updatedAt
8915
- }
8916
- }
8917
- `;
8918
- const data = await query(url, doc, { id: addr.toLowerCase() });
8919
- const split = data?.premiumRevSplit;
8920
- if (!split) return null;
8921
- return {
8922
- id: String(split.id),
8923
- subdao: safeGetAddress(split.subdao) || addr,
8924
- treasuryBps: Number(split.treasuryBps || 0),
8925
- protocolBps: Number(split.protocolBps || 0),
8926
- creatorBps: Number(split.creatorBps || 0),
8927
- updatedAt: Number(split.updatedAt || 0)
8928
- };
8929
- }
8930
- module2.exports = {
8931
- listPremiumPrompts,
8932
- getPremiumPrompt,
8933
- listPremiumPurchases,
8934
- hasPurchased,
8935
- getHolderBalance,
8936
- listHolders,
8937
- getRevSplit
8938
- };
8939
- }
8940
- });
8941
-
8942
8666
  // src/utils/privateTx.js
8943
8667
  var require_privateTx = __commonJS({
8944
8668
  "src/utils/privateTx.js"(exports2, module2) {
@@ -9451,70 +9175,146 @@ var require_boost = __commonJS({
9451
9175
  throw new SageSDKError(CODES.RPC_ERROR, "failed to normalise bigint", { cause: err });
9452
9176
  }
9453
9177
  }
9454
- async function getMerkleConfig({ provider, manager, proposalId }) {
9178
+ var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
9179
+ async function getMerkleBoost({ provider, manager, proposalId }) {
9455
9180
  if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
9456
9181
  const addr = normalise(manager, "manager");
9457
9182
  const contract = new Contract(addr, ABI.GovernanceBoostMerkle, provider);
9458
- const config = await contract.getProposalConfig(proposalId).catch(() => null);
9459
- if (!config) return null;
9183
+ const result = await contract.getBoost(proposalId).catch(() => null);
9184
+ if (!result) return null;
9185
+ const [totalPool, totalClaimed, merkleRoot, expiresAt, active, finalized, creator] = result;
9186
+ const creatorAddr = creator ? getAddress(creator) : ZERO_ADDRESS;
9187
+ const pool = toBigInt(totalPool);
9188
+ if (!active && !finalized && pool === 0n && creatorAddr === ZERO_ADDRESS) return null;
9460
9189
  return {
9461
9190
  manager: addr,
9462
- proposalId: Number(config.proposalId ?? proposalId),
9463
- token: config.token ? getAddress(config.token) : null,
9464
- totalAmount: toBigInt(config.totalAmount),
9465
- startTime: Number(config.startTime ?? 0),
9466
- endTime: Number(config.endTime ?? 0),
9467
- merkleRoot: toBigInt(config.merkleRoot ?? 0n)
9191
+ proposalId: Number(proposalId),
9192
+ totalPool: pool,
9193
+ totalClaimed: toBigInt(totalClaimed),
9194
+ merkleRoot,
9195
+ expiresAt: toBigInt(expiresAt),
9196
+ active: Boolean(active),
9197
+ finalized: Boolean(finalized),
9198
+ creator: creatorAddr
9468
9199
  };
9469
9200
  }
9470
- function buildMerkleFundTx({ manager, proposalId, amount }) {
9201
+ function buildMerkleCreateTx({ manager, proposalId, totalPool, amount }) {
9202
+ const addr = normalise(manager, "manager");
9203
+ const pool = totalPool ?? amount;
9204
+ const data = MerkleInterface.encodeFunctionData("createBoost", [Number(proposalId), BigInt(pool ?? 0n)]);
9205
+ return { to: addr, data, value: 0n };
9206
+ }
9207
+ function buildMerkleSetMerkleRootTx({ manager, proposalId, root, merkleRoot }) {
9208
+ const addr = normalise(manager, "manager");
9209
+ const nextRoot = root ?? merkleRoot;
9210
+ const data = MerkleInterface.encodeFunctionData("setMerkleRoot", [Number(proposalId), nextRoot]);
9211
+ return { to: addr, data, value: 0n };
9212
+ }
9213
+ function buildMerkleFinalizeTx({ manager, proposalId }) {
9471
9214
  const addr = normalise(manager, "manager");
9472
- const data = MerkleInterface.encodeFunctionData("fund", [Number(proposalId), BigInt(amount ?? 0n)]);
9215
+ const data = MerkleInterface.encodeFunctionData("finalize", [Number(proposalId)]);
9473
9216
  return { to: addr, data, value: 0n };
9474
9217
  }
9475
- function buildMerkleSetRootTx({ manager, proposalId, merkleRoot }) {
9218
+ function buildMerkleClaimTx({ manager, proposalId, account, amount, proof }) {
9476
9219
  const addr = normalise(manager, "manager");
9477
- const data = MerkleInterface.encodeFunctionData("setRoot", [Number(proposalId), BigInt(merkleRoot ?? 0n)]);
9220
+ const data = MerkleInterface.encodeFunctionData("claim", [
9221
+ Number(proposalId),
9222
+ normalise(account, "account"),
9223
+ BigInt(amount ?? 0n),
9224
+ proof || []
9225
+ ]);
9478
9226
  return { to: addr, data, value: 0n };
9479
9227
  }
9480
- async function getDirectConfig({ provider, manager, proposalId }) {
9228
+ async function getDirectBoost({ provider, manager, proposalId }) {
9481
9229
  if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
9482
9230
  const addr = normalise(manager, "manager");
9483
9231
  const contract = new Contract(addr, ABI.GovernanceBoostDirect, provider);
9484
- const config = await contract.getDirectConfig(proposalId).catch(() => null);
9485
- if (!config) return null;
9232
+ const boost = await contract.getBoost(proposalId).catch(() => null);
9233
+ if (!boost) return null;
9234
+ const creatorAddr = boost.creator ? getAddress(boost.creator) : ZERO_ADDRESS;
9235
+ const pool = toBigInt(boost.totalPool);
9236
+ if (!boost.active && pool === 0n && creatorAddr === ZERO_ADDRESS) return null;
9486
9237
  return {
9487
9238
  manager: addr,
9488
- proposalId: Number(config.proposalId ?? proposalId),
9489
- token: config.token ? getAddress(config.token) : null,
9490
- perVoter: toBigInt(config.perVoter),
9491
- maxVoters: toBigInt(config.maxVoters),
9492
- startTime: Number(config.startTime ?? 0),
9493
- endTime: Number(config.endTime ?? 0)
9239
+ proposalId: Number(boost.proposalId ?? proposalId),
9240
+ creator: creatorAddr,
9241
+ governor: boost.governor ? getAddress(boost.governor) : null,
9242
+ snapshot: toBigInt(boost.snapshot),
9243
+ perVoter: toBigInt(boost.perVoter),
9244
+ maxVoters: toBigInt(boost.maxVoters),
9245
+ votersPaid: toBigInt(boost.votersPaid),
9246
+ minVotes: toBigInt(boost.minVotes),
9247
+ payoutMode: Number(boost.payoutMode ?? 0),
9248
+ support: Number(boost.support ?? 0),
9249
+ startAt: Number(boost.startAt ?? 0),
9250
+ expiresAt: Number(boost.expiresAt ?? 0),
9251
+ totalPool: pool,
9252
+ totalPaid: toBigInt(boost.totalPaid),
9253
+ kind: Number(boost.kind ?? 0),
9254
+ policy: boost.policy ? getAddress(boost.policy) : null,
9255
+ active: Boolean(boost.active),
9256
+ paused: Boolean(boost.paused)
9494
9257
  };
9495
9258
  }
9496
- function buildDirectCreateTx({ manager, proposalId, token, perVoter, maxVoters }) {
9259
+ function buildDirectCreateTx({
9260
+ manager,
9261
+ governor,
9262
+ proposalId,
9263
+ perVoter,
9264
+ maxVoters,
9265
+ kind = 0,
9266
+ policy = ZERO_ADDRESS,
9267
+ minVotes = 0n,
9268
+ payoutMode = 0,
9269
+ support = 0,
9270
+ startAt = 0n,
9271
+ expiresAt = 0n
9272
+ }) {
9497
9273
  const addr = normalise(manager, "manager");
9498
- const data = DirectInterface.encodeFunctionData("create", [
9499
- Number(proposalId),
9500
- normalise(token, "token"),
9274
+ const params = [
9275
+ normalise(governor, "governor"),
9276
+ BigInt(proposalId ?? 0n),
9501
9277
  BigInt(perVoter ?? 0n),
9502
- BigInt(maxVoters ?? 0n)
9503
- ]);
9278
+ BigInt(maxVoters ?? 0n),
9279
+ Number(kind),
9280
+ policy ? normalise(policy, "policy") : ZERO_ADDRESS,
9281
+ BigInt(minVotes ?? 0n),
9282
+ Number(payoutMode),
9283
+ Number(support),
9284
+ BigInt(startAt ?? 0n),
9285
+ BigInt(expiresAt ?? 0n)
9286
+ ];
9287
+ const data = DirectInterface.encodeFunctionData("createBoost", [params]);
9504
9288
  return { to: addr, data, value: 0n };
9505
9289
  }
9506
- function buildDirectFundTx({ manager, proposalId, amount }) {
9290
+ function buildDirectClaimTx({ manager, proposalId, data = "0x" }) {
9291
+ const addr = normalise(manager, "manager");
9292
+ const callData = DirectInterface.encodeFunctionData("claim", [BigInt(proposalId ?? 0n), data]);
9293
+ return { to: addr, data: callData, value: 0n };
9294
+ }
9295
+ function buildDirectFinalizeTx({ manager, proposalId }) {
9507
9296
  const addr = normalise(manager, "manager");
9508
- const data = DirectInterface.encodeFunctionData("fund", [Number(proposalId), BigInt(amount ?? 0n)]);
9297
+ const data = DirectInterface.encodeFunctionData("finalize", [BigInt(proposalId ?? 0n)]);
9509
9298
  return { to: addr, data, value: 0n };
9510
9299
  }
9511
9300
  module2.exports = {
9512
- getMerkleConfig,
9513
- buildMerkleFundTx,
9514
- buildMerkleSetRootTx,
9515
- getDirectConfig,
9301
+ // Merkle manager (GovernanceBoostManagerMerkle)
9302
+ getMerkleBoost,
9303
+ buildMerkleCreateTx,
9304
+ buildMerkleSetMerkleRootTx,
9305
+ buildMerkleFinalizeTx,
9306
+ buildMerkleClaimTx,
9307
+ // Legacy names (back-compat)
9308
+ getMerkleConfig: getMerkleBoost,
9309
+ buildMerkleFundTx: buildMerkleCreateTx,
9310
+ buildMerkleSetRootTx: buildMerkleSetMerkleRootTx,
9311
+ // Direct manager (GovernanceBoostManager)
9312
+ getDirectBoost,
9516
9313
  buildDirectCreateTx,
9517
- buildDirectFundTx
9314
+ buildDirectClaimTx,
9315
+ buildDirectFinalizeTx,
9316
+ // Legacy name (back-compat)
9317
+ getDirectConfig: getDirectBoost
9518
9318
  };
9519
9319
  }
9520
9320
  });
@@ -10661,13 +10461,13 @@ var require_auction = __commonJS({
10661
10461
  }
10662
10462
  async function getConfig({ provider, auctionHouse }) {
10663
10463
  const c = getAuctionContract(provider, auctionHouse);
10664
- const [nft, treasury, weth, timeBuffer, reservePrice, minBidIncrementPercentage, duration, mintTierId, defaultTokenURI, paused, owner] = await Promise.all([
10464
+ const [nft, treasury, weth, timeBuffer, reservePrice, minBidIncrementBps, duration, mintTierId, defaultTokenURI, paused, owner] = await Promise.all([
10665
10465
  c.nft(),
10666
10466
  c.treasury(),
10667
10467
  c.weth(),
10668
10468
  c.timeBuffer(),
10669
10469
  c.reservePrice(),
10670
- c.minBidIncrementPercentage(),
10470
+ c.minBidIncrementBps(),
10671
10471
  c.duration(),
10672
10472
  c.mintTierId(),
10673
10473
  c.defaultTokenURI(),
@@ -10680,7 +10480,7 @@ var require_auction = __commonJS({
10680
10480
  weth: getAddress(weth),
10681
10481
  timeBuffer: BigInt(timeBuffer.toString()),
10682
10482
  reservePrice: BigInt(reservePrice.toString()),
10683
- minBidIncrementPercentage: BigInt(minBidIncrementPercentage.toString()),
10483
+ minBidIncrementBps: BigInt(minBidIncrementBps.toString()),
10684
10484
  duration: BigInt(duration.toString()),
10685
10485
  mintTierId: BigInt(mintTierId.toString()),
10686
10486
  defaultTokenURI: String(defaultTokenURI),
@@ -10736,10 +10536,10 @@ var require_auction = __commonJS({
10736
10536
  const data = iface.encodeFunctionData("setReservePrice", [toBigInt(reservePrice, "reservePrice")]);
10737
10537
  return { to: addr, data, value: 0n };
10738
10538
  }
10739
- function buildSetMinBidIncrementTx({ auctionHouse, percentage }) {
10539
+ function buildSetMinBidIncrementTx({ auctionHouse, bps }) {
10740
10540
  const addr = normaliseAddress(auctionHouse, "auctionHouse");
10741
10541
  const iface = new Interface(ABI.SageAuctionHouse);
10742
- const data = iface.encodeFunctionData("setMinBidIncrementPercentage", [toBigInt(percentage, "percentage")]);
10542
+ const data = iface.encodeFunctionData("setMinBidIncrementBps", [toBigInt(bps, "bps")]);
10743
10543
  return { to: addr, data, value: 0n };
10744
10544
  }
10745
10545
  function buildSetDurationTx({ auctionHouse, duration }) {
@@ -11935,6 +11735,24 @@ ${error}` : ""}`;
11935
11735
  } else if (data.startsWith(require("ethers").id("authorizeBurner(address)").slice(0, 10))) {
11936
11736
  const burner = this.extractAddressFromData(data, 0);
11937
11737
  return { signature: "authorizeBurner(address)", args: [burner] };
11738
+ } else if (data.startsWith(require("ethers").id("createBoost((address,uint256,uint256,uint256,uint8,address,uint96,uint8,uint8,uint256,uint256))").slice(0, 10))) {
11739
+ const { ethers: ethers2 } = require("ethers");
11740
+ const sig = "createBoost((address,uint256,uint256,uint256,uint8,address,uint96,uint8,uint8,uint256,uint256))";
11741
+ const iface = new ethers2.Interface([`function ${sig}`]);
11742
+ const d = iface.decodeFunctionData("createBoost", data);
11743
+ const params = d?.[0] ?? d;
11744
+ const governor = String(params?.governor ?? params?.[0]);
11745
+ const proposalId = (params?.proposalId ?? params?.[1])?.toString();
11746
+ const perVoter = (params?.perVoter ?? params?.[2])?.toString();
11747
+ const maxVoters = (params?.maxVoters ?? params?.[3])?.toString();
11748
+ const kind = (params?.kind ?? params?.[4])?.toString();
11749
+ const policy = String(params?.policy ?? params?.[5]);
11750
+ const minVotes = (params?.minVotes ?? params?.[6])?.toString();
11751
+ const payoutMode = (params?.payoutMode ?? params?.[7])?.toString();
11752
+ const support = (params?.support ?? params?.[8])?.toString();
11753
+ const startAt = (params?.startAt ?? params?.[9])?.toString();
11754
+ const expiresAt = (params?.expiresAt ?? params?.[10])?.toString();
11755
+ return { signature: sig, args: [governor, proposalId, perVoter, maxVoters, kind, policy, minVotes, payoutMode, support, startAt, expiresAt] };
11938
11756
  } else if (data.startsWith(require("ethers").id("createBoost(address,uint256,uint256,uint256,uint8,address,uint96,uint8,uint8,uint256,uint256)").slice(0, 10))) {
11939
11757
  const { ethers: ethers2 } = require("ethers");
11940
11758
  const sig = "createBoost(address,uint256,uint256,uint256,uint8,address,uint96,uint8,uint8,uint256,uint256)";
@@ -12005,39 +11823,6 @@ ${error}` : ""}`;
12005
11823
  const d = iface.decodeFunctionData("forkPromptWithStable", data);
12006
11824
  const args = [`"${String(d[0])}"`, `"${String(d[1])}"`, `"${String(d[2])}"`, `"${String(d[3])}"`, "[permit]"];
12007
11825
  return { signature: sig, args };
12008
- } else if (data.startsWith(require("ethers").id("createPremiumPrompt(bytes32,address,uint256)").slice(0, 10))) {
12009
- const { ethers: ethers2 } = require("ethers");
12010
- const sig = "createPremiumPrompt(bytes32,address,uint256)";
12011
- const iface = new ethers2.Interface([`function ${sig}`]);
12012
- const d = iface.decodeFunctionData("createPremiumPrompt", data);
12013
- const hash = d[0];
12014
- const subdao = d[1];
12015
- const price = d[2].toString();
12016
- return { signature: sig, args: [hash, subdao, price] };
12017
- } else if (data.startsWith(require("ethers").id("createPremiumPromptWithManifest(bytes32,address,uint256,string)").slice(0, 10))) {
12018
- const { ethers: ethers2 } = require("ethers");
12019
- const sig = "createPremiumPromptWithManifest(bytes32,address,uint256,string)";
12020
- const iface = new ethers2.Interface([`function ${sig}`]);
12021
- const d = iface.decodeFunctionData("createPremiumPromptWithManifest", data);
12022
- const hash = d[0];
12023
- const subdao = d[1];
12024
- const price = d[2].toString();
12025
- const manifest = d[3];
12026
- return { signature: sig, args: [hash, subdao, price, `"${manifest}"`] };
12027
- } else if (data.startsWith(require("ethers").id("setWrappedKey(bytes32,bytes,bytes32)").slice(0, 10))) {
12028
- const { ethers: ethers2 } = require("ethers");
12029
- const sig = "setWrappedKey(bytes32,bytes,bytes32)";
12030
- const iface = new ethers2.Interface([`function ${sig}`]);
12031
- const d = iface.decodeFunctionData("setWrappedKey", data);
12032
- const cidHash = d[0];
12033
- const wrapped = d[1];
12034
- const wrapperId = d[2];
12035
- return { signature: sig, args: [cidHash, wrapped, wrapperId] };
12036
- } else if (data.startsWith(require("ethers").id("lockKey(bytes32)").slice(0, 10))) {
12037
- const { ethers: ethers2 } = require("ethers");
12038
- const iface = new ethers2.Interface(["function lockKey(bytes32)"]);
12039
- const d = iface.decodeFunctionData("lockKey", data);
12040
- return { signature: "lockKey(bytes32)", args: [d[0]] };
12041
11826
  } else if (data.startsWith(require("ethers").id("claim(uint256,address,uint256,bytes32[])").slice(0, 10))) {
12042
11827
  const { ethers: ethers2 } = require("ethers");
12043
11828
  const sig = "claim(uint256,address,uint256,bytes32[])";
@@ -12049,18 +11834,6 @@ ${error}` : ""}`;
12049
11834
  const proofArray = (d[3] || []).map((x) => String(x));
12050
11835
  const formattedProof = `[${proofArray.join(",")}]`;
12051
11836
  return { signature: sig, args: [proposalId, account, amount, formattedProof] };
12052
- } else if (data.startsWith(require("ethers").id("purchaseAccess(bytes32)").slice(0, 10))) {
12053
- const { ethers: ethers2 } = require("ethers");
12054
- const iface = new ethers2.Interface(["function purchaseAccess(bytes32)"]);
12055
- const d = iface.decodeFunctionData("purchaseAccess", data);
12056
- return { signature: "purchaseAccess(bytes32)", args: [d[0]] };
12057
- } else if (data.startsWith(require("ethers").id("setProtocolRake(uint96,address)").slice(0, 10))) {
12058
- const { ethers: ethers2 } = require("ethers");
12059
- const iface = new ethers2.Interface(["function setProtocolRake(uint96,address)"]);
12060
- const decoded = iface.decodeFunctionData("setProtocolRake", data);
12061
- const bps = decoded[0].toString();
12062
- const treas = decoded[1];
12063
- return { signature: "setProtocolRake(uint96,address)", args: [bps, treas] };
12064
11837
  } else if (data.startsWith(require("ethers").id("revokeBurner(address)").slice(0, 10))) {
12065
11838
  const burner = this.extractAddressFromData(data, 0);
12066
11839
  return { signature: "revokeBurner(address)", args: [burner] };
@@ -12510,276 +12283,6 @@ var require_typed = __commonJS({
12510
12283
  }
12511
12284
  });
12512
12285
 
12513
- // src/doppler/index.js
12514
- var require_doppler = __commonJS({
12515
- "src/doppler/index.js"(exports2, module2) {
12516
- var { createPublicClient, createWalletClient, http } = require("viem");
12517
- var { privateKeyToAccount } = require("viem/accounts");
12518
- var { erc20Abi } = require("viem");
12519
- var { base, baseSepolia } = require("viem/chains");
12520
- var dopplerLib = require("@whetstone-research/doppler-sdk");
12521
- function getChainById(chainId) {
12522
- if (Number(chainId) === baseSepolia.id) return baseSepolia;
12523
- if (Number(chainId) === base.id) return base;
12524
- return { id: Number(chainId), name: `chain-${chainId}` };
12525
- }
12526
- function initDoppler(opts) {
12527
- const chain = getChainById(opts.chainId);
12528
- const publicClient = createPublicClient({ chain, transport: http(opts.rpcUrl) });
12529
- let walletClient;
12530
- if (opts.privateKey) {
12531
- const pk = opts.privateKey.startsWith("0x") ? opts.privateKey : `0x${opts.privateKey}`;
12532
- const account = privateKeyToAccount(pk);
12533
- walletClient = createWalletClient({ chain, transport: http(opts.rpcUrl), account });
12534
- } else if (opts.account) {
12535
- walletClient = createWalletClient({ chain, transport: http(opts.rpcUrl), account: opts.account });
12536
- }
12537
- const DopplerSDK = dopplerLib.DopplerSDK || dopplerLib.default?.DopplerSDK || dopplerLib;
12538
- const sdk = new DopplerSDK({ publicClient, walletClient, chainId: chain.id });
12539
- return sdk;
12540
- }
12541
- async function deployDynamicAuction(sdk, user, p) {
12542
- const DynamicAuctionBuilder = dopplerLib.DynamicAuctionBuilder || dopplerLib.default?.DynamicAuctionBuilder;
12543
- if (!DynamicAuctionBuilder) throw new Error("DynamicAuctionBuilder missing from doppler-sdk");
12544
- const builder = new DynamicAuctionBuilder().tokenConfig({ name: p.token.name, symbol: p.token.symbol, tokenURI: p.token.tokenURI }).saleConfig({ initialSupply: p.sale.initialSupply, numTokensToSell: p.sale.numTokensToSell, numeraire: p.sale.numeraire }).poolConfig({ fee: p.pool.fee, tickSpacing: p.pool.tickSpacing }).withUserAddress(user);
12545
- if (p.auction && p.auction.startPrice && p.auction.endPrice && typeof builder.auctionByPriceRange === "function") {
12546
- builder.auctionByPriceRange({
12547
- priceRange: { startPrice: p.auction.startPrice, endPrice: p.auction.endPrice },
12548
- minProceeds: p.auction.minProceeds || 0n,
12549
- maxProceeds: p.auction.maxProceeds || 0n,
12550
- durationDays: p.auction.durationDays,
12551
- epochLength: p.auction.epochLength,
12552
- numPdSlugs: p.auction.numPdSlugs || 5
12553
- });
12554
- } else if (typeof builder.auctionByTicks === "function") {
12555
- throw new Error("auctionByPriceRange not supported by current doppler-sdk version; please provide tick params instead");
12556
- } else {
12557
- throw new Error("No supported auction configuration method on doppler-sdk builder");
12558
- }
12559
- builder.withMigration({
12560
- type: p.migration.type || "uniswapV4",
12561
- fee: p.migration.fee,
12562
- tickSpacing: p.migration.tickSpacing,
12563
- lpRecipient: p.migration.lpRecipient
12564
- });
12565
- if (p.governance && typeof builder.withGovernance === "function") {
12566
- builder.withGovernance(p.governance);
12567
- }
12568
- if (p.overrides?.airlock && typeof builder.withAirlock === "function") builder.withAirlock(p.overrides.airlock);
12569
- if (p.overrides?.dopplerDeployer && typeof builder.withDopplerDeployer === "function") builder.withDopplerDeployer(p.overrides.dopplerDeployer);
12570
- if (p.overrides?.governanceFactory && typeof builder.withGovernanceFactory === "function") builder.withGovernanceFactory(p.overrides.governanceFactory);
12571
- if (p.overrides?.v4Initializer && typeof builder.withV4Initializer === "function") builder.withV4Initializer(p.overrides.v4Initializer);
12572
- const params = builder.build();
12573
- const result = await sdk.factory.createDynamicAuction(params);
12574
- return result;
12575
- }
12576
- async function getAuctionStatus(sdk, auctionAddress) {
12577
- const lens = sdk.lens;
12578
- if (lens && typeof lens.getAuctionStatus === "function") {
12579
- return await lens.getAuctionStatus({ auctionAddress });
12580
- }
12581
- return { auctionAddress, note: "Lens API not available in this doppler-sdk version" };
12582
- }
12583
- async function listAuctions(sdk, { limit = 10, cursor } = {}) {
12584
- const lens = sdk.lens;
12585
- if (lens) {
12586
- if (typeof lens.listAuctions === "function") {
12587
- try {
12588
- return await lens.listAuctions({ limit, cursor });
12589
- } catch (e) {
12590
- }
12591
- }
12592
- if (typeof lens.getAuctions === "function") {
12593
- try {
12594
- return await lens.getAuctions({ limit, cursor });
12595
- } catch (e) {
12596
- }
12597
- }
12598
- }
12599
- const fac = sdk.factory;
12600
- if (fac && typeof fac.listAuctions === "function") {
12601
- try {
12602
- return await fac.listAuctions({ limit, cursor });
12603
- } catch (e) {
12604
- }
12605
- }
12606
- return { ok: false, error: "LIST_UNSUPPORTED", message: "Listing auctions not supported by this doppler-sdk version" };
12607
- }
12608
- async function buyTokens(sdk, { auctionAddress, numeraireAmount }) {
12609
- const trade = sdk.trade || sdk.swap || sdk.auction;
12610
- if (trade && typeof trade.buy === "function") {
12611
- try {
12612
- return await trade.buy({ auctionAddress, numeraireAmount });
12613
- } catch (e) {
12614
- }
12615
- }
12616
- return { ok: false, error: "BUY_UNSUPPORTED", message: "Buy not supported by this doppler-sdk version. Use executeV3BuyExactIn/urExecute helpers or upgrade doppler-sdk." };
12617
- }
12618
- async function migrate(sdk, asset) {
12619
- if (sdk.airlock && typeof sdk.airlock.migrate === "function") {
12620
- return await sdk.airlock.migrate({ asset });
12621
- }
12622
- throw new Error("Migrate is not supported by the current doppler-sdk version");
12623
- }
12624
- module2.exports = {
12625
- initDoppler,
12626
- deployDynamicAuction,
12627
- getAuctionStatus,
12628
- listAuctions,
12629
- buyTokens,
12630
- migrate
12631
- };
12632
- module2.exports.deployStaticAuction = async function deployStaticAuction(sdk, user, p) {
12633
- const StaticAuctionBuilder = dopplerLib.StaticAuctionBuilder || dopplerLib.default?.StaticAuctionBuilder;
12634
- if (!StaticAuctionBuilder) throw new Error("StaticAuctionBuilder missing from doppler-sdk");
12635
- const builder = new StaticAuctionBuilder().tokenConfig({ name: p.token.name, symbol: p.token.symbol, tokenURI: p.token.tokenURI }).saleConfig({ initialSupply: p.sale.initialSupply, numTokensToSell: p.sale.numTokensToSell, numeraire: p.sale.numeraire }).poolByTicks({ startTick: p.pool.startTick, endTick: p.pool.endTick, fee: p.pool.fee, numPositions: p.pool.numPositions || 15 }).withUserAddress(user);
12636
- if (p.governance?.noOp) builder.withGovernance({ noOp: true });
12637
- if (p.migration) builder.withMigration(p.migration);
12638
- if (p.modules?.airlock && typeof builder.withAirlock === "function") builder.withAirlock(p.modules.airlock);
12639
- if (p.modules?.v3Initializer && typeof builder.withV3Initializer === "function") builder.withV3Initializer(p.modules.v3Initializer);
12640
- const params = builder.build();
12641
- const res = await sdk.factory.createStaticAuction(params);
12642
- return res;
12643
- };
12644
- module2.exports.getStaticPoolInfo = async function getStaticPoolInfo(sdk, poolAddress) {
12645
- const auction = await sdk.getStaticAuction(poolAddress);
12646
- return auction.getPoolInfo();
12647
- };
12648
- module2.exports.quoteV3ExactIn = async function quoteV3ExactIn(sdk, { tokenIn, tokenOut, amountIn, fee, sqrtPriceLimitX96 = 0n }) {
12649
- return sdk.quoter.quoteExactInputV3({ tokenIn, tokenOut, amountIn, fee, sqrtPriceLimitX96 });
12650
- };
12651
- var WETH_ABI = [
12652
- { type: "function", name: "deposit", stateMutability: "payable", inputs: [], outputs: [] },
12653
- { type: "function", name: "withdraw", stateMutability: "nonpayable", inputs: [{ name: "wad", type: "uint256" }], outputs: [] },
12654
- { type: "function", name: "balanceOf", stateMutability: "view", inputs: [{ name: "a", type: "address" }], outputs: [{ type: "uint256" }] }
12655
- ];
12656
- module2.exports.wrapEthToWethIfNeeded = async function wrapEthToWethIfNeeded({ rpcUrl, chainId, privateKey, weth, owner, minAmount }) {
12657
- const chain = getChainById(chainId);
12658
- const accountObj = privateKeyToAccount(privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`);
12659
- const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
12660
- const walletClient = createWalletClient({ chain, transport: http(rpcUrl), account: accountObj });
12661
- const bal = await publicClient.readContract({ address: weth, abi: WETH_ABI, functionName: "balanceOf", args: [owner] });
12662
- if (bal >= minAmount) return { deposited: 0n };
12663
- const needed = minAmount - bal;
12664
- const hash = await walletClient.writeContract({ address: weth, abi: WETH_ABI, functionName: "deposit", args: [], value: needed });
12665
- await publicClient.waitForTransactionReceipt({ hash });
12666
- return { deposited: needed, hash };
12667
- };
12668
- module2.exports.getDynamicHookInfo = async function getDynamicHookInfo(sdk, hookAddress) {
12669
- const auction = await sdk.getDynamicAuction(hookAddress);
12670
- return auction.getHookInfo();
12671
- };
12672
- module2.exports.quoteV4ExactIn = async function quoteV4ExactIn(sdk, { poolKey, zeroForOne, exactAmount, hookData }) {
12673
- return sdk.quoter.quoteExactInputV4({ poolKey, zeroForOne, exactAmount, hookData });
12674
- };
12675
- var UR_ABI = [
12676
- { name: "execute", type: "function", stateMutability: "payable", inputs: [{ name: "commands", type: "bytes" }, { name: "inputs", type: "bytes[]" }], outputs: [] }
12677
- ];
12678
- module2.exports.urExecute = async function urExecute({ rpcUrl, chainId, privateKey, universalRouter, commands, inputs, value }) {
12679
- const chain = getChainById(chainId);
12680
- const accountObj = privateKeyToAccount(privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`);
12681
- const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
12682
- const walletClient = createWalletClient({ chain, transport: http(rpcUrl), account: accountObj });
12683
- const hash = await walletClient.writeContract({ address: universalRouter, abi: UR_ABI, functionName: "execute", args: [commands, inputs], value: value || 0n });
12684
- const receipt = await publicClient.waitForTransactionReceipt({ hash });
12685
- return { hash, receipt };
12686
- };
12687
- module2.exports.simulateCreateStaticAuction = async function simulateCreateStaticAuction(sdk, builderParams) {
12688
- const StaticAuctionBuilder = dopplerLib.StaticAuctionBuilder || dopplerLib.default?.StaticAuctionBuilder;
12689
- if (!StaticAuctionBuilder) throw new Error("StaticAuctionBuilder missing from doppler-sdk");
12690
- const builder = new StaticAuctionBuilder().tokenConfig(builderParams.token).saleConfig(builderParams.sale).poolByTicks(builderParams.pool).withUserAddress(builderParams.userAddress);
12691
- if (builderParams.governance) builder.withGovernance(builderParams.governance);
12692
- if (builderParams.migration) builder.withMigration(builderParams.migration);
12693
- if (builderParams.modules?.v3Initializer && typeof builder.withV3Initializer === "function") builder.withV3Initializer(builderParams.modules.v3Initializer);
12694
- if (builderParams.modules?.airlock && typeof builder.withAirlock === "function") builder.withAirlock(builderParams.modules.airlock);
12695
- const params = builder.build();
12696
- return sdk.factory.simulateCreateStaticAuction(params);
12697
- };
12698
- module2.exports.simulateBundleExactOut = async function simulateBundleExactOut(sdk, createParams, { tokenIn, tokenOut, amount, fee, sqrtPriceLimitX96 = 0n }) {
12699
- return sdk.factory.simulateBundleExactOutput(createParams, { tokenIn, tokenOut, amount, fee, sqrtPriceLimitX96 });
12700
- };
12701
- module2.exports.factoryBundle = async function factoryBundle(sdk, createParams, { commands, inputs, value }) {
12702
- return sdk.factory.bundle(createParams, commands, inputs, { value });
12703
- };
12704
- var V3_SWAP_ROUTER_ABI = [
12705
- {
12706
- name: "exactInputSingle",
12707
- type: "function",
12708
- stateMutability: "payable",
12709
- inputs: [
12710
- {
12711
- name: "params",
12712
- type: "tuple",
12713
- components: [
12714
- { name: "tokenIn", type: "address" },
12715
- { name: "tokenOut", type: "address" },
12716
- { name: "fee", type: "uint24" },
12717
- { name: "recipient", type: "address" },
12718
- { name: "deadline", type: "uint256" },
12719
- { name: "amountIn", type: "uint256" },
12720
- { name: "amountOutMinimum", type: "uint256" },
12721
- { name: "sqrtPriceLimitX96", type: "uint160" }
12722
- ]
12723
- }
12724
- ],
12725
- outputs: [{ name: "amountOut", type: "uint256" }]
12726
- }
12727
- ];
12728
- module2.exports.executeV3BuyExactIn = async function executeV3BuyExactIn({
12729
- rpcUrl,
12730
- chainId,
12731
- privateKey,
12732
- router,
12733
- tokenIn,
12734
- tokenOut,
12735
- fee,
12736
- amountIn,
12737
- amountOutMinimum,
12738
- recipient,
12739
- deadline
12740
- }) {
12741
- const chain = getChainById(chainId);
12742
- const accountObj = privateKeyToAccount(privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`);
12743
- const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
12744
- const walletClient = createWalletClient({ chain, transport: http(rpcUrl), account: accountObj });
12745
- const allowance = await publicClient.readContract({
12746
- address: tokenIn,
12747
- abi: erc20Abi,
12748
- functionName: "allowance",
12749
- args: [accountObj.address, router]
12750
- });
12751
- if (allowance < amountIn) {
12752
- await walletClient.writeContract({
12753
- address: tokenIn,
12754
- abi: erc20Abi,
12755
- functionName: "approve",
12756
- args: [router, amountIn]
12757
- });
12758
- }
12759
- const hash = await walletClient.writeContract({
12760
- address: router,
12761
- abi: V3_SWAP_ROUTER_ABI,
12762
- functionName: "exactInputSingle",
12763
- args: [
12764
- {
12765
- tokenIn,
12766
- tokenOut,
12767
- fee,
12768
- recipient,
12769
- deadline,
12770
- amountIn,
12771
- amountOutMinimum,
12772
- sqrtPriceLimitX96: 0n
12773
- }
12774
- ],
12775
- value: 0n
12776
- });
12777
- const receipt = await publicClient.waitForTransactionReceipt({ hash });
12778
- return { hash, receipt };
12779
- };
12780
- }
12781
- });
12782
-
12783
12286
  // src/points.js
12784
12287
  var require_points = __commonJS({
12785
12288
  "src/points.js"(exports2, module2) {
@@ -14852,7 +14355,6 @@ var require_src = __commonJS({
14852
14355
  var ipns = require_ipns();
14853
14356
  var token = require_token();
14854
14357
  var personal = require_personal();
14855
- var premium = require_premium();
14856
14358
  var subgraph = require_subgraph();
14857
14359
  var privateTx = require_privateTx();
14858
14360
  var safe = require_safe();
@@ -14871,7 +14373,6 @@ var require_src = __commonJS({
14871
14373
  var walletTyped = require_typed();
14872
14374
  var utils = require_provider();
14873
14375
  var errors = require_errors();
14874
- var doppler = require_doppler();
14875
14376
  var adapters = {
14876
14377
  transports: require_transports(),
14877
14378
  governance: {
@@ -14907,7 +14408,7 @@ var require_src = __commonJS({
14907
14408
  SageEchoExecutor,
14908
14409
  token,
14909
14410
  personal,
14910
- premium,
14411
+ // premium: removed — PremiumPrompts deprecated
14911
14412
  treasury,
14912
14413
  boost,
14913
14414
  // bond module removed; bonds deprecated in CLI/SDK
@@ -14924,7 +14425,6 @@ var require_src = __commonJS({
14924
14425
  }),
14925
14426
  walletTyped,
14926
14427
  errors,
14927
- doppler,
14928
14428
  adapters,
14929
14429
  // Season points helpers (airdrops/testnet)
14930
14430
  points,