@flaunch/sdk 0.8.3-beta.5 → 0.8.3-beta.7

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.esm.js CHANGED
@@ -5316,7 +5316,7 @@ const FlaunchPositionManagerV1_1Address = {
5316
5316
  [baseSepolia.id]: "0x24347e0dd16357059abfc1b321df354873552fdc",
5317
5317
  };
5318
5318
  const FlaunchPositionManagerV1_2Address = {
5319
- [base.id]: zeroAddress, // TODO: add mainnet address
5319
+ [base.id]: "0x23321f11a6d44fd1ab790044fdfde5758c902fdc", // "1.3" from github releases
5320
5320
  [baseSepolia.id]: "0x4e7cb1e6800a7b297b38bddcecaf9ca5b6616fdc",
5321
5321
  };
5322
5322
  const AnyPositionManagerAddress = {
@@ -5381,7 +5381,7 @@ const FairLaunchAddress = {
5381
5381
  };
5382
5382
  // also supports AnyPositionManager & PositionManagerV1_2 (sepolia)
5383
5383
  const FairLaunchV1_1Address = {
5384
- [base.id]: "0x4dc442403e8c758425b93c59dc737da522f32640",
5384
+ [base.id]: "0x4dc442403e8c758425b93C59Dc737da522f32640",
5385
5385
  [baseSepolia.id]: "0x7922c1ead7c5825fb52ed6b14f397d064508acbe",
5386
5386
  };
5387
5387
  const FlaunchAddress = {
@@ -5394,7 +5394,7 @@ const FlaunchV1_1Address = {
5394
5394
  [baseSepolia.id]: "0x96be8ff5e244294a34bfa507a39190dc7a839baa",
5395
5395
  };
5396
5396
  const FlaunchV1_2Address = {
5397
- [base.id]: zeroAddress, // TODO: add mainnet address
5397
+ [base.id]: "0x516af52d0c629b5e378da4dc64ecb0744ce10109", // "1.3" from github releases
5398
5398
  [baseSepolia.id]: "0xe2ef58a54ee79dac0D4A130ea58b340124DF9438",
5399
5399
  };
5400
5400
  const AnyFlaunchAddress = {
@@ -5414,12 +5414,13 @@ const AnyBidWallAddress = {
5414
5414
  [base.id]: "0x2154c604df568A5285284D1c4918DC98C39240df",
5415
5415
  [baseSepolia.id]: "0xcfF222eA42E43F46A98755db237E4c9C2CA9B772",
5416
5416
  };
5417
+ // @deprecated: FlaunchZap used instead
5417
5418
  const FastFlaunchZapAddress = {
5418
5419
  [base.id]: "0x68d967d25806fef4aa134db031cdcc55d3e20f92",
5419
5420
  [baseSepolia.id]: "0x821d9f6075e7971cc71c379081de9d532f5f9957",
5420
5421
  };
5421
5422
  const FlaunchZapAddress = {
5422
- [base.id]: "0x2bC8cbfE237AEddc7C296436fefe239A0A22dAbF",
5423
+ [base.id]: "0xf9753e6e4fdd1869be40685690a28bff26b8b114",
5423
5424
  [baseSepolia.id]: "0x808DA25e8ecbCC2C0339B6A436AAEAe2021C235d",
5424
5425
  };
5425
5426
  const TreasuryManagerFactoryAddress = {
@@ -19376,25 +19377,31 @@ class ReadWriteTokenImporter extends ReadTokenImporter {
19376
19377
  constructor(chainId, address, drift = createDrift$1()) {
19377
19378
  super(chainId, address, drift);
19378
19379
  }
19379
- async initialize({ coinAddress, creatorFeeAllocationPercent, initialMarketCapUSD, verifier, }) {
19380
- return this.contract.write("initialize", await this.getInitializeParams({
19381
- memecoin: coinAddress,
19382
- creatorFeeAllocationPercent,
19383
- initialMarketCapUSD,
19384
- verifier,
19385
- }));
19380
+ async initialize(params) {
19381
+ return this.contract.write("initialize", await this.getInitializeParams(params));
19386
19382
  }
19387
- async getInitializeParams({ memecoin, creatorFeeAllocationPercent, initialMarketCapUSD, verifier, }) {
19383
+ async getInitializeParams(params) {
19384
+ let initialMarketCapUSD;
19385
+ if ("initialMarketCapUSD" in params) {
19386
+ initialMarketCapUSD = params.initialMarketCapUSD;
19387
+ }
19388
+ else {
19389
+ const memecoin = new ReadMemecoin(params.coinAddress, this.drift);
19390
+ const totalSupply = await memecoin.totalSupply();
19391
+ const decimals = await memecoin.decimals();
19392
+ const formattedTotalSupply = parseFloat(formatUnits$1(totalSupply, decimals));
19393
+ initialMarketCapUSD = params.initialPriceUSD * formattedTotalSupply;
19394
+ }
19388
19395
  const initialMCapInUSDCWei = parseUnits(initialMarketCapUSD.toString(), 6);
19389
- const creatorFeeAllocationInBps = creatorFeeAllocationPercent * 100;
19396
+ const creatorFeeAllocationInBps = params.creatorFeeAllocationPercent * 100;
19390
19397
  // Passing in the verifier here, as drift doesn't recognize the other initialize function without the verifier param
19391
- let _verifier = verifier
19392
- ? this.verifierAddress(verifier)
19398
+ let _verifier = params.verifier
19399
+ ? this.verifierAddress(params.verifier)
19393
19400
  : await this.contract.read("verifyMemecoin", {
19394
- _memecoin: memecoin,
19401
+ _memecoin: params.coinAddress,
19395
19402
  });
19396
19403
  return {
19397
- _memecoin: memecoin,
19404
+ _memecoin: params.coinAddress,
19398
19405
  _creatorFeeAllocation: creatorFeeAllocationInBps,
19399
19406
  _initialMarketCap: initialMCapInUSDCWei,
19400
19407
  _verifier,
@@ -25550,7 +25557,25 @@ class ReadFlaunchSDK {
25550
25557
  };
25551
25558
  }
25552
25559
  }
25553
- async calculateAddLiquidityAmounts({ coinAddress, liquidityMode, coinOrEthInputAmount, inputToken, minMarketCap, maxMarketCap, currentMarketCap, }) {
25560
+ async calculateAddLiquidityAmounts(params) {
25561
+ const { coinAddress, liquidityMode, inputToken, coinOrEthInputAmount } = params;
25562
+ let minMarketCap;
25563
+ let maxMarketCap;
25564
+ let currentMarketCap;
25565
+ if ("minMarketCap" in params) {
25566
+ minMarketCap = params.minMarketCap;
25567
+ maxMarketCap = params.maxMarketCap;
25568
+ currentMarketCap = params.currentMarketCap;
25569
+ }
25570
+ else {
25571
+ const { totalSupply, decimals } = await this.getCoinInfo(coinAddress);
25572
+ const formattedTotalSupply = parseFloat(formatUnits$1(totalSupply, decimals));
25573
+ minMarketCap = (parseFloat(params.minPriceUSD) * formattedTotalSupply).toString();
25574
+ maxMarketCap = (parseFloat(params.maxPriceUSD) * formattedTotalSupply).toString();
25575
+ if (params.currentPriceUSD) {
25576
+ currentMarketCap = (params.currentPriceUSD * formattedTotalSupply).toString();
25577
+ }
25578
+ }
25554
25579
  let { tickLower, tickUpper, currentTick } = await this.calculateAddLiquidityTicks({
25555
25580
  coinAddress,
25556
25581
  liquidityMode,
@@ -25558,15 +25583,25 @@ class ReadFlaunchSDK {
25558
25583
  maxMarketCap,
25559
25584
  currentMarketCap,
25560
25585
  });
25586
+ // get the current pool state for the coin
25561
25587
  if (!currentTick) {
25562
- // get the current pool state for AnyPositionManager pool for the coin
25588
+ let version = params.version;
25589
+ // if version is not provided, check on existing managers, else default to ANY
25590
+ if (!version) {
25591
+ try {
25592
+ version = await this.getCoinVersion(coinAddress);
25593
+ }
25594
+ catch {
25595
+ version = FlaunchVersion.ANY;
25596
+ }
25597
+ }
25563
25598
  const poolState = await this.readStateView.poolSlot0({
25564
25599
  poolId: getPoolId(orderPoolKey({
25565
25600
  currency0: coinAddress,
25566
25601
  currency1: FLETHAddress[this.chainId],
25567
25602
  fee: 0,
25568
25603
  tickSpacing: TICK_SPACING,
25569
- hooks: AnyPositionManagerAddress[this.chainId],
25604
+ hooks: this.getPositionManagerAddress(version),
25570
25605
  })),
25571
25606
  });
25572
25607
  currentTick = poolState.tick;
@@ -26072,12 +26107,21 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
26072
26107
  let tickLower;
26073
26108
  let tickUpper;
26074
26109
  let currentTick;
26110
+ let version = params.version;
26111
+ if (!version) {
26112
+ try {
26113
+ version = await this.getCoinVersion(coinAddress);
26114
+ }
26115
+ catch {
26116
+ version = FlaunchVersion.ANY;
26117
+ }
26118
+ }
26075
26119
  const poolKey = orderPoolKey({
26076
26120
  currency0: coinAddress,
26077
26121
  currency1: flethAddress,
26078
26122
  fee: 0,
26079
26123
  tickSpacing: this.TICK_SPACING,
26080
- hooks: AnyPositionManagerAddress[this.chainId],
26124
+ hooks: this.getPositionManagerAddress(version),
26081
26125
  });
26082
26126
  // Check if we need to calculate values or use direct values
26083
26127
  if ("tickLower" in params) {
@@ -26098,16 +26142,32 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
26098
26142
  }
26099
26143
  else {
26100
26144
  // Calculate the amounts
26145
+ let minMarketCap;
26146
+ let maxMarketCap;
26147
+ let initialMarketCapUSD;
26148
+ if ("minMarketCap" in params) {
26149
+ minMarketCap = params.minMarketCap;
26150
+ maxMarketCap = params.maxMarketCap;
26151
+ initialMarketCapUSD = params.initialMarketCapUSD;
26152
+ }
26153
+ else {
26154
+ const { totalSupply, decimals } = await this.getCoinInfo(coinAddress);
26155
+ const formattedTotalSupply = parseFloat(formatUnits$1(totalSupply, decimals));
26156
+ minMarketCap = (parseFloat(params.minPriceUSD) * formattedTotalSupply).toString();
26157
+ maxMarketCap = (parseFloat(params.maxPriceUSD) * formattedTotalSupply).toString();
26158
+ if (params.initialPriceUSD) {
26159
+ initialMarketCapUSD = params.initialPriceUSD * formattedTotalSupply;
26160
+ }
26161
+ }
26101
26162
  const calculated = await this.calculateAddLiquidityAmounts({
26102
26163
  coinAddress,
26103
26164
  liquidityMode: params.liquidityMode,
26104
26165
  coinOrEthInputAmount: params.coinOrEthInputAmount,
26105
26166
  inputToken: params.inputToken,
26106
- minMarketCap: params.minMarketCap,
26107
- maxMarketCap: params.maxMarketCap,
26108
- currentMarketCap: params.initialMarketCapUSD
26109
- ? params.initialMarketCapUSD.toString()
26110
- : undefined,
26167
+ minMarketCap,
26168
+ maxMarketCap,
26169
+ currentMarketCap: initialMarketCapUSD?.toString(),
26170
+ version,
26111
26171
  });
26112
26172
  coinAmount = calculated.coinAmount;
26113
26173
  flethAmount = calculated.ethAmount;
@@ -26416,12 +26476,15 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
26416
26476
  */
26417
26477
  async getImportAndAddLiquidityCalls(params) {
26418
26478
  const importParams = await this.readWriteTokenImporter.getInitializeParams({
26419
- memecoin: params.coinAddress,
26479
+ coinAddress: params.coinAddress,
26420
26480
  creatorFeeAllocationPercent: params.creatorFeeAllocationPercent,
26421
26481
  initialMarketCapUSD: params.initialMarketCapUSD,
26422
26482
  verifier: params.verifier,
26423
26483
  });
26424
- const addLiquidityCalls = await this.getAddLiquidityCalls(params);
26484
+ const addLiquidityCalls = await this.getAddLiquidityCalls({
26485
+ ...params,
26486
+ version: FlaunchVersion.ANY, // optimize to avoid fetching if not passed
26487
+ });
26425
26488
  return [
26426
26489
  {
26427
26490
  to: this.readWriteTokenImporter.contract.address,