Skip to content

Commit

Permalink
chore: add pair url for api ticker coingecko (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
trungbach authored Feb 23, 2024
1 parent 39d9021 commit 9b23bf3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/oraidex-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import {
} from "./helper";
import { CACHE_KEY, cache, registerListener, updateInterval } from "./map-cache";
import { BigDecimal } from "@oraichain/oraidex-common/build/bigdecimal";
import { ORAIX_CONTRACT, USDC_CONTRACT } from "@oraichain/oraidex-common";
import { ORAIX_CONTRACT, USDC_CONTRACT, oraichainTokens } from "@oraichain/oraidex-common";

// cache

Expand Down Expand Up @@ -175,6 +175,12 @@ app.get("/tickers", async (req, res) => {
const targetInfo = parseAssetInfoOnlyDenom(pair.asset_infos[targetIndex]);
const volume = await duckDb.queryAllVolumeRange(baseInfo, targetInfo, then, latestTimestamp);
const liquidityInUsd = await getPairLiquidity(pairInfo);
const BASE_API_ORAIDEX_UNIVERSAL_SWAP_URL = "https://oraidex.io/universalswap";

const [from, to] = [
oraichainTokens.find((token) => token.contractAddress === baseInfo || token.denom === baseInfo),
oraichainTokens.find((token) => token.contractAddress === targetInfo || token.denom === targetInfo)
];

const tickerInfo: TickerInfo = {
ticker_id: tickerId,
Expand All @@ -186,7 +192,10 @@ app.get("/tickers", async (req, res) => {
pool_id: pairAddr ?? "",
base: symbols[baseIndex],
target: symbols[targetIndex],
liquidity_in_usd: new BigDecimal(liquidityInUsd).div(10 ** 6).toString()
liquidity_in_usd: new BigDecimal(liquidityInUsd).div(10 ** 6).toString(),
pair_url: `${BASE_API_ORAIDEX_UNIVERSAL_SWAP_URL}?from=${from ? from.denom : "orai"}&to=${
to ? to.denom : "usdt"
}`
};
data.push(tickerInfo);
}
Expand Down
1 change: 1 addition & 0 deletions packages/oraidex-sync/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export type TickerInfo = {
target: string;
pool_id: string;
liquidity_in_usd: string;
pair_url: string;
};

export type SummaryInfo = {
Expand Down

0 comments on commit 9b23bf3

Please sign in to comment.