Skip to content

Commit

Permalink
fix: filter chart kwt-orai & liquidity oraix/usdc (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
trungbach authored Mar 7, 2024
1 parent 7f4b267 commit 7322f7e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
18 changes: 17 additions & 1 deletion packages/oraidex-server/src/db-query.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { BigDecimal, CW20_DECIMALS, oraichainTokens, parseTokenInfoRawDenom } from "@oraichain/oraidex-common";
import {
BigDecimal,
CW20_DECIMALS,
KWT_CONTRACT,
ORAI,
oraichainTokens,
parseTokenInfoRawDenom
} from "@oraichain/oraidex-common";
import { DuckDb, PoolAmountHistory, SwapOperationData, parseAssetInfoOnlyDenom } from "@oraichain/oraidex-sync";
import { ARRANGED_PAIRS_CHART, AllPairsInfo, getAssetInfosFromPairString } from "./helper";
import "./polyfill";
Expand Down Expand Up @@ -169,6 +176,15 @@ export class DbQuery {
value: liquidityInUsdt
});
}
const KWT_ORAI_PAIR = `${KWT_CONTRACT}-${ORAI}`;

// TODO: current harcode filter data for kwt-orai pair
if (pair === KWT_ORAI_PAIR)
return liquiditiesAvg.filter((item) => {
const itemTime = item?.time ? new Date(item.time) : null;
return itemTime && itemTime.getDate() > 1 && itemTime.getMonth() > 1 && itemTime.getFullYear() > 2023;
});

return liquiditiesAvg;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/oraidex-server/src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export type AllPairsInfo = {
symbols: [string, string];
factoryV1?: boolean;
};
export const ARRANGED_PAIRS_CHART: AllPairsInfo[] = ARRANGED_PAIRS.map((pair) => {
export const ARRANGED_PAIRS_CHART: AllPairsInfo[] = PAIRS.map((pair) => {
const assets = pair.asset_infos.map(parseAssetInfoOnlyDenom);
return {
...pair,
Expand Down
17 changes: 9 additions & 8 deletions packages/oraidex-server/tests/db-query.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe("test-db-query", () => {
])("test-getSwapVolumeAllPair", async (type, expectedResult) => {
// setup
const PAIR_ORAIX_USDC =
"orai1lus0f0rhx8s03gdllx2n6vhkmf0536dv57wfge-orai15un8msx3n5zf9ahlxmfeqd2kwa5wm0nrpxer304m9nd5q6qq0g6sku5pdd";
"orai15un8msx3n5zf9ahlxmfeqd2kwa5wm0nrpxer304m9nd5q6qq0g6sku5pdd-orai1lus0f0rhx8s03gdllx2n6vhkmf0536dv57wfge";
const PAIR_ORAI_USDT = "orai-orai12hzjxfh77wl572gdzct2fxv2arxcwh6gykc7qh";
const duckdb = await DuckDb.create(":memory:");
const dbQuery = new DbQuery(duckdb);
Expand Down Expand Up @@ -324,8 +324,8 @@ describe("test-db-query", () => {
toIconUrl: "1"
},
{
firstAssetInfo: JSON.stringify({ token: { contract_addr: ORAIX_CONTRACT } }),
secondAssetInfo: JSON.stringify({ token: { contract_addr: USDC_CONTRACT } }),
firstAssetInfo: JSON.stringify({ token: { contract_addr: USDC_CONTRACT } }),
secondAssetInfo: JSON.stringify({ token: { contract_addr: ORAIX_CONTRACT } }),
commissionRate: "1",
pairAddr: pairAddrOraixUsdc,
liquidityAddr: "2",
Expand All @@ -339,7 +339,8 @@ describe("test-db-query", () => {
// mock price orai = 1 usdt
const coingeckoPrices = {
"oraichain-token": 1,
oraidex: 1
oraidex: 1,
"usd-coin": 1
};
cache.set(CACHE_KEY.COINGECKO_PRICES, coingeckoPrices);

Expand All @@ -351,10 +352,10 @@ describe("test-db-query", () => {
symbols: ["ORAI", "USDT"]
},
{
symbol: "oraix/usdc",
info: `${ORAIX_CONTRACT}-${USDC_CONTRACT}`,
asset_infos: [ORAIX_INFO, USDC_INFO],
symbols: ["ORAIX", "USDC"]
symbol: "usdc/oraix",
info: `${USDC_CONTRACT}-${ORAIX_CONTRACT}`,
asset_infos: [USDC_INFO, ORAIX_INFO],
symbols: ["USDC", "ORAIX"]
}
];

Expand Down
8 changes: 4 additions & 4 deletions packages/oraidex-server/tests/helper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ describe("test-helper", () => {
"orai15un8msx3n5zf9ahlxmfeqd2kwa5wm0nrpxer304m9nd5q6qq0g6sku5pdd-orai1lus0f0rhx8s03gdllx2n6vhkmf0536dv57wfge",
[
{
token: { contract_addr: "orai1lus0f0rhx8s03gdllx2n6vhkmf0536dv57wfge" }
token: { contract_addr: "orai15un8msx3n5zf9ahlxmfeqd2kwa5wm0nrpxer304m9nd5q6qq0g6sku5pdd" }
},
{
token: { contract_addr: "orai15un8msx3n5zf9ahlxmfeqd2kwa5wm0nrpxer304m9nd5q6qq0g6sku5pdd" }
token: { contract_addr: "orai1lus0f0rhx8s03gdllx2n6vhkmf0536dv57wfge" }
}
]
],
[
"orai1lus0f0rhx8s03gdllx2n6vhkmf0536dv57wfge-orai15un8msx3n5zf9ahlxmfeqd2kwa5wm0nrpxer304m9nd5q6qq0g6sku5pdd",
[
{
token: { contract_addr: "orai1lus0f0rhx8s03gdllx2n6vhkmf0536dv57wfge" }
token: { contract_addr: "orai15un8msx3n5zf9ahlxmfeqd2kwa5wm0nrpxer304m9nd5q6qq0g6sku5pdd" }
},
{
token: { contract_addr: "orai15un8msx3n5zf9ahlxmfeqd2kwa5wm0nrpxer304m9nd5q6qq0g6sku5pdd" }
token: { contract_addr: "orai1lus0f0rhx8s03gdllx2n6vhkmf0536dv57wfge" }
}
]
]
Expand Down
2 changes: 1 addition & 1 deletion packages/oraidex-sync/src/query.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fromBinary, toBinary } from "@cosmjs/cosmwasm-stargate";
import { Addr, MulticallQueryClient, MulticallReadOnlyInterface } from "@oraichain/common-contracts-sdk";
import { Addr, MulticallQueryClient } from "@oraichain/common-contracts-sdk";
import { Call } from "@oraichain/common-contracts-sdk/build/Multicall.types";
import {
AssetInfo,
Expand Down

0 comments on commit 7322f7e

Please sign in to comment.