diff --git a/packages/oraidex-server/package.json b/packages/oraidex-server/package.json index 15583525..6012970e 100644 --- a/packages/oraidex-server/package.json +++ b/packages/oraidex-server/package.json @@ -1,6 +1,6 @@ { "name": "@oraichain/oraidex-server", - "version": "1.0.17", + "version": "1.0.18", "main": "dist/index.js", "bin": "dist/index.js", "license": "MIT", diff --git a/packages/oraidex-server/package.staging.json b/packages/oraidex-server/package.staging.json index 6b00ad36..6101526c 100644 --- a/packages/oraidex-server/package.staging.json +++ b/packages/oraidex-server/package.staging.json @@ -1,6 +1,6 @@ { "name": "@oraichain/oraidex-server-staging", - "version": "1.0.16", + "version": "1.0.17", "main": "dist/index.js", "bin": "dist/index.js", "license": "MIT", diff --git a/packages/oraidex-sync/src/db.ts b/packages/oraidex-sync/src/db.ts index 8db2041c..f71fb55e 100644 --- a/packages/oraidex-sync/src/db.ts +++ b/packages/oraidex-sync/src/db.ts @@ -469,26 +469,6 @@ export class DuckDb { return BigInt(result[0]?.totalVolume ?? 0); } - async getVolumeLiquidity(payload: GetFeeSwap): Promise { - const { offerDenom, askDenom, startTime, endTime } = payload; - const result = await this.conn.all( - ` - SELECT - sum(baseTokenAmount) as totalVolume, - FROM lp_ops_data - WHERE timestamp >= ? - AND timestamp <= ? - AND baseTokenDenom = ? - AND quoteTokenDenom = ? - `, - startTime, - endTime, - offerDenom, - askDenom - ); - return BigInt(result[0]?.totalVolume ?? 0); - } - async createLpAmountHistoryTable() { await this.conn.exec( `CREATE TABLE IF NOT EXISTS lp_amount_history ( diff --git a/packages/oraidex-sync/src/helper.ts b/packages/oraidex-sync/src/helper.ts index e764a4b1..f620e29c 100644 --- a/packages/oraidex-sync/src/helper.ts +++ b/packages/oraidex-sync/src/helper.ts @@ -390,23 +390,14 @@ export const getVolumePairByAsset = async ( ): Promise => { const duckDb = DuckDb.instances; const pair = `${baseDenom}-${quoteDenom}`; - const [volumeSwapPairInBaseAsset, volumeLiquidityPairInBaseAsset] = await Promise.all([ - duckDb.getVolumeSwap({ - pair, - startTime: convertDateToSecond(startTime), - endTime: convertDateToSecond(endTime) - }), - duckDb.getVolumeLiquidity({ - offerDenom: baseDenom, - askDenom: quoteDenom, - startTime: convertDateToSecond(startTime), - endTime: convertDateToSecond(endTime) - }) - ]); - // sum of base & quote asset volume. - const totalVolumeLiquidityPair = volumeLiquidityPairInBaseAsset * 2n; - return volumeSwapPairInBaseAsset + totalVolumeLiquidityPair; + const volumeSwapPairInBaseAsset = await duckDb.getVolumeSwap({ + pair, + startTime: convertDateToSecond(startTime), + endTime: convertDateToSecond(endTime) + }); + + return volumeSwapPairInBaseAsset; }; export const getVolumePairByUsdt = async ( diff --git a/packages/oraidex-sync/tests/db.spec.ts b/packages/oraidex-sync/tests/db.spec.ts index 2499969b..47b29422 100644 --- a/packages/oraidex-sync/tests/db.spec.ts +++ b/packages/oraidex-sync/tests/db.spec.ts @@ -413,20 +413,6 @@ describe("test-duckdb", () => { // assertion expect(feeSwap).toEqual(3n); }); - - it("test-getVolumeLiquidity-should-return-correctly-volume-liquidity-in-base-asset", async () => { - // act - const payload: GetFeeSwap = { - offerDenom: "orai", - askDenom: "atom", - startTime: 1589610068000 / 1000, - endTime: 1689610068000 / 1000 - }; - const volumeByBaseAsset = await duckDb.getVolumeLiquidity(payload); - - // assertion - expect(volumeByBaseAsset).toEqual(2n); - }); }); describe("test-apr", () => { diff --git a/packages/oraidex-sync/tests/helper.spec.ts b/packages/oraidex-sync/tests/helper.spec.ts index 71f6bb9c..88772590 100644 --- a/packages/oraidex-sync/tests/helper.spec.ts +++ b/packages/oraidex-sync/tests/helper.spec.ts @@ -723,13 +723,12 @@ describe("test-helper", () => { it("test-getVolumePairByAsset-should-return-correctly-sum-volume-swap-&-liquidity", async () => { // setup mock jest.spyOn(duckDb, "getVolumeSwap").mockResolvedValue(1n); - jest.spyOn(duckDb, "getVolumeLiquidity").mockResolvedValue(1n); // act const result = await getVolumePairByAsset(["orai", "usdt"], new Date(1693394183), new Date(1693394183)); // assert - expect(result).toEqual(3n); + expect(result).toEqual(1n); }); it("test-getVolumePairByUsdt-should-return-correctly-volume-pair-in-USDT", async () => {