@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.
package/dist/index.mjs CHANGED
@@ -20,7 +20,7 @@ var require_package = __commonJS({
20
20
  "package.json"(exports2, module2) {
21
21
  module2.exports = {
22
22
  name: "@sage-protocol/sdk",
23
- version: "0.2.6",
23
+ version: "0.2.9",
24
24
  description: "Backend-agnostic SDK for interacting with the Sage Protocol (governance, SubDAOs, tokens).",
25
25
  main: "dist/index.cjs",
26
26
  module: "dist/index.mjs",
@@ -78,7 +78,6 @@ var require_package = __commonJS({
78
78
  },
79
79
  dependencies: {
80
80
  "@merit-systems/echo-typescript-sdk": "^1.0.17",
81
- "@whetstone-research/doppler-sdk": "^0.0.1-alpha.40",
82
81
  ai: "^5.0.52",
83
82
  axios: "^1.11.0",
84
83
  ethers: "^6.15.0",
@@ -146,7 +145,6 @@ var require_abi = __commonJS({
146
145
  // Core factory reads
147
146
  "function timelockMinDelay() view returns (uint256)",
148
147
  "function premiumPromptsAddress() view returns (address)",
149
- "function simpleKeyStoreAddress() view returns (address)",
150
148
  "function governanceConfigAddress() view returns (address)",
151
149
  "function libraryRegistryAddress() view returns (address)",
152
150
  // Canonical per‑SubDAO mapping
@@ -171,8 +169,14 @@ var require_abi = __commonJS({
171
169
  "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)",
172
170
  "function createSubDAOOperator(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount, address operatorExecutor, address operatorAdmin) returns (address subDAO, address registry)",
173
171
  "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)",
172
+ // Forking (legacy overloads forward with maxForkFee=type(uint256).max)
174
173
  "function createForkedSubDAO(string newName, string newDescription, string originalName, address originalSubDAO, address forker, bool copyLibrary) returns (address subDAO, address registry)",
175
- "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)"
174
+ // Forking (preferred: explicit maxForkFee slippage cap)
175
+ "function createForkedSubDAO(string newName, string newDescription, string originalName, address originalSubDAO, address forker, uint256 maxForkFee, bool copyLibrary) returns (address subDAO, address registry)",
176
+ // Stable-fee forking (legacy overloads forward with maxForkFee=type(uint256).max)
177
+ "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)",
178
+ // Stable-fee forking (preferred: explicit maxForkFee slippage cap)
179
+ "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)"
176
180
  ];
177
181
  var TemplateModule = [
178
182
  "function getActiveTemplates() view returns (uint256[])",
@@ -183,13 +187,11 @@ var require_abi = __commonJS({
183
187
  "function maxCreationBurn() view returns (uint256)"
184
188
  ];
185
189
  var LibraryRegistry = [
186
- "function libraryByDAO(address) view returns (string manifestCID, address lastUpdater, uint256 lastUpdated, string version, address forkedFromDAO, uint256 sxxxForkFee, uint256 nonce)",
190
+ "function libraryByDAO(address) view returns (string manifestCID, address lastUpdater, uint256 lastUpdated, string version, uint256 nonce)",
187
191
  "function daoTimelock(address) view returns (address)",
188
- "function getLibrary(address) view returns (tuple(string manifestCID, address lastUpdater, uint256 lastUpdated, string version, address forkedFromDAO, uint256 sxxxForkFee, uint256 nonce))",
192
+ "function getLibrary(address) view returns (tuple(string manifestCID, address lastUpdater, uint256 lastUpdated, string version, uint256 nonce))",
189
193
  "function getLibraryIds(address dao) view returns (bytes32[] memory)",
190
- "function getLibraryStream(address dao, string libraryId) view returns (tuple(string manifestCID, address lastUpdater, uint256 lastUpdated, string version, address forkedFromDAO, uint256 sxxxForkFee, uint256 nonce))",
191
- "function getLibraryForkFee(address dao) view returns (uint256)",
192
- "function setLibraryForkFee(address dao, uint256 fee)",
194
+ "function getLibraryStream(address dao, string libraryId) view returns (tuple(string manifestCID, address lastUpdater, uint256 lastUpdated, string version, uint256 nonce))",
193
195
  "function updateLibrary(address dao, string manifestCID, string version)",
194
196
  "function updateLibraryCAS(address dao, string manifestCID, string version, uint256 expectedNonce)",
195
197
  "function updateLibraryStream(address dao, string libraryId, string manifestCID, string version)",
@@ -308,9 +310,6 @@ var require_abi = __commonJS({
308
310
  "function getForkBurnDiscount(address) view returns (uint256)",
309
311
  "function totalBurned() view returns (uint256)"
310
312
  ];
311
- var PersonalLibraryFacet = [
312
- "function createPersonalRegistry(uint8 policy) returns (address)"
313
- ];
314
313
  var PersonalMarketplace = [
315
314
  "function setPrice(bytes32 key, uint256 price)",
316
315
  "function purchase(address creator, bytes32 key, uint256 expectedPrice, uint256 deadline)"
@@ -333,14 +332,28 @@ var require_abi = __commonJS({
333
332
  "event TokensSwept(address indexed token, address indexed to, uint256 amount)"
334
333
  ];
335
334
  var GovernanceBoostMerkle = [
336
- "function getProposalConfig(uint256) view returns (tuple(uint256 proposalId,address token,uint256 totalAmount,uint64 startTime,uint64 endTime,uint256 merkleRoot))",
337
- "function fund(uint256 proposalId, uint256 amount)",
338
- "function setRoot(uint256 proposalId, uint256 merkleRoot)"
335
+ "function createBoost(uint256 proposalId, uint256 totalPool)",
336
+ "function setMerkleRoot(uint256 proposalId, bytes32 root)",
337
+ "function finalize(uint256 proposalId)",
338
+ "function claim(uint256 proposalId, address account, uint256 amount, bytes32[] proof)",
339
+ "function getBoost(uint256 proposalId) view returns (uint256 totalPool, uint256 totalClaimed, bytes32 merkleRoot, uint256 expiresAt, bool active, bool finalized, address creator)",
340
+ "function claimed(uint256 proposalId, address account) view returns (bool)",
341
+ "event BoostCreated(uint256 indexed proposalId, address indexed creator, uint256 totalPool)",
342
+ "event MerkleRootSet(uint256 indexed proposalId, bytes32 merkleRoot)",
343
+ "event RewardClaimed(uint256 indexed proposalId, address indexed voter, uint256 amount)",
344
+ "event BoostFinalized(uint256 indexed proposalId, uint256 totalClaimed, uint256 refunded)"
339
345
  ];
340
346
  var GovernanceBoostDirect = [
341
- "function getDirectConfig(uint256) view returns (tuple(uint256 proposalId,address token,uint256 perVoter,uint256 maxVoters,uint64 startTime,uint64 endTime))",
342
- "function create(uint256 proposalId, address token, uint256 perVoter, uint256 maxVoters)",
343
- "function fund(uint256 proposalId, uint256 amount)"
347
+ "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)",
348
+ "function claim(uint256 proposalId, bytes data)",
349
+ "function finalize(uint256 proposalId)",
350
+ "function pause(uint256 proposalId, bool paused)",
351
+ "function setProtocolRake(uint96 rakeBps, address protocolTreasury)",
352
+ "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)",
353
+ "function claimed(uint256 proposalId, address account) view returns (bool)",
354
+ "event BoostCreated(uint256 indexed proposalId, address indexed governor, uint256 perVoter, uint256 maxVoters, uint256 snapshot, uint8 kind, address policy, uint96 minVotes)",
355
+ "event BoostClaimed(uint256 indexed proposalId, address indexed claimer, uint256 amount, uint256 rake)",
356
+ "event BoostFinalized(uint256 indexed proposalId, uint256 paidCount, uint256 refund)"
344
357
  ];
345
358
  var VotingMultiplierNFT = [
346
359
  // Constants
@@ -348,6 +361,7 @@ var require_abi = __commonJS({
348
361
  "function MAX_NFTS_PER_ACCOUNT() view returns (uint256)",
349
362
  // Tier Management
350
363
  "function createTier(address dao, string name, uint256 multiplier, uint256 maxSupply, uint256 price) returns (uint256 tierId)",
364
+ "function createTierViaGovernance(address subdao, string name, uint256 multiplier, uint256 maxSupply, uint256 price) returns (uint256 tierId)",
351
365
  "function getTier(uint256 tierId) view returns (tuple(string name, uint256 multiplier, uint256 maxSupply, uint256 minted, uint256 price, address dao))",
352
366
  "function tierCount() view returns (uint256)",
353
367
  "function tiers(uint256) view returns (string name, uint256 multiplier, uint256 maxSupply, uint256 minted, uint256 price, address dao)",
@@ -420,7 +434,7 @@ var require_abi = __commonJS({
420
434
  "function weth() view returns (address)",
421
435
  "function timeBuffer() view returns (uint256)",
422
436
  "function reservePrice() view returns (uint256)",
423
- "function minBidIncrementPercentage() view returns (uint256)",
437
+ "function minBidIncrementBps() view returns (uint256)",
424
438
  "function duration() view returns (uint256)",
425
439
  "function mintTierId() view returns (uint256)",
426
440
  "function defaultTokenURI() view returns (string)",
@@ -430,7 +444,7 @@ var require_abi = __commonJS({
430
444
  "function paused() view returns (bool)",
431
445
  "function setTimeBuffer(uint256 _timeBuffer)",
432
446
  "function setReservePrice(uint256 _reservePrice)",
433
- "function setMinBidIncrementPercentage(uint256 _minBidIncrementPercentage)",
447
+ "function setMinBidIncrementBps(uint256 _minBidIncrementBps)",
434
448
  "function setDuration(uint256 _duration)",
435
449
  "function setMintTierId(uint256 _tierId)",
436
450
  "function setDefaultTokenURI(string _uri)",
@@ -443,7 +457,7 @@ var require_abi = __commonJS({
443
457
  "event AuctionSettled(uint256 indexed nftId, address winner, uint256 amount)",
444
458
  "event AuctionTimeBufferUpdated(uint256 timeBuffer)",
445
459
  "event AuctionReservePriceUpdated(uint256 reservePrice)",
446
- "event AuctionMinBidIncrementPercentageUpdated(uint256 minBidIncrementPercentage)",
460
+ "event AuctionMinBidIncrementBpsUpdated(uint256 minBidIncrementBps)",
447
461
  "event AuctionDurationUpdated(uint256 duration)"
448
462
  ];
449
463
  var SimpleBountySystem = [
@@ -453,10 +467,8 @@ var require_abi = __commonJS({
453
467
  // Bounty Creation
454
468
  "function createBounty(string title, string description, string ipfsCID, uint256 reward, uint256 deadline) returns (uint256)",
455
469
  "function createBountyAdvanced(string title, string description, string ipfsCID, uint256 reward, uint256 deadline, uint256 votingDuration, uint8 mode, uint8 libraryAction, address assignee, string libraryKey) returns (uint256)",
456
- // Submission & Claiming
457
- "function claimBounty(uint256 bountyId)",
470
+ // Submission
458
471
  "function submitEntry(uint256 bountyId, string promptIPFS, string deliverableIPFS) returns (uint256)",
459
- "function completeBounty(uint256 bountyId, string deliverableIPFS)",
460
472
  // Voting (COMPETITIVE mode)
461
473
  "function startVoting(uint256 bountyId)",
462
474
  "function vote(uint256 bountyId, uint256 submissionId)",
@@ -535,7 +547,6 @@ var require_abi = __commonJS({
535
547
  Timelock,
536
548
  ERC20Votes,
537
549
  SXXX,
538
- PersonalLibraryFacet,
539
550
  PersonalMarketplace,
540
551
  PersonalLicenseReceipt,
541
552
  TreasuryWrapper,
@@ -3870,15 +3881,17 @@ var require_library = __commonJS({
3870
3881
  return {
3871
3882
  manifestCID: info.manifestCID,
3872
3883
  previousCID: "",
3873
- // Not tracked on-chain in V4 (history is in events/subgraph)
3884
+ // Not tracked on-chain (history is in events/subgraph)
3874
3885
  timestamp: BigInt(info.lastUpdated.toString()),
3875
3886
  proposer: getAddress(info.lastUpdater),
3876
3887
  promptCount: 0,
3877
- // Not tracked on-chain in V4
3888
+ // Not tracked on-chain
3878
3889
  version: info.version,
3879
3890
  nonce: BigInt(info.nonce.toString()),
3880
- forkedFromDAO: info.forkedFromDAO && info.forkedFromDAO !== "0x0000000000000000000000000000000000000000" ? getAddress(info.forkedFromDAO) : null,
3881
- sxxxForkFee: BigInt(info.sxxxForkFee.toString())
3891
+ forkedFromDAO: null,
3892
+ // Removed from on-chain struct; use events/subgraph
3893
+ sxxxForkFee: 0n
3894
+ // Removed from on-chain struct
3882
3895
  };
3883
3896
  }
3884
3897
  async function getLibraryStreamInfo({ provider, registry, subdao, libraryId = "default" }) {
@@ -3898,8 +3911,10 @@ var require_library = __commonJS({
3898
3911
  promptCount: 0,
3899
3912
  version: info.version,
3900
3913
  nonce: BigInt(info.nonce.toString()),
3901
- forkedFromDAO: info.forkedFromDAO && info.forkedFromDAO !== "0x0000000000000000000000000000000000000000" ? getAddress(info.forkedFromDAO) : null,
3902
- sxxxForkFee: BigInt(info.sxxxForkFee.toString())
3914
+ forkedFromDAO: null,
3915
+ // Removed from on-chain struct; use events/subgraph
3916
+ sxxxForkFee: 0n
3917
+ // Removed from on-chain struct
3903
3918
  };
3904
3919
  }
3905
3920
  async function getLibraryIds({ provider, registry, subdao }) {
@@ -4555,8 +4570,8 @@ var require_governance = __commonJS({
4555
4570
  const reg = new Contract(
4556
4571
  targets[i],
4557
4572
  [
4558
- "function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,address forkedFromDAO,uint256 sxxxForkFee))",
4559
- "function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,address forkedFromDAO,uint256 sxxxForkFee,uint256 nonce))"
4573
+ "function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))",
4574
+ "function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))"
4560
4575
  ],
4561
4576
  provider
4562
4577
  );
@@ -4590,8 +4605,8 @@ var require_governance = __commonJS({
4590
4605
  const reg = new Contract(
4591
4606
  targets[i],
4592
4607
  [
4593
- "function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,address forkedFromDAO,uint256 sxxxForkFee))",
4594
- "function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,address forkedFromDAO,uint256 sxxxForkFee,uint256 nonce))"
4608
+ "function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))",
4609
+ "function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))"
4595
4610
  ],
4596
4611
  provider
4597
4612
  );
@@ -4625,8 +4640,8 @@ var require_governance = __commonJS({
4625
4640
  const reg = new Contract(
4626
4641
  targets[i],
4627
4642
  [
4628
- "function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,address forkedFromDAO,uint256 sxxxForkFee,uint256 nonce))",
4629
- "function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,address forkedFromDAO,uint256 sxxxForkFee))"
4643
+ "function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))",
4644
+ "function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))"
4630
4645
  ],
4631
4646
  provider
4632
4647
  );
@@ -4667,8 +4682,8 @@ var require_governance = __commonJS({
4667
4682
  const reg = new Contract(
4668
4683
  targets[i],
4669
4684
  [
4670
- "function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,address forkedFromDAO,uint256 sxxxForkFee,uint256 nonce))",
4671
- "function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,address forkedFromDAO,uint256 sxxxForkFee))"
4685
+ "function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))",
4686
+ "function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,uint256 nonce))"
4672
4687
  ],
4673
4688
  provider
4674
4689
  );
@@ -6931,6 +6946,7 @@ var require_factory = __commonJS({
6931
6946
  var { Contract, Interface, getAddress } = __require("ethers");
6932
6947
  var ABI = require_abi();
6933
6948
  var { SageSDKError, CODES } = require_errors();
6949
+ var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
6934
6950
  function normalise(address, label) {
6935
6951
  if (!address) throw new SageSDKError(CODES.INVALID_ARGS, `${label} required`);
6936
6952
  try {
@@ -6939,6 +6955,14 @@ var require_factory = __commonJS({
6939
6955
  throw new SageSDKError(CODES.INVALID_ARGS, `invalid ${label}`, { cause: err });
6940
6956
  }
6941
6957
  }
6958
+ function normaliseNonZero(address, label) {
6959
+ const addr = normalise(address, label);
6960
+ if (addr === ZERO_ADDRESS) {
6961
+ const hint = label === "operatorAdmin" ? " (set it explicitly; it may be the same as operatorExecutor)" : "";
6962
+ throw new SageSDKError(CODES.INVALID_ARGS, `${label} cannot be zero address${hint}`);
6963
+ }
6964
+ return addr;
6965
+ }
6942
6966
  async function getFactoryConfig({ provider, factory }) {
6943
6967
  if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
6944
6968
  const addr = normalise(factory, "factory");
@@ -6952,7 +6976,6 @@ var require_factory = __commonJS({
6952
6976
  allowStableForkFee,
6953
6977
  timelockMinDelay,
6954
6978
  premiumPromptsAddress,
6955
- simpleKeyStoreAddress,
6956
6979
  governanceConfigAddress,
6957
6980
  libraryRegistryAddress,
6958
6981
  templateModule
@@ -6975,7 +6998,6 @@ var require_factory = __commonJS({
6975
6998
  contract.allowStableForkFee().catch(() => null),
6976
6999
  contract.timelockMinDelay().catch(() => null),
6977
7000
  contract.premiumPromptsAddress().catch(() => null),
6978
- contract.simpleKeyStoreAddress().catch(() => null),
6979
7001
  contract.governanceConfigAddress().catch(() => null),
6980
7002
  contract.libraryRegistryAddress().catch(() => null),
6981
7003
  contract.templateModule().catch(() => null)
@@ -6990,7 +7012,6 @@ var require_factory = __commonJS({
6990
7012
  allowStableForkFee,
6991
7013
  timelockMinDelay,
6992
7014
  premiumPromptsAddress: premiumPromptsAddress && premiumPromptsAddress !== "0x0000000000000000000000000000000000000000" ? getAddress(premiumPromptsAddress) : null,
6993
- simpleKeyStoreAddress: simpleKeyStoreAddress && simpleKeyStoreAddress !== "0x0000000000000000000000000000000000000000" ? getAddress(simpleKeyStoreAddress) : null,
6994
7015
  governanceConfigAddress: governanceConfigAddress && governanceConfigAddress !== "0x0000000000000000000000000000000000000000" ? getAddress(governanceConfigAddress) : null,
6995
7016
  libraryRegistryAddress: libraryRegistryAddress && libraryRegistryAddress !== "0x0000000000000000000000000000000000000000" ? getAddress(libraryRegistryAddress) : null,
6996
7017
  templateModule: templateModule ? getAddress(templateModule) : null
@@ -7108,18 +7129,45 @@ var require_factory = __commonJS({
7108
7129
  ]);
7109
7130
  return { to: addr, data: payload, value: 0n };
7110
7131
  }
7111
- function buildCreateForkedSubDAOTx({ factory, newName, newDescription, originalName, originalSubDAO, forker }) {
7132
+ function buildCreateForkedSubDAOTx({
7133
+ factory,
7134
+ newName,
7135
+ newDescription,
7136
+ originalName,
7137
+ originalSubDAO,
7138
+ forker,
7139
+ copyLibrary = false,
7140
+ maxForkFee
7141
+ }) {
7112
7142
  const addr = normalise(factory, "factory");
7113
- const payload = FactoryWriteInterface.encodeFunctionData("createForkedSubDAO", [
7143
+ const argsBase = [
7114
7144
  String(newName),
7115
7145
  String(newDescription),
7116
7146
  String(originalName),
7117
7147
  normalise(originalSubDAO, "originalSubDAO"),
7118
7148
  normalise(forker, "forker")
7119
- ]);
7149
+ ];
7150
+ const payload = maxForkFee === void 0 || maxForkFee === null ? FactoryWriteInterface.encodeFunctionData(
7151
+ "createForkedSubDAO(string,string,string,address,address,bool)",
7152
+ [...argsBase, Boolean(copyLibrary)]
7153
+ ) : FactoryWriteInterface.encodeFunctionData(
7154
+ "createForkedSubDAO(string,string,string,address,address,uint256,bool)",
7155
+ [...argsBase, BigInt(maxForkFee), Boolean(copyLibrary)]
7156
+ );
7120
7157
  return { to: addr, data: payload, value: 0n };
7121
7158
  }
7122
- function buildCreateForkedSubDAOWithStableTx({ factory, newName, newDescription, originalName, originalSubDAO, forker, authorizationNonce, permit }) {
7159
+ function buildCreateForkedSubDAOWithStableTx({
7160
+ factory,
7161
+ newName,
7162
+ newDescription,
7163
+ originalName,
7164
+ originalSubDAO,
7165
+ forker,
7166
+ authorizationNonce,
7167
+ permit,
7168
+ copyLibrary = false,
7169
+ maxForkFee
7170
+ }) {
7123
7171
  const addr = normalise(factory, "factory");
7124
7172
  if (!permit) throw new SageSDKError(CODES.INVALID_ARGS, "permit required for stable fork");
7125
7173
  const tuple = [
@@ -7129,7 +7177,7 @@ var require_factory = __commonJS({
7129
7177
  permit.r ?? "0x0000000000000000000000000000000000000000000000000000000000000000",
7130
7178
  permit.s ?? "0x0000000000000000000000000000000000000000000000000000000000000000"
7131
7179
  ];
7132
- const payload = FactoryWriteInterface.encodeFunctionData("createForkedSubDAOWithStable", [
7180
+ const argsBase = [
7133
7181
  String(newName),
7134
7182
  String(newDescription),
7135
7183
  String(originalName),
@@ -7137,7 +7185,14 @@ var require_factory = __commonJS({
7137
7185
  normalise(forker, "forker"),
7138
7186
  Number(authorizationNonce ?? 0),
7139
7187
  tuple
7140
- ]);
7188
+ ];
7189
+ const payload = maxForkFee === void 0 || maxForkFee === null ? FactoryWriteInterface.encodeFunctionData(
7190
+ "createForkedSubDAOWithStable(string,string,string,address,address,uint64,(uint256,uint256,uint8,bytes32,bytes32),bool)",
7191
+ [...argsBase, Boolean(copyLibrary)]
7192
+ ) : FactoryWriteInterface.encodeFunctionData(
7193
+ "createForkedSubDAOWithStable(string,string,string,address,address,uint64,(uint256,uint256,uint8,bytes32,bytes32),uint256,bool)",
7194
+ [...argsBase, BigInt(maxForkFee), Boolean(copyLibrary)]
7195
+ );
7141
7196
  return { to: addr, data: payload, value: 0n };
7142
7197
  }
7143
7198
  function buildCreateSubDAOWithParamsTx({
@@ -7204,7 +7259,7 @@ var require_factory = __commonJS({
7204
7259
  0n,
7205
7260
  // minStakeAmount deprecated
7206
7261
  normalise(operatorExecutor, "operatorExecutor"),
7207
- normalise(operatorAdmin, "operatorAdmin"),
7262
+ normaliseNonZero(operatorAdmin, "operatorAdmin"),
7208
7263
  tuple
7209
7264
  ]);
7210
7265
  return { to: addr, data: payload, value: 0n };
@@ -7236,7 +7291,7 @@ var require_factory = __commonJS({
7236
7291
  0n,
7237
7292
  // minStakeAmount deprecated
7238
7293
  normalise(operatorExecutor, "operatorExecutor"),
7239
- normalise(operatorAdmin, "operatorAdmin"),
7294
+ normaliseNonZero(operatorAdmin, "operatorAdmin"),
7240
7295
  Boolean(anyoneExec),
7241
7296
  Boolean(governorProposer),
7242
7297
  tuple
@@ -7338,10 +7393,8 @@ var require_lineage = __commonJS({
7338
7393
  var { Contract, getAddress } = __require("ethers");
7339
7394
  var { SageSDKError, CODES } = require_errors();
7340
7395
  var LINEAGE_ABI = [
7341
- "function libraryByDAO(address) view returns (string manifestCID, address lastUpdater, uint256 lastUpdated, string version, address forkedFromDAO, uint256 sxxxForkFee)",
7342
- "function getLibraryForkFee(address) view returns (uint256)"
7396
+ "function libraryByDAO(address) view returns (string manifestCID, address lastUpdater, uint256 lastUpdated, string version, uint256 nonce)"
7343
7397
  ];
7344
- var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
7345
7398
  function normalise(address, label) {
7346
7399
  if (!address) throw new SageSDKError(CODES.INVALID_ARGS, `${label} required`);
7347
7400
  try {
@@ -7355,13 +7408,7 @@ var require_lineage = __commonJS({
7355
7408
  if (!registry) throw new SageSDKError(CODES.INVALID_ARGS, "registry required");
7356
7409
  if (!subdao) throw new SageSDKError(CODES.INVALID_ARGS, "subdao required");
7357
7410
  try {
7358
- const contract = new Contract(normalise(registry, "registry"), LINEAGE_ABI, provider);
7359
- const info = await contract.libraryByDAO(normalise(subdao, "subdao"));
7360
- const parent = info.forkedFromDAO;
7361
- if (!parent || parent === ZERO_ADDRESS) {
7362
- return null;
7363
- }
7364
- return getAddress(parent).toLowerCase();
7411
+ return null;
7365
7412
  } catch (err) {
7366
7413
  throw new SageSDKError(CODES.CONTRACT_ERROR, "Failed to fetch parent library", { cause: err });
7367
7414
  }
@@ -7371,25 +7418,11 @@ var require_lineage = __commonJS({
7371
7418
  if (!registry) throw new SageSDKError(CODES.INVALID_ARGS, "registry required");
7372
7419
  if (!subdao) throw new SageSDKError(CODES.INVALID_ARGS, "subdao required");
7373
7420
  try {
7374
- const contract = new Contract(normalise(registry, "registry"), LINEAGE_ABI, provider);
7375
- const chain = [];
7376
- let current = normalise(subdao, "subdao");
7377
- const MAX_DEPTH = 100;
7378
- let iterations = 0;
7379
- while (current && iterations < MAX_DEPTH) {
7380
- chain.unshift(getAddress(current).toLowerCase());
7381
- const info = await contract.libraryByDAO(current);
7382
- const parent = info.forkedFromDAO;
7383
- if (!parent || parent === ZERO_ADDRESS) {
7384
- break;
7385
- }
7386
- current = parent;
7387
- iterations++;
7388
- }
7421
+ const addr = getAddress(normalise(subdao, "subdao")).toLowerCase();
7389
7422
  return {
7390
- chain,
7391
- depth: chain.length - 1,
7392
- root: chain[0]
7423
+ chain: [addr],
7424
+ depth: 0,
7425
+ root: addr
7393
7426
  };
7394
7427
  } catch (err) {
7395
7428
  throw new SageSDKError(CODES.CONTRACT_ERROR, "Failed to fetch lineage chain", { cause: err });
@@ -7400,16 +7433,7 @@ var require_lineage = __commonJS({
7400
7433
  return parent !== null;
7401
7434
  }
7402
7435
  async function getLibraryForkFee({ provider, registry, subdao }) {
7403
- if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
7404
- if (!registry) throw new SageSDKError(CODES.INVALID_ARGS, "registry required");
7405
- if (!subdao) throw new SageSDKError(CODES.INVALID_ARGS, "subdao required");
7406
- try {
7407
- const contract = new Contract(normalise(registry, "registry"), LINEAGE_ABI, provider);
7408
- const fee = await contract.getLibraryForkFee(normalise(subdao, "subdao"));
7409
- return BigInt(fee.toString());
7410
- } catch (err) {
7411
- throw new SageSDKError(CODES.CONTRACT_ERROR, "Failed to fetch library fork fee", { cause: err });
7412
- }
7436
+ return 0n;
7413
7437
  }
7414
7438
  async function getLibraryInfo({ provider, registry, subdao }) {
7415
7439
  if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
@@ -7418,10 +7442,11 @@ var require_lineage = __commonJS({
7418
7442
  try {
7419
7443
  const contract = new Contract(normalise(registry, "registry"), LINEAGE_ABI, provider);
7420
7444
  const info = await contract.libraryByDAO(normalise(subdao, "subdao"));
7421
- const parent = info.forkedFromDAO;
7422
7445
  return {
7423
- parentDAO: !parent || parent === ZERO_ADDRESS ? null : getAddress(parent).toLowerCase(),
7424
- forkFee: BigInt(info.sxxxForkFee.toString()),
7446
+ parentDAO: null,
7447
+ // Fork lineage removed from on-chain struct
7448
+ forkFee: 0n,
7449
+ // Fork fees removed from on-chain struct
7425
7450
  manifestCID: info.manifestCID,
7426
7451
  version: info.version
7427
7452
  };
@@ -8617,12 +8642,6 @@ var require_personal = __commonJS({
8617
8642
  var { Interface } = __require("ethers");
8618
8643
  var ABI = require_abi();
8619
8644
  var { normaliseAddress, toBytes32Key } = require_helpers();
8620
- function buildCreatePersonalRegistryTx({ factory, policy }) {
8621
- const to = normaliseAddress(factory, "factory");
8622
- const iface = new Interface(ABI.PersonalLibraryFacet);
8623
- const data = iface.encodeFunctionData("createPersonalRegistry", [policy >>> 0]);
8624
- return { to, data, value: 0n };
8625
- }
8626
8645
  function buildSetPriceTx({ marketplace, key, price }) {
8627
8646
  const to = normaliseAddress(marketplace, "marketplace");
8628
8647
  const k = toBytes32Key(key);
@@ -8642,7 +8661,6 @@ var require_personal = __commonJS({
8642
8661
  return { to, data, value: 0n };
8643
8662
  }
8644
8663
  module2.exports = {
8645
- buildCreatePersonalRegistryTx,
8646
8664
  buildSetPriceTx,
8647
8665
  buildBuyTx,
8648
8666
  ...require_receipt(),
@@ -8651,300 +8669,6 @@ var require_personal = __commonJS({
8651
8669
  }
8652
8670
  });
8653
8671
 
8654
- // src/premium/index.js
8655
- var require_premium = __commonJS({
8656
- "src/premium/index.js"(exports2, module2) {
8657
- var axios = __require("axios");
8658
- var { getAddress } = __require("ethers");
8659
- function safeGetAddress(value) {
8660
- try {
8661
- return getAddress(value);
8662
- } catch {
8663
- return null;
8664
- }
8665
- }
8666
- function mapSafe(list, mapper) {
8667
- const out = [];
8668
- for (const item of list || []) {
8669
- try {
8670
- const v = mapper(item);
8671
- if (v != null) out.push(v);
8672
- } catch {
8673
- }
8674
- }
8675
- return out;
8676
- }
8677
- async function query(url, document, variables) {
8678
- if (!url) throw new Error("subgraph url required");
8679
- const resp = await axios.post(url, { query: document, variables }, { timeout: 1e4 });
8680
- if (resp.data && resp.data.errors) {
8681
- throw new Error(resp.data.errors.map((e) => e.message).join("; "));
8682
- }
8683
- return resp.data.data;
8684
- }
8685
- async function listPremiumPrompts({ url, subdao = null, first = 50, skip = 0, orderBy = "blockTimestamp", orderDirection = "desc" }) {
8686
- const safeOrderBy = ["blockTimestamp", "price"].includes(orderBy) ? orderBy : "blockTimestamp";
8687
- const safeOrderDirection = orderDirection === "asc" ? "asc" : "desc";
8688
- let doc;
8689
- const variables = {
8690
- first: Math.min(Math.max(1, Number(first || 50)), 200),
8691
- skip: Number(skip || 0)
8692
- };
8693
- if (subdao) {
8694
- const addr = safeGetAddress(subdao);
8695
- if (!addr) throw new Error("invalid subdao address");
8696
- variables.subdao = addr.toLowerCase();
8697
- doc = `
8698
- query($subdao: Bytes!, $first: Int!, $skip: Int!) {
8699
- premiumPrompts(
8700
- where: { subdao: $subdao }
8701
- first: $first
8702
- skip: $skip
8703
- orderBy: ${safeOrderBy}
8704
- orderDirection: ${safeOrderDirection}
8705
- ) {
8706
- id
8707
- cidHash
8708
- subdao
8709
- price
8710
- manifestCID
8711
- blockNumber
8712
- blockTimestamp
8713
- transactionHash
8714
- }
8715
- }
8716
- `;
8717
- } else {
8718
- doc = `
8719
- query($first: Int!, $skip: Int!) {
8720
- premiumPrompts(
8721
- first: $first
8722
- skip: $skip
8723
- orderBy: ${safeOrderBy}
8724
- orderDirection: ${safeOrderDirection}
8725
- ) {
8726
- id
8727
- cidHash
8728
- subdao
8729
- price
8730
- manifestCID
8731
- blockNumber
8732
- blockTimestamp
8733
- transactionHash
8734
- }
8735
- }
8736
- `;
8737
- }
8738
- const data = await query(url, doc, variables);
8739
- return mapSafe(data?.premiumPrompts, (p) => {
8740
- const sub = safeGetAddress(p.subdao);
8741
- if (!sub) return null;
8742
- return {
8743
- id: String(p.id),
8744
- cidHash: String(p.cidHash),
8745
- subdao: sub,
8746
- price: BigInt(String(p.price || "0")),
8747
- manifestCID: p.manifestCID || null,
8748
- blockNumber: Number(p.blockNumber || 0),
8749
- blockTimestamp: Number(p.blockTimestamp || 0),
8750
- transactionHash: p.transactionHash || null
8751
- };
8752
- });
8753
- }
8754
- async function getPremiumPrompt({ url, cidHash }) {
8755
- const id2 = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
8756
- const doc = `
8757
- query($id: ID!) {
8758
- premiumPrompt(id: $id) {
8759
- id
8760
- cidHash
8761
- subdao
8762
- price
8763
- manifestCID
8764
- blockNumber
8765
- blockTimestamp
8766
- transactionHash
8767
- }
8768
- premiumPromptStats(id: $id) {
8769
- totalRevenue
8770
- purchaseCount
8771
- uniqueBuyers
8772
- currentHolders
8773
- }
8774
- }
8775
- `;
8776
- const data = await query(url, doc, { id: id2 });
8777
- const p = data?.premiumPrompt;
8778
- if (!p) return null;
8779
- const sub = safeGetAddress(p.subdao);
8780
- if (!sub) return null;
8781
- const stats = data?.premiumPromptStats || {};
8782
- return {
8783
- id: String(p.id),
8784
- cidHash: String(p.cidHash),
8785
- subdao: sub,
8786
- price: BigInt(String(p.price || "0")),
8787
- manifestCID: p.manifestCID || null,
8788
- blockNumber: Number(p.blockNumber || 0),
8789
- blockTimestamp: Number(p.blockTimestamp || 0),
8790
- transactionHash: p.transactionHash || null,
8791
- // Stats
8792
- totalRevenue: stats.totalRevenue ? BigInt(String(stats.totalRevenue)) : null,
8793
- purchaseCount: stats.purchaseCount ? BigInt(String(stats.purchaseCount)) : null,
8794
- uniqueBuyers: stats.uniqueBuyers ? BigInt(String(stats.uniqueBuyers)) : null,
8795
- currentHolders: stats.currentHolders ? BigInt(String(stats.currentHolders)) : null
8796
- };
8797
- }
8798
- async function listPremiumPurchases({ url, cidHash, first = 50, skip = 0 }) {
8799
- const normalizedCidHash = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
8800
- const doc = `
8801
- query($cidHash: Bytes!, $first: Int!, $skip: Int!) {
8802
- premiumPurchases(
8803
- where: { cidHash: $cidHash }
8804
- first: $first
8805
- skip: $skip
8806
- orderBy: blockTimestamp
8807
- orderDirection: desc
8808
- ) {
8809
- id
8810
- cidHash
8811
- buyer
8812
- price
8813
- treasury
8814
- blockNumber
8815
- blockTimestamp
8816
- transactionHash
8817
- }
8818
- }
8819
- `;
8820
- const data = await query(url, doc, {
8821
- cidHash: normalizedCidHash,
8822
- first: Math.min(Math.max(1, Number(first || 50)), 200),
8823
- skip: Number(skip || 0)
8824
- });
8825
- return mapSafe(data?.premiumPurchases, (p) => {
8826
- const buyer = safeGetAddress(p.buyer);
8827
- const treasury = safeGetAddress(p.treasury);
8828
- if (!buyer || !treasury) return null;
8829
- return {
8830
- id: String(p.id),
8831
- cidHash: String(p.cidHash),
8832
- buyer,
8833
- price: BigInt(String(p.price || "0")),
8834
- treasury,
8835
- blockNumber: Number(p.blockNumber || 0),
8836
- blockTimestamp: Number(p.blockTimestamp || 0),
8837
- transactionHash: p.transactionHash || null
8838
- };
8839
- });
8840
- }
8841
- async function hasPurchased({ url, cidHash, holder }) {
8842
- const normalizedCidHash = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
8843
- const normalizedHolder = holder.toLowerCase();
8844
- const id2 = `${normalizedCidHash}-${normalizedHolder}`;
8845
- const doc = `
8846
- query($id: ID!) {
8847
- premiumHolderBalance(id: $id) {
8848
- balance
8849
- }
8850
- }
8851
- `;
8852
- const data = await query(url, doc, { id: id2 });
8853
- const balance = data?.premiumHolderBalance?.balance;
8854
- return balance ? BigInt(String(balance)) > 0n : false;
8855
- }
8856
- async function getHolderBalance({ url, cidHash, holder }) {
8857
- const normalizedCidHash = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
8858
- const normalizedHolder = holder.toLowerCase();
8859
- const id2 = `${normalizedCidHash}-${normalizedHolder}`;
8860
- const doc = `
8861
- query($id: ID!) {
8862
- premiumHolderBalance(id: $id) {
8863
- balance
8864
- updatedAt
8865
- }
8866
- }
8867
- `;
8868
- const data = await query(url, doc, { id: id2 });
8869
- const row = data?.premiumHolderBalance;
8870
- if (!row) return 0n;
8871
- return BigInt(String(row.balance || "0"));
8872
- }
8873
- async function listHolders({ url, cidHash, first = 100, skip = 0 }) {
8874
- const normalizedCidHash = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
8875
- const doc = `
8876
- query($cidHash: Bytes!, $first: Int!, $skip: Int!) {
8877
- premiumHolderBalances(
8878
- where: { cidHash: $cidHash, balance_gt: "0" }
8879
- first: $first
8880
- skip: $skip
8881
- orderBy: balance
8882
- orderDirection: desc
8883
- ) {
8884
- id
8885
- cidHash
8886
- holder
8887
- balance
8888
- updatedAt
8889
- }
8890
- }
8891
- `;
8892
- const data = await query(url, doc, {
8893
- cidHash: normalizedCidHash,
8894
- first: Math.min(Math.max(1, Number(first || 100)), 500),
8895
- skip: Number(skip || 0)
8896
- });
8897
- return mapSafe(data?.premiumHolderBalances, (h) => {
8898
- const holder = safeGetAddress(h.holder);
8899
- if (!holder) return null;
8900
- return {
8901
- id: String(h.id),
8902
- cidHash: String(h.cidHash),
8903
- holder,
8904
- balance: BigInt(String(h.balance || "0")),
8905
- updatedAt: Number(h.updatedAt || 0)
8906
- };
8907
- });
8908
- }
8909
- async function getRevSplit({ url, subdao }) {
8910
- const addr = safeGetAddress(subdao);
8911
- if (!addr) throw new Error("invalid subdao address");
8912
- const doc = `
8913
- query($id: ID!) {
8914
- premiumRevSplit(id: $id) {
8915
- id
8916
- subdao
8917
- treasuryBps
8918
- protocolBps
8919
- creatorBps
8920
- updatedAt
8921
- }
8922
- }
8923
- `;
8924
- const data = await query(url, doc, { id: addr.toLowerCase() });
8925
- const split = data?.premiumRevSplit;
8926
- if (!split) return null;
8927
- return {
8928
- id: String(split.id),
8929
- subdao: safeGetAddress(split.subdao) || addr,
8930
- treasuryBps: Number(split.treasuryBps || 0),
8931
- protocolBps: Number(split.protocolBps || 0),
8932
- creatorBps: Number(split.creatorBps || 0),
8933
- updatedAt: Number(split.updatedAt || 0)
8934
- };
8935
- }
8936
- module2.exports = {
8937
- listPremiumPrompts,
8938
- getPremiumPrompt,
8939
- listPremiumPurchases,
8940
- hasPurchased,
8941
- getHolderBalance,
8942
- listHolders,
8943
- getRevSplit
8944
- };
8945
- }
8946
- });
8947
-
8948
8672
  // src/utils/privateTx.js
8949
8673
  var require_privateTx = __commonJS({
8950
8674
  "src/utils/privateTx.js"(exports2, module2) {
@@ -9457,70 +9181,146 @@ var require_boost = __commonJS({
9457
9181
  throw new SageSDKError(CODES.RPC_ERROR, "failed to normalise bigint", { cause: err });
9458
9182
  }
9459
9183
  }
9460
- async function getMerkleConfig({ provider, manager, proposalId }) {
9184
+ var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
9185
+ async function getMerkleBoost({ provider, manager, proposalId }) {
9461
9186
  if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
9462
9187
  const addr = normalise(manager, "manager");
9463
9188
  const contract = new Contract(addr, ABI.GovernanceBoostMerkle, provider);
9464
- const config = await contract.getProposalConfig(proposalId).catch(() => null);
9465
- if (!config) return null;
9189
+ const result = await contract.getBoost(proposalId).catch(() => null);
9190
+ if (!result) return null;
9191
+ const [totalPool, totalClaimed, merkleRoot, expiresAt, active, finalized, creator] = result;
9192
+ const creatorAddr = creator ? getAddress(creator) : ZERO_ADDRESS;
9193
+ const pool = toBigInt(totalPool);
9194
+ if (!active && !finalized && pool === 0n && creatorAddr === ZERO_ADDRESS) return null;
9466
9195
  return {
9467
9196
  manager: addr,
9468
- proposalId: Number(config.proposalId ?? proposalId),
9469
- token: config.token ? getAddress(config.token) : null,
9470
- totalAmount: toBigInt(config.totalAmount),
9471
- startTime: Number(config.startTime ?? 0),
9472
- endTime: Number(config.endTime ?? 0),
9473
- merkleRoot: toBigInt(config.merkleRoot ?? 0n)
9197
+ proposalId: Number(proposalId),
9198
+ totalPool: pool,
9199
+ totalClaimed: toBigInt(totalClaimed),
9200
+ merkleRoot,
9201
+ expiresAt: toBigInt(expiresAt),
9202
+ active: Boolean(active),
9203
+ finalized: Boolean(finalized),
9204
+ creator: creatorAddr
9474
9205
  };
9475
9206
  }
9476
- function buildMerkleFundTx({ manager, proposalId, amount }) {
9207
+ function buildMerkleCreateTx({ manager, proposalId, totalPool, amount }) {
9208
+ const addr = normalise(manager, "manager");
9209
+ const pool = totalPool ?? amount;
9210
+ const data = MerkleInterface.encodeFunctionData("createBoost", [Number(proposalId), BigInt(pool ?? 0n)]);
9211
+ return { to: addr, data, value: 0n };
9212
+ }
9213
+ function buildMerkleSetMerkleRootTx({ manager, proposalId, root, merkleRoot }) {
9214
+ const addr = normalise(manager, "manager");
9215
+ const nextRoot = root ?? merkleRoot;
9216
+ const data = MerkleInterface.encodeFunctionData("setMerkleRoot", [Number(proposalId), nextRoot]);
9217
+ return { to: addr, data, value: 0n };
9218
+ }
9219
+ function buildMerkleFinalizeTx({ manager, proposalId }) {
9477
9220
  const addr = normalise(manager, "manager");
9478
- const data = MerkleInterface.encodeFunctionData("fund", [Number(proposalId), BigInt(amount ?? 0n)]);
9221
+ const data = MerkleInterface.encodeFunctionData("finalize", [Number(proposalId)]);
9479
9222
  return { to: addr, data, value: 0n };
9480
9223
  }
9481
- function buildMerkleSetRootTx({ manager, proposalId, merkleRoot }) {
9224
+ function buildMerkleClaimTx({ manager, proposalId, account, amount, proof }) {
9482
9225
  const addr = normalise(manager, "manager");
9483
- const data = MerkleInterface.encodeFunctionData("setRoot", [Number(proposalId), BigInt(merkleRoot ?? 0n)]);
9226
+ const data = MerkleInterface.encodeFunctionData("claim", [
9227
+ Number(proposalId),
9228
+ normalise(account, "account"),
9229
+ BigInt(amount ?? 0n),
9230
+ proof || []
9231
+ ]);
9484
9232
  return { to: addr, data, value: 0n };
9485
9233
  }
9486
- async function getDirectConfig({ provider, manager, proposalId }) {
9234
+ async function getDirectBoost({ provider, manager, proposalId }) {
9487
9235
  if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
9488
9236
  const addr = normalise(manager, "manager");
9489
9237
  const contract = new Contract(addr, ABI.GovernanceBoostDirect, provider);
9490
- const config = await contract.getDirectConfig(proposalId).catch(() => null);
9491
- if (!config) return null;
9238
+ const boost = await contract.getBoost(proposalId).catch(() => null);
9239
+ if (!boost) return null;
9240
+ const creatorAddr = boost.creator ? getAddress(boost.creator) : ZERO_ADDRESS;
9241
+ const pool = toBigInt(boost.totalPool);
9242
+ if (!boost.active && pool === 0n && creatorAddr === ZERO_ADDRESS) return null;
9492
9243
  return {
9493
9244
  manager: addr,
9494
- proposalId: Number(config.proposalId ?? proposalId),
9495
- token: config.token ? getAddress(config.token) : null,
9496
- perVoter: toBigInt(config.perVoter),
9497
- maxVoters: toBigInt(config.maxVoters),
9498
- startTime: Number(config.startTime ?? 0),
9499
- endTime: Number(config.endTime ?? 0)
9245
+ proposalId: Number(boost.proposalId ?? proposalId),
9246
+ creator: creatorAddr,
9247
+ governor: boost.governor ? getAddress(boost.governor) : null,
9248
+ snapshot: toBigInt(boost.snapshot),
9249
+ perVoter: toBigInt(boost.perVoter),
9250
+ maxVoters: toBigInt(boost.maxVoters),
9251
+ votersPaid: toBigInt(boost.votersPaid),
9252
+ minVotes: toBigInt(boost.minVotes),
9253
+ payoutMode: Number(boost.payoutMode ?? 0),
9254
+ support: Number(boost.support ?? 0),
9255
+ startAt: Number(boost.startAt ?? 0),
9256
+ expiresAt: Number(boost.expiresAt ?? 0),
9257
+ totalPool: pool,
9258
+ totalPaid: toBigInt(boost.totalPaid),
9259
+ kind: Number(boost.kind ?? 0),
9260
+ policy: boost.policy ? getAddress(boost.policy) : null,
9261
+ active: Boolean(boost.active),
9262
+ paused: Boolean(boost.paused)
9500
9263
  };
9501
9264
  }
9502
- function buildDirectCreateTx({ manager, proposalId, token, perVoter, maxVoters }) {
9265
+ function buildDirectCreateTx({
9266
+ manager,
9267
+ governor,
9268
+ proposalId,
9269
+ perVoter,
9270
+ maxVoters,
9271
+ kind = 0,
9272
+ policy = ZERO_ADDRESS,
9273
+ minVotes = 0n,
9274
+ payoutMode = 0,
9275
+ support = 0,
9276
+ startAt = 0n,
9277
+ expiresAt = 0n
9278
+ }) {
9503
9279
  const addr = normalise(manager, "manager");
9504
- const data = DirectInterface.encodeFunctionData("create", [
9505
- Number(proposalId),
9506
- normalise(token, "token"),
9280
+ const params = [
9281
+ normalise(governor, "governor"),
9282
+ BigInt(proposalId ?? 0n),
9507
9283
  BigInt(perVoter ?? 0n),
9508
- BigInt(maxVoters ?? 0n)
9509
- ]);
9284
+ BigInt(maxVoters ?? 0n),
9285
+ Number(kind),
9286
+ policy ? normalise(policy, "policy") : ZERO_ADDRESS,
9287
+ BigInt(minVotes ?? 0n),
9288
+ Number(payoutMode),
9289
+ Number(support),
9290
+ BigInt(startAt ?? 0n),
9291
+ BigInt(expiresAt ?? 0n)
9292
+ ];
9293
+ const data = DirectInterface.encodeFunctionData("createBoost", [params]);
9510
9294
  return { to: addr, data, value: 0n };
9511
9295
  }
9512
- function buildDirectFundTx({ manager, proposalId, amount }) {
9296
+ function buildDirectClaimTx({ manager, proposalId, data = "0x" }) {
9297
+ const addr = normalise(manager, "manager");
9298
+ const callData = DirectInterface.encodeFunctionData("claim", [BigInt(proposalId ?? 0n), data]);
9299
+ return { to: addr, data: callData, value: 0n };
9300
+ }
9301
+ function buildDirectFinalizeTx({ manager, proposalId }) {
9513
9302
  const addr = normalise(manager, "manager");
9514
- const data = DirectInterface.encodeFunctionData("fund", [Number(proposalId), BigInt(amount ?? 0n)]);
9303
+ const data = DirectInterface.encodeFunctionData("finalize", [BigInt(proposalId ?? 0n)]);
9515
9304
  return { to: addr, data, value: 0n };
9516
9305
  }
9517
9306
  module2.exports = {
9518
- getMerkleConfig,
9519
- buildMerkleFundTx,
9520
- buildMerkleSetRootTx,
9521
- getDirectConfig,
9307
+ // Merkle manager (GovernanceBoostManagerMerkle)
9308
+ getMerkleBoost,
9309
+ buildMerkleCreateTx,
9310
+ buildMerkleSetMerkleRootTx,
9311
+ buildMerkleFinalizeTx,
9312
+ buildMerkleClaimTx,
9313
+ // Legacy names (back-compat)
9314
+ getMerkleConfig: getMerkleBoost,
9315
+ buildMerkleFundTx: buildMerkleCreateTx,
9316
+ buildMerkleSetRootTx: buildMerkleSetMerkleRootTx,
9317
+ // Direct manager (GovernanceBoostManager)
9318
+ getDirectBoost,
9522
9319
  buildDirectCreateTx,
9523
- buildDirectFundTx
9320
+ buildDirectClaimTx,
9321
+ buildDirectFinalizeTx,
9322
+ // Legacy name (back-compat)
9323
+ getDirectConfig: getDirectBoost
9524
9324
  };
9525
9325
  }
9526
9326
  });
@@ -10667,13 +10467,13 @@ var require_auction = __commonJS({
10667
10467
  }
10668
10468
  async function getConfig({ provider, auctionHouse }) {
10669
10469
  const c = getAuctionContract(provider, auctionHouse);
10670
- const [nft, treasury, weth, timeBuffer, reservePrice, minBidIncrementPercentage, duration, mintTierId, defaultTokenURI, paused, owner] = await Promise.all([
10470
+ const [nft, treasury, weth, timeBuffer, reservePrice, minBidIncrementBps, duration, mintTierId, defaultTokenURI, paused, owner] = await Promise.all([
10671
10471
  c.nft(),
10672
10472
  c.treasury(),
10673
10473
  c.weth(),
10674
10474
  c.timeBuffer(),
10675
10475
  c.reservePrice(),
10676
- c.minBidIncrementPercentage(),
10476
+ c.minBidIncrementBps(),
10677
10477
  c.duration(),
10678
10478
  c.mintTierId(),
10679
10479
  c.defaultTokenURI(),
@@ -10686,7 +10486,7 @@ var require_auction = __commonJS({
10686
10486
  weth: getAddress(weth),
10687
10487
  timeBuffer: BigInt(timeBuffer.toString()),
10688
10488
  reservePrice: BigInt(reservePrice.toString()),
10689
- minBidIncrementPercentage: BigInt(minBidIncrementPercentage.toString()),
10489
+ minBidIncrementBps: BigInt(minBidIncrementBps.toString()),
10690
10490
  duration: BigInt(duration.toString()),
10691
10491
  mintTierId: BigInt(mintTierId.toString()),
10692
10492
  defaultTokenURI: String(defaultTokenURI),
@@ -10742,10 +10542,10 @@ var require_auction = __commonJS({
10742
10542
  const data = iface.encodeFunctionData("setReservePrice", [toBigInt(reservePrice, "reservePrice")]);
10743
10543
  return { to: addr, data, value: 0n };
10744
10544
  }
10745
- function buildSetMinBidIncrementTx({ auctionHouse, percentage }) {
10545
+ function buildSetMinBidIncrementTx({ auctionHouse, bps }) {
10746
10546
  const addr = normaliseAddress(auctionHouse, "auctionHouse");
10747
10547
  const iface = new Interface(ABI.SageAuctionHouse);
10748
- const data = iface.encodeFunctionData("setMinBidIncrementPercentage", [toBigInt(percentage, "percentage")]);
10548
+ const data = iface.encodeFunctionData("setMinBidIncrementBps", [toBigInt(bps, "bps")]);
10749
10549
  return { to: addr, data, value: 0n };
10750
10550
  }
10751
10551
  function buildSetDurationTx({ auctionHouse, duration }) {
@@ -11941,6 +11741,24 @@ ${error}` : ""}`;
11941
11741
  } else if (data.startsWith(__require("ethers").id("authorizeBurner(address)").slice(0, 10))) {
11942
11742
  const burner = this.extractAddressFromData(data, 0);
11943
11743
  return { signature: "authorizeBurner(address)", args: [burner] };
11744
+ } else if (data.startsWith(__require("ethers").id("createBoost((address,uint256,uint256,uint256,uint8,address,uint96,uint8,uint8,uint256,uint256))").slice(0, 10))) {
11745
+ const { ethers: ethers2 } = __require("ethers");
11746
+ const sig = "createBoost((address,uint256,uint256,uint256,uint8,address,uint96,uint8,uint8,uint256,uint256))";
11747
+ const iface = new ethers2.Interface([`function ${sig}`]);
11748
+ const d = iface.decodeFunctionData("createBoost", data);
11749
+ const params = d?.[0] ?? d;
11750
+ const governor = String(params?.governor ?? params?.[0]);
11751
+ const proposalId = (params?.proposalId ?? params?.[1])?.toString();
11752
+ const perVoter = (params?.perVoter ?? params?.[2])?.toString();
11753
+ const maxVoters = (params?.maxVoters ?? params?.[3])?.toString();
11754
+ const kind = (params?.kind ?? params?.[4])?.toString();
11755
+ const policy = String(params?.policy ?? params?.[5]);
11756
+ const minVotes = (params?.minVotes ?? params?.[6])?.toString();
11757
+ const payoutMode = (params?.payoutMode ?? params?.[7])?.toString();
11758
+ const support = (params?.support ?? params?.[8])?.toString();
11759
+ const startAt = (params?.startAt ?? params?.[9])?.toString();
11760
+ const expiresAt = (params?.expiresAt ?? params?.[10])?.toString();
11761
+ return { signature: sig, args: [governor, proposalId, perVoter, maxVoters, kind, policy, minVotes, payoutMode, support, startAt, expiresAt] };
11944
11762
  } else if (data.startsWith(__require("ethers").id("createBoost(address,uint256,uint256,uint256,uint8,address,uint96,uint8,uint8,uint256,uint256)").slice(0, 10))) {
11945
11763
  const { ethers: ethers2 } = __require("ethers");
11946
11764
  const sig = "createBoost(address,uint256,uint256,uint256,uint8,address,uint96,uint8,uint8,uint256,uint256)";
@@ -12011,39 +11829,6 @@ ${error}` : ""}`;
12011
11829
  const d = iface.decodeFunctionData("forkPromptWithStable", data);
12012
11830
  const args = [`"${String(d[0])}"`, `"${String(d[1])}"`, `"${String(d[2])}"`, `"${String(d[3])}"`, "[permit]"];
12013
11831
  return { signature: sig, args };
12014
- } else if (data.startsWith(__require("ethers").id("createPremiumPrompt(bytes32,address,uint256)").slice(0, 10))) {
12015
- const { ethers: ethers2 } = __require("ethers");
12016
- const sig = "createPremiumPrompt(bytes32,address,uint256)";
12017
- const iface = new ethers2.Interface([`function ${sig}`]);
12018
- const d = iface.decodeFunctionData("createPremiumPrompt", data);
12019
- const hash = d[0];
12020
- const subdao = d[1];
12021
- const price = d[2].toString();
12022
- return { signature: sig, args: [hash, subdao, price] };
12023
- } else if (data.startsWith(__require("ethers").id("createPremiumPromptWithManifest(bytes32,address,uint256,string)").slice(0, 10))) {
12024
- const { ethers: ethers2 } = __require("ethers");
12025
- const sig = "createPremiumPromptWithManifest(bytes32,address,uint256,string)";
12026
- const iface = new ethers2.Interface([`function ${sig}`]);
12027
- const d = iface.decodeFunctionData("createPremiumPromptWithManifest", data);
12028
- const hash = d[0];
12029
- const subdao = d[1];
12030
- const price = d[2].toString();
12031
- const manifest = d[3];
12032
- return { signature: sig, args: [hash, subdao, price, `"${manifest}"`] };
12033
- } else if (data.startsWith(__require("ethers").id("setWrappedKey(bytes32,bytes,bytes32)").slice(0, 10))) {
12034
- const { ethers: ethers2 } = __require("ethers");
12035
- const sig = "setWrappedKey(bytes32,bytes,bytes32)";
12036
- const iface = new ethers2.Interface([`function ${sig}`]);
12037
- const d = iface.decodeFunctionData("setWrappedKey", data);
12038
- const cidHash = d[0];
12039
- const wrapped = d[1];
12040
- const wrapperId = d[2];
12041
- return { signature: sig, args: [cidHash, wrapped, wrapperId] };
12042
- } else if (data.startsWith(__require("ethers").id("lockKey(bytes32)").slice(0, 10))) {
12043
- const { ethers: ethers2 } = __require("ethers");
12044
- const iface = new ethers2.Interface(["function lockKey(bytes32)"]);
12045
- const d = iface.decodeFunctionData("lockKey", data);
12046
- return { signature: "lockKey(bytes32)", args: [d[0]] };
12047
11832
  } else if (data.startsWith(__require("ethers").id("claim(uint256,address,uint256,bytes32[])").slice(0, 10))) {
12048
11833
  const { ethers: ethers2 } = __require("ethers");
12049
11834
  const sig = "claim(uint256,address,uint256,bytes32[])";
@@ -12055,18 +11840,6 @@ ${error}` : ""}`;
12055
11840
  const proofArray = (d[3] || []).map((x) => String(x));
12056
11841
  const formattedProof = `[${proofArray.join(",")}]`;
12057
11842
  return { signature: sig, args: [proposalId, account, amount, formattedProof] };
12058
- } else if (data.startsWith(__require("ethers").id("purchaseAccess(bytes32)").slice(0, 10))) {
12059
- const { ethers: ethers2 } = __require("ethers");
12060
- const iface = new ethers2.Interface(["function purchaseAccess(bytes32)"]);
12061
- const d = iface.decodeFunctionData("purchaseAccess", data);
12062
- return { signature: "purchaseAccess(bytes32)", args: [d[0]] };
12063
- } else if (data.startsWith(__require("ethers").id("setProtocolRake(uint96,address)").slice(0, 10))) {
12064
- const { ethers: ethers2 } = __require("ethers");
12065
- const iface = new ethers2.Interface(["function setProtocolRake(uint96,address)"]);
12066
- const decoded = iface.decodeFunctionData("setProtocolRake", data);
12067
- const bps = decoded[0].toString();
12068
- const treas = decoded[1];
12069
- return { signature: "setProtocolRake(uint96,address)", args: [bps, treas] };
12070
11843
  } else if (data.startsWith(__require("ethers").id("revokeBurner(address)").slice(0, 10))) {
12071
11844
  const burner = this.extractAddressFromData(data, 0);
12072
11845
  return { signature: "revokeBurner(address)", args: [burner] };
@@ -12516,276 +12289,6 @@ var require_typed = __commonJS({
12516
12289
  }
12517
12290
  });
12518
12291
 
12519
- // src/doppler/index.js
12520
- var require_doppler = __commonJS({
12521
- "src/doppler/index.js"(exports2, module2) {
12522
- var { createPublicClient, createWalletClient, http } = __require("viem");
12523
- var { privateKeyToAccount } = __require("viem/accounts");
12524
- var { erc20Abi } = __require("viem");
12525
- var { base, baseSepolia } = __require("viem/chains");
12526
- var dopplerLib = __require("@whetstone-research/doppler-sdk");
12527
- function getChainById(chainId) {
12528
- if (Number(chainId) === baseSepolia.id) return baseSepolia;
12529
- if (Number(chainId) === base.id) return base;
12530
- return { id: Number(chainId), name: `chain-${chainId}` };
12531
- }
12532
- function initDoppler(opts) {
12533
- const chain = getChainById(opts.chainId);
12534
- const publicClient = createPublicClient({ chain, transport: http(opts.rpcUrl) });
12535
- let walletClient;
12536
- if (opts.privateKey) {
12537
- const pk = opts.privateKey.startsWith("0x") ? opts.privateKey : `0x${opts.privateKey}`;
12538
- const account = privateKeyToAccount(pk);
12539
- walletClient = createWalletClient({ chain, transport: http(opts.rpcUrl), account });
12540
- } else if (opts.account) {
12541
- walletClient = createWalletClient({ chain, transport: http(opts.rpcUrl), account: opts.account });
12542
- }
12543
- const DopplerSDK = dopplerLib.DopplerSDK || dopplerLib.default?.DopplerSDK || dopplerLib;
12544
- const sdk = new DopplerSDK({ publicClient, walletClient, chainId: chain.id });
12545
- return sdk;
12546
- }
12547
- async function deployDynamicAuction(sdk, user, p) {
12548
- const DynamicAuctionBuilder = dopplerLib.DynamicAuctionBuilder || dopplerLib.default?.DynamicAuctionBuilder;
12549
- if (!DynamicAuctionBuilder) throw new Error("DynamicAuctionBuilder missing from doppler-sdk");
12550
- 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);
12551
- if (p.auction && p.auction.startPrice && p.auction.endPrice && typeof builder.auctionByPriceRange === "function") {
12552
- builder.auctionByPriceRange({
12553
- priceRange: { startPrice: p.auction.startPrice, endPrice: p.auction.endPrice },
12554
- minProceeds: p.auction.minProceeds || 0n,
12555
- maxProceeds: p.auction.maxProceeds || 0n,
12556
- durationDays: p.auction.durationDays,
12557
- epochLength: p.auction.epochLength,
12558
- numPdSlugs: p.auction.numPdSlugs || 5
12559
- });
12560
- } else if (typeof builder.auctionByTicks === "function") {
12561
- throw new Error("auctionByPriceRange not supported by current doppler-sdk version; please provide tick params instead");
12562
- } else {
12563
- throw new Error("No supported auction configuration method on doppler-sdk builder");
12564
- }
12565
- builder.withMigration({
12566
- type: p.migration.type || "uniswapV4",
12567
- fee: p.migration.fee,
12568
- tickSpacing: p.migration.tickSpacing,
12569
- lpRecipient: p.migration.lpRecipient
12570
- });
12571
- if (p.governance && typeof builder.withGovernance === "function") {
12572
- builder.withGovernance(p.governance);
12573
- }
12574
- if (p.overrides?.airlock && typeof builder.withAirlock === "function") builder.withAirlock(p.overrides.airlock);
12575
- if (p.overrides?.dopplerDeployer && typeof builder.withDopplerDeployer === "function") builder.withDopplerDeployer(p.overrides.dopplerDeployer);
12576
- if (p.overrides?.governanceFactory && typeof builder.withGovernanceFactory === "function") builder.withGovernanceFactory(p.overrides.governanceFactory);
12577
- if (p.overrides?.v4Initializer && typeof builder.withV4Initializer === "function") builder.withV4Initializer(p.overrides.v4Initializer);
12578
- const params = builder.build();
12579
- const result = await sdk.factory.createDynamicAuction(params);
12580
- return result;
12581
- }
12582
- async function getAuctionStatus(sdk, auctionAddress) {
12583
- const lens = sdk.lens;
12584
- if (lens && typeof lens.getAuctionStatus === "function") {
12585
- return await lens.getAuctionStatus({ auctionAddress });
12586
- }
12587
- return { auctionAddress, note: "Lens API not available in this doppler-sdk version" };
12588
- }
12589
- async function listAuctions(sdk, { limit = 10, cursor } = {}) {
12590
- const lens = sdk.lens;
12591
- if (lens) {
12592
- if (typeof lens.listAuctions === "function") {
12593
- try {
12594
- return await lens.listAuctions({ limit, cursor });
12595
- } catch (e) {
12596
- }
12597
- }
12598
- if (typeof lens.getAuctions === "function") {
12599
- try {
12600
- return await lens.getAuctions({ limit, cursor });
12601
- } catch (e) {
12602
- }
12603
- }
12604
- }
12605
- const fac = sdk.factory;
12606
- if (fac && typeof fac.listAuctions === "function") {
12607
- try {
12608
- return await fac.listAuctions({ limit, cursor });
12609
- } catch (e) {
12610
- }
12611
- }
12612
- return { ok: false, error: "LIST_UNSUPPORTED", message: "Listing auctions not supported by this doppler-sdk version" };
12613
- }
12614
- async function buyTokens(sdk, { auctionAddress, numeraireAmount }) {
12615
- const trade = sdk.trade || sdk.swap || sdk.auction;
12616
- if (trade && typeof trade.buy === "function") {
12617
- try {
12618
- return await trade.buy({ auctionAddress, numeraireAmount });
12619
- } catch (e) {
12620
- }
12621
- }
12622
- return { ok: false, error: "BUY_UNSUPPORTED", message: "Buy not supported by this doppler-sdk version. Use executeV3BuyExactIn/urExecute helpers or upgrade doppler-sdk." };
12623
- }
12624
- async function migrate(sdk, asset) {
12625
- if (sdk.airlock && typeof sdk.airlock.migrate === "function") {
12626
- return await sdk.airlock.migrate({ asset });
12627
- }
12628
- throw new Error("Migrate is not supported by the current doppler-sdk version");
12629
- }
12630
- module2.exports = {
12631
- initDoppler,
12632
- deployDynamicAuction,
12633
- getAuctionStatus,
12634
- listAuctions,
12635
- buyTokens,
12636
- migrate
12637
- };
12638
- module2.exports.deployStaticAuction = async function deployStaticAuction(sdk, user, p) {
12639
- const StaticAuctionBuilder = dopplerLib.StaticAuctionBuilder || dopplerLib.default?.StaticAuctionBuilder;
12640
- if (!StaticAuctionBuilder) throw new Error("StaticAuctionBuilder missing from doppler-sdk");
12641
- 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);
12642
- if (p.governance?.noOp) builder.withGovernance({ noOp: true });
12643
- if (p.migration) builder.withMigration(p.migration);
12644
- if (p.modules?.airlock && typeof builder.withAirlock === "function") builder.withAirlock(p.modules.airlock);
12645
- if (p.modules?.v3Initializer && typeof builder.withV3Initializer === "function") builder.withV3Initializer(p.modules.v3Initializer);
12646
- const params = builder.build();
12647
- const res = await sdk.factory.createStaticAuction(params);
12648
- return res;
12649
- };
12650
- module2.exports.getStaticPoolInfo = async function getStaticPoolInfo(sdk, poolAddress) {
12651
- const auction = await sdk.getStaticAuction(poolAddress);
12652
- return auction.getPoolInfo();
12653
- };
12654
- module2.exports.quoteV3ExactIn = async function quoteV3ExactIn(sdk, { tokenIn, tokenOut, amountIn, fee, sqrtPriceLimitX96 = 0n }) {
12655
- return sdk.quoter.quoteExactInputV3({ tokenIn, tokenOut, amountIn, fee, sqrtPriceLimitX96 });
12656
- };
12657
- var WETH_ABI = [
12658
- { type: "function", name: "deposit", stateMutability: "payable", inputs: [], outputs: [] },
12659
- { type: "function", name: "withdraw", stateMutability: "nonpayable", inputs: [{ name: "wad", type: "uint256" }], outputs: [] },
12660
- { type: "function", name: "balanceOf", stateMutability: "view", inputs: [{ name: "a", type: "address" }], outputs: [{ type: "uint256" }] }
12661
- ];
12662
- module2.exports.wrapEthToWethIfNeeded = async function wrapEthToWethIfNeeded({ rpcUrl, chainId, privateKey, weth, owner, minAmount }) {
12663
- const chain = getChainById(chainId);
12664
- const accountObj = privateKeyToAccount(privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`);
12665
- const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
12666
- const walletClient = createWalletClient({ chain, transport: http(rpcUrl), account: accountObj });
12667
- const bal = await publicClient.readContract({ address: weth, abi: WETH_ABI, functionName: "balanceOf", args: [owner] });
12668
- if (bal >= minAmount) return { deposited: 0n };
12669
- const needed = minAmount - bal;
12670
- const hash = await walletClient.writeContract({ address: weth, abi: WETH_ABI, functionName: "deposit", args: [], value: needed });
12671
- await publicClient.waitForTransactionReceipt({ hash });
12672
- return { deposited: needed, hash };
12673
- };
12674
- module2.exports.getDynamicHookInfo = async function getDynamicHookInfo(sdk, hookAddress) {
12675
- const auction = await sdk.getDynamicAuction(hookAddress);
12676
- return auction.getHookInfo();
12677
- };
12678
- module2.exports.quoteV4ExactIn = async function quoteV4ExactIn(sdk, { poolKey, zeroForOne, exactAmount, hookData }) {
12679
- return sdk.quoter.quoteExactInputV4({ poolKey, zeroForOne, exactAmount, hookData });
12680
- };
12681
- var UR_ABI = [
12682
- { name: "execute", type: "function", stateMutability: "payable", inputs: [{ name: "commands", type: "bytes" }, { name: "inputs", type: "bytes[]" }], outputs: [] }
12683
- ];
12684
- module2.exports.urExecute = async function urExecute({ rpcUrl, chainId, privateKey, universalRouter, commands, inputs, value }) {
12685
- const chain = getChainById(chainId);
12686
- const accountObj = privateKeyToAccount(privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`);
12687
- const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
12688
- const walletClient = createWalletClient({ chain, transport: http(rpcUrl), account: accountObj });
12689
- const hash = await walletClient.writeContract({ address: universalRouter, abi: UR_ABI, functionName: "execute", args: [commands, inputs], value: value || 0n });
12690
- const receipt = await publicClient.waitForTransactionReceipt({ hash });
12691
- return { hash, receipt };
12692
- };
12693
- module2.exports.simulateCreateStaticAuction = async function simulateCreateStaticAuction(sdk, builderParams) {
12694
- const StaticAuctionBuilder = dopplerLib.StaticAuctionBuilder || dopplerLib.default?.StaticAuctionBuilder;
12695
- if (!StaticAuctionBuilder) throw new Error("StaticAuctionBuilder missing from doppler-sdk");
12696
- const builder = new StaticAuctionBuilder().tokenConfig(builderParams.token).saleConfig(builderParams.sale).poolByTicks(builderParams.pool).withUserAddress(builderParams.userAddress);
12697
- if (builderParams.governance) builder.withGovernance(builderParams.governance);
12698
- if (builderParams.migration) builder.withMigration(builderParams.migration);
12699
- if (builderParams.modules?.v3Initializer && typeof builder.withV3Initializer === "function") builder.withV3Initializer(builderParams.modules.v3Initializer);
12700
- if (builderParams.modules?.airlock && typeof builder.withAirlock === "function") builder.withAirlock(builderParams.modules.airlock);
12701
- const params = builder.build();
12702
- return sdk.factory.simulateCreateStaticAuction(params);
12703
- };
12704
- module2.exports.simulateBundleExactOut = async function simulateBundleExactOut(sdk, createParams, { tokenIn, tokenOut, amount, fee, sqrtPriceLimitX96 = 0n }) {
12705
- return sdk.factory.simulateBundleExactOutput(createParams, { tokenIn, tokenOut, amount, fee, sqrtPriceLimitX96 });
12706
- };
12707
- module2.exports.factoryBundle = async function factoryBundle(sdk, createParams, { commands, inputs, value }) {
12708
- return sdk.factory.bundle(createParams, commands, inputs, { value });
12709
- };
12710
- var V3_SWAP_ROUTER_ABI = [
12711
- {
12712
- name: "exactInputSingle",
12713
- type: "function",
12714
- stateMutability: "payable",
12715
- inputs: [
12716
- {
12717
- name: "params",
12718
- type: "tuple",
12719
- components: [
12720
- { name: "tokenIn", type: "address" },
12721
- { name: "tokenOut", type: "address" },
12722
- { name: "fee", type: "uint24" },
12723
- { name: "recipient", type: "address" },
12724
- { name: "deadline", type: "uint256" },
12725
- { name: "amountIn", type: "uint256" },
12726
- { name: "amountOutMinimum", type: "uint256" },
12727
- { name: "sqrtPriceLimitX96", type: "uint160" }
12728
- ]
12729
- }
12730
- ],
12731
- outputs: [{ name: "amountOut", type: "uint256" }]
12732
- }
12733
- ];
12734
- module2.exports.executeV3BuyExactIn = async function executeV3BuyExactIn({
12735
- rpcUrl,
12736
- chainId,
12737
- privateKey,
12738
- router,
12739
- tokenIn,
12740
- tokenOut,
12741
- fee,
12742
- amountIn,
12743
- amountOutMinimum,
12744
- recipient,
12745
- deadline
12746
- }) {
12747
- const chain = getChainById(chainId);
12748
- const accountObj = privateKeyToAccount(privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`);
12749
- const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
12750
- const walletClient = createWalletClient({ chain, transport: http(rpcUrl), account: accountObj });
12751
- const allowance = await publicClient.readContract({
12752
- address: tokenIn,
12753
- abi: erc20Abi,
12754
- functionName: "allowance",
12755
- args: [accountObj.address, router]
12756
- });
12757
- if (allowance < amountIn) {
12758
- await walletClient.writeContract({
12759
- address: tokenIn,
12760
- abi: erc20Abi,
12761
- functionName: "approve",
12762
- args: [router, amountIn]
12763
- });
12764
- }
12765
- const hash = await walletClient.writeContract({
12766
- address: router,
12767
- abi: V3_SWAP_ROUTER_ABI,
12768
- functionName: "exactInputSingle",
12769
- args: [
12770
- {
12771
- tokenIn,
12772
- tokenOut,
12773
- fee,
12774
- recipient,
12775
- deadline,
12776
- amountIn,
12777
- amountOutMinimum,
12778
- sqrtPriceLimitX96: 0n
12779
- }
12780
- ],
12781
- value: 0n
12782
- });
12783
- const receipt = await publicClient.waitForTransactionReceipt({ hash });
12784
- return { hash, receipt };
12785
- };
12786
- }
12787
- });
12788
-
12789
12292
  // src/points.js
12790
12293
  var require_points = __commonJS({
12791
12294
  "src/points.js"(exports2, module2) {
@@ -14858,7 +14361,6 @@ var require_src = __commonJS({
14858
14361
  var ipns = require_ipns();
14859
14362
  var token = require_token();
14860
14363
  var personal = require_personal();
14861
- var premium = require_premium();
14862
14364
  var subgraph = require_subgraph();
14863
14365
  var privateTx = require_privateTx();
14864
14366
  var safe = require_safe();
@@ -14877,7 +14379,6 @@ var require_src = __commonJS({
14877
14379
  var walletTyped = require_typed();
14878
14380
  var utils = require_provider();
14879
14381
  var errors = require_errors();
14880
- var doppler = require_doppler();
14881
14382
  var adapters = {
14882
14383
  transports: require_transports(),
14883
14384
  governance: {
@@ -14913,7 +14414,7 @@ var require_src = __commonJS({
14913
14414
  SageEchoExecutor,
14914
14415
  token,
14915
14416
  personal,
14916
- premium,
14417
+ // premium: removed — PremiumPrompts deprecated
14917
14418
  treasury,
14918
14419
  boost,
14919
14420
  // bond module removed; bonds deprecated in CLI/SDK
@@ -14930,7 +14431,6 @@ var require_src = __commonJS({
14930
14431
  }),
14931
14432
  walletTyped,
14932
14433
  errors,
14933
- doppler,
14934
14434
  adapters,
14935
14435
  // Season points helpers (airdrops/testnet)
14936
14436
  points,