punkkit-sdk 1.0.17 → 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 +26 -2
- package/dist/index.mjs +26 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35530,7 +35530,14 @@ function getAbi(artifact) {
|
|
|
35530
35530
|
return artifact.abi ? artifact.abi : artifact;
|
|
35531
35531
|
}
|
|
35532
35532
|
async function getContract(wallet, name) {
|
|
35533
|
-
|
|
35533
|
+
const address = CONTRACT_ADDRESSES[`${name}`];
|
|
35534
|
+
console.log(`[SDK] Getting contract ${name} at address: ${address}`);
|
|
35535
|
+
if (wallet.provider) {
|
|
35536
|
+
const code = await wallet.provider.getCode(address);
|
|
35537
|
+
if (code === "0x") {
|
|
35538
|
+
console.error(`[SDK] WARNING: Contract ${name} at ${address} has NO CODE (it is empty). Check your network connection or deployment.`);
|
|
35539
|
+
}
|
|
35540
|
+
}
|
|
35534
35541
|
switch (name) {
|
|
35535
35542
|
case "Token0":
|
|
35536
35543
|
return new ethers_exports.Contract(CONTRACT_ADDRESSES.Token0, getAbi(CONTRACTS_ABI.MockERC20), wallet);
|
|
@@ -38010,9 +38017,26 @@ async function addLiq(wallet, priceLower, priceUpper, amount02, amount12, poolKe
|
|
|
38010
38017
|
const token0 = await getContract(wallet, "Token0");
|
|
38011
38018
|
const token1 = await getContract(wallet, "Token1");
|
|
38012
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
|
+
}
|
|
38013
38027
|
const ticklow = calculateTickFromPriceWithSpacing(priceLower, poolKey.tickSpacing);
|
|
38014
38028
|
const tickhigh = calculateTickFromPriceWithSpacing(priceUpper, poolKey.tickSpacing);
|
|
38015
|
-
|
|
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
|
+
}
|
|
38016
38040
|
const [liqDelta, amount0Add, amount1Add] = calculateLiqDelta(ticklow, sqrtCurrent, tickhigh, amount02, amount12);
|
|
38017
38041
|
let modifyPositionParams = {
|
|
38018
38042
|
tickLower: ticklow,
|
package/dist/index.mjs
CHANGED
|
@@ -35534,7 +35534,14 @@ function getAbi(artifact) {
|
|
|
35534
35534
|
return artifact.abi ? artifact.abi : artifact;
|
|
35535
35535
|
}
|
|
35536
35536
|
async function getContract(wallet, name) {
|
|
35537
|
-
|
|
35537
|
+
const address = CONTRACT_ADDRESSES[`${name}`];
|
|
35538
|
+
console.log(`[SDK] Getting contract ${name} at address: ${address}`);
|
|
35539
|
+
if (wallet.provider) {
|
|
35540
|
+
const code = await wallet.provider.getCode(address);
|
|
35541
|
+
if (code === "0x") {
|
|
35542
|
+
console.error(`[SDK] WARNING: Contract ${name} at ${address} has NO CODE (it is empty). Check your network connection or deployment.`);
|
|
35543
|
+
}
|
|
35544
|
+
}
|
|
35538
35545
|
switch (name) {
|
|
35539
35546
|
case "Token0":
|
|
35540
35547
|
return new ethers_exports.Contract(CONTRACT_ADDRESSES.Token0, getAbi(CONTRACTS_ABI.MockERC20), wallet);
|
|
@@ -38013,9 +38020,26 @@ async function addLiq(wallet, priceLower, priceUpper, amount02, amount12, poolKe
|
|
|
38013
38020
|
const token0 = await getContract(wallet, "Token0");
|
|
38014
38021
|
const token1 = await getContract(wallet, "Token1");
|
|
38015
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
|
+
}
|
|
38016
38030
|
const ticklow = calculateTickFromPriceWithSpacing(priceLower, poolKey.tickSpacing);
|
|
38017
38031
|
const tickhigh = calculateTickFromPriceWithSpacing(priceUpper, poolKey.tickSpacing);
|
|
38018
|
-
|
|
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
|
+
}
|
|
38019
38043
|
const [liqDelta, amount0Add, amount1Add] = calculateLiqDelta(ticklow, sqrtCurrent, tickhigh, amount02, amount12);
|
|
38020
38044
|
let modifyPositionParams = {
|
|
38021
38045
|
tickLower: ticklow,
|