punkkit-sdk 1.0.25 → 1.0.26

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
@@ -36119,6 +36119,64 @@ var init_contract = __esm({
36119
36119
  }
36120
36120
  });
36121
36121
 
36122
+ // src/uniswap/1-marketprice/removeLiquidity.ts
36123
+ var require_removeLiquidity = __commonJS({
36124
+ "src/uniswap/1-marketprice/removeLiquidity.ts"(exports2, module2) {
36125
+ "use strict";
36126
+ init_lib49();
36127
+ init_uniswap_config();
36128
+ init_pool();
36129
+ init_ERC20();
36130
+ init_liqCalculation();
36131
+ init_contract();
36132
+ async function removeLiq(wallet2, priceLower, priceUpper, amount02, amount12, poolKey) {
36133
+ const ticklow = calculateTickFromPriceWithSpacing(priceLower, poolKey.tickSpacing);
36134
+ const tickhigh = calculateTickFromPriceWithSpacing(priceUpper, poolKey.tickSpacing);
36135
+ const liqPool = await getContract(wallet2, "LiquidPool");
36136
+ const sqrtCurrent = await getPoolSqrtPrice(liqPool);
36137
+ const [liqDelta, amount0Rmv, amount1Rmv] = calculateLiqDelta(ticklow, sqrtCurrent, tickhigh, amount02, amount12);
36138
+ console.log(`Attempting to remove liquidity ${liqDelta} to price range [${priceLower}, ${priceUpper}] with amount0[${amount0Rmv.toString()}], amount1[${amount1Rmv.toString()}]`);
36139
+ const modifyPositionParams = {
36140
+ tickLower: ticklow,
36141
+ tickUpper: tickhigh,
36142
+ liquidityDelta: liqDelta * BigInt(-1)
36143
+ };
36144
+ await modifyPosition(liqPool, modifyPositionParams, "0x00");
36145
+ }
36146
+ async function main3() {
36147
+ const provider2 = new lib_exports3.JsonRpcProvider(RPC_URL);
36148
+ const wallet2 = new Wallet(PRIVATE_KEY, provider2);
36149
+ const liqPoolAddress = CONTRACT_ADDRESSES.LiquidPool;
36150
+ const token0 = await getContract(wallet2, "Token0");
36151
+ const token1 = await getContract(wallet2, "Token1");
36152
+ const liqPool = await getContract(wallet2, "LiquidPool");
36153
+ let poolPrice = await getPoolPrice(liqPool);
36154
+ console.log(`Current price of pool ${liqPool.address} before removing liquidity is ${poolPrice}`);
36155
+ const token0Before = await getERC20Balance(token0, wallet2.address);
36156
+ const token1Before = await getERC20Balance(token1, wallet2.address);
36157
+ console.log("Token0 balance before removing liquidity:", token0Before.toString());
36158
+ console.log("Token1 balance before removing liquidity:", token1Before.toString());
36159
+ const priceLower = 0.5;
36160
+ const priceUpper = 1.5;
36161
+ const amount02 = 100n;
36162
+ const amount12 = 100n;
36163
+ await removeLiq(wallet2, priceLower, priceUpper, amount02, amount12, POOL_KEYS.limitOrderPoolKey);
36164
+ poolPrice = await getPoolPrice(liqPool);
36165
+ console.log(`Current price of pool ${liqPool.address} after removing liquidity is ${poolPrice}`);
36166
+ const token0After = await getERC20Balance(token0, wallet2.address);
36167
+ const token1After = await getERC20Balance(token1, wallet2.address);
36168
+ console.log("Token0 change:", token0After - token0Before);
36169
+ console.log("Token1 change:", token1After - token1Before);
36170
+ }
36171
+ if (typeof require !== "undefined" && typeof module2 !== "undefined" && require.main === module2) {
36172
+ main3().catch((error) => {
36173
+ console.error(error);
36174
+ process.exit(1);
36175
+ });
36176
+ }
36177
+ }
36178
+ });
36179
+
36122
36180
  // src/uniswap/2-limitorder/place.ts
