From d3012a69ebfd71143bf5a3b28f62230739cf1e75 Mon Sep 17 00:00:00 2001 From: vuonghuuhung Date: Wed, 27 Nov 2024 11:54:47 +0700 Subject: [PATCH 1/3] fix: logic check in range --- packages/oraiswap-v3/src/main.ts | 39 ++++++++++++------------ packages/oraiswap-v3/src/zap-consumer.ts | 2 +- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/packages/oraiswap-v3/src/main.ts b/packages/oraiswap-v3/src/main.ts index 501342e4..de6fd917 100644 --- a/packages/oraiswap-v3/src/main.ts +++ b/packages/oraiswap-v3/src/main.ts @@ -29,7 +29,7 @@ async function main() { }); const tokenIn = oraichainTokens.find((t) => t.name === "USDT") as TokenItemType; - const pool = `${OSMOSIS_ORAICHAIN_DENOM}-orai-${(0.3 / 100) * 10 ** 12}-100`; + const pool = `orai-orai12hzjxfh77wl572gdzct2fxv2arxcwh6gykc7qh-3000000000-100`; const poolKey = parsePoolKey(pool); // for (let i = 0; i < 10; i++) { @@ -42,25 +42,26 @@ async function main() { // console.log(getTickAtSqrtPrice(314557996917228655710133n, 10)); - // console.time("processZapInPositionLiquidity"); - // const res = await zapper.processZapInPositionLiquidity({ - // poolKey: poolKey, - // tokenIn: tokenIn as TokenItemType, - // amountIn: "1000000000", - // lowerTick: currentTick - tickSpacing * 1, - // upperTick: currentTick + tickSpacing * 1, - // tokenX: oraichainTokens.find((t) => extractAddress(t) === poolKey.token_x) as TokenItemType, - // tokenY: oraichainTokens.find((t) => extractAddress(t) === poolKey.token_y) as TokenItemType, - // }); - // console.timeEnd("processZapInPositionLiquidity"); - - const res = await zapper.processZapOutPositionLiquidity({ - owner: "orai1hvr9d72r5um9lvt0rpkd4r75vrsqtw6yujhqs2", - tokenId: 4275, - tokenOut: tokenIn, - zapFee: 0, + console.time("processZapInPositionLiquidity"); + const res = await zapper.processZapInPositionLiquidity({ + poolKey: poolKey, + tokenIn: tokenIn as TokenItemType, + amountIn: "1000000", + lowerTick: currentTick, + upperTick: currentTick + tickSpacing, + tokenX: oraichainTokens.find((t) => extractAddress(t) === poolKey.token_x) as TokenItemType, + tokenY: oraichainTokens.find((t) => extractAddress(t) === poolKey.token_y) as TokenItemType, }); - console.dir(res, { depth: null }); + console.log(res); + console.timeEnd("processZapInPositionLiquidity"); + + // const res = await zapper.processZapOutPositionLiquidity({ + // owner: "orai1hvr9d72r5um9lvt0rpkd4r75vrsqtw6yujhqs2", + // tokenId: 4275, + // tokenOut: tokenIn, + // zapFee: 0, + // }); + // console.dir(res, { depth: null }); // console.dir(res, { depth: null }); } diff --git a/packages/oraiswap-v3/src/zap-consumer.ts b/packages/oraiswap-v3/src/zap-consumer.ts index e29223b8..8a9a8edc 100644 --- a/packages/oraiswap-v3/src/zap-consumer.ts +++ b/packages/oraiswap-v3/src/zap-consumer.ts @@ -315,7 +315,7 @@ export class ZapConsumer { zapInResult.tickUpperIndex = upperTick; // if the position is out range, call @processZapInWithSingleSide - if (lowerTick >= pool.pool.current_tick_index || upperTick < pool.pool.current_tick_index) { + if (lowerTick > pool.pool.current_tick_index || upperTick <= pool.pool.current_tick_index) { console.log("Position is out of range"); const zapInSingleSideResult = await this.processZapInWithSingleSide({ poolKey: pool.pool_key, From 7fe27e907d99b3a425c80b2ea27c8f8ab040bdb3 Mon Sep 17 00:00:00 2001 From: vuonghuuhung Date: Wed, 27 Nov 2024 11:55:21 +0700 Subject: [PATCH 2/3] ignore main.ts change --- packages/oraiswap-v3/src/main.ts | 39 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/packages/oraiswap-v3/src/main.ts b/packages/oraiswap-v3/src/main.ts index de6fd917..501342e4 100644 --- a/packages/oraiswap-v3/src/main.ts +++ b/packages/oraiswap-v3/src/main.ts @@ -29,7 +29,7 @@ async function main() { }); const tokenIn = oraichainTokens.find((t) => t.name === "USDT") as TokenItemType; - const pool = `orai-orai12hzjxfh77wl572gdzct2fxv2arxcwh6gykc7qh-3000000000-100`; + const pool = `${OSMOSIS_ORAICHAIN_DENOM}-orai-${(0.3 / 100) * 10 ** 12}-100`; const poolKey = parsePoolKey(pool); // for (let i = 0; i < 10; i++) { @@ -42,26 +42,25 @@ async function main() { // console.log(getTickAtSqrtPrice(314557996917228655710133n, 10)); - console.time("processZapInPositionLiquidity"); - const res = await zapper.processZapInPositionLiquidity({ - poolKey: poolKey, - tokenIn: tokenIn as TokenItemType, - amountIn: "1000000", - lowerTick: currentTick, - upperTick: currentTick + tickSpacing, - tokenX: oraichainTokens.find((t) => extractAddress(t) === poolKey.token_x) as TokenItemType, - tokenY: oraichainTokens.find((t) => extractAddress(t) === poolKey.token_y) as TokenItemType, - }); - console.log(res); - console.timeEnd("processZapInPositionLiquidity"); - - // const res = await zapper.processZapOutPositionLiquidity({ - // owner: "orai1hvr9d72r5um9lvt0rpkd4r75vrsqtw6yujhqs2", - // tokenId: 4275, - // tokenOut: tokenIn, - // zapFee: 0, + // console.time("processZapInPositionLiquidity"); + // const res = await zapper.processZapInPositionLiquidity({ + // poolKey: poolKey, + // tokenIn: tokenIn as TokenItemType, + // amountIn: "1000000000", + // lowerTick: currentTick - tickSpacing * 1, + // upperTick: currentTick + tickSpacing * 1, + // tokenX: oraichainTokens.find((t) => extractAddress(t) === poolKey.token_x) as TokenItemType, + // tokenY: oraichainTokens.find((t) => extractAddress(t) === poolKey.token_y) as TokenItemType, // }); - // console.dir(res, { depth: null }); + // console.timeEnd("processZapInPositionLiquidity"); + + const res = await zapper.processZapOutPositionLiquidity({ + owner: "orai1hvr9d72r5um9lvt0rpkd4r75vrsqtw6yujhqs2", + tokenId: 4275, + tokenOut: tokenIn, + zapFee: 0, + }); + console.dir(res, { depth: null }); // console.dir(res, { depth: null }); } From 61431ea6ab68d08bacebe9d4fd170641d2e52dff Mon Sep 17 00:00:00 2001 From: vuonghuuhung Date: Wed, 27 Nov 2024 11:56:43 +0700 Subject: [PATCH 3/3] pump version --- packages/oraiswap-v3/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/oraiswap-v3/package.json b/packages/oraiswap-v3/package.json index 6b3b9841..ef5c4c6a 100644 --- a/packages/oraiswap-v3/package.json +++ b/packages/oraiswap-v3/package.json @@ -1,6 +1,6 @@ { "name": "@oraichain/oraiswap-v3", - "version": "1.1.1", + "version": "1.1.2", "main": "build/index.js", "files": [ "build/"