@flaunch/sdk 0.9.12 → 0.9.14

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.cjs.js CHANGED
@@ -5710,7 +5710,6 @@ const FlaunchAddress = {
5710
5710
  [base.id]: "0xCc7A4A00072ccbeEEbd999edc812C0ce498Fb63B",
5711
5711
  [baseSepolia.id]: "0x7D375C9133721083DF7b7e5Cb0Ed8Fc78862dfe3",
5712
5712
  };
5713
- // also supports AnyPositionManager
5714
5713
  const FlaunchV1_1Address = {
5715
5714
  [base.id]: "0xb4512bf57d50fbcb64a3adf8b17a79b2a204c18c",
5716
5715
  [baseSepolia.id]: "0x96be8ff5e244294a34bfa507a39190dc7a839baa",
@@ -15161,6 +15160,554 @@ class ReadFlaunch {
15161
15160
  }
15162
15161
  }
15163
15162
 
15163
+ const AnyFlaunchAbi = [
15164
+ {
15165
+ inputs: [{ internalType: "string", name: "_baseURI", type: "string" }],
15166
+ stateMutability: "nonpayable",
15167
+ type: "constructor",
15168
+ },
15169
+ { inputs: [], name: "AccountBalanceOverflow", type: "error" },
15170
+ { inputs: [], name: "AlreadyInitialized", type: "error" },
15171
+ { inputs: [], name: "BalanceQueryForZeroAddress", type: "error" },
15172
+ { inputs: [], name: "BaseURICannotBeEmpty", type: "error" },
15173
+ { inputs: [], name: "CallerIsNotPositionManager", type: "error" },
15174
+ {
15175
+ inputs: [
15176
+ { internalType: "uint24", name: "_allocation", type: "uint24" },
15177
+ { internalType: "uint256", name: "_maxAllocation", type: "uint256" },
15178
+ ],
15179
+ name: "CreatorFeeAllocationInvalid",
15180
+ type: "error",
15181
+ },
15182
+ { inputs: [], name: "InvalidInitialization", type: "error" },
15183
+ { inputs: [], name: "NewOwnerIsZeroAddress", type: "error" },
15184
+ { inputs: [], name: "NoHandoverRequest", type: "error" },
15185
+ { inputs: [], name: "NotInitializing", type: "error" },
15186
+ { inputs: [], name: "NotOwnerNorApproved", type: "error" },
15187
+ { inputs: [], name: "TokenAlreadyExists", type: "error" },
15188
+ { inputs: [], name: "TokenDoesNotExist", type: "error" },
15189
+ { inputs: [], name: "TransferFromIncorrectOwner", type: "error" },
15190
+ { inputs: [], name: "TransferToNonERC721ReceiverImplementer", type: "error" },
15191
+ { inputs: [], name: "TransferToZeroAddress", type: "error" },
15192
+ { inputs: [], name: "Unauthorized", type: "error" },
15193
+ {
15194
+ anonymous: false,
15195
+ inputs: [
15196
+ {
15197
+ indexed: true,
15198
+ internalType: "address",
15199
+ name: "owner",
15200
+ type: "address",
15201
+ },
15202
+ {
15203
+ indexed: true,
15204
+ internalType: "address",
15205
+ name: "account",
15206
+ type: "address",
15207
+ },
15208
+ { indexed: true, internalType: "uint256", name: "id", type: "uint256" },
15209
+ ],
15210
+ name: "Approval",
15211
+ type: "event",
15212
+ },
15213
+ {
15214
+ anonymous: false,
15215
+ inputs: [
15216
+ {
15217
+ indexed: true,
15218
+ internalType: "address",
15219
+ name: "owner",
15220
+ type: "address",
15221
+ },
15222
+ {
15223
+ indexed: true,
15224
+ internalType: "address",
15225
+ name: "operator",
15226
+ type: "address",
15227
+ },
15228
+ {
15229
+ indexed: false,
15230
+ internalType: "bool",
15231
+ name: "isApproved",
15232
+ type: "bool",
15233
+ },
15234
+ ],
15235
+ name: "ApprovalForAll",
15236
+ type: "event",
15237
+ },
15238
+ {
15239
+ anonymous: false,
15240
+ inputs: [
15241
+ {
15242
+ indexed: false,
15243
+ internalType: "string",
15244
+ name: "_newBaseURI",
15245
+ type: "string",
15246
+ },
15247
+ ],
15248
+ name: "BaseURIUpdated",
15249
+ type: "event",
15250
+ },
15251
+ {
15252
+ anonymous: false,
15253
+ inputs: [
15254
+ {
15255
+ indexed: false,
15256
+ internalType: "uint64",
15257
+ name: "version",
15258
+ type: "uint64",
15259
+ },
15260
+ ],
15261
+ name: "Initialized",
15262
+ type: "event",
15263
+ },
15264
+ {
15265
+ anonymous: false,
15266
+ inputs: [
15267
+ {
15268
+ indexed: false,
15269
+ internalType: "address",
15270
+ name: "_newImplementation",
15271
+ type: "address",
15272
+ },
15273
+ ],
15274
+ name: "MemecoinTreasuryImplementationUpdated",
15275
+ type: "event",
15276
+ },
15277
+ {
15278
+ anonymous: false,
15279
+ inputs: [
15280
+ {
15281
+ indexed: true,
15282
+ internalType: "address",
15283
+ name: "pendingOwner",
15284
+ type: "address",
15285
+ },
15286
+ ],
15287
+ name: "OwnershipHandoverCanceled",
15288
+ type: "event",
15289
+ },
15290
+ {
15291
+ anonymous: false,
15292
+ inputs: [
15293
+ {
15294
+ indexed: true,
15295
+ internalType: "address",
15296
+ name: "pendingOwner",
15297
+ type: "address",
15298
+ },
15299
+ ],
15300
+ name: "OwnershipHandoverRequested",
15301
+ type: "event",
15302
+ },
15303
+ {
15304
+ anonymous: false,
15305
+ inputs: [
15306
+ {
15307
+ indexed: true,
15308
+ internalType: "address",
15309
+ name: "oldOwner",
15310
+ type: "address",
15311
+ },
15312
+ {
15313
+ indexed: true,
15314
+ internalType: "address",
15315
+ name: "newOwner",
15316
+ type: "address",
15317
+ },
15318
+ ],
15319
+ name: "OwnershipTransferred",
15320
+ type: "event",
15321
+ },
15322
+ {
15323
+ anonymous: false,
15324
+ inputs: [
15325
+ { indexed: true, internalType: "address", name: "from", type: "address" },
15326
+ { indexed: true, internalType: "address", name: "to", type: "address" },
15327
+ { indexed: true, internalType: "uint256", name: "id", type: "uint256" },
15328
+ ],
15329
+ name: "Transfer",
15330
+ type: "event",
15331
+ },
15332
+ {
15333
+ inputs: [],
15334
+ name: "MAX_CREATOR_ALLOCATION",
15335
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
15336
+ stateMutability: "view",
15337
+ type: "function",
15338
+ },
15339
+ {
15340
+ inputs: [
15341
+ { internalType: "address", name: "account", type: "address" },
15342
+ { internalType: "uint256", name: "id", type: "uint256" },
15343
+ ],
15344
+ name: "approve",
15345
+ outputs: [],
15346
+ stateMutability: "payable",
15347
+ type: "function",
15348
+ },
15349
+ {
15350
+ inputs: [{ internalType: "address", name: "owner", type: "address" }],
15351
+ name: "balanceOf",
15352
+ outputs: [{ internalType: "uint256", name: "result", type: "uint256" }],
15353
+ stateMutability: "view",
15354
+ type: "function",
15355
+ },
15356
+ {
15357
+ inputs: [],
15358
+ name: "baseURI",
15359
+ outputs: [{ internalType: "string", name: "", type: "string" }],
15360
+ stateMutability: "view",
15361
+ type: "function",
15362
+ },
15363
+ {
15364
+ inputs: [{ internalType: "uint256", name: "_tokenId", type: "uint256" }],
15365
+ name: "burn",
15366
+ outputs: [],
15367
+ stateMutability: "nonpayable",
15368
+ type: "function",
15369
+ },
15370
+ {
15371
+ inputs: [],
15372
+ name: "cancelOwnershipHandover",
15373
+ outputs: [],
15374
+ stateMutability: "payable",
15375
+ type: "function",
15376
+ },
15377
+ {
15378
+ inputs: [
15379
+ { internalType: "address", name: "pendingOwner", type: "address" },
15380
+ ],
15381
+ name: "completeOwnershipHandover",
15382
+ outputs: [],
15383
+ stateMutability: "payable",
15384
+ type: "function",
15385
+ },
15386
+ {
15387
+ inputs: [{ internalType: "address", name: "_memecoin", type: "address" }],
15388
+ name: "creator",
15389
+ outputs: [{ internalType: "address", name: "creator_", type: "address" }],
15390
+ stateMutability: "view",
15391
+ type: "function",
15392
+ },
15393
+ {
15394
+ inputs: [
15395
+ {
15396
+ components: [
15397
+ { internalType: "address", name: "memecoin", type: "address" },
15398
+ { internalType: "address", name: "creator", type: "address" },
15399
+ {
15400
+ internalType: "uint24",
15401
+ name: "creatorFeeAllocation",
15402
+ type: "uint24",
15403
+ },
15404
+ { internalType: "bytes", name: "initialPriceParams", type: "bytes" },
15405
+ { internalType: "bytes", name: "feeCalculatorParams", type: "bytes" },
15406
+ ],
15407
+ internalType: "struct AnyPositionManager.FlaunchParams",
15408
+ name: "_params",
15409
+ type: "tuple",
15410
+ },
15411
+ ],
15412
+ name: "flaunch",
15413
+ outputs: [
15414
+ {
15415
+ internalType: "address payable",
15416
+ name: "memecoinTreasury_",
15417
+ type: "address",
15418
+ },
15419
+ { internalType: "uint256", name: "tokenId_", type: "uint256" },
15420
+ ],
15421
+ stateMutability: "nonpayable",
15422
+ type: "function",
15423
+ },
15424
+ {
15425
+ inputs: [{ internalType: "uint256", name: "id", type: "uint256" }],
15426
+ name: "getApproved",
15427
+ outputs: [{ internalType: "address", name: "result", type: "address" }],
15428
+ stateMutability: "view",
15429
+ type: "function",
15430
+ },
15431
+ {
15432
+ inputs: [
15433
+ {
15434
+ internalType: "contract AnyPositionManager",
15435
+ name: "_positionManager",
15436
+ type: "address",
15437
+ },
15438
+ {
15439
+ internalType: "address",
15440
+ name: "_memecoinTreasuryImplementation",
15441
+ type: "address",
15442
+ },
15443
+ ],
15444
+ name: "initialize",
15445
+ outputs: [],
15446
+ stateMutability: "nonpayable",
15447
+ type: "function",
15448
+ },
15449
+ {
15450
+ inputs: [
15451
+ { internalType: "address", name: "owner", type: "address" },
15452
+ { internalType: "address", name: "operator", type: "address" },
15453
+ ],
15454
+ name: "isApprovedForAll",
15455
+ outputs: [{ internalType: "bool", name: "result", type: "bool" }],
15456
+ stateMutability: "view",
15457
+ type: "function",
15458
+ },
15459
+ {
15460
+ inputs: [{ internalType: "uint256", name: "_tokenId", type: "uint256" }],
15461
+ name: "memecoin",
15462
+ outputs: [{ internalType: "address", name: "", type: "address" }],
15463
+ stateMutability: "view",
15464
+ type: "function",
15465
+ },
15466
+ {
15467
+ inputs: [{ internalType: "address", name: "_memecoin", type: "address" }],
15468
+ name: "memecoinTreasury",
15469
+ outputs: [{ internalType: "address payable", name: "", type: "address" }],
15470
+ stateMutability: "view",
15471
+ type: "function",
15472
+ },
15473
+ {
15474
+ inputs: [{ internalType: "uint256", name: "_tokenId", type: "uint256" }],
15475
+ name: "memecoinTreasury",
15476
+ outputs: [{ internalType: "address payable", name: "", type: "address" }],
15477
+ stateMutability: "view",
15478
+ type: "function",
15479
+ },
15480
+ {
15481
+ inputs: [],
15482
+ name: "memecoinTreasuryImplementation",
15483
+ outputs: [{ internalType: "address", name: "", type: "address" }],
15484
+ stateMutability: "view",
15485
+ type: "function",
15486
+ },
15487
+ {
15488
+ inputs: [],
15489
+ name: "name",
15490
+ outputs: [{ internalType: "string", name: "", type: "string" }],
15491
+ stateMutability: "view",
15492
+ type: "function",
15493
+ },
15494
+ {
15495
+ inputs: [],
15496
+ name: "nextTokenId",
15497
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
15498
+ stateMutability: "view",
15499
+ type: "function",
15500
+ },
15501
+ {
15502
+ inputs: [],
15503
+ name: "owner",
15504
+ outputs: [{ internalType: "address", name: "result", type: "address" }],
15505
+ stateMutability: "view",
15506
+ type: "function",
15507
+ },
15508
+ {
15509
+ inputs: [{ internalType: "uint256", name: "id", type: "uint256" }],
15510
+ name: "ownerOf",
15511
+ outputs: [{ internalType: "address", name: "result", type: "address" }],
15512
+ stateMutability: "view",
15513
+ type: "function",
15514
+ },
15515
+ {
15516
+ inputs: [
15517
+ { internalType: "address", name: "pendingOwner", type: "address" },
15518
+ ],
15519
+ name: "ownershipHandoverExpiresAt",
15520
+ outputs: [{ internalType: "uint256", name: "result", type: "uint256" }],
15521
+ stateMutability: "view",
15522
+ type: "function",
15523
+ },
15524
+ {
15525
+ inputs: [{ internalType: "uint256", name: "_tokenId", type: "uint256" }],
15526
+ name: "poolId",
15527
+ outputs: [{ internalType: "PoolId", name: "", type: "bytes32" }],
15528
+ stateMutability: "view",
15529
+ type: "function",
15530
+ },
15531
+ {
15532
+ inputs: [],
15533
+ name: "positionManager",
15534
+ outputs: [
15535
+ {
15536
+ internalType: "contract AnyPositionManager",
15537
+ name: "",
15538
+ type: "address",
15539
+ },
15540
+ ],
15541
+ stateMutability: "view",
15542
+ type: "function",
15543
+ },
15544
+ {
15545
+ inputs: [],
15546
+ name: "renounceOwnership",
15547
+ outputs: [],
15548
+ stateMutability: "payable",
15549
+ type: "function",
15550
+ },
15551
+ {
15552
+ inputs: [],
15553
+ name: "requestOwnershipHandover",
15554
+ outputs: [],
15555
+ stateMutability: "payable",
15556
+ type: "function",
15557
+ },
15558
+ {
15559
+ inputs: [
15560
+ { internalType: "address", name: "from", type: "address" },
15561
+ { internalType: "address", name: "to", type: "address" },
15562
+ { internalType: "uint256", name: "id", type: "uint256" },
15563
+ ],
15564
+ name: "safeTransferFrom",
15565
+ outputs: [],
15566
+ stateMutability: "payable",
15567
+ type: "function",
15568
+ },
15569
+ {
15570
+ inputs: [
15571
+ { internalType: "address", name: "from", type: "address" },
15572
+ { internalType: "address", name: "to", type: "address" },
15573
+ { internalType: "uint256", name: "id", type: "uint256" },
15574
+ { internalType: "bytes", name: "data", type: "bytes" },
15575
+ ],
15576
+ name: "safeTransferFrom",
15577
+ outputs: [],
15578
+ stateMutability: "payable",
15579
+ type: "function",
15580
+ },
15581
+ {
15582
+ inputs: [
15583
+ { internalType: "address", name: "operator", type: "address" },
15584
+ { internalType: "bool", name: "isApproved", type: "bool" },
15585
+ ],
15586
+ name: "setApprovalForAll",
15587
+ outputs: [],
15588
+ stateMutability: "nonpayable",
15589
+ type: "function",
15590
+ },
15591
+ {
15592
+ inputs: [{ internalType: "string", name: "_baseURI", type: "string" }],
15593
+ name: "setBaseURI",
15594
+ outputs: [],
15595
+ stateMutability: "nonpayable",
15596
+ type: "function",
15597
+ },
15598
+ {
15599
+ inputs: [
15600
+ {
15601
+ internalType: "address",
15602
+ name: "_memecoinTreasuryImplementation",
15603
+ type: "address",
15604
+ },
15605
+ ],
15606
+ name: "setMemecoinTreasuryImplementation",
15607
+ outputs: [],
15608
+ stateMutability: "nonpayable",
15609
+ type: "function",
15610
+ },
15611
+ {
15612
+ inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }],
15613
+ name: "supportsInterface",
15614
+ outputs: [{ internalType: "bool", name: "result", type: "bool" }],
15615
+ stateMutability: "view",
15616
+ type: "function",
15617
+ },
15618
+ {
15619
+ inputs: [],
15620
+ name: "symbol",
15621
+ outputs: [{ internalType: "string", name: "", type: "string" }],
15622
+ stateMutability: "view",
15623
+ type: "function",
15624
+ },
15625
+ {
15626
+ inputs: [{ internalType: "address", name: "_memecoin", type: "address" }],
15627
+ name: "tokenId",
15628
+ outputs: [{ internalType: "uint256", name: "_tokenId", type: "uint256" }],
15629
+ stateMutability: "view",
15630
+ type: "function",
15631
+ },
15632
+ {
15633
+ inputs: [{ internalType: "uint256", name: "_tokenId", type: "uint256" }],
15634
+ name: "tokenURI",
15635
+ outputs: [{ internalType: "string", name: "", type: "string" }],
15636
+ stateMutability: "view",
15637
+ type: "function",
15638
+ },
15639
+ {
15640
+ inputs: [
15641
+ { internalType: "address", name: "from", type: "address" },
15642
+ { internalType: "address", name: "to", type: "address" },
15643
+ { internalType: "uint256", name: "id", type: "uint256" },
15644
+ ],
15645
+ name: "transferFrom",
15646
+ outputs: [],
15647
+ stateMutability: "payable",
15648
+ type: "function",
15649
+ },
15650
+ {
15651
+ inputs: [{ internalType: "address", name: "newOwner", type: "address" }],
15652
+ name: "transferOwnership",
15653
+ outputs: [],
15654
+ stateMutability: "payable",
15655
+ type: "function",
15656
+ },
15657
+ ];
15658
+
15659
+ /**
15660
+ * Client for interacting with the AnyFlaunch contract in read-only mode
15661
+ * Provides methods to query token IDs and metadata URIs
15662
+ */
15663
+ class ReadAnyFlaunch {
15664
+ /**
15665
+ * Creates a new ReadAnyFlaunch instance
15666
+ * @param address - The address of the AnyFlaunch contract
15667
+ * @param drift - Optional drift instance for contract interactions (creates new instance if not provided)
15668
+ * @throws Error if address is not provided
15669
+ */
15670
+ constructor(address, drift$1 = drift.createDrift()) {
15671
+ if (!address) {
15672
+ throw new Error("Address is required");
15673
+ }
15674
+ this.contract = drift$1.contract({
15675
+ abi: AnyFlaunchAbi,
15676
+ address,
15677
+ });
15678
+ }
15679
+ /**
15680
+ * Gets the token ID associated with a memecoin
15681
+ * @param coinAddress - The address of the memecoin
15682
+ * @returns Promise<bigint> - The token ID
15683
+ */
15684
+ tokenId(coinAddress) {
15685
+ return this.contract.read("tokenId", {
15686
+ _memecoin: coinAddress,
15687
+ });
15688
+ }
15689
+ /**
15690
+ * Gets the metadata URI for a token
15691
+ * @param tokenId - The ID of the token
15692
+ * @returns Promise<string> - The token's metadata URI
15693
+ */
15694
+ tokenURI(tokenId) {
15695
+ return this.contract.read("tokenURI", {
15696
+ _tokenId: tokenId,
15697
+ });
15698
+ }
15699
+ /**
15700
+ * Gets the memecoin address for a given token ID
15701
+ * @param tokenId - The ID of the token
15702
+ * @returns Promise<Address> - The address of the memecoin
15703
+ */
15704
+ memecoin(tokenId) {
15705
+ return this.contract.read("memecoin", {
15706
+ _tokenId: tokenId,
15707
+ });
15708
+ }
15709
+ }
15710
+
15164
15711
  const MemecoinAbi = [
15165
15712
  { inputs: [], stateMutability: "nonpayable", type: "constructor" },
15166
15713
  { inputs: [], name: "CallerNotFlaunch", type: "error" },
@@ -26295,6 +26842,7 @@ class ReadFlaunchSDK {
26295
26842
  this.readFlaunch = new ReadFlaunch(FlaunchAddress[this.chainId], drift$1);
26296
26843
  this.readFlaunchV1_1 = new ReadFlaunchV1_1(FlaunchV1_1Address[this.chainId], drift$1);
26297
26844
  this.readFlaunchV1_2 = new ReadFlaunchV1_2(FlaunchV1_2Address[this.chainId], drift$1);
26845
+ this.readAnyFlaunch = new ReadAnyFlaunch(AnyFlaunchAddress[this.chainId], drift$1);
26298
26846
  this.readQuoter = new ReadQuoter(this.chainId, QuoterAddress[this.chainId], drift$1);
26299
26847
  this.readPermit2 = new ReadPermit2(Permit2Address[this.chainId], drift$1);
26300
26848
  }
@@ -26385,23 +26933,30 @@ class ReadFlaunchSDK {
26385
26933
  }
26386
26934
  }
