punkkit-sdk 1.0.18 → 1.0.20
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +21 -2
- package/dist/index.mjs +21 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -129,7 +129,7 @@ interface ModifyPositionParams {
|
|
|
129
129
|
salt?: string;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
declare function addLiq(wallet: Wallet, priceLower: number, priceUpper: number, amount0: bigint, amount1: bigint, poolKey: PoolKey): Promise<void>;
|
|
132
|
+
declare function addLiq(wallet: Wallet, priceLower: number, priceUpper: number, amount0: bigint | number, amount1: bigint | number, poolKey: PoolKey): Promise<void>;
|
|
133
133
|
|
|
134
134
|
declare function getContract(wallet: Wallet, name: string): Promise<Contract>;
|
|
135
135
|
|
package/dist/index.d.ts
CHANGED
|
@@ -129,7 +129,7 @@ interface ModifyPositionParams {
|
|
|
129
129
|
salt?: string;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
declare function addLiq(wallet: Wallet, priceLower: number, priceUpper: number, amount0: bigint, amount1: bigint, poolKey: PoolKey): Promise<void>;
|
|
132
|
+
declare function addLiq(wallet: Wallet, priceLower: number, priceUpper: number, amount0: bigint | number, amount1: bigint | number, poolKey: PoolKey): Promise<void>;
|
|
133
133
|
|
|
134
134
|
declare function getContract(wallet: Wallet, name: string): Promise<Contract>;
|
|
135
135
|
|
package/dist/index.js
CHANGED
|
@@ -38017,10 +38017,29 @@ 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
|
+
const amount0Big = BigInt(amount02);
|
|
38021
|
+
const amount1Big = BigInt(amount12);
|
|
38022
|
+
console.log(`[SDK] Validating network and wallet...`);
|
|
38023
|
+
if (wallet.provider) {
|
|
38024
|
+
const net = await wallet.provider.getNetwork();
|
|
38025
|
+
console.log(`[SDK] Wallet connected to chainId: ${net.chainId}`);
|
|
38026
|
+
} else {
|
|
38027
|
+
console.warn(`[SDK] Wallet has no provider attached!`);
|
|
38028
|
+
}
|
|
38020
38029
|
const ticklow = calculateTickFromPriceWithSpacing(priceLower, poolKey.tickSpacing);
|
|
38021
38030
|
const tickhigh = calculateTickFromPriceWithSpacing(priceUpper, poolKey.tickSpacing);
|
|
38022
|
-
|
|
38023
|
-
|
|
38031
|
+
let sqrtCurrent;
|
|
38032
|
+
try {
|
|
38033
|
+
console.log(`[SDK] Fetching sqrtPrice from LiquidPool (${liqPool.address})...`);
|
|
38034
|
+
sqrtCurrent = await getPoolSqrtPrice(liqPool);
|
|
38035
|
+
console.log(`[SDK] SqrtPrice fetched: ${sqrtCurrent}`);
|
|
38036
|
+
} catch (e) {
|
|
38037
|
+
console.error(`[SDK] Failed to fetch sqrtPrice. Attempting diagnosis...`);
|
|
38038
|
+
const code = await wallet.provider.getCode(liqPool.address);
|
|
38039
|
+
console.log(`[SDK] Code length at ${liqPool.address}: ${code.length}`);
|
|
38040
|
+
throw e;
|
|
38041
|
+
}
|
|
38042
|
+
const [liqDelta, amount0Add, amount1Add] = calculateLiqDelta(ticklow, sqrtCurrent, tickhigh, amount0Big, amount1Big);
|
|
38024
38043
|
let modifyPositionParams = {
|
|
38025
38044
|
tickLower: ticklow,
|
|
38026
38045
|
tickUpper: tickhigh,
|
package/dist/index.mjs
CHANGED
|
@@ -38020,10 +38020,29 @@ 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
|
+
const amount0Big = BigInt(amount02);
|
|
38024
|
+
const amount1Big = BigInt(amount12);
|
|
38025
|
+
console.log(`[SDK] Validating network and wallet...`);
|
|
38026
|
+
if (wallet.provider) {
|
|
38027
|
+
const net = await wallet.provider.getNetwork();
|
|
38028
|
+
console.log(`[SDK] Wallet connected to chainId: ${net.chainId}`);
|
|
38029
|
+
} else {
|
|
38030
|
+
console.warn(`[SDK] Wallet has no provider attached!`);
|
|
38031
|
+
}
|
|
38023
38032
|
const ticklow = calculateTickFromPriceWithSpacing(priceLower, poolKey.tickSpacing);
|
|
38024
38033
|
const tickhigh = calculateTickFromPriceWithSpacing(priceUpper, poolKey.tickSpacing);
|
|
38025
|
-
|
|
38026
|
-
|
|
38034
|
+
let sqrtCurrent;
|
|
38035
|
+
try {
|
|
38036
|
+
console.log(`[SDK] Fetching sqrtPrice from LiquidPool (${liqPool.address})...`);
|
|
38037
|
+
sqrtCurrent = await getPoolSqrtPrice(liqPool);
|
|
38038
|
+
console.log(`[SDK] SqrtPrice fetched: ${sqrtCurrent}`);
|
|
38039
|
+
} catch (e) {
|
|
38040
|
+
console.error(`[SDK] Failed to fetch sqrtPrice. Attempting diagnosis...`);
|
|
38041
|
+
const code = await wallet.provider.getCode(liqPool.address);
|
|
38042
|
+
console.log(`[SDK] Code length at ${liqPool.address}: ${code.length}`);
|
|
38043
|
+
throw e;
|
|
38044
|
+
}
|
|
38045
|
+
const [liqDelta, amount0Add, amount1Add] = calculateLiqDelta(ticklow, sqrtCurrent, tickhigh, amount0Big, amount1Big);
|
|
38027
38046
|
let modifyPositionParams = {
|
|
38028
38047
|
tickLower: ticklow,
|
|
38029
38048
|
tickUpper: tickhigh,
|