punkkit-sdk 1.0.18 → 1.0.19

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.js CHANGED
@@ -38017,9 +38017,26 @@ async function addLiq(wallet, priceLower, priceUpper, amount02, amount12, poolKe
38017
38017
  const token0 = await getContract(wallet, "Token0");
38018
38018
  const token1 = await getContract(wallet, "Token1");
38019
38019
  const liqPool = await getContract(wallet, "LiquidPool");
38020
+ console.log(`[SDK] Validating network and wallet...`);
38021
+ if (wallet.provider) {
38022
+ const net = await wallet.provider.getNetwork();
38023
+ console.log(`[SDK] Wallet connected to chainId: ${net.chainId}`);
38024
+ } else {
38025
+ console.warn(`[SDK] Wallet has no provider attached!`);
38026
+ }
38020
38027
  const ticklow = calculateTickFromPriceWithSpacing(priceLower, poolKey.tickSpacing);
38021
38028
  const tickhigh = calculateTickFromPriceWithSpacing(priceUpper, poolKey.tickSpacing);
38022
- const sqrtCurrent = await getPoolSqrtPrice(liqPool);
38029
+ let sqrtCurrent;
38030
+ try {
38031
+ console.log(`[SDK] Fetching sqrtPrice from LiquidPool (${liqPool.address})...`);
38032
+ sqrtCurrent = await getPoolSqrtPrice(liqPool);
38033
+ console.log(`[SDK] SqrtPrice fetched: ${sqrtCurrent}`);
38034
+ } catch (e) {
38035
+ console.error(`[SDK] Failed to fetch sqrtPrice. Attempting diagnosis...`);
38036
+ const code = await wallet.provider.getCode(liqPool.address);
38037
+ console.log(`[SDK] Code length at ${liqPool.address}: ${code.length}`);
38038
+ throw e;
38039
+ }
38023
38040
  const [liqDelta, amount0Add, amount1Add] = calculateLiqDelta(ticklow, sqrtCurrent, tickhigh, amount02, amount12);
38024
38041
  let modifyPositionParams = {
38025
38042
  tickLower: ticklow,
package/dist/index.mjs CHANGED
@@ -38020,9 +38020,26 @@ async function addLiq(wallet, priceLower, priceUpper, amount02, amount12, poolKe
38020
38020
  const token0 = await getContract(wallet, "Token0");
38021
38021
  const token1 = await getContract(wallet, "Token1");
38022
38022
  const liqPool = await getContract(wallet, "LiquidPool");
38023
+ console.log(`[SDK] Validating network and wallet...`);
38024
+ if (wallet.provider) {
38025
+ const net = await wallet.provider.getNetwork();
38026
+ console.log(`[SDK] Wallet connected to chainId: ${net.chainId}`);
38027
+ } else {
38028
+ console.warn(`[SDK] Wallet has no provider attached!`);
38029
+ }
38023
38030
  const ticklow = calculateTickFromPriceWithSpacing(priceLower, poolKey.tickSpacing);
38024
38031
  const tickhigh = calculateTickFromPriceWithSpacing(priceUpper, poolKey.tickSpacing);
38025
- const sqrtCurrent = await getPoolSqrtPrice(liqPool);
38032
+ let sqrtCurrent;
38033
+ try {
38034
+ console.log(`[SDK] Fetching sqrtPrice from LiquidPool (${liqPool.address})...`);
38035
+ sqrtCurrent = await getPoolSqrtPrice(liqPool);
38036
+ console.log(`[SDK] SqrtPrice fetched: ${sqrtCurrent}`);
38037
+ } catch (e) {
38038
+ console.error(`[SDK] Failed to fetch sqrtPrice. Attempting diagnosis...`);
38039
+ const code = await wallet.provider.getCode(liqPool.address);
38040
+ console.log(`[SDK] Code length at ${liqPool.address}: ${code.length}`);
38041
+ throw e;
38042
+ }
38026
38043
  const [liqDelta, amount0Add, amount1Add] = calculateLiqDelta(ticklow, sqrtCurrent, tickhigh, amount02, amount12);
38027
38044
  let modifyPositionParams = {
38028
38045
  tickLower: ticklow,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "punkkit-sdk",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "devDependencies": {
5
5
  "@nomicfoundation/hardhat-chai-matchers": "1.0.2",
6
6
  "@nomicfoundation/hardhat-network-helpers": "^1.1.2",