26387
26935
  /**
26388
- * Gets the flaunch contract address for a given version
26389
- * @param version - The version to get the flaunch contract address for
26936
+ * Gets the flaunch contract instance for a given version
26937
+ * @param version - The version to get the flaunch contract instance for
26390
26938
  */
26391
- getFlaunchAddress(version) {
26939
+ getFlaunch(version) {
26392
26940
  switch (version) {
26393
26941
  case exports.FlaunchVersion.V1:
26394
- return this.readFlaunch.contract.address;
26942
+ return this.readFlaunch;
26395
26943
  case exports.FlaunchVersion.V1_1:
26396
- return this.readFlaunchV1_1.contract.address;
26944
+ return this.readFlaunchV1_1;
26397
26945
  case exports.FlaunchVersion.V1_2:
26398
- return this.readFlaunchV1_2.contract.address;
26946
+ return this.readFlaunchV1_2;
26399
26947
  case exports.FlaunchVersion.ANY:
26400
- return this.readFlaunchV1_1.contract.address;
26948
+ return this.readAnyFlaunch;
26401
26949
  default:
26402
- return this.readFlaunchV1_1.contract.address;
26950
+ return this.readFlaunchV1_2;
26403
26951
  }
26404
26952
  }
26953
+ /**
26954
+ * Gets the flaunch contract address for a given version
26955
+ * @param version - The version to get the flaunch contract address for
26956
+ */
26957
+ getFlaunchAddress(version) {
26958
+ return this.getFlaunch(version).contract.address;
26959
+ }
26405
26960
  getPositionManagerAddress(version) {
26406
26961
  return this.getPositionManager(version).contract.address;
26407
26962
  }
@@ -26411,6 +26966,20 @@ class ReadFlaunchSDK {
26411
26966
  getBidWallAddress(version) {
26412
26967
  return this.getBidWall(version).contract.address;
26413
26968
  }
26969
+ /**
26970
+ * Gets the flaunch contract address and token ID for a memecoin
26971
+ * @param coinAddress - The address of the memecoin
26972
+ * @returns Promise<{ flaunchAddress: Address; tokenId: bigint }> - The flaunch contract address and token ID
26973
+ */
26974
+ async getFlaunchTokenIdForMemecoin(coinAddress) {
26975
+ const version = await this.getCoinVersion(coinAddress);
26976
+ const flaunch = this.getFlaunch(version);
26977
+ const tokenId = await flaunch.tokenId(coinAddress);
26978
+ return {
26979
+ flaunchAddress: flaunch.contract.address,
26980
+ tokenId,
26981
+ };
26982
+ }
26414
26983
  /**
26415
26984
  * Retrieves metadata for a given Flaunch coin
26416
26985
  * @param coinAddress - The address of the coin
@@ -28232,7 +28801,8 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
28232
28801
  const amount0 = poolKey.currency0 === coinAddress ? coinAmount : flethAmount;
28233
28802
  const amount1 = poolKey.currency0 === coinAddress ? flethAmount : coinAmount;
28234
28803
  // Calculate and constrain liquidity using shared method
28235
- const { finalLiquidity, finalAmount0, finalAmount1 } = this.calculateConstrainedLiquidity(currentTick, tickLower, tickUpper, amount0, amount1);
28804
+ const slippagePercent = params.slippagePercent;
28805
+ const { finalLiquidity, finalAmount0, finalAmount1 } = this.calculateConstrainedLiquidity(currentTick, tickLower, tickUpper, amount0, amount1, slippagePercent);
28236
28806
  // 6. Add liquidity
28237
28807
  calls.push(this.createLiquidityCall(poolKey, tickLower, tickUpper, finalLiquidity, finalAmount0, finalAmount1, userAddress));
28238
28808
  return calls;
@@ -28281,11 +28851,22 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
28281
28851
  const version = await this.determineCoinVersion(coinAddress, params.version);
28282
28852
  const poolKey = this.createPoolKey(coinAddress, version);
28283
28853
  let currentTick;
28284
- // if initial marketcap or price is provided, it means that the pool is not initialized yet
28285
- // so determining the currentTick
28286
- if (("initialMarketCapUSD" in params && params.initialMarketCapUSD) ||
28287
- ("initialPriceUSD" in params && params.initialPriceUSD)) {
28288
- const { decimals: coinDecimals, formattedTotalSupplyInDecimals } = await this.getCoinInfo(coinAddress);
28854
+ // First, check if the pool is initialized as we can then get the current tick directly from
28855
+ // the state view.
28856
+ const poolState = await this.readStateView.poolSlot0({
28857
+ poolId: getPoolId(poolKey),
28858
+ });
28859
+ currentTick = poolState.tick;
28860
+ // If the current sqrtPriceX96 of the pool is zero, and the initial marketcap or price is provided,
28861
+ // we can use this to determine the current tick.
28862
+ if (poolState.sqrtPriceX96 === 0n &&
28863
+ (("initialMarketCapUSD" in params && params.initialMarketCapUSD) ||
28864
+ ("initialPriceUSD" in params && params.initialPriceUSD))) {
28865
+ let { decimals: coinDecimals, formattedTotalSupplyInDecimals } = await this.getCoinInfo(coinAddress);
28866
+ // If we have a tokenSupply set, then overwrite the value
28867
+ if ("tokenSupply" in params && params.tokenSupply !== undefined) {
28868
+ formattedTotalSupplyInDecimals = parseFloat(viem.formatUnits(params.tokenSupply, coinDecimals));
28869
+ }
28289
28870
  // Determine market cap based on provided parameter
28290
28871
  let initialMarketCapUSD;
28291
28872
  if ("initialMarketCapUSD" in params && params.initialMarketCapUSD) {
@@ -28305,13 +28886,6 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
28305
28886
  }
28306
28887
  currentTick = calculatedTick;
28307
28888
  }
28308
- else {
28309
- // the pool is already initialized, get the current tick from the pool
28310
- const poolState = await this.readStateView.poolSlot0({
28311
- poolId: getPoolId(poolKey),
28312
- });
28313
- currentTick = poolState.tick;
28314
- }
28315
28889
  // We want to add liquidity from current price to infinity (as coin appreciates vs flETH)
28316
28890
  // This means providing single-sided coin liquidity that becomes active as coin price increases
28317
28891
  const isFLETHZero = this.flETHIsCurrencyZero(coinAddress);
@@ -28419,7 +28993,8 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
28419
28993
  const amount0 = poolKey.currency0 === coinAddress ? coinAmount : flethAmount;
28420
28994
  const amount1 = poolKey.currency0 === coinAddress ? flethAmount : coinAmount;
28421
28995
  // Calculate and constrain liquidity using shared method
28422
- const { finalLiquidity, finalAmount0, finalAmount1 } = this.calculateConstrainedLiquidity(currentTick, tickLower, tickUpper, amount0, amount1);
28996
+ const slippagePercent = params.slippagePercent;
28997
+ const { finalLiquidity, finalAmount0, finalAmount1 } = this.calculateConstrainedLiquidity(currentTick, tickLower, tickUpper, amount0, amount1, slippagePercent);
28423
28998
  // 3. Add liquidity
28424
28999
  calls.push(this.createLiquidityCall(poolKey, tickLower, tickUpper, finalLiquidity, finalAmount0, finalAmount1, userAddress));
28425
29000
  return calls;
@@ -28470,7 +29045,13 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
28470
29045
  }
28471
29046
  }
28472
29047
  const addLiquidityCalls = await this.getSingleSidedCoinAddLiquidityCalls({
29048
+ // Add our liquidity parameters
28473
29049
  ...params,
29050
+ // Add our optional tokenSupply if provided from our initialize params
29051
+ ...("_totalSupply" in importParams && {
29052
+ tokenSupply: importParams._totalSupply,
29053
+ }),
29054
+ // Set our FlaunchVersion
28474
29055
  version: exports.FlaunchVersion.ANY, // optimize to avoid fetching if not passed
28475
29056
  });
28476
29057
  return [
@@ -28494,7 +29075,8 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
28494
29075
  * @param amount1 - Amount of currency1
28495
29076
  * @returns Final liquidity and amounts
28496
29077
  */
28497
- calculateConstrainedLiquidity(currentTick, tickLower, tickUpper, amount0, amount1) {
29078
+ calculateConstrainedLiquidity(currentTick, tickLower, tickUpper, amount0, amount1, slippagePercent = 0.05 // Default to 0.05%
29079
+ ) {
28498
29080
  // Calculate liquidity first using user's input amounts
28499
29081
  const initialLiquidity = getLiquidityFromAmounts({
28500
29082
  currentTick,
@@ -28548,8 +29130,11 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
28548
29130
  finalAmount1 = constrainedAmounts.amount1;
28549
29131
  }
28550
29132
  // IMPORTANT: Add conservative buffer to account for contract rounding differences
28551
- // Reduce liquidity by 0.05% to ensure contract calculations stay within user bounds
28552
- const liquidityBuffer = finalLiquidity / 2000n; // 0.05%
29133
+ // Reduce liquidity by slippagePercent to ensure contract calculations stay within user bounds
29134
+ // slippagePercent is passed as decimal percentage (e.g., 0.05 for 0.05%), convert to decimal
29135
+ const slippageAsDecimal = slippagePercent / 100;
29136
+ const slippageMultiplier = BigInt(Math.floor(1 / slippageAsDecimal));
29137
+ const liquidityBuffer = finalLiquidity / slippageMultiplier;
28553
29138
  const conservativeLiquidity = finalLiquidity - (liquidityBuffer > 1n ? liquidityBuffer : 1n);
28554
29139
  // Use conservative liquidity but keep user's original amounts as maximums
28555
29140
  // The conservative liquidity ensures the contract won't need more than user provided