@sage-protocol/sdk 0.2.8 → 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/browser/index.mjs +16 -19
- package/dist/index.cjs +111 -692
- package/dist/index.mjs +111 -692
- package/dist/node/index.cjs +111 -692
- package/dist/node/index.mjs +111 -692
- package/package.json +1 -2
- package/types/index.d.ts +36 -11
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.
|
|
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",
|
|
@@ -170,8 +169,14 @@ var require_abi = __commonJS({
|
|
|
170
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)",
|
|
171
170
|
"function createSubDAOOperator(string name, string description, uint8 accessModel, uint256 minStakeAmount, uint256 burnAmount, address operatorExecutor, address operatorAdmin) returns (address subDAO, address registry)",
|
|
172
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)
|
|
173
173
|
"function createForkedSubDAO(string newName, string newDescription, string originalName, address originalSubDAO, address forker, bool copyLibrary) returns (address subDAO, address registry)",
|
|
174
|
-
|
|
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)"
|
|
175
180
|
];
|
|
176
181
|
var TemplateModule = [
|
|
177
182
|
"function getActiveTemplates() view returns (uint256[])",
|
|
@@ -182,13 +187,11 @@ var require_abi = __commonJS({
|
|
|
182
187
|
"function maxCreationBurn() view returns (uint256)"
|
|
183
188
|
];
|
|
184
189
|
var LibraryRegistry = [
|
|
185
|
-
"function libraryByDAO(address) view returns (string manifestCID, address lastUpdater, uint256 lastUpdated, string version,
|
|
190
|
+
"function libraryByDAO(address) view returns (string manifestCID, address lastUpdater, uint256 lastUpdated, string version, uint256 nonce)",
|
|
186
191
|
"function daoTimelock(address) view returns (address)",
|
|
187
|
-
"function getLibrary(address) view returns (tuple(string manifestCID, address lastUpdater, uint256 lastUpdated, string version,
|
|
192
|
+
"function getLibrary(address) view returns (tuple(string manifestCID, address lastUpdater, uint256 lastUpdated, string version, uint256 nonce))",
|
|
188
193
|
"function getLibraryIds(address dao) view returns (bytes32[] memory)",
|
|
189
|
-
"function getLibraryStream(address dao, string libraryId) view returns (tuple(string manifestCID, address lastUpdater, uint256 lastUpdated, string version,
|
|
190
|
-
"function getLibraryForkFee(address dao) view returns (uint256)",
|
|
191
|
-
"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))",
|
|
192
195
|
"function updateLibrary(address dao, string manifestCID, string version)",
|
|
193
196
|
"function updateLibraryCAS(address dao, string manifestCID, string version, uint256 expectedNonce)",
|
|
194
197
|
"function updateLibraryStream(address dao, string libraryId, string manifestCID, string version)",
|
|
@@ -307,9 +310,6 @@ var require_abi = __commonJS({
|
|
|
307
310
|
"function getForkBurnDiscount(address) view returns (uint256)",
|
|
308
311
|
"function totalBurned() view returns (uint256)"
|
|
309
312
|
];
|
|
310
|
-
var PersonalLibraryFacet = [
|
|
311
|
-
"function createPersonalRegistry(uint8 policy) returns (address)"
|
|
312
|
-
];
|
|
313
313
|
var PersonalMarketplace = [
|
|
314
314
|
"function setPrice(bytes32 key, uint256 price)",
|
|
315
315
|
"function purchase(address creator, bytes32 key, uint256 expectedPrice, uint256 deadline)"
|
|
@@ -336,7 +336,7 @@ var require_abi = __commonJS({
|
|
|
336
336
|
"function setMerkleRoot(uint256 proposalId, bytes32 root)",
|
|
337
337
|
"function finalize(uint256 proposalId)",
|
|
338
338
|
"function claim(uint256 proposalId, address account, uint256 amount, bytes32[] proof)",
|
|
339
|
-
"function getBoost(uint256 proposalId) view returns (uint256 totalPool, uint256 totalClaimed, bytes32 merkleRoot, bool active, bool finalized, address creator)",
|
|
339
|
+
"function getBoost(uint256 proposalId) view returns (uint256 totalPool, uint256 totalClaimed, bytes32 merkleRoot, uint256 expiresAt, bool active, bool finalized, address creator)",
|
|
340
340
|
"function claimed(uint256 proposalId, address account) view returns (bool)",
|
|
341
341
|
"event BoostCreated(uint256 indexed proposalId, address indexed creator, uint256 totalPool)",
|
|
342
342
|
"event MerkleRootSet(uint256 indexed proposalId, bytes32 merkleRoot)",
|
|
@@ -434,7 +434,7 @@ var require_abi = __commonJS({
|
|
|
434
434
|
"function weth() view returns (address)",
|
|
435
435
|
"function timeBuffer() view returns (uint256)",
|
|
436
436
|
"function reservePrice() view returns (uint256)",
|
|
437
|
-
"function
|
|
437
|
+
"function minBidIncrementBps() view returns (uint256)",
|
|
438
438
|
"function duration() view returns (uint256)",
|
|
439
439
|
"function mintTierId() view returns (uint256)",
|
|
440
440
|
"function defaultTokenURI() view returns (string)",
|
|
@@ -444,7 +444,7 @@ var require_abi = __commonJS({
|
|
|
444
444
|
"function paused() view returns (bool)",
|
|
445
445
|
"function setTimeBuffer(uint256 _timeBuffer)",
|
|
446
446
|
"function setReservePrice(uint256 _reservePrice)",
|
|
447
|
-
"function
|
|
447
|
+
"function setMinBidIncrementBps(uint256 _minBidIncrementBps)",
|
|
448
448
|
"function setDuration(uint256 _duration)",
|
|
449
449
|
"function setMintTierId(uint256 _tierId)",
|
|
450
450
|
"function setDefaultTokenURI(string _uri)",
|
|
@@ -457,7 +457,7 @@ var require_abi = __commonJS({
|
|
|
457
457
|
"event AuctionSettled(uint256 indexed nftId, address winner, uint256 amount)",
|
|
458
458
|
"event AuctionTimeBufferUpdated(uint256 timeBuffer)",
|
|
459
459
|
"event AuctionReservePriceUpdated(uint256 reservePrice)",
|
|
460
|
-
"event
|
|
460
|
+
"event AuctionMinBidIncrementBpsUpdated(uint256 minBidIncrementBps)",
|
|
461
461
|
"event AuctionDurationUpdated(uint256 duration)"
|
|
462
462
|
];
|
|
463
463
|
var SimpleBountySystem = [
|
|
@@ -467,10 +467,8 @@ var require_abi = __commonJS({
|
|
|
467
467
|
// Bounty Creation
|
|
468
468
|
"function createBounty(string title, string description, string ipfsCID, uint256 reward, uint256 deadline) returns (uint256)",
|
|
469
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)",
|
|
470
|
-
// Submission
|
|
471
|
-
"function claimBounty(uint256 bountyId)",
|
|
470
|
+
// Submission
|
|
472
471
|
"function submitEntry(uint256 bountyId, string promptIPFS, string deliverableIPFS) returns (uint256)",
|
|
473
|
-
"function completeBounty(uint256 bountyId, string deliverableIPFS)",
|
|
474
472
|
// Voting (COMPETITIVE mode)
|
|
475
473
|
"function startVoting(uint256 bountyId)",
|
|
476
474
|
"function vote(uint256 bountyId, uint256 submissionId)",
|
|
@@ -549,7 +547,6 @@ var require_abi = __commonJS({
|
|
|
549
547
|
Timelock,
|
|
550
548
|
ERC20Votes,
|
|
551
549
|
SXXX,
|
|
552
|
-
PersonalLibraryFacet,
|
|
553
550
|
PersonalMarketplace,
|
|
554
551
|
PersonalLicenseReceipt,
|
|
555
552
|
TreasuryWrapper,
|
|
@@ -3884,15 +3881,17 @@ var require_library = __commonJS({
|
|
|
3884
3881
|
return {
|
|
3885
3882
|
manifestCID: info.manifestCID,
|
|
3886
3883
|
previousCID: "",
|
|
3887
|
-
// Not tracked on-chain
|
|
3884
|
+
// Not tracked on-chain (history is in events/subgraph)
|
|
3888
3885
|
timestamp: BigInt(info.lastUpdated.toString()),
|
|
3889
3886
|
proposer: getAddress(info.lastUpdater),
|
|
3890
3887
|
promptCount: 0,
|
|
3891
|
-
// Not tracked on-chain
|
|
3888
|
+
// Not tracked on-chain
|
|
3892
3889
|
version: info.version,
|
|
3893
3890
|
nonce: BigInt(info.nonce.toString()),
|
|
3894
|
-
forkedFromDAO:
|
|
3895
|
-
|
|
3891
|
+
forkedFromDAO: null,
|
|
3892
|
+
// Removed from on-chain struct; use events/subgraph
|
|
3893
|
+
sxxxForkFee: 0n
|
|
3894
|
+
// Removed from on-chain struct
|
|
3896
3895
|
};
|
|
3897
3896
|
}
|
|
3898
3897
|
async function getLibraryStreamInfo({ provider, registry, subdao, libraryId = "default" }) {
|
|
@@ -3912,8 +3911,10 @@ var require_library = __commonJS({
|
|
|
3912
3911
|
promptCount: 0,
|
|
3913
3912
|
version: info.version,
|
|
3914
3913
|
nonce: BigInt(info.nonce.toString()),
|
|
3915
|
-
forkedFromDAO:
|
|
3916
|
-
|
|
3914
|
+
forkedFromDAO: null,
|
|
3915
|
+
// Removed from on-chain struct; use events/subgraph
|
|
3916
|
+
sxxxForkFee: 0n
|
|
3917
|
+
// Removed from on-chain struct
|
|
3917
3918
|
};
|
|
3918
3919
|
}
|
|
3919
3920
|
async function getLibraryIds({ provider, registry, subdao }) {
|
|
@@ -4569,8 +4570,8 @@ var require_governance = __commonJS({
|
|
|
4569
4570
|
const reg = new Contract(
|
|
4570
4571
|
targets[i],
|
|
4571
4572
|
[
|
|
4572
|
-
"function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
4573
|
-
"function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
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))"
|
|
4574
4575
|
],
|
|
4575
4576
|
provider
|
|
4576
4577
|
);
|
|
@@ -4604,8 +4605,8 @@ var require_governance = __commonJS({
|
|
|
4604
4605
|
const reg = new Contract(
|
|
4605
4606
|
targets[i],
|
|
4606
4607
|
[
|
|
4607
|
-
"function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
4608
|
-
"function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
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))"
|
|
4609
4610
|
],
|
|
4610
4611
|
provider
|
|
4611
4612
|
);
|
|
@@ -4639,8 +4640,8 @@ var require_governance = __commonJS({
|
|
|
4639
4640
|
const reg = new Contract(
|
|
4640
4641
|
targets[i],
|
|
4641
4642
|
[
|
|
4642
|
-
"function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
4643
|
-
"function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
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))"
|
|
4644
4645
|
],
|
|
4645
4646
|
provider
|
|
4646
4647
|
);
|
|
@@ -4681,8 +4682,8 @@ var require_governance = __commonJS({
|
|
|
4681
4682
|
const reg = new Contract(
|
|
4682
4683
|
targets[i],
|
|
4683
4684
|
[
|
|
4684
|
-
"function getLibraryStream(address,string) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
4685
|
-
"function libraryByDAO(address) view returns (tuple(string manifestCID,address lastUpdater,uint256 lastUpdated,string version,
|
|
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))"
|
|
4686
4687
|
],
|
|
4687
4688
|
provider
|
|
4688
4689
|
);
|
|
@@ -7128,18 +7129,45 @@ var require_factory = __commonJS({
|
|
|
7128
7129
|
]);
|
|
7129
7130
|
return { to: addr, data: payload, value: 0n };
|
|
7130
7131
|
}
|
|
7131
|
-
function buildCreateForkedSubDAOTx({
|
|
7132
|
+
function buildCreateForkedSubDAOTx({
|
|
7133
|
+
factory,
|
|
7134
|
+
newName,
|
|
7135
|
+
newDescription,
|
|
7136
|
+
originalName,
|
|
7137
|
+
originalSubDAO,
|
|
7138
|
+
forker,
|
|
7139
|
+
copyLibrary = false,
|
|
7140
|
+
maxForkFee
|
|
7141
|
+
}) {
|
|
7132
7142
|
const addr = normalise(factory, "factory");
|
|
7133
|
-
const
|
|
7143
|
+
const argsBase = [
|
|
7134
7144
|
String(newName),
|
|
7135
7145
|
String(newDescription),
|
|
7136
7146
|
String(originalName),
|
|
7137
7147
|
normalise(originalSubDAO, "originalSubDAO"),
|
|
7138
7148
|
normalise(forker, "forker")
|
|
7139
|
-
]
|
|
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
|
+
);
|
|
7140
7157
|
return { to: addr, data: payload, value: 0n };
|
|
7141
7158
|
}
|
|
7142
|
-
function buildCreateForkedSubDAOWithStableTx({
|
|
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
|
+
}) {
|
|
7143
7171
|
const addr = normalise(factory, "factory");
|
|
7144
7172
|
if (!permit) throw new SageSDKError(CODES.INVALID_ARGS, "permit required for stable fork");
|
|
7145
7173
|
const tuple = [
|
|
@@ -7149,7 +7177,7 @@ var require_factory = __commonJS({
|
|
|
7149
7177
|
permit.r ?? "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
7150
7178
|
permit.s ?? "0x0000000000000000000000000000000000000000000000000000000000000000"
|
|
7151
7179
|
];
|
|
7152
|
-
const
|
|
7180
|
+
const argsBase = [
|
|
7153
7181
|
String(newName),
|
|
7154
7182
|
String(newDescription),
|
|
7155
7183
|
String(originalName),
|
|
@@ -7157,7 +7185,14 @@ var require_factory = __commonJS({
|
|
|
7157
7185
|
normalise(forker, "forker"),
|
|
7158
7186
|
Number(authorizationNonce ?? 0),
|
|
7159
7187
|
tuple
|
|
7160
|
-
]
|
|
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
|
+
);
|
|
7161
7196
|
return { to: addr, data: payload, value: 0n };
|
|
7162
7197
|
}
|
|
7163
7198
|
function buildCreateSubDAOWithParamsTx({
|
|
@@ -7358,10 +7393,8 @@ var require_lineage = __commonJS({
|
|
|
7358
7393
|
var { Contract, getAddress } = __require("ethers");
|
|
7359
7394
|
var { SageSDKError, CODES } = require_errors();
|
|
7360
7395
|
var LINEAGE_ABI = [
|
|
7361
|
-
"function libraryByDAO(address) view returns (string manifestCID, address lastUpdater, uint256 lastUpdated, string version,
|
|
7362
|
-
"function getLibraryForkFee(address) view returns (uint256)"
|
|
7396
|
+
"function libraryByDAO(address) view returns (string manifestCID, address lastUpdater, uint256 lastUpdated, string version, uint256 nonce)"
|
|
7363
7397
|
];
|
|
7364
|
-
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
7365
7398
|
function normalise(address, label) {
|
|
7366
7399
|
if (!address) throw new SageSDKError(CODES.INVALID_ARGS, `${label} required`);
|
|
7367
7400
|
try {
|
|
@@ -7375,13 +7408,7 @@ var require_lineage = __commonJS({
|
|
|
7375
7408
|
if (!registry) throw new SageSDKError(CODES.INVALID_ARGS, "registry required");
|
|
7376
7409
|
if (!subdao) throw new SageSDKError(CODES.INVALID_ARGS, "subdao required");
|
|
7377
7410
|
try {
|
|
7378
|
-
|
|
7379
|
-
const info = await contract.libraryByDAO(normalise(subdao, "subdao"));
|
|
7380
|
-
const parent = info.forkedFromDAO;
|
|
7381
|
-
if (!parent || parent === ZERO_ADDRESS) {
|
|
7382
|
-
return null;
|
|
7383
|
-
}
|
|
7384
|
-
return getAddress(parent).toLowerCase();
|
|
7411
|
+
return null;
|
|
7385
7412
|
} catch (err) {
|
|
7386
7413
|
throw new SageSDKError(CODES.CONTRACT_ERROR, "Failed to fetch parent library", { cause: err });
|
|
7387
7414
|
}
|
|
@@ -7391,25 +7418,11 @@ var require_lineage = __commonJS({
|
|
|
7391
7418
|
if (!registry) throw new SageSDKError(CODES.INVALID_ARGS, "registry required");
|
|
7392
7419
|
if (!subdao) throw new SageSDKError(CODES.INVALID_ARGS, "subdao required");
|
|
7393
7420
|
try {
|
|
7394
|
-
const
|
|
7395
|
-
const chain = [];
|
|
7396
|
-
let current = normalise(subdao, "subdao");
|
|
7397
|
-
const MAX_DEPTH = 100;
|
|
7398
|
-
let iterations = 0;
|
|
7399
|
-
while (current && iterations < MAX_DEPTH) {
|
|
7400
|
-
chain.unshift(getAddress(current).toLowerCase());
|
|
7401
|
-
const info = await contract.libraryByDAO(current);
|
|
7402
|
-
const parent = info.forkedFromDAO;
|
|
7403
|
-
if (!parent || parent === ZERO_ADDRESS) {
|
|
7404
|
-
break;
|
|
7405
|
-
}
|
|
7406
|
-
current = parent;
|
|
7407
|
-
iterations++;
|
|
7408
|
-
}
|
|
7421
|
+
const addr = getAddress(normalise(subdao, "subdao")).toLowerCase();
|
|
7409
7422
|
return {
|
|
7410
|
-
chain,
|
|
7411
|
-
depth:
|
|
7412
|
-
root:
|
|
7423
|
+
chain: [addr],
|
|
7424
|
+
depth: 0,
|
|
7425
|
+
root: addr
|
|
7413
7426
|
};
|
|
7414
7427
|
} catch (err) {
|
|
7415
7428
|
throw new SageSDKError(CODES.CONTRACT_ERROR, "Failed to fetch lineage chain", { cause: err });
|
|
@@ -7420,16 +7433,7 @@ var require_lineage = __commonJS({
|
|
|
7420
7433
|
return parent !== null;
|
|
7421
7434
|
}
|
|
7422
7435
|
async function getLibraryForkFee({ provider, registry, subdao }) {
|
|
7423
|
-
|
|
7424
|
-
if (!registry) throw new SageSDKError(CODES.INVALID_ARGS, "registry required");
|
|
7425
|
-
if (!subdao) throw new SageSDKError(CODES.INVALID_ARGS, "subdao required");
|
|
7426
|
-
try {
|
|
7427
|
-
const contract = new Contract(normalise(registry, "registry"), LINEAGE_ABI, provider);
|
|
7428
|
-
const fee = await contract.getLibraryForkFee(normalise(subdao, "subdao"));
|
|
7429
|
-
return BigInt(fee.toString());
|
|
7430
|
-
} catch (err) {
|
|
7431
|
-
throw new SageSDKError(CODES.CONTRACT_ERROR, "Failed to fetch library fork fee", { cause: err });
|
|
7432
|
-
}
|
|
7436
|
+
return 0n;
|
|
7433
7437
|
}
|
|
7434
7438
|
async function getLibraryInfo({ provider, registry, subdao }) {
|
|
7435
7439
|
if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
|
|
@@ -7438,10 +7442,11 @@ var require_lineage = __commonJS({
|
|
|
7438
7442
|
try {
|
|
7439
7443
|
const contract = new Contract(normalise(registry, "registry"), LINEAGE_ABI, provider);
|
|
7440
7444
|
const info = await contract.libraryByDAO(normalise(subdao, "subdao"));
|
|
7441
|
-
const parent = info.forkedFromDAO;
|
|
7442
7445
|
return {
|
|
7443
|
-
parentDAO:
|
|
7444
|
-
|
|
7446
|
+
parentDAO: null,
|
|
7447
|
+
// Fork lineage removed from on-chain struct
|
|
7448
|
+
forkFee: 0n,
|
|
7449
|
+
// Fork fees removed from on-chain struct
|
|
7445
7450
|
manifestCID: info.manifestCID,
|
|
7446
7451
|
version: info.version
|
|
7447
7452
|
};
|
|
@@ -8637,12 +8642,6 @@ var require_personal = __commonJS({
|
|
|
8637
8642
|
var { Interface } = __require("ethers");
|
|
8638
8643
|
var ABI = require_abi();
|
|
8639
8644
|
var { normaliseAddress, toBytes32Key } = require_helpers();
|
|
8640
|
-
function buildCreatePersonalRegistryTx({ factory, policy }) {
|
|
8641
|
-
const to = normaliseAddress(factory, "factory");
|
|
8642
|
-
const iface = new Interface(ABI.PersonalLibraryFacet);
|
|
8643
|
-
const data = iface.encodeFunctionData("createPersonalRegistry", [policy >>> 0]);
|
|
8644
|
-
return { to, data, value: 0n };
|
|
8645
|
-
}
|
|
8646
8645
|
function buildSetPriceTx({ marketplace, key, price }) {
|
|
8647
8646
|
const to = normaliseAddress(marketplace, "marketplace");
|
|
8648
8647
|
const k = toBytes32Key(key);
|
|
@@ -8662,7 +8661,6 @@ var require_personal = __commonJS({
|
|
|
8662
8661
|
return { to, data, value: 0n };
|
|
8663
8662
|
}
|
|
8664
8663
|
module2.exports = {
|
|
8665
|
-
buildCreatePersonalRegistryTx,
|
|
8666
8664
|
buildSetPriceTx,
|
|
8667
8665
|
buildBuyTx,
|
|
8668
8666
|
...require_receipt(),
|
|
@@ -8671,300 +8669,6 @@ var require_personal = __commonJS({
|
|
|
8671
8669
|
}
|
|
8672
8670
|
});
|
|
8673
8671
|
|
|
8674
|
-
// src/premium/index.js
|
|
8675
|
-
var require_premium = __commonJS({
|
|
8676
|
-
"src/premium/index.js"(exports2, module2) {
|
|
8677
|
-
var axios = __require("axios");
|
|
8678
|
-
var { getAddress } = __require("ethers");
|
|
8679
|
-
function safeGetAddress(value) {
|
|
8680
|
-
try {
|
|
8681
|
-
return getAddress(value);
|
|
8682
|
-
} catch {
|
|
8683
|
-
return null;
|
|
8684
|
-
}
|
|
8685
|
-
}
|
|
8686
|
-
function mapSafe(list, mapper) {
|
|
8687
|
-
const out = [];
|
|
8688
|
-
for (const item of list || []) {
|
|
8689
|
-
try {
|
|
8690
|
-
const v = mapper(item);
|
|
8691
|
-
if (v != null) out.push(v);
|
|
8692
|
-
} catch {
|
|
8693
|
-
}
|
|
8694
|
-
}
|
|
8695
|
-
return out;
|
|
8696
|
-
}
|
|
8697
|
-
async function query(url, document, variables) {
|
|
8698
|
-
if (!url) throw new Error("subgraph url required");
|
|
8699
|
-
const resp = await axios.post(url, { query: document, variables }, { timeout: 1e4 });
|
|
8700
|
-
if (resp.data && resp.data.errors) {
|
|
8701
|
-
throw new Error(resp.data.errors.map((e) => e.message).join("; "));
|
|
8702
|
-
}
|
|
8703
|
-
return resp.data.data;
|
|
8704
|
-
}
|
|
8705
|
-
async function listPremiumPrompts({ url, subdao = null, first = 50, skip = 0, orderBy = "blockTimestamp", orderDirection = "desc" }) {
|
|
8706
|
-
const safeOrderBy = ["blockTimestamp", "price"].includes(orderBy) ? orderBy : "blockTimestamp";
|
|
8707
|
-
const safeOrderDirection = orderDirection === "asc" ? "asc" : "desc";
|
|
8708
|
-
let doc;
|
|
8709
|
-
const variables = {
|
|
8710
|
-
first: Math.min(Math.max(1, Number(first || 50)), 200),
|
|
8711
|
-
skip: Number(skip || 0)
|
|
8712
|
-
};
|
|
8713
|
-
if (subdao) {
|
|
8714
|
-
const addr = safeGetAddress(subdao);
|
|
8715
|
-
if (!addr) throw new Error("invalid subdao address");
|
|
8716
|
-
variables.subdao = addr.toLowerCase();
|
|
8717
|
-
doc = `
|
|
8718
|
-
query($subdao: Bytes!, $first: Int!, $skip: Int!) {
|
|
8719
|
-
premiumPrompts(
|
|
8720
|
-
where: { subdao: $subdao }
|
|
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
|
-
} else {
|
|
8738
|
-
doc = `
|
|
8739
|
-
query($first: Int!, $skip: Int!) {
|
|
8740
|
-
premiumPrompts(
|
|
8741
|
-
first: $first
|
|
8742
|
-
skip: $skip
|
|
8743
|
-
orderBy: ${safeOrderBy}
|
|
8744
|
-
orderDirection: ${safeOrderDirection}
|
|
8745
|
-
) {
|
|
8746
|
-
id
|
|
8747
|
-
cidHash
|
|
8748
|
-
subdao
|
|
8749
|
-
price
|
|
8750
|
-
manifestCID
|
|
8751
|
-
blockNumber
|
|
8752
|
-
blockTimestamp
|
|
8753
|
-
transactionHash
|
|
8754
|
-
}
|
|
8755
|
-
}
|
|
8756
|
-
`;
|
|
8757
|
-
}
|
|
8758
|
-
const data = await query(url, doc, variables);
|
|
8759
|
-
return mapSafe(data?.premiumPrompts, (p) => {
|
|
8760
|
-
const sub = safeGetAddress(p.subdao);
|
|
8761
|
-
if (!sub) return null;
|
|
8762
|
-
return {
|
|
8763
|
-
id: String(p.id),
|
|
8764
|
-
cidHash: String(p.cidHash),
|
|
8765
|
-
subdao: sub,
|
|
8766
|
-
price: BigInt(String(p.price || "0")),
|
|
8767
|
-
manifestCID: p.manifestCID || null,
|
|
8768
|
-
blockNumber: Number(p.blockNumber || 0),
|
|
8769
|
-
blockTimestamp: Number(p.blockTimestamp || 0),
|
|
8770
|
-
transactionHash: p.transactionHash || null
|
|
8771
|
-
};
|
|
8772
|
-
});
|
|
8773
|
-
}
|
|
8774
|
-
async function getPremiumPrompt({ url, cidHash }) {
|
|
8775
|
-
const id2 = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
|
|
8776
|
-
const doc = `
|
|
8777
|
-
query($id: ID!) {
|
|
8778
|
-
premiumPrompt(id: $id) {
|
|
8779
|
-
id
|
|
8780
|
-
cidHash
|
|
8781
|
-
subdao
|
|
8782
|
-
price
|
|
8783
|
-
manifestCID
|
|
8784
|
-
blockNumber
|
|
8785
|
-
blockTimestamp
|
|
8786
|
-
transactionHash
|
|
8787
|
-
}
|
|
8788
|
-
premiumPromptStats(id: $id) {
|
|
8789
|
-
totalRevenue
|
|
8790
|
-
purchaseCount
|
|
8791
|
-
uniqueBuyers
|
|
8792
|
-
currentHolders
|
|
8793
|
-
}
|
|
8794
|
-
}
|
|
8795
|
-
`;
|
|
8796
|
-
const data = await query(url, doc, { id: id2 });
|
|
8797
|
-
const p = data?.premiumPrompt;
|
|
8798
|
-
if (!p) return null;
|
|
8799
|
-
const sub = safeGetAddress(p.subdao);
|
|
8800
|
-
if (!sub) return null;
|
|
8801
|
-
const stats = data?.premiumPromptStats || {};
|
|
8802
|
-
return {
|
|
8803
|
-
id: String(p.id),
|
|
8804
|
-
cidHash: String(p.cidHash),
|
|
8805
|
-
subdao: sub,
|
|
8806
|
-
price: BigInt(String(p.price || "0")),
|
|
8807
|
-
manifestCID: p.manifestCID || null,
|
|
8808
|
-
blockNumber: Number(p.blockNumber || 0),
|
|
8809
|
-
blockTimestamp: Number(p.blockTimestamp || 0),
|
|
8810
|
-
transactionHash: p.transactionHash || null,
|
|
8811
|
-
// Stats
|
|
8812
|
-
totalRevenue: stats.totalRevenue ? BigInt(String(stats.totalRevenue)) : null,
|
|
8813
|
-
purchaseCount: stats.purchaseCount ? BigInt(String(stats.purchaseCount)) : null,
|
|
8814
|
-
uniqueBuyers: stats.uniqueBuyers ? BigInt(String(stats.uniqueBuyers)) : null,
|
|
8815
|
-
currentHolders: stats.currentHolders ? BigInt(String(stats.currentHolders)) : null
|
|
8816
|
-
};
|
|
8817
|
-
}
|
|
8818
|
-
async function listPremiumPurchases({ url, cidHash, first = 50, skip = 0 }) {
|
|
8819
|
-
const normalizedCidHash = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
|
|
8820
|
-
const doc = `
|
|
8821
|
-
query($cidHash: Bytes!, $first: Int!, $skip: Int!) {
|
|
8822
|
-
premiumPurchases(
|
|
8823
|
-
where: { cidHash: $cidHash }
|
|
8824
|
-
first: $first
|
|
8825
|
-
skip: $skip
|
|
8826
|
-
orderBy: blockTimestamp
|
|
8827
|
-
orderDirection: desc
|
|
8828
|
-
) {
|
|
8829
|
-
id
|
|
8830
|
-
cidHash
|
|
8831
|
-
buyer
|
|
8832
|
-
price
|
|
8833
|
-
treasury
|
|
8834
|
-
blockNumber
|
|
8835
|
-
blockTimestamp
|
|
8836
|
-
transactionHash
|
|
8837
|
-
}
|
|
8838
|
-
}
|
|
8839
|
-
`;
|
|
8840
|
-
const data = await query(url, doc, {
|
|
8841
|
-
cidHash: normalizedCidHash,
|
|
8842
|
-
first: Math.min(Math.max(1, Number(first || 50)), 200),
|
|
8843
|
-
skip: Number(skip || 0)
|
|
8844
|
-
});
|
|
8845
|
-
return mapSafe(data?.premiumPurchases, (p) => {
|
|
8846
|
-
const buyer = safeGetAddress(p.buyer);
|
|
8847
|
-
const treasury = safeGetAddress(p.treasury);
|
|
8848
|
-
if (!buyer || !treasury) return null;
|
|
8849
|
-
return {
|
|
8850
|
-
id: String(p.id),
|
|
8851
|
-
cidHash: String(p.cidHash),
|
|
8852
|
-
buyer,
|
|
8853
|
-
price: BigInt(String(p.price || "0")),
|
|
8854
|
-
treasury,
|
|
8855
|
-
blockNumber: Number(p.blockNumber || 0),
|
|
8856
|
-
blockTimestamp: Number(p.blockTimestamp || 0),
|
|
8857
|
-
transactionHash: p.transactionHash || null
|
|
8858
|
-
};
|
|
8859
|
-
});
|
|
8860
|
-
}
|
|
8861
|
-
async function hasPurchased({ url, cidHash, holder }) {
|
|
8862
|
-
const normalizedCidHash = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
|
|
8863
|
-
const normalizedHolder = holder.toLowerCase();
|
|
8864
|
-
const id2 = `${normalizedCidHash}-${normalizedHolder}`;
|
|
8865
|
-
const doc = `
|
|
8866
|
-
query($id: ID!) {
|
|
8867
|
-
premiumHolderBalance(id: $id) {
|
|
8868
|
-
balance
|
|
8869
|
-
}
|
|
8870
|
-
}
|
|
8871
|
-
`;
|
|
8872
|
-
const data = await query(url, doc, { id: id2 });
|
|
8873
|
-
const balance = data?.premiumHolderBalance?.balance;
|
|
8874
|
-
return balance ? BigInt(String(balance)) > 0n : false;
|
|
8875
|
-
}
|
|
8876
|
-
async function getHolderBalance({ url, cidHash, holder }) {
|
|
8877
|
-
const normalizedCidHash = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
|
|
8878
|
-
const normalizedHolder = holder.toLowerCase();
|
|
8879
|
-
const id2 = `${normalizedCidHash}-${normalizedHolder}`;
|
|
8880
|
-
const doc = `
|
|
8881
|
-
query($id: ID!) {
|
|
8882
|
-
premiumHolderBalance(id: $id) {
|
|
8883
|
-
balance
|
|
8884
|
-
updatedAt
|
|
8885
|
-
}
|
|
8886
|
-
}
|
|
8887
|
-
`;
|
|
8888
|
-
const data = await query(url, doc, { id: id2 });
|
|
8889
|
-
const row = data?.premiumHolderBalance;
|
|
8890
|
-
if (!row) return 0n;
|
|
8891
|
-
return BigInt(String(row.balance || "0"));
|
|
8892
|
-
}
|
|
8893
|
-
async function listHolders({ url, cidHash, first = 100, skip = 0 }) {
|
|
8894
|
-
const normalizedCidHash = cidHash.toLowerCase().startsWith("0x") ? cidHash.toLowerCase() : `0x${cidHash.toLowerCase()}`;
|
|
8895
|
-
const doc = `
|
|
8896
|
-
query($cidHash: Bytes!, $first: Int!, $skip: Int!) {
|
|
8897
|
-
premiumHolderBalances(
|
|
8898
|
-
where: { cidHash: $cidHash, balance_gt: "0" }
|
|
8899
|
-
first: $first
|
|
8900
|
-
skip: $skip
|
|
8901
|
-
orderBy: balance
|
|
8902
|
-
orderDirection: desc
|
|
8903
|
-
) {
|
|
8904
|
-
id
|
|
8905
|
-
cidHash
|
|
8906
|
-
holder
|
|
8907
|
-
balance
|
|
8908
|
-
updatedAt
|
|
8909
|
-
}
|
|
8910
|
-
}
|
|
8911
|
-
`;
|
|
8912
|
-
const data = await query(url, doc, {
|
|
8913
|
-
cidHash: normalizedCidHash,
|
|
8914
|
-
first: Math.min(Math.max(1, Number(first || 100)), 500),
|
|
8915
|
-
skip: Number(skip || 0)
|
|
8916
|
-
});
|
|
8917
|
-
return mapSafe(data?.premiumHolderBalances, (h) => {
|
|
8918
|
-
const holder = safeGetAddress(h.holder);
|
|
8919
|
-
if (!holder) return null;
|
|
8920
|
-
return {
|
|
8921
|
-
id: String(h.id),
|
|
8922
|
-
cidHash: String(h.cidHash),
|
|
8923
|
-
holder,
|
|
8924
|
-
balance: BigInt(String(h.balance || "0")),
|
|
8925
|
-
updatedAt: Number(h.updatedAt || 0)
|
|
8926
|
-
};
|
|
8927
|
-
});
|
|
8928
|
-
}
|
|
8929
|
-
async function getRevSplit({ url, subdao }) {
|
|
8930
|
-
const addr = safeGetAddress(subdao);
|
|
8931
|
-
if (!addr) throw new Error("invalid subdao address");
|
|
8932
|
-
const doc = `
|
|
8933
|
-
query($id: ID!) {
|
|
8934
|
-
premiumRevSplit(id: $id) {
|
|
8935
|
-
id
|
|
8936
|
-
subdao
|
|
8937
|
-
treasuryBps
|
|
8938
|
-
protocolBps
|
|
8939
|
-
creatorBps
|
|
8940
|
-
updatedAt
|
|
8941
|
-
}
|
|
8942
|
-
}
|
|
8943
|
-
`;
|
|
8944
|
-
const data = await query(url, doc, { id: addr.toLowerCase() });
|
|
8945
|
-
const split = data?.premiumRevSplit;
|
|
8946
|
-
if (!split) return null;
|
|
8947
|
-
return {
|
|
8948
|
-
id: String(split.id),
|
|
8949
|
-
subdao: safeGetAddress(split.subdao) || addr,
|
|
8950
|
-
treasuryBps: Number(split.treasuryBps || 0),
|
|
8951
|
-
protocolBps: Number(split.protocolBps || 0),
|
|
8952
|
-
creatorBps: Number(split.creatorBps || 0),
|
|
8953
|
-
updatedAt: Number(split.updatedAt || 0)
|
|
8954
|
-
};
|
|
8955
|
-
}
|
|
8956
|
-
module2.exports = {
|
|
8957
|
-
listPremiumPrompts,
|
|
8958
|
-
getPremiumPrompt,
|
|
8959
|
-
listPremiumPurchases,
|
|
8960
|
-
hasPurchased,
|
|
8961
|
-
getHolderBalance,
|
|
8962
|
-
listHolders,
|
|
8963
|
-
getRevSplit
|
|
8964
|
-
};
|
|
8965
|
-
}
|
|
8966
|
-
});
|
|
8967
|
-
|
|
8968
8672
|
// src/utils/privateTx.js
|
|
8969
8673
|
var require_privateTx = __commonJS({
|
|
8970
8674
|
"src/utils/privateTx.js"(exports2, module2) {
|
|
@@ -9484,7 +9188,7 @@ var require_boost = __commonJS({
|
|
|
9484
9188
|
const contract = new Contract(addr, ABI.GovernanceBoostMerkle, provider);
|
|
9485
9189
|
const result = await contract.getBoost(proposalId).catch(() => null);
|
|
9486
9190
|
if (!result) return null;
|
|
9487
|
-
const [totalPool, totalClaimed, merkleRoot, active, finalized, creator] = result;
|
|
9191
|
+
const [totalPool, totalClaimed, merkleRoot, expiresAt, active, finalized, creator] = result;
|
|
9488
9192
|
const creatorAddr = creator ? getAddress(creator) : ZERO_ADDRESS;
|
|
9489
9193
|
const pool = toBigInt(totalPool);
|
|
9490
9194
|
if (!active && !finalized && pool === 0n && creatorAddr === ZERO_ADDRESS) return null;
|
|
@@ -9494,6 +9198,7 @@ var require_boost = __commonJS({
|
|
|
9494
9198
|
totalPool: pool,
|
|
9495
9199
|
totalClaimed: toBigInt(totalClaimed),
|
|
9496
9200
|
merkleRoot,
|
|
9201
|
+
expiresAt: toBigInt(expiresAt),
|
|
9497
9202
|
active: Boolean(active),
|
|
9498
9203
|
finalized: Boolean(finalized),
|
|
9499
9204
|
creator: creatorAddr
|
|
@@ -10762,13 +10467,13 @@ var require_auction = __commonJS({
|
|
|
10762
10467
|
}
|
|
10763
10468
|
async function getConfig({ provider, auctionHouse }) {
|
|
10764
10469
|
const c = getAuctionContract(provider, auctionHouse);
|
|
10765
|
-
const [nft, treasury, weth, timeBuffer, reservePrice,
|
|
10470
|
+
const [nft, treasury, weth, timeBuffer, reservePrice, minBidIncrementBps, duration, mintTierId, defaultTokenURI, paused, owner] = await Promise.all([
|
|
10766
10471
|
c.nft(),
|
|
10767
10472
|
c.treasury(),
|
|
10768
10473
|
c.weth(),
|
|
10769
10474
|
c.timeBuffer(),
|
|
10770
10475
|
c.reservePrice(),
|
|
10771
|
-
c.
|
|
10476
|
+
c.minBidIncrementBps(),
|
|
10772
10477
|
c.duration(),
|
|
10773
10478
|
c.mintTierId(),
|
|
10774
10479
|
c.defaultTokenURI(),
|
|
@@ -10781,7 +10486,7 @@ var require_auction = __commonJS({
|
|
|
10781
10486
|
weth: getAddress(weth),
|
|
10782
10487
|
timeBuffer: BigInt(timeBuffer.toString()),
|
|
10783
10488
|
reservePrice: BigInt(reservePrice.toString()),
|
|
10784
|
-
|
|
10489
|
+
minBidIncrementBps: BigInt(minBidIncrementBps.toString()),
|
|
10785
10490
|
duration: BigInt(duration.toString()),
|
|
10786
10491
|
mintTierId: BigInt(mintTierId.toString()),
|
|
10787
10492
|
defaultTokenURI: String(defaultTokenURI),
|
|
@@ -10837,10 +10542,10 @@ var require_auction = __commonJS({
|
|
|
10837
10542
|
const data = iface.encodeFunctionData("setReservePrice", [toBigInt(reservePrice, "reservePrice")]);
|
|
10838
10543
|
return { to: addr, data, value: 0n };
|
|
10839
10544
|
}
|
|
10840
|
-
function buildSetMinBidIncrementTx({ auctionHouse,
|
|
10545
|
+
function buildSetMinBidIncrementTx({ auctionHouse, bps }) {
|
|
10841
10546
|
const addr = normaliseAddress(auctionHouse, "auctionHouse");
|
|
10842
10547
|
const iface = new Interface(ABI.SageAuctionHouse);
|
|
10843
|
-
const data = iface.encodeFunctionData("
|
|
10548
|
+
const data = iface.encodeFunctionData("setMinBidIncrementBps", [toBigInt(bps, "bps")]);
|
|
10844
10549
|
return { to: addr, data, value: 0n };
|
|
10845
10550
|
}
|
|
10846
10551
|
function buildSetDurationTx({ auctionHouse, duration }) {
|
|
@@ -12036,6 +11741,24 @@ ${error}` : ""}`;
|
|
|
12036
11741
|
} else if (data.startsWith(__require("ethers").id("authorizeBurner(address)").slice(0, 10))) {
|
|
12037
11742
|
const burner = this.extractAddressFromData(data, 0);
|
|
12038
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] };
|
|
12039
11762
|
} else if (data.startsWith(__require("ethers").id("createBoost(address,uint256,uint256,uint256,uint8,address,uint96,uint8,uint8,uint256,uint256)").slice(0, 10))) {
|
|
12040
11763
|
const { ethers: ethers2 } = __require("ethers");
|
|
12041
11764
|
const sig = "createBoost(address,uint256,uint256,uint256,uint8,address,uint96,uint8,uint8,uint256,uint256)";
|
|
@@ -12106,25 +11829,6 @@ ${error}` : ""}`;
|
|
|
12106
11829
|
const d = iface.decodeFunctionData("forkPromptWithStable", data);
|
|
12107
11830
|
const args = [`"${String(d[0])}"`, `"${String(d[1])}"`, `"${String(d[2])}"`, `"${String(d[3])}"`, "[permit]"];
|
|
12108
11831
|
return { signature: sig, args };
|
|
12109
|
-
} else if (data.startsWith(__require("ethers").id("createPremiumPrompt(bytes32,address,uint256)").slice(0, 10))) {
|
|
12110
|
-
const { ethers: ethers2 } = __require("ethers");
|
|
12111
|
-
const sig = "createPremiumPrompt(bytes32,address,uint256)";
|
|
12112
|
-
const iface = new ethers2.Interface([`function ${sig}`]);
|
|
12113
|
-
const d = iface.decodeFunctionData("createPremiumPrompt", data);
|
|
12114
|
-
const hash = d[0];
|
|
12115
|
-
const subdao = d[1];
|
|
12116
|
-
const price = d[2].toString();
|
|
12117
|
-
return { signature: sig, args: [hash, subdao, price] };
|
|
12118
|
-
} else if (data.startsWith(__require("ethers").id("createPremiumPromptWithManifest(bytes32,address,uint256,string)").slice(0, 10))) {
|
|
12119
|
-
const { ethers: ethers2 } = __require("ethers");
|
|
12120
|
-
const sig = "createPremiumPromptWithManifest(bytes32,address,uint256,string)";
|
|
12121
|
-
const iface = new ethers2.Interface([`function ${sig}`]);
|
|
12122
|
-
const d = iface.decodeFunctionData("createPremiumPromptWithManifest", data);
|
|
12123
|
-
const hash = d[0];
|
|
12124
|
-
const subdao = d[1];
|
|
12125
|
-
const price = d[2].toString();
|
|
12126
|
-
const manifest = d[3];
|
|
12127
|
-
return { signature: sig, args: [hash, subdao, price, `"${manifest}"`] };
|
|
12128
11832
|
} else if (data.startsWith(__require("ethers").id("claim(uint256,address,uint256,bytes32[])").slice(0, 10))) {
|
|
12129
11833
|
const { ethers: ethers2 } = __require("ethers");
|
|
12130
11834
|
const sig = "claim(uint256,address,uint256,bytes32[])";
|
|
@@ -12136,18 +11840,6 @@ ${error}` : ""}`;
|
|
|
12136
11840
|
const proofArray = (d[3] || []).map((x) => String(x));
|
|
12137
11841
|
const formattedProof = `[${proofArray.join(",")}]`;
|
|
12138
11842
|
return { signature: sig, args: [proposalId, account, amount, formattedProof] };
|
|
12139
|
-
} else if (data.startsWith(__require("ethers").id("purchaseAccess(bytes32)").slice(0, 10))) {
|
|
12140
|
-
const { ethers: ethers2 } = __require("ethers");
|
|
12141
|
-
const iface = new ethers2.Interface(["function purchaseAccess(bytes32)"]);
|
|
12142
|
-
const d = iface.decodeFunctionData("purchaseAccess", data);
|
|
12143
|
-
return { signature: "purchaseAccess(bytes32)", args: [d[0]] };
|
|
12144
|
-
} else if (data.startsWith(__require("ethers").id("setProtocolRake(uint96,address)").slice(0, 10))) {
|
|
12145
|
-
const { ethers: ethers2 } = __require("ethers");
|
|
12146
|
-
const iface = new ethers2.Interface(["function setProtocolRake(uint96,address)"]);
|
|
12147
|
-
const decoded = iface.decodeFunctionData("setProtocolRake", data);
|
|
12148
|
-
const bps = decoded[0].toString();
|
|
12149
|
-
const treas = decoded[1];
|
|
12150
|
-
return { signature: "setProtocolRake(uint96,address)", args: [bps, treas] };
|
|
12151
11843
|
} else if (data.startsWith(__require("ethers").id("revokeBurner(address)").slice(0, 10))) {
|
|
12152
11844
|
const burner = this.extractAddressFromData(data, 0);
|
|
12153
11845
|
return { signature: "revokeBurner(address)", args: [burner] };
|
|
@@ -12597,276 +12289,6 @@ var require_typed = __commonJS({
|
|
|
12597
12289
|
}
|
|
12598
12290
|
});
|
|
12599
12291
|
|
|
12600
|
-
// src/doppler/index.js
|
|
12601
|
-
var require_doppler = __commonJS({
|
|
12602
|
-
"src/doppler/index.js"(exports2, module2) {
|
|
12603
|
-
var { createPublicClient, createWalletClient, http } = __require("viem");
|
|
12604
|
-
var { privateKeyToAccount } = __require("viem/accounts");
|
|
12605
|
-
var { erc20Abi } = __require("viem");
|
|
12606
|
-
var { base, baseSepolia } = __require("viem/chains");
|
|
12607
|
-
var dopplerLib = __require("@whetstone-research/doppler-sdk");
|
|
12608
|
-
function getChainById(chainId) {
|
|
12609
|
-
if (Number(chainId) === baseSepolia.id) return baseSepolia;
|
|
12610
|
-
if (Number(chainId) === base.id) return base;
|
|
12611
|
-
return { id: Number(chainId), name: `chain-${chainId}` };
|
|
12612
|
-
}
|
|
12613
|
-
function initDoppler(opts) {
|
|
12614
|
-
const chain = getChainById(opts.chainId);
|
|
12615
|
-
const publicClient = createPublicClient({ chain, transport: http(opts.rpcUrl) });
|
|
12616
|
-
let walletClient;
|
|
12617
|
-
if (opts.privateKey) {
|
|
12618
|
-
const pk = opts.privateKey.startsWith("0x") ? opts.privateKey : `0x${opts.privateKey}`;
|
|
12619
|
-
const account = privateKeyToAccount(pk);
|
|
12620
|
-
walletClient = createWalletClient({ chain, transport: http(opts.rpcUrl), account });
|
|
12621
|
-
} else if (opts.account) {
|
|
12622
|
-
walletClient = createWalletClient({ chain, transport: http(opts.rpcUrl), account: opts.account });
|
|
12623
|
-
}
|
|
12624
|
-
const DopplerSDK = dopplerLib.DopplerSDK || dopplerLib.default?.DopplerSDK || dopplerLib;
|
|
12625
|
-
const sdk = new DopplerSDK({ publicClient, walletClient, chainId: chain.id });
|
|
12626
|
-
return sdk;
|
|
12627
|
-
}
|
|
12628
|
-
async function deployDynamicAuction(sdk, user, p) {
|
|
12629
|
-
const DynamicAuctionBuilder = dopplerLib.DynamicAuctionBuilder || dopplerLib.default?.DynamicAuctionBuilder;
|
|
12630
|
-
if (!DynamicAuctionBuilder) throw new Error("DynamicAuctionBuilder missing from doppler-sdk");
|
|
12631
|
-
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);
|
|
12632
|
-
if (p.auction && p.auction.startPrice && p.auction.endPrice && typeof builder.auctionByPriceRange === "function") {
|
|
12633
|
-
builder.auctionByPriceRange({
|
|
12634
|
-
priceRange: { startPrice: p.auction.startPrice, endPrice: p.auction.endPrice },
|
|
12635
|
-
minProceeds: p.auction.minProceeds || 0n,
|
|
12636
|
-
maxProceeds: p.auction.maxProceeds || 0n,
|
|
12637
|
-
durationDays: p.auction.durationDays,
|
|
12638
|
-
epochLength: p.auction.epochLength,
|
|
12639
|
-
numPdSlugs: p.auction.numPdSlugs || 5
|
|
12640
|
-
});
|
|
12641
|
-
} else if (typeof builder.auctionByTicks === "function") {
|
|
12642
|
-
throw new Error("auctionByPriceRange not supported by current doppler-sdk version; please provide tick params instead");
|
|
12643
|
-
} else {
|
|
12644
|
-
throw new Error("No supported auction configuration method on doppler-sdk builder");
|
|
12645
|
-
}
|
|
12646
|
-
builder.withMigration({
|
|
12647
|
-
type: p.migration.type || "uniswapV4",
|
|
12648
|
-
fee: p.migration.fee,
|
|
12649
|
-
tickSpacing: p.migration.tickSpacing,
|
|
12650
|
-
lpRecipient: p.migration.lpRecipient
|
|
12651
|
-
});
|
|
12652
|
-
if (p.governance && typeof builder.withGovernance === "function") {
|
|
12653
|
-
builder.withGovernance(p.governance);
|
|
12654
|
-
}
|
|
12655
|
-
if (p.overrides?.airlock && typeof builder.withAirlock === "function") builder.withAirlock(p.overrides.airlock);
|
|
12656
|
-
if (p.overrides?.dopplerDeployer && typeof builder.withDopplerDeployer === "function") builder.withDopplerDeployer(p.overrides.dopplerDeployer);
|
|
12657
|
-
if (p.overrides?.governanceFactory && typeof builder.withGovernanceFactory === "function") builder.withGovernanceFactory(p.overrides.governanceFactory);
|
|
12658
|
-
if (p.overrides?.v4Initializer && typeof builder.withV4Initializer === "function") builder.withV4Initializer(p.overrides.v4Initializer);
|
|
12659
|
-
const params = builder.build();
|
|
12660
|
-
const result = await sdk.factory.createDynamicAuction(params);
|
|
12661
|
-
return result;
|
|
12662
|
-
}
|
|
12663
|
-
async function getAuctionStatus(sdk, auctionAddress) {
|
|
12664
|
-
const lens = sdk.lens;
|
|
12665
|
-
if (lens && typeof lens.getAuctionStatus === "function") {
|
|
12666
|
-
return await lens.getAuctionStatus({ auctionAddress });
|
|
12667
|
-
}
|
|
12668
|
-
return { auctionAddress, note: "Lens API not available in this doppler-sdk version" };
|
|
12669
|
-
}
|
|
12670
|
-
async function listAuctions(sdk, { limit = 10, cursor } = {}) {
|
|
12671
|
-
const lens = sdk.lens;
|
|
12672
|
-
if (lens) {
|
|
12673
|
-
if (typeof lens.listAuctions === "function") {
|
|
12674
|
-
try {
|
|
12675
|
-
return await lens.listAuctions({ limit, cursor });
|
|
12676
|
-
} catch (e) {
|
|
12677
|
-
}
|
|
12678
|
-
}
|
|
12679
|
-
if (typeof lens.getAuctions === "function") {
|
|
12680
|
-
try {
|
|
12681
|
-
return await lens.getAuctions({ limit, cursor });
|
|
12682
|
-
} catch (e) {
|
|
12683
|
-
}
|
|
12684
|
-
}
|
|
12685
|
-
}
|
|
12686
|
-
const fac = sdk.factory;
|
|
12687
|
-
if (fac && typeof fac.listAuctions === "function") {
|
|
12688
|
-
try {
|
|
12689
|
-
return await fac.listAuctions({ limit, cursor });
|
|
12690
|
-
} catch (e) {
|
|
12691
|
-
}
|
|
12692
|
-
}
|
|
12693
|
-
return { ok: false, error: "LIST_UNSUPPORTED", message: "Listing auctions not supported by this doppler-sdk version" };
|
|
12694
|
-
}
|
|
12695
|
-
async function buyTokens(sdk, { auctionAddress, numeraireAmount }) {
|
|
12696
|
-
const trade = sdk.trade || sdk.swap || sdk.auction;
|
|
12697
|
-
if (trade && typeof trade.buy === "function") {
|
|
12698
|
-
try {
|
|
12699
|
-
return await trade.buy({ auctionAddress, numeraireAmount });
|
|
12700
|
-
} catch (e) {
|
|
12701
|
-
}
|
|
12702
|
-
}
|
|
12703
|
-
return { ok: false, error: "BUY_UNSUPPORTED", message: "Buy not supported by this doppler-sdk version. Use executeV3BuyExactIn/urExecute helpers or upgrade doppler-sdk." };
|
|
12704
|
-
}
|
|
12705
|
-
async function migrate(sdk, asset) {
|
|
12706
|
-
if (sdk.airlock && typeof sdk.airlock.migrate === "function") {
|
|
12707
|
-
return await sdk.airlock.migrate({ asset });
|
|
12708
|
-
}
|
|
12709
|
-
throw new Error("Migrate is not supported by the current doppler-sdk version");
|
|
12710
|
-
}
|
|
12711
|
-
module2.exports = {
|
|
12712
|
-
initDoppler,
|
|
12713
|
-
deployDynamicAuction,
|
|
12714
|
-
getAuctionStatus,
|
|
12715
|
-
listAuctions,
|
|
12716
|
-
buyTokens,
|
|
12717
|
-
migrate
|
|
12718
|
-
};
|
|
12719
|
-
module2.exports.deployStaticAuction = async function deployStaticAuction(sdk, user, p) {
|
|
12720
|
-
const StaticAuctionBuilder = dopplerLib.StaticAuctionBuilder || dopplerLib.default?.StaticAuctionBuilder;
|
|
12721
|
-
if (!StaticAuctionBuilder) throw new Error("StaticAuctionBuilder missing from doppler-sdk");
|
|
12722
|
-
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);
|
|
12723
|
-
if (p.governance?.noOp) builder.withGovernance({ noOp: true });
|
|
12724
|
-
if (p.migration) builder.withMigration(p.migration);
|
|
12725
|
-
if (p.modules?.airlock && typeof builder.withAirlock === "function") builder.withAirlock(p.modules.airlock);
|
|
12726
|
-
if (p.modules?.v3Initializer && typeof builder.withV3Initializer === "function") builder.withV3Initializer(p.modules.v3Initializer);
|
|
12727
|
-
const params = builder.build();
|
|
12728
|
-
const res = await sdk.factory.createStaticAuction(params);
|
|
12729
|
-
return res;
|
|
12730
|
-
};
|
|
12731
|
-
module2.exports.getStaticPoolInfo = async function getStaticPoolInfo(sdk, poolAddress) {
|
|
12732
|
-
const auction = await sdk.getStaticAuction(poolAddress);
|
|
12733
|
-
return auction.getPoolInfo();
|
|
12734
|
-
};
|
|
12735
|
-
module2.exports.quoteV3ExactIn = async function quoteV3ExactIn(sdk, { tokenIn, tokenOut, amountIn, fee, sqrtPriceLimitX96 = 0n }) {
|
|
12736
|
-
return sdk.quoter.quoteExactInputV3({ tokenIn, tokenOut, amountIn, fee, sqrtPriceLimitX96 });
|
|
12737
|
-
};
|
|
12738
|
-
var WETH_ABI = [
|
|
12739
|
-
{ type: "function", name: "deposit", stateMutability: "payable", inputs: [], outputs: [] },
|
|
12740
|
-
{ type: "function", name: "withdraw", stateMutability: "nonpayable", inputs: [{ name: "wad", type: "uint256" }], outputs: [] },
|
|
12741
|
-
{ type: "function", name: "balanceOf", stateMutability: "view", inputs: [{ name: "a", type: "address" }], outputs: [{ type: "uint256" }] }
|
|
12742
|
-
];
|
|
12743
|
-
module2.exports.wrapEthToWethIfNeeded = async function wrapEthToWethIfNeeded({ rpcUrl, chainId, privateKey, weth, owner, minAmount }) {
|
|
12744
|
-
const chain = getChainById(chainId);
|
|
12745
|
-
const accountObj = privateKeyToAccount(privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`);
|
|
12746
|
-
const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
|
|
12747
|
-
const walletClient = createWalletClient({ chain, transport: http(rpcUrl), account: accountObj });
|
|
12748
|
-
const bal = await publicClient.readContract({ address: weth, abi: WETH_ABI, functionName: "balanceOf", args: [owner] });
|
|
12749
|
-
if (bal >= minAmount) return { deposited: 0n };
|
|
12750
|
-
const needed = minAmount - bal;
|
|
12751
|
-
const hash = await walletClient.writeContract({ address: weth, abi: WETH_ABI, functionName: "deposit", args: [], value: needed });
|
|
12752
|
-
await publicClient.waitForTransactionReceipt({ hash });
|
|
12753
|
-
return { deposited: needed, hash };
|
|
12754
|
-
};
|
|
12755
|
-
module2.exports.getDynamicHookInfo = async function getDynamicHookInfo(sdk, hookAddress) {
|
|
12756
|
-
const auction = await sdk.getDynamicAuction(hookAddress);
|
|
12757
|
-
return auction.getHookInfo();
|
|
12758
|
-
};
|
|
12759
|
-
module2.exports.quoteV4ExactIn = async function quoteV4ExactIn(sdk, { poolKey, zeroForOne, exactAmount, hookData }) {
|
|
12760
|
-
return sdk.quoter.quoteExactInputV4({ poolKey, zeroForOne, exactAmount, hookData });
|
|
12761
|
-
};
|
|
12762
|
-
var UR_ABI = [
|
|
12763
|
-
{ name: "execute", type: "function", stateMutability: "payable", inputs: [{ name: "commands", type: "bytes" }, { name: "inputs", type: "bytes[]" }], outputs: [] }
|
|
12764
|
-
];
|
|
12765
|
-
module2.exports.urExecute = async function urExecute({ rpcUrl, chainId, privateKey, universalRouter, commands, inputs, value }) {
|
|
12766
|
-
const chain = getChainById(chainId);
|
|
12767
|
-
const accountObj = privateKeyToAccount(privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`);
|
|
12768
|
-
const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
|
|
12769
|
-
const walletClient = createWalletClient({ chain, transport: http(rpcUrl), account: accountObj });
|
|
12770
|
-
const hash = await walletClient.writeContract({ address: universalRouter, abi: UR_ABI, functionName: "execute", args: [commands, inputs], value: value || 0n });
|
|
12771
|
-
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
12772
|
-
return { hash, receipt };
|
|
12773
|
-
};
|
|
12774
|
-
module2.exports.simulateCreateStaticAuction = async function simulateCreateStaticAuction(sdk, builderParams) {
|
|
12775
|
-
const StaticAuctionBuilder = dopplerLib.StaticAuctionBuilder || dopplerLib.default?.StaticAuctionBuilder;
|
|
12776
|
-
if (!StaticAuctionBuilder) throw new Error("StaticAuctionBuilder missing from doppler-sdk");
|
|
12777
|
-
const builder = new StaticAuctionBuilder().tokenConfig(builderParams.token).saleConfig(builderParams.sale).poolByTicks(builderParams.pool).withUserAddress(builderParams.userAddress);
|
|
12778
|
-
if (builderParams.governance) builder.withGovernance(builderParams.governance);
|
|
12779
|
-
if (builderParams.migration) builder.withMigration(builderParams.migration);
|
|
12780
|
-
if (builderParams.modules?.v3Initializer && typeof builder.withV3Initializer === "function") builder.withV3Initializer(builderParams.modules.v3Initializer);
|
|
12781
|
-
if (builderParams.modules?.airlock && typeof builder.withAirlock === "function") builder.withAirlock(builderParams.modules.airlock);
|
|
12782
|
-
const params = builder.build();
|
|
12783
|
-
return sdk.factory.simulateCreateStaticAuction(params);
|
|
12784
|
-
};
|
|
12785
|
-
module2.exports.simulateBundleExactOut = async function simulateBundleExactOut(sdk, createParams, { tokenIn, tokenOut, amount, fee, sqrtPriceLimitX96 = 0n }) {
|
|
12786
|
-
return sdk.factory.simulateBundleExactOutput(createParams, { tokenIn, tokenOut, amount, fee, sqrtPriceLimitX96 });
|
|
12787
|
-
};
|
|
12788
|
-
module2.exports.factoryBundle = async function factoryBundle(sdk, createParams, { commands, inputs, value }) {
|
|
12789
|
-
return sdk.factory.bundle(createParams, commands, inputs, { value });
|
|
12790
|
-
};
|
|
12791
|
-
var V3_SWAP_ROUTER_ABI = [
|
|
12792
|
-
{
|
|
12793
|
-
name: "exactInputSingle",
|
|
12794
|
-
type: "function",
|
|
12795
|
-
stateMutability: "payable",
|
|
12796
|
-
inputs: [
|
|
12797
|
-
{
|
|
12798
|
-
name: "params",
|
|
12799
|
-
type: "tuple",
|
|
12800
|
-
components: [
|
|
12801
|
-
{ name: "tokenIn", type: "address" },
|
|
12802
|
-
{ name: "tokenOut", type: "address" },
|
|
12803
|
-
{ name: "fee", type: "uint24" },
|
|
12804
|
-
{ name: "recipient", type: "address" },
|
|
12805
|
-
{ name: "deadline", type: "uint256" },
|
|
12806
|
-
{ name: "amountIn", type: "uint256" },
|
|
12807
|
-
{ name: "amountOutMinimum", type: "uint256" },
|
|
12808
|
-
{ name: "sqrtPriceLimitX96", type: "uint160" }
|
|
12809
|
-
]
|
|
12810
|
-
}
|
|
12811
|
-
],
|
|
12812
|
-
outputs: [{ name: "amountOut", type: "uint256" }]
|
|
12813
|
-
}
|
|
12814
|
-
];
|
|
12815
|
-
module2.exports.executeV3BuyExactIn = async function executeV3BuyExactIn({
|
|
12816
|
-
rpcUrl,
|
|
12817
|
-
chainId,
|
|
12818
|
-
privateKey,
|
|
12819
|
-
router,
|
|
12820
|
-
tokenIn,
|
|
12821
|
-
tokenOut,
|
|
12822
|
-
fee,
|
|
12823
|
-
amountIn,
|
|
12824
|
-
amountOutMinimum,
|
|
12825
|
-
recipient,
|
|
12826
|
-
deadline
|
|
12827
|
-
}) {
|
|
12828
|
-
const chain = getChainById(chainId);
|
|
12829
|
-
const accountObj = privateKeyToAccount(privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`);
|
|
12830
|
-
const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
|
|
12831
|
-
const walletClient = createWalletClient({ chain, transport: http(rpcUrl), account: accountObj });
|
|
12832
|
-
const allowance = await publicClient.readContract({
|
|
12833
|
-
address: tokenIn,
|
|
12834
|
-
abi: erc20Abi,
|
|
12835
|
-
functionName: "allowance",
|
|
12836
|
-
args: [accountObj.address, router]
|
|
12837
|
-
});
|
|
12838
|
-
if (allowance < amountIn) {
|
|
12839
|
-
await walletClient.writeContract({
|
|
12840
|
-
address: tokenIn,
|
|
12841
|
-
abi: erc20Abi,
|
|
12842
|
-
functionName: "approve",
|
|
12843
|
-
args: [router, amountIn]
|
|
12844
|
-
});
|
|
12845
|
-
}
|
|
12846
|
-
const hash = await walletClient.writeContract({
|
|
12847
|
-
address: router,
|
|
12848
|
-
abi: V3_SWAP_ROUTER_ABI,
|
|
12849
|
-
functionName: "exactInputSingle",
|
|
12850
|
-
args: [
|
|
12851
|
-
{
|
|
12852
|
-
tokenIn,
|
|
12853
|
-
tokenOut,
|
|
12854
|
-
fee,
|
|
12855
|
-
recipient,
|
|
12856
|
-
deadline,
|
|
12857
|
-
amountIn,
|
|
12858
|
-
amountOutMinimum,
|
|
12859
|
-
sqrtPriceLimitX96: 0n
|
|
12860
|
-
}
|
|
12861
|
-
],
|
|
12862
|
-
value: 0n
|
|
12863
|
-
});
|
|
12864
|
-
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
12865
|
-
return { hash, receipt };
|
|
12866
|
-
};
|
|
12867
|
-
}
|
|
12868
|
-
});
|
|
12869
|
-
|
|
12870
12292
|
// src/points.js
|
|
12871
12293
|
var require_points = __commonJS({
|
|
12872
12294
|
"src/points.js"(exports2, module2) {
|
|
@@ -14939,7 +14361,6 @@ var require_src = __commonJS({
|
|
|
14939
14361
|
var ipns = require_ipns();
|
|
14940
14362
|
var token = require_token();
|
|
14941
14363
|
var personal = require_personal();
|
|
14942
|
-
var premium = require_premium();
|
|
14943
14364
|
var subgraph = require_subgraph();
|
|
14944
14365
|
var privateTx = require_privateTx();
|
|
14945
14366
|
var safe = require_safe();
|
|
@@ -14958,7 +14379,6 @@ var require_src = __commonJS({
|
|
|
14958
14379
|
var walletTyped = require_typed();
|
|
14959
14380
|
var utils = require_provider();
|
|
14960
14381
|
var errors = require_errors();
|
|
14961
|
-
var doppler = require_doppler();
|
|
14962
14382
|
var adapters = {
|
|
14963
14383
|
transports: require_transports(),
|
|
14964
14384
|
governance: {
|
|
@@ -14994,7 +14414,7 @@ var require_src = __commonJS({
|
|
|
14994
14414
|
SageEchoExecutor,
|
|
14995
14415
|
token,
|
|
14996
14416
|
personal,
|
|
14997
|
-
premium
|
|
14417
|
+
// premium: removed — PremiumPrompts deprecated
|
|
14998
14418
|
treasury,
|
|
14999
14419
|
boost,
|
|
15000
14420
|
// bond module removed; bonds deprecated in CLI/SDK
|
|
@@ -15011,7 +14431,6 @@ var require_src = __commonJS({
|
|
|
15011
14431
|
}),
|
|
15012
14432
|
walletTyped,
|
|
15013
14433
|
errors,
|
|
15014
|
-
doppler,
|
|
15015
14434
|
adapters,
|
|
15016
14435
|
// Season points helpers (airdrops/testnet)
|
|
15017
14436
|
points,
|