@flaunch/sdk 0.9.8 → 0.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createDrift as createDrift$1 } from '@delvtech/drift';
2
- import { zeroAddress, parseEther, encodeAbiParameters as encodeAbiParameters$1, maxUint256 as maxUint256$1, encodeFunctionData, maxUint160, maxUint48, parseUnits, hexToBigInt as hexToBigInt$1, pad as pad$1, keccak256 as keccak256$1, encodePacked, stringToHex as stringToHex$1, zeroHash, formatUnits as formatUnits$1, parseEventLogs, concat as concat$1, toHex as toHex$1, erc721Abi, erc20Abi, parseAbi, createWalletClient, http, decodeFunctionData } from 'viem';
2
+ import { zeroAddress, parseEther, encodeAbiParameters as encodeAbiParameters$1, maxUint256 as maxUint256$1, encodeFunctionData, maxUint160, maxUint48, parseUnits, hexToBigInt as hexToBigInt$1, pad as pad$1, keccak256 as keccak256$1, encodePacked, stringToHex as stringToHex$1, concat as concat$1, toHex as toHex$1, zeroHash, formatUnits as formatUnits$1, parseEventLogs, erc721Abi, erc20Abi, parseAbi, createWalletClient, http, decodeFunctionData } from 'viem';
3
3
  import axios from 'axios';
4
4
  import { viemAdapter } from '@delvtech/drift-viem';
5
5
 
@@ -5753,6 +5753,10 @@ const StakingManagerAddress = {
5753
5753
  [base.id]: "0xec0069F8DBbbC94058dc895000dd38ef40b3125d",
5754
5754
  [baseSepolia.id]: "0xB8f1cb6B4Ff8f07149276bbfA617aed7bd32d20D",
5755
5755
  };
5756
+ const BuyBackManagerAddress = {
5757
+ [base.id]: "0x3AAF3b1D8cD5b61C77f99bA7cdf41E9eC0Ba8a3f",
5758
+ [baseSepolia.id]: "0xc3947EC9d687053bBA72b36Fd6b2567e775E82C7",
5759
+ };
5756
5760
  /** Verifiers */
5757
5761
  const TokenImporterAddress = {
5758
5762
  [base.id]: "0xb47af90ae61bc916ea4b4bacffae4570e7435842",
@@ -13769,195 +13773,485 @@ class ReadWriteFlaunchPositionManagerV1_1 extends ReadFlaunchPositionManagerV1_1
13769
13773
  }
13770
13774
  }
13771
13775
 
