@flaunch/sdk 0.9.13 → 0.9.15
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/addresses/index.cjs +2 -2
- package/dist/addresses/index.js +2 -2
- package/dist/index.cjs.js +16 -9
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +16 -9
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +3 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/sdk/FlaunchSDK.d.ts.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -5762,8 +5762,8 @@ const TokenImporterAddress = {
|
|
|
5762
5762
|
[baseSepolia.id]: "0x7981369D21975F39773f289F759F7d7CE1097139",
|
|
5763
5763
|
};
|
|
5764
5764
|
const ClankerWorldVerifierAddress = {
|
|
5765
|
-
[base.id]: "
|
|
5766
|
-
[baseSepolia.id]: "
|
|
5765
|
+
[base.id]: "0xFe55dFf581b665479ABe9Fc0A0578FB222cB4Dda",
|
|
5766
|
+
[baseSepolia.id]: "0x2874F9A30348aCAaaD55D74B0BEc9C18f04b471a",
|
|
5767
5767
|
};
|
|
5768
5768
|
const DopplerVerifierAddress = {
|
|
5769
5769
|
[base.id]: "0xedd66b080b8e9425c39d349a3fb69f480580f993",
|
|
@@ -28793,7 +28793,8 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
|
|
|
28793
28793
|
const amount0 = poolKey.currency0 === coinAddress ? coinAmount : flethAmount;
|
|
28794
28794
|
const amount1 = poolKey.currency0 === coinAddress ? flethAmount : coinAmount;
|
|
28795
28795
|
// Calculate and constrain liquidity using shared method
|
|
28796
|
-
const
|
|
28796
|
+
const slippagePercent = params.slippagePercent;
|
|
28797
|
+
const { finalLiquidity, finalAmount0, finalAmount1 } = this.calculateConstrainedLiquidity(currentTick, tickLower, tickUpper, amount0, amount1, slippagePercent);
|
|
28797
28798
|
// 6. Add liquidity
|
|
28798
28799
|
calls.push(this.createLiquidityCall(poolKey, tickLower, tickUpper, finalLiquidity, finalAmount0, finalAmount1, userAddress));
|
|
28799
28800
|
return calls;
|
|
@@ -28850,8 +28851,9 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
|
|
|
28850
28851
|
currentTick = poolState.tick;
|
|
28851
28852
|
// If the current sqrtPriceX96 of the pool is zero, and the initial marketcap or price is provided,
|
|
28852
28853
|
// we can use this to determine the current tick.
|
|
28853
|
-
if (poolState.sqrtPriceX96 === 0n &&
|
|
28854
|
-
("
|
|
28854
|
+
if (poolState.sqrtPriceX96 === 0n &&
|
|
28855
|
+
(("initialMarketCapUSD" in params && params.initialMarketCapUSD) ||
|
|
28856
|
+
("initialPriceUSD" in params && params.initialPriceUSD))) {
|
|
28855
28857
|
let { decimals: coinDecimals, formattedTotalSupplyInDecimals } = await this.getCoinInfo(coinAddress);
|
|
28856
28858
|
// If we have a tokenSupply set, then overwrite the value
|
|
28857
28859
|
if ("tokenSupply" in params && params.tokenSupply !== undefined) {
|
|
@@ -28983,7 +28985,8 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
|
|
|
28983
28985
|
const amount0 = poolKey.currency0 === coinAddress ? coinAmount : flethAmount;
|
|
28984
28986
|
const amount1 = poolKey.currency0 === coinAddress ? flethAmount : coinAmount;
|
|
28985
28987
|
// Calculate and constrain liquidity using shared method
|
|
28986
|
-
const
|
|
28988
|
+
const slippagePercent = params.slippagePercent;
|
|
28989
|
+
const { finalLiquidity, finalAmount0, finalAmount1 } = this.calculateConstrainedLiquidity(currentTick, tickLower, tickUpper, amount0, amount1, slippagePercent);
|
|
28987
28990
|
// 3. Add liquidity
|
|
28988
28991
|
calls.push(this.createLiquidityCall(poolKey, tickLower, tickUpper, finalLiquidity, finalAmount0, finalAmount1, userAddress));
|
|
28989
28992
|
return calls;
|
|
@@ -29064,7 +29067,8 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
|
|
|
29064
29067
|
* @param amount1 - Amount of currency1
|
|
29065
29068
|
* @returns Final liquidity and amounts
|
|
29066
29069
|
*/
|
|
29067
|
-
calculateConstrainedLiquidity(currentTick, tickLower, tickUpper, amount0, amount1
|
|
29070
|
+
calculateConstrainedLiquidity(currentTick, tickLower, tickUpper, amount0, amount1, slippagePercent = 0.05 // Default to 0.05%
|
|
29071
|
+
) {
|
|
29068
29072
|
// Calculate liquidity first using user's input amounts
|
|
29069
29073
|
const initialLiquidity = getLiquidityFromAmounts({
|
|
29070
29074
|
currentTick,
|
|
@@ -29118,8 +29122,11 @@ class ReadWriteFlaunchSDK extends ReadFlaunchSDK {
|
|
|
29118
29122
|
finalAmount1 = constrainedAmounts.amount1;
|
|
29119
29123
|
}
|
|
29120
29124
|
// IMPORTANT: Add conservative buffer to account for contract rounding differences
|
|
29121
|
-
// Reduce liquidity by
|
|
29122
|
-
|
|
29125
|
+
// Reduce liquidity by slippagePercent to ensure contract calculations stay within user bounds
|
|
29126
|
+
// slippagePercent is passed as decimal percentage (e.g., 0.05 for 0.05%), convert to decimal
|
|
29127
|
+
const slippageAsDecimal = slippagePercent / 100;
|
|
29128
|
+
const slippageMultiplier = BigInt(Math.floor(1 / slippageAsDecimal));
|
|
29129
|
+
const liquidityBuffer = finalLiquidity / slippageMultiplier;
|
|
29123
29130
|
const conservativeLiquidity = finalLiquidity - (liquidityBuffer > 1n ? liquidityBuffer : 1n);
|
|
29124
29131
|
// Use conservative liquidity but keep user's original amounts as maximums
|
|
29125
29132
|
// The conservative liquidity ensures the contract won't need more than user provided
|