36123
36181
  var require_place = __commonJS({
36124
36182
  "src/uniswap/2-limitorder/place.ts"(exports2, module2) {
@@ -38582,13 +38640,6 @@ async function addLiq(wallet2, priceLower, priceUpper, amount02, amount12, poolK
38582
38640
  const liqPool = await getContract(wallet2, "LiquidPool");
38583
38641
  const amount0Big = BigInt(amount02);
38584
38642
  const amount1Big = BigInt(amount12);
38585
- console.log(`[SDK] Validating network and wallet...`);
38586
- if (wallet2.provider) {
38587
- const net = await wallet2.provider.getNetwork();
38588
- console.log(`[SDK] Wallet connected to chainId: ${net.chainId}`);
38589
- } else {
38590
- console.warn(`[SDK] Wallet has no provider attached!`);
38591
- }
38592
38643
  const ticklow = calculateTickFromPriceWithSpacing(priceLower, poolKey.tickSpacing);
38593
38644
  const tickhigh = calculateTickFromPriceWithSpacing(priceUpper, poolKey.tickSpacing);
38594
38645
  let sqrtCurrent;
@@ -38648,6 +38699,9 @@ if (typeof require !== "undefined" && typeof module !== "undefined" && require.m
38648
38699
  });
38649
38700
  }
38650
38701
 
38702
+ // src/index.ts
38703
+ __reExport(index_exports, __toESM(require_removeLiquidity()), module.exports);
38704
+
38651
38705
  // src/uniswap/1-marketprice/getPositions.ts
38652
38706
  init_contract();
38653
38707
  async function getUserPositions(wallet2, userAddress) {
package/dist/index.mjs CHANGED
@@ -36123,6 +36123,64 @@ var init_contract = __esm({
36123
36123
  }
36124
36124
  });
36125
36125
 
36126
+ // src/uniswap/1-marketprice/removeLiquidity.ts
36127
+ var require_removeLiquidity = __commonJS({
36128
+ "src/uniswap/1-marketprice/removeLiquidity.ts"(exports, module2) {
36129
+ "use strict";
36130
+ init_lib49();
36131
+ init_uniswap_config();
36132
+ init_pool();
36133
+ init_ERC20();
36134
+ init_liqCalculation();
36135
+ init_contract();
36136
+ async function removeLiq(wallet2, priceLower, priceUpper, amount02, amount12, poolKey) {
36137
+ const ticklow = calculateTickFromPriceWithSpacing(priceLower, poolKey.tickSpacing);
36138
+ const tickhigh = calculateTickFromPriceWithSpacing(priceUpper, poolKey.tickSpacing);
36139
+ const liqPool = await getContract(wallet2, "LiquidPool");
36140
+ const sqrtCurrent = await getPoolSqrtPrice(liqPool);
36141
+ const [liqDelta, amount0Rmv, amount1Rmv] = calculateLiqDelta(ticklow, sqrtCurrent, tickhigh, amount02, amount12);
36142
+ console.log(`Attempting to remove liquidity ${liqDelta} to price range [${priceLower}, ${priceUpper}] with amount0[${amount0Rmv.toString()}], amount1[${amount1Rmv.toString()}]`);
36143
+ const modifyPositionParams = {
36144
+ tickLower: ticklow,
36145
+ tickUpper: tickhigh,
36146
+ liquidityDelta: liqDelta * BigInt(-1)
36147
+ };
36148
+ await modifyPosition(liqPool, modifyPositionParams, "0x00");
36149
+ }
36150
+ async function main3() {
36151
+ const provider2 = new lib_exports3.JsonRpcProvider(RPC_URL);
36152
+ const wallet2 = new Wallet(PRIVATE_KEY, provider2);
36153
+ const liqPoolAddress = CONTRACT_ADDRESSES.LiquidPool;
36154
+ const token0 = await getContract(wallet2, "Token0");
36155
+ const token1 = await getContract(wallet2, "Token1");
36156
+ const liqPool = await getContract(wallet2, "LiquidPool");
36157
+ let poolPrice = await getPoolPrice(liqPool);
36158
+ console.log(`Current price of pool ${liqPool.address} before removing liquidity is ${poolPrice}`);
36159
+ const token0Before = await getERC20Balance(token0, wallet2.address);
36160
+ const token1Before = await getERC20Balance(token1, wallet2.address);
36161
+ console.log("Token0 balance before removing liquidity:", token0Before.toString());
36162
+ console.log("Token1 balance before removing liquidity:", token1Before.toString());
36163
+ const priceLower = 0.5;
36164
+ const priceUpper = 1.5;
36165
+ const amount02 = 100n;
36166
+ const amount12 = 100n;
36167
+ await removeLiq(wallet2, priceLower, priceUpper, amount02, amount12, POOL_KEYS.limitOrderPoolKey);
36168
+ poolPrice = await getPoolPrice(liqPool);
36169
+ console.log(`Current price of pool ${liqPool.address} after removing liquidity is ${poolPrice}`);
36170
+ const token0After = await getERC20Balance(token0, wallet2.address);
36171
+ const token1After = await getERC20Balance(token1, wallet2.address);
36172
+ console.log("Token0 change:", token0After - token0Before);
36173
+ console.log("Token1 change:", token1After - token1Before);
36174
+ }
36175
+ if (typeof __require !== "undefined" && typeof module2 !== "undefined" && __require.main === module2) {
36176
+ main3().catch((error) => {
36177
+ console.error(error);
36178
+ process.exit(1);
36179
+ });
36180
+ }
36181
+ }
36182
+ });
36183
+
36126
36184
  // src/uniswap/2-limitorder/place.ts
36127
36185
  var require_place = __commonJS({
36128
36186
  "src/uniswap/2-limitorder/place.ts"(exports, module2) {
@@ -38585,13 +38643,6 @@ async function addLiq(wallet2, priceLower, priceUpper, amount02, amount12, poolK
38585
38643
  const liqPool = await getContract(wallet2, "LiquidPool");
38586
38644
  const amount0Big = BigInt(amount02);
38587
38645
  const amount1Big = BigInt(amount12);
38588
- console.log(`[SDK] Validating network and wallet...`);
38589
- if (wallet2.provider) {
38590
- const net = await wallet2.provider.getNetwork();
38591
- console.log(`[SDK] Wallet connected to chainId: ${net.chainId}`);
38592
- } else {
38593
- console.warn(`[SDK] Wallet has no provider attached!`);
38594
- }
38595
38646
  const ticklow = calculateTickFromPriceWithSpacing(priceLower, poolKey.tickSpacing);
38596
38647
  const tickhigh = calculateTickFromPriceWithSpacing(priceUpper, poolKey.tickSpacing);
38597
38648
  let sqrtCurrent;
@@ -38651,6 +38702,9 @@ if (typeof __require !== "undefined" && typeof module !== "undefined" && __requi
38651
38702
  });
38652
38703
  }
38653
38704
 
38705
+ // src/index.ts
38706
+ __reExport(index_exports, __toESM(require_removeLiquidity()));
38707
+
38654
38708
  // src/uniswap/1-marketprice/getPositions.ts
38655
38709
  init_contract();
38656
38710
  async function getUserPositions(wallet2, userAddress) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "punkkit-sdk",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "devDependencies": {
5
5
  "@nomicfoundation/hardhat-chai-matchers": "1.0.2",
6
6
  "@nomicfoundation/hardhat-network-helpers": "^1.1.2",