13772
- /**
13773
- * Base client for interacting with the FlaunchZap contract in read-only mode
13774
- * Provides basic contract initialization
13775
- */
13776
- class ReadFlaunchZap {
13777
- /**
13778
- * Creates a new ReadFlaunchZap instance
13779
- * @param chainId - The chain ID of the contract
13780
- * @param address - The address of the FlaunchZap contract
13781
- * @param drift - Optional drift instance for contract interactions (creates new instance if not provided)
13782
- * @throws Error if address is not provided
13783
- */
13784
- constructor(chainId, address, drift = createDrift$1()) {
13785
- this.TOTAL_SUPPLY = 100n * 10n ** 27n; // 100 Billion tokens in wei
13786
- this.chainId = chainId;
13787
- this.drift = drift;
13788
- if (!address) {
13789
- throw new Error("Address is required");
13790
- }
13791
- this.contract = drift.contract({
13792
- abi: FlaunchZapAbi,
13793
- address,
13794
- });
13795
- this.readPositionManagerV1_1 = new ReadFlaunchPositionManagerV1_1(FlaunchPositionManagerV1_1Address[this.chainId], drift);
13796
- }
13797
- async getPremineCostInWei(params) {
13798
- const mcapInWei = await this.readPositionManagerV1_1.getFlaunchingMarketCap(params.initialPriceParams);
13799
- const premineCostInWei = (mcapInWei * params.premineAmount) / this.TOTAL_SUPPLY;
13800
- // increase the premine cost by the slippage percent
13801
- const premineCostInWeiWithSlippage = getAmountWithSlippage({
13802
- amount: premineCostInWei,
13803
- slippage: (params.slippagePercent ?? 0 / 100).toFixed(18).toString(),
13804
- swapType: "EXACT_OUT", // as we know the output premine amount
13805
- });
13806
- return premineCostInWeiWithSlippage;
13776
+ // our min/max tick range that is valid for the tick spacing (60)
13777
+ const TickFinder = {
13778
+ MIN_TICK: -887220,
13779
+ MAX_TICK: 887220,
13780
+ };
13781
+ const Q96 = 2n ** 96n;
13782
+ const Q192 = 2n ** 192n;
13783
+ const TICK_SPACING = 60;
13784
+ const getPoolId = (poolKey) => {
13785
+ // Pack the data in the same order as Solidity struct
13786
+ const packed = concat$1([
13787
+ pad$1(poolKey.currency0, { size: 32 }), // address padded to 32 bytes
13788
+ pad$1(poolKey.currency1, { size: 32 }), // address padded to 32 bytes
13789
+ pad$1(toHex$1(poolKey.fee), { size: 32 }), // uint24 padded to 32 bytes
13790
+ pad$1(toHex$1(poolKey.tickSpacing), { size: 32 }), // int24 padded to 32 bytes
13791
+ pad$1(poolKey.hooks, { size: 32 }), // address padded to 32 bytes
13792
+ ]);
13793
+ return keccak256$1(packed);
13794
+ };
13795
+ const orderPoolKey = (poolKey) => {
13796
+ const [currency0, currency1] = poolKey.currency0 < poolKey.currency1
13797
+ ? [poolKey.currency0, poolKey.currency1]
13798
+ : [poolKey.currency1, poolKey.currency0];
13799
+ return {
13800
+ ...poolKey,
13801
+ currency0,
13802
+ currency1,
13803
+ };
13804
+ };
13805
+ const getValidTick = ({ tick, tickSpacing, roundDown = true, }) => {
13806
+ // If the tick is already valid, exit early
13807
+ if (tick % tickSpacing === 0) {
13808
+ return tick;
13807
13809
  }
13808
- async getFlaunchingFee(params) {
13809
- const readInitialPrice = new ReadInitialPrice(await this.readPositionManagerV1_1.initialPrice(), this.drift);
13810
- const flaunchingFee = await readInitialPrice.getFlaunchingFee(params);
13811
- // increase the flaunching fee by the slippage percent
13812
- const flaunchingFeeWithSlippage = getAmountWithSlippage({
13813
- amount: flaunchingFee,
13814
- slippage: (params.slippagePercent ?? 0 / 100).toFixed(18).toString(),
13815
- swapType: "EXACT_OUT",
13816
- });
13817
- return flaunchingFeeWithSlippage;
13810
+ // Division that rounds towards zero (like Solidity)
13811
+ let validTick = Math.trunc(tick / tickSpacing) * tickSpacing;
13812
+ // Handle negative ticks (Solidity behavior)
13813
+ if (tick < 0 && tick % tickSpacing !== 0) {
13814
+ validTick -= tickSpacing;
13818
13815
  }
13819
- /**
13820
- * Calculates the ETH required to flaunch a token, takes into account the ETH for premine and the flaunching fee
13821
- */
13822
- ethRequiredToFlaunch(params) {
13823
- return this.contract.read("calculateFee", {
13824
- _premineAmount: params.premineAmount ?? 0n,
13825
- _slippage: params.slippagePercent
13826
- ? BigInt(params.slippagePercent * 100)
13827
- : 0n,
13828
- _initialPriceParams: params.initialPriceParams,
13829
- });
13816
+ // If not rounding down, add TICK_SPACING to get the upper tick
13817
+ if (!roundDown) {
13818
+ validTick += tickSpacing;
13830
13819
  }
13831
- }
13832
- /**
13833
- * Extended client for interacting with the FlaunchZap contract with write capabilities
13834
- */
13835
- class ReadWriteFlaunchZap extends ReadFlaunchZap {
13836
- constructor(chainId, address, drift = createDrift$1()) {
13837
- super(chainId, address, drift);
13820
+ return validTick;
13821
+ };
13822
+ // Rounds up or down to the nearest tick
13823
+ const getNearestUsableTick = ({ tick, tickSpacing, }) => {
13824
+ const rounded = Math.round(tick / tickSpacing) * tickSpacing;
13825
+ return Math.max(TickFinder.MIN_TICK, Math.min(TickFinder.MAX_TICK, rounded));
13826
+ };
13827
+ const getAmount0ForLiquidity = (sqrtRatioAX96, sqrtRatioBX96, liquidity) => {
13828
+ let [sqrtRatioA, sqrtRatioB] = [sqrtRatioAX96, sqrtRatioBX96];
13829
+ if (sqrtRatioA > sqrtRatioB) {
13830
+ [sqrtRatioA, sqrtRatioB] = [sqrtRatioB, sqrtRatioA];
13838
13831
  }
13839
- /**
13840
- * Flaunches a new token, supports premine
13841
- * @param params - Parameters for the flaunch
13842
- * @returns Transaction response for the flaunch creation
13843
- */
13844
- async flaunch(params) {
13845
- const initialMCapInUSDCWei = parseUnits(params.initialMarketCapUSD.toString(), 6);
13846
- const initialPriceParams = encodeAbiParameters$1([
13847
- {
13848
- type: "uint256",
13849
- },
13850
- ], [initialMCapInUSDCWei]);
13851
- const fairLaunchInBps = BigInt(params.fairLaunchPercent * 100);
13852
- const creatorFeeAllocationInBps = params.creatorFeeAllocationPercent * 100;
13853
- const ethRequired = await this.ethRequiredToFlaunch({
13854
- premineAmount: params.premineAmount ?? 0n,
13855
- initialPriceParams,
13856
- slippagePercent: 5,
13857
- });
13858
- const _treasuryManagerParams = params.treasuryManagerParams
13859
- ? {
13860
- manager: params.treasuryManagerParams.manager ?? zeroAddress,
13861
- permissions: params.treasuryManagerParams.permissions ?? Permissions.OPEN,
13862
- initializeData: params.treasuryManagerParams.initializeData ?? "0x",
13863
- depositData: params.treasuryManagerParams.depositData ?? "0x",
13864
- }
13865
- : {
13866
- manager: zeroAddress,
13867
- permissions: Permissions.OPEN,
13868
- initializeData: "0x",
13869
- depositData: "0x",
13870
- };
13871
- const feeCalculatorParams = params.trustedSignerSettings
13872
- ? encodeAbiParameters$1([
13873
- { type: "bool", name: "enabled" },
13874
- { type: "uint256", name: "walletCap" },
13875
- { type: "uint256", name: "txCap" },
13876
- ], [
13877
- params.trustedSignerSettings.enabled,
13878
- params.trustedSignerSettings.walletCap ?? 0n,
13879
- params.trustedSignerSettings.txCap ?? 0n,
13880
- ])
13881
- : "0x";
13882
- const _premineSwapHookData = params.trustedSignerSettings?.enabled
13883
- ? encodeAbiParameters$1([
13884
- { type: "address", name: "referrer" },
13885
- {
13886
- type: "tuple",
13887
- components: [
13888
- { type: "uint256", name: "deadline" },
13889
- { type: "bytes", name: "signature" },
13890
- ],
13891
- },
13892
- ], [
13893
- zeroAddress,
13894
- {
13895
- deadline: BigInt(params.trustedSignerSettings.premineSignedMessage?.deadline ?? 0),
13896
- signature: params.trustedSignerSettings.premineSignedMessage?.signature ??
13897
- "0x",
13898
- },
13899
- ])
13900
- : "0x";
13901
- return this.contract.write("flaunch", {
13902
- _flaunchParams: {
13903
- name: params.name,
13904
- symbol: params.symbol,
13905
- tokenUri: params.tokenUri,
13906
- initialTokenFairLaunch: (this.TOTAL_SUPPLY * fairLaunchInBps) / 10000n,
13907
- fairLaunchDuration: BigInt(params.fairLaunchDuration),
13908
- premineAmount: params.premineAmount ?? 0n,
13909
- creator: params.creator,
13910
- creatorFeeAllocation: creatorFeeAllocationInBps,
13911
- flaunchAt: params.flaunchAt ?? 0n,
13912
- initialPriceParams,
13913
- feeCalculatorParams,
13914
- },
13915
- _trustedFeeSigner: params.trustedSignerSettings?.trustedFeeSigner ?? zeroAddress,
13916
- _premineSwapHookData,
13917
- _treasuryManagerParams: {
13918
- ..._treasuryManagerParams,
13919
- permissions: getPermissionsAddress(_treasuryManagerParams.permissions, this.chainId),
13920
- },
13921
- _whitelistParams: {
13922
- merkleRoot: zeroHash,
13923
- merkleIPFSHash: "",
13924
- maxTokens: 0n,
13925
- },
13926
- _airdropParams: {
13927
- airdropIndex: 0n,
13928
- airdropAmount: 0n,
13929
- airdropEndTime: 0n,
13930
- merkleRoot: zeroHash,
13931
- merkleIPFSHash: "",
13932
- },
13933
- }, {
13934
- value: ethRequired,
13935
- });
13832
+ const leftShiftedLiquidity = liquidity << 96n;
13833
+ const sqrtDiff = sqrtRatioB - sqrtRatioA;
13834
+ const multipliedRes = leftShiftedLiquidity * sqrtDiff;
13835
+ const numerator = multipliedRes / sqrtRatioB;
13836
+ const amount0 = numerator / sqrtRatioA;
13837
+ return amount0;
13838
+ };
13839
+ const getAmount1ForLiquidity = (sqrtRatioAX96, sqrtRatioBX96, liquidity) => {
13840
+ let [sqrtRatioA, sqrtRatioB] = [sqrtRatioAX96, sqrtRatioBX96];
13841
+ if (sqrtRatioA > sqrtRatioB) {
13842
+ [sqrtRatioA, sqrtRatioB] = [sqrtRatioB, sqrtRatioA];
13936
13843
  }
13937
- async flaunchIPFS(params) {
13938
- const tokenUri = await generateTokenUri(params.name, params.symbol, {
13939
- metadata: params.metadata,
13940
- pinataConfig: params.pinataConfig,
13941
- });
13942
- return this.flaunch({
13943
- ...params,
13944
- tokenUri,
13945
- });
13844
+ const sqrtDiff = sqrtRatioB - sqrtRatioA;
13845
+ const multipliedRes = liquidity * sqrtDiff;
13846
+ const amount1 = multipliedRes / 2n ** 96n;
13847
+ return amount1;
13848
+ };
13849
+ const getSqrtPriceX96FromTick = (tick) => {
13850
+ const absTick = tick < 0 ? BigInt(-tick) : BigInt(tick);
13851
+ if (absTick > TickFinder.MAX_TICK) {
13852
+ throw new Error("Tick out of range");
13946
13853
  }
13947
- /**
13948
- * Flaunches a new token for a revenue manager
13949
- * @param params - Parameters for the flaunch with revenue manager
13950
- * @param params.name - The name of the token
13951
- * @param params.symbol - The symbol of the token
13952
- * @param params.tokenUri - The URI containing the token metadata
13953
- * @param params.fairLaunchPercent - Percentage of total supply to be used in fair launch (0-100)
13954
- * @param params.fairLaunchDuration - Duration of fair launch in seconds
13955
- * @param params.initialMarketCapUSD - Initial market cap in USD
13956
- * @param params.creator - Address of the token creator
13957
- * @param params.creatorFeeAllocationPercent - Percentage of fees allocated to creator (0-100)
13958
- * @param params.protocolRecipient - Address to receive protocol fees
13959
- * @param params.protocolFeePercent - Percentage of fees allocated to protocol (0-100)
13960
- * @param params.flaunchAt - Optional timestamp when the flaunch should start
13854
+ let ratio = (absTick & 1n) !== 0n
13855
+ ? 0xfffcb933bd6fad37aa2d162d1a594001n
13856
+ : 0x100000000000000000000000000000000n;
13857
+ if ((absTick & 2n) !== 0n)
13858
+ ratio = (ratio * 0xfff97272373d413259a46990580e213an) >> 128n;
13859
+ if ((absTick & 4n) !== 0n)
13860
+ ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdccn) >> 128n;
13861
+ if ((absTick & 8n) !== 0n)
13862
+ ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0n) >> 128n;
13863
+ if ((absTick & 16n) !== 0n)
13864
+ ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644n) >> 128n;
13865
+ if ((absTick & 32n) !== 0n)
13866
+ ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0n) >> 128n;
13867
+ if ((absTick & 64n) !== 0n)
13868
+ ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861n) >> 128n;
13869
+ if ((absTick & 128n) !== 0n)
13870
+ ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053n) >> 128n;
13871
+ if ((absTick & 256n) !== 0n)
13872
+ ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4n) >> 128n;
13873
+ if ((absTick & 512n) !== 0n)
13874
+ ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54n) >> 128n;
13875
+ if ((absTick & 1024n) !== 0n)
13876
+ ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3n) >> 128n;
13877
+ if ((absTick & 2048n) !== 0n)
13878
+ ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9n) >> 128n;
13879
+ if ((absTick & 4096n) !== 0n)
13880
+ ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825n) >> 128n;
13881
+ if ((absTick & 8192n) !== 0n)
13882
+ ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5n) >> 128n;
13883
+ if ((absTick & 16384n) !== 0n)
13884
+ ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7n) >> 128n;
13885
+ if ((absTick & 32768n) !== 0n)
13886
+ ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6n) >> 128n;
13887
+ if ((absTick & 65536n) !== 0n)
13888
+ ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9n) >> 128n;
13889
+ if ((absTick & 131072n) !== 0n)
13890
+ ratio = (ratio * 0x5d6af8dedb81196699c329225ee604n) >> 128n;
13891
+ if ((absTick & 262144n) !== 0n)
13892
+ ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98n) >> 128n;
13893
+ if ((absTick & 524288n) !== 0n)
13894
+ ratio = (ratio * 0x48a170391f7dc42444e8fa2n) >> 128n;
13895
+ if (tick > 0) {
13896
+ ratio = (2n ** 256n - 1n) / ratio;
13897
+ }
13898
+ // Convert from Q128.128 to Q128.96
13899
+ const resultShifted = ratio >> 32n;
13900
+ if (ratio % (1n << 32n) === 0n) {
13901
+ return resultShifted;
13902
+ }
13903
+ return resultShifted + 1n;
13904
+ };
13905
+ const calculateUnderlyingTokenBalances = (liquidity, tickLower, tickUpper, tickCurrent) => {
13906
+ const sqrtPriceCurrentX96 = getSqrtPriceX96FromTick(tickCurrent);
13907
+ const sqrtPriceLowerX96 = getSqrtPriceX96FromTick(tickLower);
13908
+ const sqrtPriceUpperX96 = getSqrtPriceX96FromTick(tickUpper);
13909
+ let amount0 = 0n;
13910
+ let amount1 = 0n;
13911
+ if (sqrtPriceCurrentX96 <= sqrtPriceLowerX96) {
13912
+ // Current price is below the position range
13913
+ amount0 = getAmount0ForLiquidity(sqrtPriceLowerX96, sqrtPriceUpperX96, liquidity);
13914
+ }
13915
+ else if (sqrtPriceCurrentX96 < sqrtPriceUpperX96) {
13916
+ // Current price is within the position range
13917
+ amount0 = getAmount0ForLiquidity(sqrtPriceCurrentX96, sqrtPriceUpperX96, liquidity);
13918
+ amount1 = getAmount1ForLiquidity(sqrtPriceLowerX96, sqrtPriceCurrentX96, liquidity);
13919
+ }
13920
+ else {
13921
+ // Current price is above the position range
13922
+ amount1 = getAmount1ForLiquidity(sqrtPriceLowerX96, sqrtPriceUpperX96, liquidity);
13923
+ }
13924
+ return { amount0, amount1 };
13925
+ };
13926
+ // Helper function to convert price ratio to tick with decimal handling
13927
+ const priceRatioToTick = ({ priceInput, isDirection1Per0, decimals0, decimals1, spacing, shouldGetNearestUsableTick = true, }) => {
13928
+ if (!priceInput || isNaN(Number(priceInput)))
13929
+ return 0;
13930
+ const inputPrice = Number(priceInput);
13931
+ try {
13932
+ // For Uniswap v3/v4, the tick represents price as: price = 1.0001^tick
13933
+ // where price = amount1/amount0 in their raw decimal format
13934
+ let priceRatio;
13935
+ if (isDirection1Per0) {
13936
+ // Input is token1 per token0 (e.g., memecoin per flETH)
13937
+ // Convert from human-readable to raw: divide by (10^decimals0 / 10^decimals1)
13938
+ priceRatio = inputPrice / Math.pow(10, decimals0 - decimals1);
13939
+ }
13940
+ else {
13941
+ // Input is token0 per token1 (e.g., flETH per memecoin)
13942
+ // Invert to get token1 per token0, then convert to raw
13943
+ priceRatio = 1 / inputPrice / Math.pow(10, decimals0 - decimals1);
13944
+ }
13945
+ // Calculate tick: tick = log(price) / log(1.0001)
13946
+ const tick = Math.log(priceRatio) / Math.log(1.0001);
13947
+ if (shouldGetNearestUsableTick) {
13948
+ return getValidTick({
13949
+ tick: Math.round(tick),
13950
+ tickSpacing: spacing,
13951
+ });
13952
+ }
13953
+ else {
13954
+ return Math.round(tick);
13955
+ }
13956
+ }
13957
+ catch (error) {
13958
+ console.error("Error converting price to tick:", error);
13959
+ // Fallback to basic calculation
13960
+ const rawTick = Math.floor(Math.log(inputPrice) / Math.log(1.0001));
13961
+ if (shouldGetNearestUsableTick) {
13962
+ return getValidTick({
13963
+ tick: rawTick,
13964
+ tickSpacing: spacing,
13965
+ });
13966
+ }
13967
+ else {
13968
+ return rawTick;
13969
+ }
13970
+ }
13971
+ };
13972
+ /**
13973
+ * Accurate liquidity calculation using proper Uniswap v3/v4 math
13974
+ */
13975
+ const getLiquidityFromAmounts = (params) => {
13976
+ const sqrtRatioCurrentX96 = getSqrtPriceX96FromTick(params.currentTick);
13977
+ let sqrtRatioAX96 = getSqrtPriceX96FromTick(params.tickLower);
13978
+ let sqrtRatioBX96 = getSqrtPriceX96FromTick(params.tickUpper);
13979
+ if (sqrtRatioAX96 > sqrtRatioBX96) {
13980
+ [sqrtRatioAX96, sqrtRatioBX96] = [sqrtRatioBX96, sqrtRatioAX96];
13981
+ }
13982
+ if (sqrtRatioCurrentX96 <= sqrtRatioAX96) {
13983
+ return maxLiquidityForAmount0Precise(sqrtRatioAX96, sqrtRatioBX96, params.amount0);
13984
+ }
13985
+ else if (sqrtRatioCurrentX96 < sqrtRatioBX96) {
13986
+ const liquidity0 = maxLiquidityForAmount0Precise(sqrtRatioCurrentX96, sqrtRatioBX96, params.amount0);
13987
+ const liquidity1 = maxLiquidityForAmount1(sqrtRatioAX96, sqrtRatioCurrentX96, params.amount1);
13988
+ return liquidity0 < liquidity1 ? liquidity0 : liquidity1;
13989
+ }
13990
+ else {
13991
+ return maxLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, params.amount1);
13992
+ }
13993
+ };
13994
+ /**
13995
+ * Returns a precise maximum amount of liquidity received for a given amount of token 0 by dividing by Q64 instead of Q96 in the intermediate step,
13996
+ * and shifting the subtracted ratio left by 32 bits.
13997
+ * @param sqrtRatioAX96 The price at the lower boundary
13998
+ * @param sqrtRatioBX96 The price at the upper boundary
13999
+ * @param amount0 The token0 amount
14000
+ * @returns liquidity for amount0, precise
14001
+ */
14002
+ function maxLiquidityForAmount0Precise(sqrtRatioAX96, sqrtRatioBX96, amount0) {
14003
+ if (sqrtRatioAX96 > sqrtRatioBX96) {
14004
+ [sqrtRatioAX96, sqrtRatioBX96] = [sqrtRatioBX96, sqrtRatioAX96];
14005
+ }
14006
+ // Handle edge case where sqrt ratios are equal (division by zero)
14007
+ if (sqrtRatioAX96 === sqrtRatioBX96) {
14008
+ return 0n;
14009
+ }
14010
+ const Q96 = 2n ** 96n;
14011
+ const numerator = amount0 * sqrtRatioAX96 * sqrtRatioBX96;
14012
+ const denominator = Q96 * (sqrtRatioBX96 - sqrtRatioAX96);
14013
+ return numerator / denominator;
14014
+ }
14015
+ /**
14016
+ * Computes the maximum amount of liquidity received for a given amount of token1
14017
+ * @param sqrtRatioAX96 The price at the lower tick boundary
14018
+ * @param sqrtRatioBX96 The price at the upper tick boundary
14019
+ * @param amount1 The token1 amount
14020
+ * @returns liquidity for amount1
14021
+ */
14022
+ function maxLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1) {
14023
+ if (sqrtRatioAX96 > sqrtRatioBX96) {
14024
+ [sqrtRatioAX96, sqrtRatioBX96] = [sqrtRatioBX96, sqrtRatioAX96];
14025
+ }
14026
+ // Handle edge case where sqrt ratios are equal (division by zero)
14027
+ if (sqrtRatioAX96 === sqrtRatioBX96) {
14028
+ return 0n;
14029
+ }
14030
+ const Q96 = 2n ** 96n;
14031
+ return (amount1 * Q96) / (sqrtRatioBX96 - sqrtRatioAX96);
14032
+ }
14033
+ /**
14034
+ * Calculate the actual amounts needed for a given liquidity
14035
+ * This prevents MaximumAmountExceeded errors by ensuring we provide sufficient maximums
14036
+ */
14037
+ const getAmountsForLiquidity = (params) => {
14038
+ // Handle zero liquidity case
14039
+ if (params.liquidity === 0n) {
14040
+ return { amount0: 0n, amount1: 0n };
14041
+ }
14042
+ const sqrtRatioCurrentX96 = getSqrtPriceX96FromTick(params.currentTick);
14043
+ let sqrtRatioAX96 = getSqrtPriceX96FromTick(params.tickLower);
14044
+ let sqrtRatioBX96 = getSqrtPriceX96FromTick(params.tickUpper);
14045
+ if (sqrtRatioAX96 > sqrtRatioBX96) {
14046
+ [sqrtRatioAX96, sqrtRatioBX96] = [sqrtRatioBX96, sqrtRatioAX96];
14047
+ }
14048
+ let amount0 = 0n;
14049
+ let amount1 = 0n;
14050
+ if (sqrtRatioCurrentX96 <= sqrtRatioAX96) {
14051
+ // Current price is below the range, only token0 needed
14052
+ amount0 = getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, params.liquidity);
14053
+ }
14054
+ else if (sqrtRatioCurrentX96 < sqrtRatioBX96) {
14055
+ // Current price is within the range, need both tokens
14056
+ amount0 = getAmount0ForLiquidity(sqrtRatioCurrentX96, sqrtRatioBX96, params.liquidity);
14057
+ amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioCurrentX96, params.liquidity);
14058
+ }
14059
+ else {
14060
+ // Current price is above the range, only token1 needed
14061
+ amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, params.liquidity);
14062
+ }
14063
+ return { amount0, amount1 };
14064
+ };
14065
+
14066
+ /**
14067
+ * Base client for interacting with the FlaunchZap contract in read-only mode
14068
+ * Provides basic contract initialization
14069
+ */
14070
+ class ReadFlaunchZap {
14071
+ /**
14072
+ * Creates a new ReadFlaunchZap instance
14073
+ * @param chainId - The chain ID of the contract
14074
+ * @param address - The address of the FlaunchZap contract
14075
+ * @param drift - Optional drift instance for contract interactions (creates new instance if not provided)
14076
+ * @throws Error if address is not provided
14077
+ */
14078
+ constructor(chainId, address, drift = createDrift$1()) {
14079
+ this.TOTAL_SUPPLY = 100n * 10n ** 27n; // 100 Billion tokens in wei
14080
+ this.chainId = chainId;
14081
+ this.drift = drift;
14082
+ if (!address) {
14083
+ throw new Error("Address is required");
14084
+ }
14085
+ this.contract = drift.contract({
14086
+ abi: FlaunchZapAbi,
14087
+ address,
14088
+ });
14089
+ this.readPositionManagerV1_1 = new ReadFlaunchPositionManagerV1_1(FlaunchPositionManagerV1_1Address[this.chainId], drift);
14090
+ }
14091
+ async getPremineCostInWei(params) {
14092
+ const mcapInWei = await this.readPositionManagerV1_1.getFlaunchingMarketCap(params.initialPriceParams);
14093
+ const premineCostInWei = (mcapInWei * params.premineAmount) / this.TOTAL_SUPPLY;
14094
+ // increase the premine cost by the slippage percent
14095
+ const premineCostInWeiWithSlippage = getAmountWithSlippage({
14096
+ amount: premineCostInWei,
14097
+ slippage: (params.slippagePercent ?? 0 / 100).toFixed(18).toString(),
14098
+ swapType: "EXACT_OUT", // as we know the output premine amount
14099
+ });
14100
+ return premineCostInWeiWithSlippage;
14101
+ }
14102
+ async getFlaunchingFee(params) {
14103
+ const readInitialPrice = new ReadInitialPrice(await this.readPositionManagerV1_1.initialPrice(), this.drift);
14104
+ const flaunchingFee = await readInitialPrice.getFlaunchingFee(params);
14105
+ // increase the flaunching fee by the slippage percent
14106
+ const flaunchingFeeWithSlippage = getAmountWithSlippage({
14107
+ amount: flaunchingFee,
14108
+ slippage: (params.slippagePercent ?? 0 / 100).toFixed(18).toString(),
14109
+ swapType: "EXACT_OUT",
14110
+ });
14111
+ return flaunchingFeeWithSlippage;
14112
+ }
14113
+ /**
14114
+ * Calculates the ETH required to flaunch a token, takes into account the ETH for premine and the flaunching fee
14115
+ */
14116
+ ethRequiredToFlaunch(params) {
14117
+ return this.contract.read("calculateFee", {
14118
+ _premineAmount: params.premineAmount ?? 0n,
14119
+ _slippage: params.slippagePercent
14120
+ ? BigInt(params.slippagePercent * 100)
14121
+ : 0n,
14122
+ _initialPriceParams: params.initialPriceParams,
14123
+ });
14124
+ }
14125
+ }
14126
+ /**
14127
+ * Extended client for interacting with the FlaunchZap contract with write capabilities
14128
+ */
14129
+ class ReadWriteFlaunchZap extends ReadFlaunchZap {
14130
+ constructor(chainId, address, drift = createDrift$1()) {
14131
+ super(chainId, address, drift);
14132
+ }
14133
+ /**
14134
+ * Flaunches a new token, supports premine
14135
+ * @param params - Parameters for the flaunch
14136
+ * @returns Transaction response for the flaunch creation
14137
+ */
14138
+ async flaunch(params) {
14139
+ const initialMCapInUSDCWei = parseUnits(params.initialMarketCapUSD.toString(), 6);
14140
+ const initialPriceParams = encodeAbiParameters$1([
14141
+ {
14142
+ type: "uint256",
14143
+ },
14144
+ ], [initialMCapInUSDCWei]);
14145
+ const fairLaunchInBps = BigInt(params.fairLaunchPercent * 100);
14146
+ const creatorFeeAllocationInBps = params.creatorFeeAllocationPercent * 100;
14147
+ const ethRequired = await this.ethRequiredToFlaunch({
14148
+ premineAmount: params.premineAmount ?? 0n,
14149
+ initialPriceParams,
14150
+ slippagePercent: 5,
14151
+ });
14152
+ const _treasuryManagerParams = params.treasuryManagerParams
14153
+ ? {
14154
+ manager: params.treasuryManagerParams.manager ?? zeroAddress,
14155
+ permissions: params.treasuryManagerParams.permissions ?? Permissions.OPEN,
14156
+ initializeData: params.treasuryManagerParams.initializeData ?? "0x",
14157
+ depositData: params.treasuryManagerParams.depositData ?? "0x",
14158
+ }
14159
+ : {
14160
+ manager: zeroAddress,
14161
+ permissions: Permissions.OPEN,
14162
+ initializeData: "0x",
14163
+ depositData: "0x",
14164
+ };
14165
+ const feeCalculatorParams = params.trustedSignerSettings
14166
+ ? encodeAbiParameters$1([
14167
+ { type: "bool", name: "enabled" },
14168
+ { type: "uint256", name: "walletCap" },
14169
+ { type: "uint256", name: "txCap" },
14170
+ ], [
14171
+ params.trustedSignerSettings.enabled,
14172
+ params.trustedSignerSettings.walletCap ?? 0n,
14173
+ params.trustedSignerSettings.txCap ?? 0n,
14174
+ ])
14175
+ : "0x";
14176
+ const _premineSwapHookData = params.trustedSignerSettings?.enabled
14177
+ ? encodeAbiParameters$1([
14178
+ { type: "address", name: "referrer" },
14179
+ {
14180
+ type: "tuple",
14181
+ components: [
14182
+ { type: "uint256", name: "deadline" },
14183
+ { type: "bytes", name: "signature" },
14184
+ ],
14185
+ },
14186
+ ], [
14187
+ zeroAddress,
14188
+ {
14189
+ deadline: BigInt(params.trustedSignerSettings.premineSignedMessage?.deadline ?? 0),
14190
+ signature: params.trustedSignerSettings.premineSignedMessage?.signature ??
14191
+ "0x",
14192
+ },
14193
+ ])
14194
+ : "0x";
14195
+ return this.contract.write("flaunch", {
14196
+ _flaunchParams: {
14197
+ name: params.name,
14198
+ symbol: params.symbol,
14199
+ tokenUri: params.tokenUri,
14200
+ initialTokenFairLaunch: (this.TOTAL_SUPPLY * fairLaunchInBps) / 10000n,
14201
+ fairLaunchDuration: BigInt(params.fairLaunchDuration),
14202
+ premineAmount: params.premineAmount ?? 0n,
14203
+ creator: params.creator,
14204
+ creatorFeeAllocation: creatorFeeAllocationInBps,
14205
+ flaunchAt: params.flaunchAt ?? 0n,
14206
+ initialPriceParams,
14207
+ feeCalculatorParams,
14208
+ },
14209
+ _trustedFeeSigner: params.trustedSignerSettings?.trustedFeeSigner ?? zeroAddress,
14210
+ _premineSwapHookData,
14211
+ _treasuryManagerParams: {
14212
+ ..._treasuryManagerParams,
14213
+ permissions: getPermissionsAddress(_treasuryManagerParams.permissions, this.chainId),
14214
+ },
14215
+ _whitelistParams: {
14216
+ merkleRoot: zeroHash,
14217
+ merkleIPFSHash: "",
14218
+ maxTokens: 0n,
14219
+ },
14220
+ _airdropParams: {
14221
+ airdropIndex: 0n,
14222
+ airdropAmount: 0n,
14223
+ airdropEndTime: 0n,
14224
+ merkleRoot: zeroHash,
14225
+ merkleIPFSHash: "",
14226
+ },
14227
+ }, {
14228
+ value: ethRequired,
14229
+ });
14230
+ }
14231
+ async flaunchIPFS(params) {
14232
+ const tokenUri = await generateTokenUri(params.name, params.symbol, {
14233
+ metadata: params.metadata,
14234
+ pinataConfig: params.pinataConfig,
14235
+ });
14236
+ return this.flaunch({
14237
+ ...params,
14238
+ tokenUri,
14239
+ });
14240
+ }
14241
+ /**
14242
+ * Flaunches a new token for a revenue manager
14243
+ * @param params - Parameters for the flaunch with revenue manager
14244
+ * @param params.name - The name of the token
14245
+ * @param params.symbol - The symbol of the token
14246
+ * @param params.tokenUri - The URI containing the token metadata
14247
+ * @param params.fairLaunchPercent - Percentage of total supply to be used in fair launch (0-100)
14248
+ * @param params.fairLaunchDuration - Duration of fair launch in seconds
14249
+ * @param params.initialMarketCapUSD - Initial market cap in USD
14250
+ * @param params.creator - Address of the token creator
14251
+ * @param params.creatorFeeAllocationPercent - Percentage of fees allocated to creator (0-100)
14252
+ * @param params.protocolRecipient - Address to receive protocol fees
14253
+ * @param params.protocolFeePercent - Percentage of fees allocated to protocol (0-100)
14254
+ * @param params.flaunchAt - Optional timestamp when the flaunch should start
13961
14255
  * @param params.premineAmount - Optional amount of tokens to premine
13962
14256
  * @returns Transaction response for the flaunch creation
13963
14257
  */
@@ -14134,11 +14428,71 @@ class ReadWriteFlaunchZap extends ReadFlaunchZap {
14134
14428
  },
14135
14429
  ], [
14136
14430
  {
14137
- stakingToken: params.stakingToken,
14138
- minEscrowDuration: params.minEscrowDuration,
14139
- minStakeDuration: params.minStakeDuration,
14431
+ stakingToken: params.stakingToken,
14432
+ minEscrowDuration: params.minEscrowDuration,
14433
+ minStakeDuration: params.minStakeDuration,
14434
+ creatorShare: (BigInt(params.creatorSharePercent) * VALID_SHARE_TOTAL) / 100n,
14435
+ ownerShare: (BigInt(params.ownerSharePercent) * VALID_SHARE_TOTAL) / 100n,
14436
+ },
14437
+ ]),
14438
+ _permissions: permissionsAddress,
14439
+ });
14440
+ }
14441
+ /**
14442
+ * Deploys a new BuyBack manager
14443
+ * @param params - Parameters for deploying the BuyBack manager
14444
+ * @param params.managerOwner - The address of the manager owner
14445
+ * @param params.creatorSharePercent - The % share that a creator will earn from their token (0-100)
14446
+ * @param params.ownerSharePercent - The % share that the manager owner will earn from their token (0-100)
14447
+ * @param params.buyBackPoolKey - The Uniswap V4 pool key configuration for the buyback pool
14448
+ * @param params.buyBackPoolKey.currency0 - The lower currency of the pool (sorted numerically)
14449
+ * @param params.buyBackPoolKey.currency1 - The higher currency of the pool (sorted numerically)
14450
+ * @param params.buyBackPoolKey.fee - The pool LP fee, capped at 1_000_000
14451
+ * @param params.buyBackPoolKey.tickSpacing - Tick spacing for the pool
14452
+ * @param params.buyBackPoolKey.hooks - The hooks address of the pool
14453
+ * @param params.permissions - The permissions for the BuyBack manager
14454
+ * @returns Transaction response
14455
+ */
14456
+ deployBuyBackManager(params) {
14457
+ const permissionsAddress = getPermissionsAddress(params.permissions ?? Permissions.OPEN, this.chainId);
14458
+ const VALID_SHARE_TOTAL = 10000000n; // 5 decimals as BigInt
14459
+ const buyBackManagerAddress = BuyBackManagerAddress[this.chainId];
14460
+ if (buyBackManagerAddress === zeroAddress) {
14461
+ throw new Error(`BuyBackManager not deployed on chainId: ${this.chainId}`);
14462
+ }
14463
+ return this.contract.write("deployAndInitializeManager", {
14464
+ _managerImplementation: buyBackManagerAddress,
14465
+ _owner: params.managerOwner,
14466
+ _data: encodeAbiParameters$1([
14467
+ {
14468
+ type: "tuple",
14469
+ components: [
14470
+ { type: "uint256", name: "creatorShare" },
14471
+ { type: "uint256", name: "ownerShare" },
14472
+ {
14473
+ type: "tuple",
14474
+ name: "buyBackPoolKey",
14475
+ components: [
14476
+ { type: "address", name: "currency0" },
14477
+ { type: "address", name: "currency1" },
14478
+ { type: "uint24", name: "fee" },
14479
+ { type: "int24", name: "tickSpacing" },
14480
+ { type: "address", name: "hooks" },
14481
+ ],
14482
+ },
14483
+ ],
14484
+ },
14485
+ ], [
14486
+ {
14140
14487
  creatorShare: (BigInt(params.creatorSharePercent) * VALID_SHARE_TOTAL) / 100n,
14141
14488
  ownerShare: (BigInt(params.ownerSharePercent) * VALID_SHARE_TOTAL) / 100n,
14489
+ buyBackPoolKey: orderPoolKey({
14490
+ currency0: params.buyBackPoolKey.currency0,
14491
+ currency1: params.buyBackPoolKey.currency1,
14492
+ fee: params.buyBackPoolKey.fee,
14493
+ tickSpacing: params.buyBackPoolKey.tickSpacing,
14494
+ hooks: params.buyBackPoolKey.hooks,
14495
+ }),
14142
14496
  },
14143
14497
  ]),
14144
14498
  _permissions: permissionsAddress,
@@ -24625,257 +24979,9 @@ const MulticallAbi = [
24625
24979
  ],
24626
24980
  stateMutability: "payable",
24627
24981
  type: "function",
24628
- },
24629
- {
24630
- inputs: [
24631
- {
24632
- components: [
24633
- {
24634
- internalType: "address",
24635
- name: "target",
24636
- type: "address",
24637
- },
24638
- {
24639
- internalType: "bytes",
24640
- name: "callData",
24641
- type: "bytes",
24642
- },
24643
- ],
24644
- internalType: "struct Multicall3.Call[]",
24645
- name: "calls",
24646
- type: "tuple[]",
24647
- },
24648
- ],
24649
- name: "blockAndAggregate",
24650
- outputs: [
24651
- {
24652
- internalType: "uint256",
24653
- name: "blockNumber",
24654
- type: "uint256",
24655
- },
24656
- {
24657
- internalType: "bytes32",
24658
- name: "blockHash",
24659
- type: "bytes32",
24660
- },
24661
- {
24662
- components: [
24663
- {
24664
- internalType: "bool",
24665
- name: "success",
24666
- type: "bool",
24667
- },
24668
- {
24669
- internalType: "bytes",
24670
- name: "returnData",
24671
- type: "bytes",
24672
- },
24673
- ],
24674
- internalType: "struct Multicall3.Result[]",
24675
- name: "returnData",
24676
- type: "tuple[]",
24677
- },
24678
- ],
24679
- stateMutability: "payable",
24680
- type: "function",
24681
- },
24682
- {
24683
- inputs: [],
24684
- name: "getBasefee",
24685
- outputs: [
24686
- {
24687
- internalType: "uint256",
24688
- name: "basefee",
24689
- type: "uint256",
24690
- },
24691
- ],
24692
- stateMutability: "view",
24693
- type: "function",
24694
- },
24695
- {
24696
- inputs: [
24697
- {
24698
- internalType: "uint256",
24699
- name: "blockNumber",
24700
- type: "uint256",
24701
- },
24702
- ],
24703
- name: "getBlockHash",
24704
- outputs: [
24705
- {
24706
- internalType: "bytes32",
24707
- name: "blockHash",
24708
- type: "bytes32",
24709
- },
24710
- ],
24711
- stateMutability: "view",
24712
- type: "function",
24713
- },
24714
- {
24715
- inputs: [],
24716
- name: "getBlockNumber",
24717
- outputs: [
24718
- {
24719
- internalType: "uint256",
24720
- name: "blockNumber",
24721
- type: "uint256",
24722
- },
24723
- ],
24724
- stateMutability: "view",
24725
- type: "function",
24726
- },
24727
- {
24728
- inputs: [],
24729
- name: "getChainId",
24730
- outputs: [
24731
- {
24732
- internalType: "uint256",
24733
- name: "chainid",
24734
- type: "uint256",
24735
- },
24736
- ],
24737
- stateMutability: "view",
24738
- type: "function",
24739
- },
24740
- {
24741
- inputs: [],
24742
- name: "getCurrentBlockCoinbase",
24743
- outputs: [
24744
- {
24745
- internalType: "address",
24746
- name: "coinbase",
24747
- type: "address",
24748
- },
24749
- ],
24750
- stateMutability: "view",
24751
- type: "function",
24752
- },
24753
- {
24754
- inputs: [],
24755
- name: "getCurrentBlockDifficulty",
24756
- outputs: [
24757
- {
24758
- internalType: "uint256",
24759
- name: "difficulty",
24760
- type: "uint256",
24761
- },
24762
- ],
24763
- stateMutability: "view",
24764
- type: "function",
24765
- },
24766
- {
24767
- inputs: [],
24768
- name: "getCurrentBlockGasLimit",
24769
- outputs: [
24770
- {
24771
- internalType: "uint256",
24772
- name: "gaslimit",
24773
- type: "uint256",
24774
- },
24775
- ],
24776
- stateMutability: "view",
24777
- type: "function",
24778
- },
24779
- {
24780
- inputs: [],
24781
- name: "getCurrentBlockTimestamp",
24782
- outputs: [
24783
- {
24784
- internalType: "uint256",
24785
- name: "timestamp",
24786
- type: "uint256",
24787
- },
24788
- ],
24789
- stateMutability: "view",
24790
- type: "function",
24791
- },
24792
- {
24793
- inputs: [
24794
- {
24795
- internalType: "address",
24796
- name: "addr",
24797
- type: "address",
24798
- },
24799
- ],
24800
- name: "getEthBalance",
24801
- outputs: [
24802
- {
24803
- internalType: "uint256",
24804
- name: "balance",
24805
- type: "uint256",
24806
- },
24807
- ],
24808
- stateMutability: "view",
24809
- type: "function",
24810
- },
24811
- {
24812
- inputs: [],
24813
- name: "getLastBlockHash",
24814
- outputs: [
24815
- {
24816
- internalType: "bytes32",
24817
- name: "blockHash",
24818
- type: "bytes32",
24819
- },
24820
- ],
24821
- stateMutability: "view",
24822
- type: "function",
24823
- },
24824
- {
24825
- inputs: [
24826
- {
24827
- internalType: "bool",
24828
- name: "requireSuccess",
24829
- type: "bool",
24830
- },
24831
- {
24832
- components: [
24833
- {
24834
- internalType: "address",
24835
- name: "target",
24836
- type: "address",
24837
- },
24838
- {
24839
- internalType: "bytes",
24840
- name: "callData",
24841
- type: "bytes",
24842
- },
24843
- ],
24844
- internalType: "struct Multicall3.Call[]",
24845
- name: "calls",
24846
- type: "tuple[]",
24847
- },
24848
- ],
24849
- name: "tryAggregate",
24850
- outputs: [
24851
- {
24852
- components: [
24853
- {
24854
- internalType: "bool",
24855
- name: "success",
24856
- type: "bool",
24857
- },
24858
- {
24859
- internalType: "bytes",
24860
- name: "returnData",
24861
- type: "bytes",
24862
- },
24863
- ],
24864
- internalType: "struct Multicall3.Result[]",
24865
- name: "returnData",
24866
- type: "tuple[]",
24867
- },
24868
- ],
24869
- stateMutability: "payable",
24870
- type: "function",
24871
- },
24872
- {
24873
- inputs: [
24874
- {
24875
- internalType: "bool",
24876
- name: "requireSuccess",
24877
- type: "bool",
24878
- },
24982
+ },
24983
+ {
24984
+ inputs: [
24879
24985
  {
24880
24986
  components: [
24881
24987
  {
@@ -24894,7 +25000,7 @@ const MulticallAbi = [
24894
25000
  type: "tuple[]",
24895
25001
  },
24896
25002
  ],
24897
- name: "tryBlockAndAggregate",
25003
+ name: "blockAndAggregate",
24898
25004
  outputs: [
24899
25005
  {
24900
25006
  internalType: "uint256",
@@ -24927,597 +25033,555 @@ const MulticallAbi = [
24927
25033
  stateMutability: "payable",
24928
25034
  type: "function",
24929
25035
  },
24930
- ];
24931
-
24932
- class ReadMulticall {
24933
- constructor(drift) {
24934
- // same address across all chains
24935
- this.address = "0xcA11bde05977b3631167028862bE2a173976CA11";
24936
- this.contract = drift.contract({
24937
- abi: MulticallAbi,
24938
- address: this.address,
24939
- });
24940
- }
24941
- aggregate3(calls) {
24942
- return this.contract.simulateWrite("aggregate3", {
24943
- calls: calls.map((call) => ({
24944
- target: call.target,
24945
- allowFailure: true,
24946
- callData: call.callData,
24947
- })),
24948
- });
24949
- }
24950
- }
24951
-
24952
- class ReadRevenueManager {
24953
- constructor(address, drift = createDrift$1()) {
24954
- this.drift = drift;
24955
- this.contract = drift.contract({
24956
- abi: RevenueManagerAbi,
24957
- address,
24958
- });
24959
- }
24960
- /**
24961
- * Gets the claimable balance of ETH for the recipient
24962
- * @param recipient - The address of the recipient to check
24963
- * @returns Promise<bigint> - The claimable balance of ETH
24964
- */
24965
- balances(address) {
24966
- return this.contract.read("balances", {
24967
- _recipient: address,
24968
- });
24969
- }
24970
- /**
24971
- * Gets the protocol recipient address
24972
- * @returns Promise<Address> - The protocol recipient address
24973
- */
24974
- protocolRecipient() {
24975
- return this.contract.read("protocolRecipient");
24976
- }
24977
- /**
24978
- * Gets the total number of tokens managed by the revenue manager
24979
- * @returns Promise<bigint> - The total count of tokens
24980
- */
24981
- async tokensCount() {
24982
- const nextInternalId = await this.contract.read("nextInternalId");
24983
- return nextInternalId - 1n;
24984
- }
24985
- /**
24986
- * Gets all tokens created by a specific creator address
24987
- * @param creator - The address of the creator to query tokens for
24988
- * @param sortByDesc - Optional boolean to sort tokens in descending order (default: false)
24989
- * @returns Promise<Array<{flaunch: Address, tokenId: bigint}>> - Array of token objects containing flaunch address and token ID
24990
- */
24991
- async allTokensByCreator(creator, sortByDesc = false) {
24992
- const tokens = await this.contract.read("tokens", {
24993
- _creator: creator,
24994
- });
24995
- if (sortByDesc) {
24996
- return [...tokens].reverse();
24997
- }
24998
- return tokens;
24999
- }
25000
- /**
25001
- * Gets all tokens currently managed by the revenue manager contract
25002
- * @dev Uses multicall to batch requests for better performance
25003
- * @param sortByDesc - Optional boolean to sort tokens in descending order (default: false)
25004
- * @returns Promise<Array<{flaunch: Address, tokenId: bigint}>> - Array of token objects containing flaunch address and token ID
25005
- */
25006
- async allTokensInManager(sortByDesc = false) {
25007
- const count = await this.tokensCount();
25008
- const multicall = new ReadMulticall(this.drift);
25009
- let calldatas = Array.from({ length: Number(count) }, (_, i) => this.contract.encodeFunctionData("internalIds", {
25010
- _internalId: BigInt(i + 1),
25011
- }));
25012
- // Reverse the array if sortByDesc is true
25013
- if (sortByDesc) {
25014
- calldatas = calldatas.reverse();
25015
- }
25016
- const result = await multicall.aggregate3(calldatas.map((calldata) => ({
25017
- target: this.contract.address,
25018
- callData: calldata,
25019
- })));
25020
- return result.map((r) => this.contract.decodeFunctionReturn("internalIds", r.returnData));
25021
- }
25022
- }
25023
- class ReadWriteRevenueManager extends ReadRevenueManager {
25024
- constructor(address, drift = createDrift$1()) {
25025
- super(address, drift);
25026
- }
25027
- /**
25028
- * Allows the protocol recipient to claim the protocol's share of the revenue
25029
- * @returns Promise<TransactionResponse> - The transaction response
25030
- */
25031
- protocolClaim() {
25032
- return this.contract.write("claim", {});
25033
- }
25034
- /**
25035
- * Allows the creator to claim their total share of the revenue from a revenue manager
25036
- * @returns Promise<TransactionResponse> - The transaction response
25037
- */
25038
- creatorClaim() {
25039
- return this.contract.write("claim", {});
25040
- }
25041
- /**
25042
- * Allows the creator to claim their share of the revenue from specific flaunch tokens
25043
- * @param flaunchTokens - The flaunch token ids to claim the revenue for
25044
- * @returns Promise<TransactionResponse> - The transaction response
25045
- */
25046
- creatorClaimForTokens(flaunchTokens) {
25047
- return this.contract.write("claim", {
25048
- _flaunchToken: flaunchTokens,
25049
- });
25050
- }
25051
- }
25052
-
25053
- const TreasuryManagerAbi = [
25054
25036
  {
25037
+ inputs: [],
25038
+ name: "getBasefee",
25039
+ outputs: [
25040
+ {
25041
+ internalType: "uint256",
25042
+ name: "basefee",
25043
+ type: "uint256",
25044
+ },
25045
+ ],
25046
+ stateMutability: "view",
25055
25047
  type: "function",
25056
- name: "deposit",
25048
+ },
25049
+ {
25057
25050
  inputs: [
25058
25051
  {
25059
- name: "_flaunchToken",
25060
- type: "tuple",
25061
- internalType: "struct ITreasuryManager.FlaunchToken",
25062
- components: [
25063
- {
25064
- name: "flaunch",
25065
- type: "address",
25066
- internalType: "contract Flaunch",
25067
- },
25068
- { name: "tokenId", type: "uint256", internalType: "uint256" },
25069
- ],
25052
+ internalType: "uint256",
25053
+ name: "blockNumber",
25054
+ type: "uint256",
25070
25055
  },
25071
- { name: "_creator", type: "address", internalType: "address" },
25072
- { name: "_data", type: "bytes", internalType: "bytes" },
25073
25056
  ],
25074
- outputs: [],
25075
- stateMutability: "nonpayable",
25057
+ name: "getBlockHash",
25058
+ outputs: [
25059
+ {
25060
+ internalType: "bytes32",
25061
+ name: "blockHash",
25062
+ type: "bytes32",
25063
+ },
25064
+ ],
25065
+ stateMutability: "view",
25066
+ type: "function",
25076
25067
  },
25077
25068
  {
25069
+ inputs: [],
25070
+ name: "getBlockNumber",
25071
+ outputs: [
25072
+ {
25073
+ internalType: "uint256",
25074
+ name: "blockNumber",
25075
+ type: "uint256",
25076
+ },
25077
+ ],
25078
+ stateMutability: "view",
25078
25079
  type: "function",
25079
- name: "initialize",
25080
+ },
25081
+ {
25082
+ inputs: [],
25083
+ name: "getChainId",
25084
+ outputs: [
25085
+ {
25086
+ internalType: "uint256",
25087
+ name: "chainid",
25088
+ type: "uint256",
25089
+ },
25090
+ ],
25091
+ stateMutability: "view",
25092
+ type: "function",
25093
+ },
25094
+ {
25095
+ inputs: [],
25096
+ name: "getCurrentBlockCoinbase",
25097
+ outputs: [
25098
+ {
25099
+ internalType: "address",
25100
+ name: "coinbase",
25101
+ type: "address",
25102
+ },
25103
+ ],
25104
+ stateMutability: "view",
25105
+ type: "function",
25106
+ },
25107
+ {
25108
+ inputs: [],
25109
+ name: "getCurrentBlockDifficulty",
25110
+ outputs: [
25111
+ {
25112
+ internalType: "uint256",
25113
+ name: "difficulty",
25114
+ type: "uint256",
25115
+ },
25116
+ ],
25117
+ stateMutability: "view",
25118
+ type: "function",
25119
+ },
25120
+ {
25121
+ inputs: [],
25122
+ name: "getCurrentBlockGasLimit",
25123
+ outputs: [
25124
+ {
25125
+ internalType: "uint256",
25126
+ name: "gaslimit",
25127
+ type: "uint256",
25128
+ },
25129
+ ],
25130
+ stateMutability: "view",
25131
+ type: "function",
25132
+ },
25133
+ {
25134
+ inputs: [],
25135
+ name: "getCurrentBlockTimestamp",
25136
+ outputs: [
25137
+ {
25138
+ internalType: "uint256",
25139
+ name: "timestamp",
25140
+ type: "uint256",
25141
+ },
25142
+ ],
25143
+ stateMutability: "view",
25144
+ type: "function",
25145
+ },
25146
+ {
25080
25147
  inputs: [
25081
- { name: "_owner", type: "address", internalType: "address" },
25082
- { name: "_data", type: "bytes", internalType: "bytes" },
25148
+ {
25149
+ internalType: "address",
25150
+ name: "addr",
25151
+ type: "address",
25152
+ },
25153
+ ],
25154
+ name: "getEthBalance",
25155
+ outputs: [
25156
+ {
25157
+ internalType: "uint256",
25158
+ name: "balance",
25159
+ type: "uint256",
25160
+ },
25083
25161
  ],
25084
- outputs: [],
25085
- stateMutability: "nonpayable",
25086
- },
25087
- {
25088
- type: "function",
25089
- name: "managerOwner",
25090
- inputs: [],
25091
- outputs: [{ name: "", type: "address", internalType: "address" }],
25092
25162
  stateMutability: "view",
25163
+ type: "function",
25093
25164
  },
25094
25165
  {
25095
- type: "function",
25096
- name: "permissions",
25097
25166
  inputs: [],
25167
+ name: "getLastBlockHash",
25098
25168
  outputs: [
25099
25169
  {
25100
- name: "",
25101
- type: "address",
25102
- internalType: "contract IManagerPermissions",
25170
+ internalType: "bytes32",
25171
+ name: "blockHash",
25172
+ type: "bytes32",
25103
25173
  },
25104
25174
  ],
25105
25175
  stateMutability: "view",
25176
+ type: "function",
25106
25177
  },
25107
25178
  {
25108
- type: "function",
25109
- name: "rescue",
25110
25179
  inputs: [
25111
25180
  {
25112
- name: "_flaunchToken",
25113
- type: "tuple",
25114
- internalType: "struct ITreasuryManager.FlaunchToken",
25181
+ internalType: "bool",
25182
+ name: "requireSuccess",
25183
+ type: "bool",
25184
+ },
25185
+ {
25115
25186
  components: [
25116
25187
  {
25117
- name: "flaunch",
25188
+ internalType: "address",
25189
+ name: "target",
25118
25190
  type: "address",
25119
- internalType: "contract Flaunch",
25120
25191
  },
25121
- { name: "tokenId", type: "uint256", internalType: "uint256" },
25192
+ {
25193
+ internalType: "bytes",
25194
+ name: "callData",
25195
+ type: "bytes",
25196
+ },
25122
25197
  ],
25198
+ internalType: "struct Multicall3.Call[]",
25199
+ name: "calls",
25200
+ type: "tuple[]",
25123
25201
  },
25124
- { name: "_recipient", type: "address", internalType: "address" },
25125
25202
  ],
25126
- outputs: [],
25127
- stateMutability: "nonpayable",
25128
- },
25129
- {
25130
- type: "function",
25131
- name: "setPermissions",
25132
- inputs: [
25133
- { name: "_permissions", type: "address", internalType: "address" },
25203
+ name: "tryAggregate",
25204
+ outputs: [
25205
+ {
25206
+ components: [
25207
+ {
25208
+ internalType: "bool",
25209
+ name: "success",
25210
+ type: "bool",
25211
+ },
25212
+ {
25213
+ internalType: "bytes",
25214
+ name: "returnData",
25215
+ type: "bytes",
25216
+ },
25217
+ ],
25218
+ internalType: "struct Multicall3.Result[]",
25219
+ name: "returnData",
25220
+ type: "tuple[]",
25221
+ },
25134
25222
  ],
25135
- outputs: [],
25136
- stateMutability: "nonpayable",
25223
+ stateMutability: "payable",
25224
+ type: "function",
25137
25225
  },
25138
25226
  {
25139
- type: "function",
25140
- name: "transferManagerOwnership",
25141
25227
  inputs: [
25142
25228
  {
25143
- name: "_newManagerOwner",
25144
- type: "address",
25145
- internalType: "address",
25229
+ internalType: "bool",
25230
+ name: "requireSuccess",
25231
+ type: "bool",
25146
25232
  },
25147
- ],
25148
- outputs: [],
25149
- stateMutability: "nonpayable",
25150
- },
25151
- ];
25152
-
25153
- /**
25154
- * Client for interacting with the TreasuryManager contract in read-only mode
25155
- * Provides methods to query permissions and manager owner
25156
- */
25157
- class ReadTreasuryManager {
25158
- /**
25159
- * Creates a new ReadTreasuryManager instance
25160
- * @param address - The address of the TreasuryManager contract
25161
- * @param drift - Optional drift instance for contract interactions (creates new instance if not provided)
25162
- * @throws Error if address is not provided
25163
- */
25164
- constructor(address, drift = createDrift$1()) {
25165
- if (!address) {
25166
- throw new Error("Address is required");
25167
- }
25168
- this.contract = drift.contract({
25169
- abi: TreasuryManagerAbi,
25170
- address,
25171
- });
25172
- }
25173
- /**
25174
- * Gets the permissions contract address
25175
- * @returns Promise<Address> - The address of the permissions contract
25176
- */
25177
- permissions() {
25178
- return this.contract.read("permissions");
25179
- }
25180
- /**
25181
- * Gets the manager owner address
25182
- * @returns Promise<Address> - The address of the manager owner
25183
- */
25184
- managerOwner() {
25185
- return this.contract.read("managerOwner");
25186
- }
25187
- }
25188
- /**
25189
- * Extended client for interacting with the TreasuryManager contract with write capabilities
25190
- * Provides methods to deposit tokens, set permissions, and transfer ownership
25191
- */
25192
- class ReadWriteTreasuryManager extends ReadTreasuryManager {
25193
- constructor(address, drift = createDrift$1()) {
25194
- super(address, drift);
25195
- }
25196
- /**
25197
- * Deposits a flaunch token to the treasury
25198
- * @param flaunchToken - The flaunch token to deposit
25199
- * @param creator - The address of the creator
25200
- * @param data - Additional data for the deposit
25201
- * @returns Promise<void>
25202
- */
25203
- deposit(flaunchToken, creator, data) {
25204
- return this.contract.write("deposit", {
25205
- _flaunchToken: flaunchToken,
25206
- _creator: creator,
25207
- _data: data,
25208
- });
25209
- }
25210
- /**
25211
- * Sets the permissions contract address
25212
- * @param permissions - The address of the new permissions contract
25213
- * @returns Promise<void>
25214
- */
25215
- setPermissions(permissions) {
25216
- return this.contract.write("setPermissions", {
25217
- _permissions: permissions,
25218
- });
25219
- }
25220
- /**
25221
- * Transfers the manager ownership to a new address
25222
- * @param newManagerOwner - The address of the new manager owner
25223
- * @returns Promise<void>
25224
- */
25225
- transferManagerOwnership(newManagerOwner) {
25226
- return this.contract.write("transferManagerOwnership", {
25227
- _newManagerOwner: newManagerOwner,
25228
- });
25229
- }
25230
- }
25231
-
25232
- // our min/max tick range that is valid for the tick spacing (60)
25233
- const TickFinder = {
25234
- MIN_TICK: -887220,
25235
- MAX_TICK: 887220,
25236
- };
25237
- const Q96 = 2n ** 96n;
25238
- const Q192 = 2n ** 192n;
25239
- const TICK_SPACING = 60;
25240
- const getPoolId = (poolKey) => {
25241
- // Pack the data in the same order as Solidity struct
25242
- const packed = concat$1([
25243
- pad$1(poolKey.currency0, { size: 32 }), // address padded to 32 bytes
25244
- pad$1(poolKey.currency1, { size: 32 }), // address padded to 32 bytes
25245
- pad$1(toHex$1(poolKey.fee), { size: 32 }), // uint24 padded to 32 bytes
25246
- pad$1(toHex$1(poolKey.tickSpacing), { size: 32 }), // int24 padded to 32 bytes
25247
- pad$1(poolKey.hooks, { size: 32 }), // address padded to 32 bytes
25248
- ]);
25249
- return keccak256$1(packed);
25250
- };
25251
- const orderPoolKey = (poolKey) => {
25252
- const [currency0, currency1] = poolKey.currency0 < poolKey.currency1
25253
- ? [poolKey.currency0, poolKey.currency1]
25254
- : [poolKey.currency1, poolKey.currency0];
25255
- return {
25256
- ...poolKey,
25257
- currency0,
25258
- currency1,
25259
- };
25260
- };
25261
- const getValidTick = ({ tick, tickSpacing, roundDown = true, }) => {
25262
- // If the tick is already valid, exit early
25263
- if (tick % tickSpacing === 0) {
25264
- return tick;
25265
- }
25266
- // Division that rounds towards zero (like Solidity)
25267
- let validTick = Math.trunc(tick / tickSpacing) * tickSpacing;
25268
- // Handle negative ticks (Solidity behavior)
25269
- if (tick < 0 && tick % tickSpacing !== 0) {
25270
- validTick -= tickSpacing;
25271
- }
25272
- // If not rounding down, add TICK_SPACING to get the upper tick
25273
- if (!roundDown) {
25274
- validTick += tickSpacing;
25275
- }
25276
- return validTick;
25277
- };
25278
- // Rounds up or down to the nearest tick
25279
- const getNearestUsableTick = ({ tick, tickSpacing, }) => {
25280
- const rounded = Math.round(tick / tickSpacing) * tickSpacing;
25281
- return Math.max(TickFinder.MIN_TICK, Math.min(TickFinder.MAX_TICK, rounded));
25282
- };
25283
- const getAmount0ForLiquidity = (sqrtRatioAX96, sqrtRatioBX96, liquidity) => {
25284
- let [sqrtRatioA, sqrtRatioB] = [sqrtRatioAX96, sqrtRatioBX96];
25285
- if (sqrtRatioA > sqrtRatioB) {
25286
- [sqrtRatioA, sqrtRatioB] = [sqrtRatioB, sqrtRatioA];
25287
- }
25288
- const leftShiftedLiquidity = liquidity << 96n;
25289
- const sqrtDiff = sqrtRatioB - sqrtRatioA;
25290
- const multipliedRes = leftShiftedLiquidity * sqrtDiff;
25291
- const numerator = multipliedRes / sqrtRatioB;
25292
- const amount0 = numerator / sqrtRatioA;
25293
- return amount0;
25294
- };
25295
- const getAmount1ForLiquidity = (sqrtRatioAX96, sqrtRatioBX96, liquidity) => {
25296
- let [sqrtRatioA, sqrtRatioB] = [sqrtRatioAX96, sqrtRatioBX96];
25297
- if (sqrtRatioA > sqrtRatioB) {
25298
- [sqrtRatioA, sqrtRatioB] = [sqrtRatioB, sqrtRatioA];
25299
- }
25300
- const sqrtDiff = sqrtRatioB - sqrtRatioA;
25301
- const multipliedRes = liquidity * sqrtDiff;
25302
- const amount1 = multipliedRes / 2n ** 96n;
25303
- return amount1;
25304
- };
25305
- const getSqrtPriceX96FromTick = (tick) => {
25306
- const absTick = tick < 0 ? BigInt(-tick) : BigInt(tick);
25307
- if (absTick > TickFinder.MAX_TICK) {
25308
- throw new Error("Tick out of range");
25233
+ {
25234
+ components: [
25235
+ {
25236
+ internalType: "address",
25237
+ name: "target",
25238
+ type: "address",
25239
+ },
25240
+ {
25241
+ internalType: "bytes",
25242
+ name: "callData",
25243
+ type: "bytes",
25244
+ },
25245
+ ],
25246
+ internalType: "struct Multicall3.Call[]",
25247
+ name: "calls",
25248
+ type: "tuple[]",
25249
+ },
25250
+ ],
25251
+ name: "tryBlockAndAggregate",
25252
+ outputs: [
25253
+ {
25254
+ internalType: "uint256",
25255
+ name: "blockNumber",
25256
+ type: "uint256",
25257
+ },
25258
+ {
25259
+ internalType: "bytes32",
25260
+ name: "blockHash",
25261
+ type: "bytes32",
25262
+ },
25263
+ {
25264
+ components: [
25265
+ {
25266
+ internalType: "bool",
25267
+ name: "success",
25268
+ type: "bool",
25269
+ },
25270
+ {
25271
+ internalType: "bytes",
25272
+ name: "returnData",
25273
+ type: "bytes",
25274
+ },
25275
+ ],
25276
+ internalType: "struct Multicall3.Result[]",
25277
+ name: "returnData",
25278
+ type: "tuple[]",
25279
+ },
25280
+ ],
25281
+ stateMutability: "payable",
25282
+ type: "function",
25283
+ },
25284
+ ];
25285
+
25286
+ class ReadMulticall {
25287
+ constructor(drift) {
25288
+ // same address across all chains
25289
+ this.address = "0xcA11bde05977b3631167028862bE2a173976CA11";
25290
+ this.contract = drift.contract({
25291
+ abi: MulticallAbi,
25292
+ address: this.address,
25293
+ });
25309
25294
  }
25310
- let ratio = (absTick & 1n) !== 0n
25311
- ? 0xfffcb933bd6fad37aa2d162d1a594001n
25312
- : 0x100000000000000000000000000000000n;
25313
- if ((absTick & 2n) !== 0n)
25314
- ratio = (ratio * 0xfff97272373d413259a46990580e213an) >> 128n;
25315
- if ((absTick & 4n) !== 0n)
25316
- ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdccn) >> 128n;
25317
- if ((absTick & 8n) !== 0n)
25318
- ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0n) >> 128n;
25319
- if ((absTick & 16n) !== 0n)
25320
- ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644n) >> 128n;
25321
- if ((absTick & 32n) !== 0n)
25322
- ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0n) >> 128n;
25323
- if ((absTick & 64n) !== 0n)
25324
- ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861n) >> 128n;
25325
- if ((absTick & 128n) !== 0n)
25326
- ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053n) >> 128n;
25327
- if ((absTick & 256n) !== 0n)
25328
- ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4n) >> 128n;
25329
- if ((absTick & 512n) !== 0n)
25330
- ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54n) >> 128n;
25331
- if ((absTick & 1024n) !== 0n)
25332
- ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3n) >> 128n;
25333
- if ((absTick & 2048n) !== 0n)
25334
- ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9n) >> 128n;
25335
- if ((absTick & 4096n) !== 0n)
25336
- ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825n) >> 128n;
25337
- if ((absTick & 8192n) !== 0n)
25338
- ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5n) >> 128n;
25339
- if ((absTick & 16384n) !== 0n)
25340
- ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7n) >> 128n;
25341
- if ((absTick & 32768n) !== 0n)
25342
- ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6n) >> 128n;
25343
- if ((absTick & 65536n) !== 0n)
25344
- ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9n) >> 128n;
25345
- if ((absTick & 131072n) !== 0n)
25346
- ratio = (ratio * 0x5d6af8dedb81196699c329225ee604n) >> 128n;
25347
- if ((absTick & 262144n) !== 0n)
25348
- ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98n) >> 128n;
25349
- if ((absTick & 524288n) !== 0n)
25350
- ratio = (ratio * 0x48a170391f7dc42444e8fa2n) >> 128n;
25351
- if (tick > 0) {
25352
- ratio = (2n ** 256n - 1n) / ratio;
25295
+ aggregate3(calls) {
25296
+ return this.contract.simulateWrite("aggregate3", {
25297
+ calls: calls.map((call) => ({
25298
+ target: call.target,
25299
+ allowFailure: true,
25300
+ callData: call.callData,
25301
+ })),
25302
+ });
25353
25303
  }
25354
- // Convert from Q128.128 to Q128.96
25355
- const resultShifted = ratio >> 32n;
25356
- if (ratio % (1n << 32n) === 0n) {
25357
- return resultShifted;
25304
+ }
25305
+
25306
+ class ReadRevenueManager {
25307
+ constructor(address, drift = createDrift$1()) {
25308
+ this.drift = drift;
25309
+ this.contract = drift.contract({
25310
+ abi: RevenueManagerAbi,
25311
+ address,
25312
+ });
25358
25313
  }
25359
- return resultShifted + 1n;
25360
- };
25361
- const calculateUnderlyingTokenBalances = (liquidity, tickLower, tickUpper, tickCurrent) => {
25362
- const sqrtPriceCurrentX96 = getSqrtPriceX96FromTick(tickCurrent);
25363
- const sqrtPriceLowerX96 = getSqrtPriceX96FromTick(tickLower);
25364
- const sqrtPriceUpperX96 = getSqrtPriceX96FromTick(tickUpper);
25365
- let amount0 = 0n;
25366
- let amount1 = 0n;
25367
- if (sqrtPriceCurrentX96 <= sqrtPriceLowerX96) {
25368
- // Current price is below the position range
25369
- amount0 = getAmount0ForLiquidity(sqrtPriceLowerX96, sqrtPriceUpperX96, liquidity);
25314
+ /**
25315
+ * Gets the claimable balance of ETH for the recipient
25316
+ * @param recipient - The address of the recipient to check
25317
+ * @returns Promise<bigint> - The claimable balance of ETH
25318
+ */
25319
+ balances(address) {
25320
+ return this.contract.read("balances", {
25321
+ _recipient: address,
25322
+ });
25370
25323
  }
25371
- else if (sqrtPriceCurrentX96 < sqrtPriceUpperX96) {
25372
- // Current price is within the position range
25373
- amount0 = getAmount0ForLiquidity(sqrtPriceCurrentX96, sqrtPriceUpperX96, liquidity);
25374
- amount1 = getAmount1ForLiquidity(sqrtPriceLowerX96, sqrtPriceCurrentX96, liquidity);
25324
+ /**
25325
+ * Gets the protocol recipient address
25326
+ * @returns Promise<Address> - The protocol recipient address
25327
+ */
25328
+ protocolRecipient() {
25329
+ return this.contract.read("protocolRecipient");
25375
25330
  }
25376
- else {
25377
- // Current price is above the position range
25378
- amount1 = getAmount1ForLiquidity(sqrtPriceLowerX96, sqrtPriceUpperX96, liquidity);
25331
+ /**
25332
+ * Gets the total number of tokens managed by the revenue manager
25333
+ * @returns Promise<bigint> - The total count of tokens
25334
+ */
25335
+ async tokensCount() {
25336
+ const nextInternalId = await this.contract.read("nextInternalId");
25337
+ return nextInternalId - 1n;
25379
25338
  }
25380
- return { amount0, amount1 };
25381
- };
25382
- // Helper function to convert price ratio to tick with decimal handling
25383
- const priceRatioToTick = ({ priceInput, isDirection1Per0, decimals0, decimals1, spacing, shouldGetNearestUsableTick = true, }) => {
25384
- if (!priceInput || isNaN(Number(priceInput)))
25385
- return 0;
25386
- const inputPrice = Number(priceInput);
25387
- try {
25388
- // For Uniswap v3/v4, the tick represents price as: price = 1.0001^tick
25389
- // where price = amount1/amount0 in their raw decimal format
25390
- let priceRatio;
25391
- if (isDirection1Per0) {
25392
- // Input is token1 per token0 (e.g., memecoin per flETH)
25393
- // Convert from human-readable to raw: divide by (10^decimals0 / 10^decimals1)
25394
- priceRatio = inputPrice / Math.pow(10, decimals0 - decimals1);
25395
- }
25396
- else {
25397
- // Input is token0 per token1 (e.g., flETH per memecoin)
25398
- // Invert to get token1 per token0, then convert to raw
25399
- priceRatio = 1 / inputPrice / Math.pow(10, decimals0 - decimals1);
25400
- }
25401
- // Calculate tick: tick = log(price) / log(1.0001)
25402
- const tick = Math.log(priceRatio) / Math.log(1.0001);
25403
- if (shouldGetNearestUsableTick) {
25404
- return getValidTick({
25405
- tick: Math.round(tick),
25406
- tickSpacing: spacing,
25407
- });
25408
- }
25409
- else {
25410
- return Math.round(tick);
25339
+ /**
25340
+ * Gets all tokens created by a specific creator address
25341
+ * @param creator - The address of the creator to query tokens for
25342
+ * @param sortByDesc - Optional boolean to sort tokens in descending order (default: false)
25343
+ * @returns Promise<Array<{flaunch: Address, tokenId: bigint}>> - Array of token objects containing flaunch address and token ID
25344
+ */
25345
+ async allTokensByCreator(creator, sortByDesc = false) {
25346
+ const tokens = await this.contract.read("tokens", {
25347
+ _creator: creator,
25348
+ });
25349
+ if (sortByDesc) {
25350
+ return [...tokens].reverse();
25411
25351
  }
25352
+ return tokens;
25412
25353
  }
25413
- catch (error) {
25414
- console.error("Error converting price to tick:", error);
25415
- // Fallback to basic calculation
25416
- const rawTick = Math.floor(Math.log(inputPrice) / Math.log(1.0001));
25417
- if (shouldGetNearestUsableTick) {
25418
- return getValidTick({
25419
- tick: rawTick,
25420
- tickSpacing: spacing,
25421
- });
25422
- }
25423
- else {
25424
- return rawTick;
25354
+ /**
25355
+ * Gets all tokens currently managed by the revenue manager contract
25356
+ * @dev Uses multicall to batch requests for better performance
25357
+ * @param sortByDesc - Optional boolean to sort tokens in descending order (default: false)
25358
+ * @returns Promise<Array<{flaunch: Address, tokenId: bigint}>> - Array of token objects containing flaunch address and token ID
25359
+ */
25360
+ async allTokensInManager(sortByDesc = false) {
25361
+ const count = await this.tokensCount();
25362
+ const multicall = new ReadMulticall(this.drift);
25363
+ let calldatas = Array.from({ length: Number(count) }, (_, i) => this.contract.encodeFunctionData("internalIds", {
25364
+ _internalId: BigInt(i + 1),
25365
+ }));
25366
+ // Reverse the array if sortByDesc is true
25367
+ if (sortByDesc) {
25368
+ calldatas = calldatas.reverse();
25425
25369
  }
25370
+ const result = await multicall.aggregate3(calldatas.map((calldata) => ({
25371
+ target: this.contract.address,
25372
+ callData: calldata,
25373
+ })));
25374
+ return result.map((r) => this.contract.decodeFunctionReturn("internalIds", r.returnData));
25426
25375
  }
25427
- };
25428
- /**
25429
- * Accurate liquidity calculation using proper Uniswap v3/v4 math
25430
- */
25431
- const getLiquidityFromAmounts = (params) => {
25432
- const sqrtRatioCurrentX96 = getSqrtPriceX96FromTick(params.currentTick);
25433
- let sqrtRatioAX96 = getSqrtPriceX96FromTick(params.tickLower);
25434
- let sqrtRatioBX96 = getSqrtPriceX96FromTick(params.tickUpper);
25435
- if (sqrtRatioAX96 > sqrtRatioBX96) {
25436
- [sqrtRatioAX96, sqrtRatioBX96] = [sqrtRatioBX96, sqrtRatioAX96];
25437
- }
25438
- if (sqrtRatioCurrentX96 <= sqrtRatioAX96) {
25439
- return maxLiquidityForAmount0Precise(sqrtRatioAX96, sqrtRatioBX96, params.amount0);
25440
- }
25441
- else if (sqrtRatioCurrentX96 < sqrtRatioBX96) {
25442
- const liquidity0 = maxLiquidityForAmount0Precise(sqrtRatioCurrentX96, sqrtRatioBX96, params.amount0);
25443
- const liquidity1 = maxLiquidityForAmount1(sqrtRatioAX96, sqrtRatioCurrentX96, params.amount1);
25444
- return liquidity0 < liquidity1 ? liquidity0 : liquidity1;
25376
+ }
25377
+ class ReadWriteRevenueManager extends ReadRevenueManager {
25378
+ constructor(address, drift = createDrift$1()) {
25379
+ super(address, drift);
25445
25380
  }
25446
- else {
25447
- return maxLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, params.amount1);
25381
+ /**
25382
+ * Allows the protocol recipient to claim the protocol's share of the revenue
25383
+ * @returns Promise<TransactionResponse> - The transaction response
25384
+ */
25385
+ protocolClaim() {
25386
+ return this.contract.write("claim", {});
25448
25387
  }
25449
- };
25450
- /**
25451
- * Returns a precise maximum amount of liquidity received for a given amount of token 0 by dividing by Q64 instead of Q96 in the intermediate step,
25452
- * and shifting the subtracted ratio left by 32 bits.
25453
- * @param sqrtRatioAX96 The price at the lower boundary
25454
- * @param sqrtRatioBX96 The price at the upper boundary
25455
- * @param amount0 The token0 amount
25456
- * @returns liquidity for amount0, precise
25457
- */
25458
- function maxLiquidityForAmount0Precise(sqrtRatioAX96, sqrtRatioBX96, amount0) {
25459
- if (sqrtRatioAX96 > sqrtRatioBX96) {
25460
- [sqrtRatioAX96, sqrtRatioBX96] = [sqrtRatioBX96, sqrtRatioAX96];
25388
+ /**
25389
+ * Allows the creator to claim their total share of the revenue from a revenue manager
25390
+ * @returns Promise<TransactionResponse> - The transaction response
25391
+ */
25392
+ creatorClaim() {
25393
+ return this.contract.write("claim", {});
25461
25394
  }
25462
- // Handle edge case where sqrt ratios are equal (division by zero)
25463
- if (sqrtRatioAX96 === sqrtRatioBX96) {
25464
- return 0n;
25395
+ /**
25396
+ * Allows the creator to claim their share of the revenue from specific flaunch tokens
25397
+ * @param flaunchTokens - The flaunch token ids to claim the revenue for
25398
+ * @returns Promise<TransactionResponse> - The transaction response
25399
+ */
25400
+ creatorClaimForTokens(flaunchTokens) {
25401
+ return this.contract.write("claim", {
25402
+ _flaunchToken: flaunchTokens,
25403
+ });
25465
25404
  }
25466
- const Q96 = 2n ** 96n;
25467
- const numerator = amount0 * sqrtRatioAX96 * sqrtRatioBX96;
25468
- const denominator = Q96 * (sqrtRatioBX96 - sqrtRatioAX96);
25469
- return numerator / denominator;
25470
25405
  }
25406
+
25407
+ const TreasuryManagerAbi = [
25408
+ {
25409
+ type: "function",
25410
+ name: "deposit",
25411
+ inputs: [
25412
+ {
25413
+ name: "_flaunchToken",
25414
+ type: "tuple",
25415
+ internalType: "struct ITreasuryManager.FlaunchToken",
25416
+ components: [
25417
+ {
25418
+ name: "flaunch",
25419
+ type: "address",
25420
+ internalType: "contract Flaunch",
25421
+ },
25422
+ { name: "tokenId", type: "uint256", internalType: "uint256" },
25423
+ ],
25424
+ },
25425
+ { name: "_creator", type: "address", internalType: "address" },
25426
+ { name: "_data", type: "bytes", internalType: "bytes" },
25427
+ ],
25428
+ outputs: [],
25429
+ stateMutability: "nonpayable",
25430
+ },
25431
+ {
25432
+ type: "function",
25433
+ name: "initialize",
25434
+ inputs: [
25435
+ { name: "_owner", type: "address", internalType: "address" },
25436
+ { name: "_data", type: "bytes", internalType: "bytes" },
25437
+ ],
25438
+ outputs: [],
25439
+ stateMutability: "nonpayable",
25440
+ },
25441
+ {
25442
+ type: "function",
25443
+ name: "managerOwner",
25444
+ inputs: [],
25445
+ outputs: [{ name: "", type: "address", internalType: "address" }],
25446
+ stateMutability: "view",
25447
+ },
25448
+ {
25449
+ type: "function",
25450
+ name: "permissions",
25451
+ inputs: [],
25452
+ outputs: [
25453
+ {
25454
+ name: "",
25455
+ type: "address",
25456
+ internalType: "contract IManagerPermissions",
25457
+ },
25458
+ ],
25459
+ stateMutability: "view",
25460
+ },
25461
+ {
25462
+ type: "function",
25463
+ name: "rescue",
25464
+ inputs: [
25465
+ {
25466
+ name: "_flaunchToken",
25467
+ type: "tuple",
25468
+ internalType: "struct ITreasuryManager.FlaunchToken",
25469
+ components: [
25470
+ {
25471
+ name: "flaunch",
25472
+ type: "address",
25473
+ internalType: "contract Flaunch",
25474
+ },
25475
+ { name: "tokenId", type: "uint256", internalType: "uint256" },
25476
+ ],
25477
+ },
25478
+ { name: "_recipient", type: "address", internalType: "address" },
25479
+ ],
25480
+ outputs: [],
25481
+ stateMutability: "nonpayable",
25482
+ },
25483
+ {
25484
+ type: "function",
25485
+ name: "setPermissions",
25486
+ inputs: [
25487
+ { name: "_permissions", type: "address", internalType: "address" },
25488
+ ],
25489
+ outputs: [],
25490
+ stateMutability: "nonpayable",
25491
+ },
25492
+ {
25493
+ type: "function",
25494
+ name: "transferManagerOwnership",
25495
+ inputs: [
25496
+ {
25497
+ name: "_newManagerOwner",
25498
+ type: "address",
25499
+ internalType: "address",
25500
+ },
25501
+ ],
25502
+ outputs: [],
25503
+ stateMutability: "nonpayable",
25504
+ },
25505
+ ];
25506
+
25471
25507
  /**
25472
- * Computes the maximum amount of liquidity received for a given amount of token1
25473
- * @param sqrtRatioAX96 The price at the lower tick boundary
25474
- * @param sqrtRatioBX96 The price at the upper tick boundary
25475
- * @param amount1 The token1 amount
25476
- * @returns liquidity for amount1
25508
+ * Client for interacting with the TreasuryManager contract in read-only mode
25509
+ * Provides methods to query permissions and manager owner
25477
25510
  */
25478
- function maxLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1) {
25479
- if (sqrtRatioAX96 > sqrtRatioBX96) {
25480
- [sqrtRatioAX96, sqrtRatioBX96] = [sqrtRatioBX96, sqrtRatioAX96];
25511
+ class ReadTreasuryManager {
25512
+ /**
25513
+ * Creates a new ReadTreasuryManager instance
25514
+ * @param address - The address of the TreasuryManager contract
25515
+ * @param drift - Optional drift instance for contract interactions (creates new instance if not provided)
25516
+ * @throws Error if address is not provided
25517
+ */
25518
+ constructor(address, drift = createDrift$1()) {
25519
+ if (!address) {
25520
+ throw new Error("Address is required");
25521
+ }
25522
+ this.contract = drift.contract({
25523
+ abi: TreasuryManagerAbi,
25524
+ address,
25525
+ });
25481
25526
  }
25482
- // Handle edge case where sqrt ratios are equal (division by zero)
25483
- if (sqrtRatioAX96 === sqrtRatioBX96) {
25484
- return 0n;
25527
+ /**
25528
+ * Gets the permissions contract address
25529
+ * @returns Promise<Address> - The address of the permissions contract
25530
+ */
25531
+ permissions() {
25532
+ return this.contract.read("permissions");
25533
+ }
25534
+ /**
25535
+ * Gets the manager owner address
25536
+ * @returns Promise<Address> - The address of the manager owner
25537
+ */
25538
+ managerOwner() {
25539
+ return this.contract.read("managerOwner");
25485
25540
  }
25486
- const Q96 = 2n ** 96n;
25487
- return (amount1 * Q96) / (sqrtRatioBX96 - sqrtRatioAX96);
25488
25541
  }
25489
25542
  /**
25490
- * Calculate the actual amounts needed for a given liquidity
25491
- * This prevents MaximumAmountExceeded errors by ensuring we provide sufficient maximums
25543
+ * Extended client for interacting with the TreasuryManager contract with write capabilities
25544
+ * Provides methods to deposit tokens, set permissions, and transfer ownership
25492
25545
  */
25493
- const getAmountsForLiquidity = (params) => {
25494
- // Handle zero liquidity case
25495
- if (params.liquidity === 0n) {
25496
- return { amount0: 0n, amount1: 0n };
25497
- }
25498
- const sqrtRatioCurrentX96 = getSqrtPriceX96FromTick(params.currentTick);
25499
- let sqrtRatioAX96 = getSqrtPriceX96FromTick(params.tickLower);
25500
- let sqrtRatioBX96 = getSqrtPriceX96FromTick(params.tickUpper);
25501
- if (sqrtRatioAX96 > sqrtRatioBX96) {
25502
- [sqrtRatioAX96, sqrtRatioBX96] = [sqrtRatioBX96, sqrtRatioAX96];
25546
+ class ReadWriteTreasuryManager extends ReadTreasuryManager {
25547
+ constructor(address, drift = createDrift$1()) {
25548
+ super(address, drift);
25503
25549
  }
25504
- let amount0 = 0n;
25505
- let amount1 = 0n;
25506
- if (sqrtRatioCurrentX96 <= sqrtRatioAX96) {
25507
- // Current price is below the range, only token0 needed
25508
- amount0 = getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, params.liquidity);
25550
+ /**
25551
+ * Deposits a flaunch token to the treasury
25552
+ * @param flaunchToken - The flaunch token to deposit
25553
+ * @param creator - The address of the creator
25554
+ * @param data - Additional data for the deposit
25555
+ * @returns Promise<void>
25556
+ */
25557
+ deposit(flaunchToken, creator, data) {
25558
+ return this.contract.write("deposit", {
25559
+ _flaunchToken: flaunchToken,
25560
+ _creator: creator,
25561
+ _data: data,
25562
+ });
25509
25563
  }
25510
- else if (sqrtRatioCurrentX96 < sqrtRatioBX96) {
25511
- // Current price is within the range, need both tokens
25512
- amount0 = getAmount0ForLiquidity(sqrtRatioCurrentX96, sqrtRatioBX96, params.liquidity);
25513
- amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioCurrentX96, params.liquidity);
25564
+ /**
25565
+ * Sets the permissions contract address
25566
+ * @param permissions - The address of the new permissions contract
25567
+ * @returns Promise<void>
25568
+ */
25569
+ setPermissions(permissions) {
25570
+ return this.contract.write("setPermissions", {
25571
+ _permissions: permissions,
25572
+ });
25514
25573
  }
25515
- else {
25516
- // Current price is above the range, only token1 needed
25517
- amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, params.liquidity);
25574
+ /**
25575
+ * Transfers the manager ownership to a new address
25576
+ * @param newManagerOwner - The address of the new manager owner
25577
+ * @returns Promise<void>
25578
+ */
25579
+ transferManagerOwnership(newManagerOwner) {
25580
+ return this.contract.write("transferManagerOwnership", {
25581
+ _newManagerOwner: newManagerOwner,
25582
+ });
25518
25583
  }
25519
- return { amount0, amount1 };
25520
- };
25584
+ }
25521
25585
 
25522
25586
  const chainIdToChain = {
25523
25587
  [base.id]: base,
@@ -27365,6 +27429,25 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
27365
27429
  const hash = await this.readWriteFlaunchZap.deployStakingManager(params);
27366
27430
  return await this.readWriteTreasuryManagerFactory.getManagerDeployedAddressFromTx(hash);
27367
27431
  }
27432
+ /**
27433
+ * Deploys a new BuyBack manager
27434
+ * @param params - Parameters for deploying the BuyBack manager
27435
+ * @param params.managerOwner - The address of the manager owner
27436
+ * @param params.creatorSharePercent - The % share that a creator will earn from their token (0-100)
27437
+ * @param params.ownerSharePercent - The % share that the manager owner will earn from their token (0-100)
27438
+ * @param params.buyBackPoolKey - The Uniswap V4 pool key configuration for the buyback pool
27439
+ * @param params.buyBackPoolKey.currency0 - The lower currency of the pool (sorted numerically)
27440
+ * @param params.buyBackPoolKey.currency1 - The higher currency of the pool (sorted numerically)
27441
+ * @param params.buyBackPoolKey.fee - The pool LP fee, capped at 1_000_000
27442
+ * @param params.buyBackPoolKey.tickSpacing - Tick spacing for the pool
27443
+ * @param params.buyBackPoolKey.hooks - The hooks address of the pool
27444
+ * @param params.permissions - The permissions for the BuyBack manager
27445
+ * @returns Address of the deployed BuyBack manager
27446
+ */
27447
+ async deployBuyBackManager(params) {
27448
+ const hash = await this.readWriteFlaunchZap.deployBuyBackManager(params);
27449
+ return await this.readWriteTreasuryManagerFactory.getManagerDeployedAddressFromTx(hash);
27450
+ }
27368
27451
  /**
27369
27452
  * Creates a new Flaunch on the specified version
27370
27453
  * @param params - Parameters for creating the Flaunch
@@ -31999,5 +32082,5 @@ const FlaunchSDK = {
31999
32082
  ReadWriteFlaunchSDK,
32000
32083
  };
32001
32084
 
32002
- export { AddressFeeSplitManagerAddress, AnyBidWallAddress, AnyFlaunchAddress, AnyPositionManagerAbi, AnyPositionManagerAddress, BidWallAddress, BidWallV1_1Abi, BidWallV1_1Address, BidwallAbi, ClankerWorldVerifierAddress, ClosedPermissionsAddress, DopplerVerifierAddress, FLETHAddress, FLETHHooksAddress, FairLaunchAbi, FairLaunchAddress, FairLaunchV1_1Abi, FairLaunchV1_1Address, FastFlaunchZapAbi, FastFlaunchZapAddress, FeeEscrowAbi, FeeEscrowAddress, FlaunchAbi, FlaunchAddress, FlaunchBackend, FlaunchPositionManagerAbi, FlaunchPositionManagerAddress, FlaunchPositionManagerV1_1Abi, FlaunchPositionManagerV1_1Address, FlaunchPositionManagerV1_2Address, FlaunchSDK, FlaunchV1_1Abi, FlaunchV1_1Address, FlaunchV1_2Address, FlaunchVersion, FlaunchZapAbi, FlaunchZapAddress, InitialPriceAbi, LiquidityMode, MemecoinAbi, MulticallAbi, PERMIT_DETAILS, PERMIT_TYPES, Permissions, Permit2Abi, Permit2Address, PoolManagerAbi, PoolManagerAddress, Q192, Q96, QuoterAbi, QuoterAddress, ReadFlaunchSDK, ReadWriteFlaunchSDK, ReferralEscrowAbi, ReferralEscrowAddress, RevenueManagerAbi, RevenueManagerAddress, StakingManagerAddress, StateViewAbi, StateViewAddress, TICK_SPACING, TickFinder, TokenImporterAddress, TreasuryManagerFactoryAbi, TreasuryManagerFactoryAddress, USDCETHPoolKeys, UniV4PositionManagerAddress, UniversalRouterAbi, UniversalRouterAddress, Verifier, VirtualsVerifierAddress, WhitelistVerifierAddress, WhitelistedPermissionsAddress, ZoraVerifierAddress, buyMemecoin, bytes32ToUint256, calculateUnderlyingTokenBalances, chainIdToChain, createCallDataWalletClient, createDrift, createFlaunch, createFlaunchCalldata, decodeCallData, encodedCallAbi, generateTokenUri, getAmountWithSlippage, getAmountsForLiquidity, getLiquidityFromAmounts, getNearestUsableTick, getPermissionsAddress, getPermit2TypedData, getPoolId, getSqrtPriceX96FromTick, getValidTick, maxLiquidityForAmount0Precise, maxLiquidityForAmount1, orderPoolKey, parseCall, parseSwapData, priceRatioToTick, resolveIPFS, sellMemecoinWithPermit2, uint256ToBytes32, uploadFileToIPFS, uploadImageToFlaunchAPI, uploadImageToIPFS, uploadJsonToIPFS, uploadMetadataToFlaunchAPI };
32085
+ export { AddressFeeSplitManagerAddress, AnyBidWallAddress, AnyFlaunchAddress, AnyPositionManagerAbi, AnyPositionManagerAddress, BidWallAddress, BidWallV1_1Abi, BidWallV1_1Address, BidwallAbi, BuyBackManagerAddress, ClankerWorldVerifierAddress, ClosedPermissionsAddress, DopplerVerifierAddress, FLETHAddress, FLETHHooksAddress, FairLaunchAbi, FairLaunchAddress, FairLaunchV1_1Abi, FairLaunchV1_1Address, FastFlaunchZapAbi, FastFlaunchZapAddress, FeeEscrowAbi, FeeEscrowAddress, FlaunchAbi, FlaunchAddress, FlaunchBackend, FlaunchPositionManagerAbi, FlaunchPositionManagerAddress, FlaunchPositionManagerV1_1Abi, FlaunchPositionManagerV1_1Address, FlaunchPositionManagerV1_2Address, FlaunchSDK, FlaunchV1_1Abi, FlaunchV1_1Address, FlaunchV1_2Address, FlaunchVersion, FlaunchZapAbi, FlaunchZapAddress, InitialPriceAbi, LiquidityMode, MemecoinAbi, MulticallAbi, PERMIT_DETAILS, PERMIT_TYPES, Permissions, Permit2Abi, Permit2Address, PoolManagerAbi, PoolManagerAddress, Q192, Q96, QuoterAbi, QuoterAddress, ReadFlaunchSDK, ReadWriteFlaunchSDK, ReferralEscrowAbi, ReferralEscrowAddress, RevenueManagerAbi, RevenueManagerAddress, StakingManagerAddress, StateViewAbi, StateViewAddress, TICK_SPACING, TickFinder, TokenImporterAddress, TreasuryManagerFactoryAbi, TreasuryManagerFactoryAddress, USDCETHPoolKeys, UniV4PositionManagerAddress, UniversalRouterAbi, UniversalRouterAddress, Verifier, VirtualsVerifierAddress, WhitelistVerifierAddress, WhitelistedPermissionsAddress, ZoraVerifierAddress, buyMemecoin, bytes32ToUint256, calculateUnderlyingTokenBalances, chainIdToChain, createCallDataWalletClient, createDrift, createFlaunch, createFlaunchCalldata, decodeCallData, encodedCallAbi, generateTokenUri, getAmountWithSlippage, getAmountsForLiquidity, getLiquidityFromAmounts, getNearestUsableTick, getPermissionsAddress, getPermit2TypedData, getPoolId, getSqrtPriceX96FromTick, getValidTick, maxLiquidityForAmount0Precise, maxLiquidityForAmount1, orderPoolKey, parseCall, parseSwapData, priceRatioToTick, resolveIPFS, sellMemecoinWithPermit2, uint256ToBytes32, uploadFileToIPFS, uploadImageToFlaunchAPI, uploadImageToIPFS, uploadJsonToIPFS, uploadMetadataToFlaunchAPI };
32003
32086
  //# sourceMappingURL=index.esm.js.map