From da0177f2cde20b37ced4542e0bbacfd2f03c8689 Mon Sep 17 00:00:00 2001 From: Anukul Pandey Date: Thu, 27 Nov 2025 19:38:18 +0530 Subject: [PATCH] feat: gate io price --- src/index.ts | 3 ++- src/routes/price.ts | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 45a365e..ae266eb 100755 --- a/src/index.ts +++ b/src/index.ts @@ -18,7 +18,7 @@ import { getProvider } from './utils/connector'; import { backtrackEvents } from './backtracking/backtracking'; import { sequelize } from './db/sequelize.db'; import { VerifiedContractMainnet, VerifiedContractTestnet } from './db/VerifiedContract.db'; -import { getReefPrice } from "./routes/price"; +import { getReefPrice, getReefPriceGateIo } from "./routes/price"; import { getVersion } from "./routes/version"; import { Umzug, SequelizeStorage } from "umzug"; import { trackFinalizedBlocks } from './services/finalized-blocks'; @@ -110,6 +110,7 @@ app.use('/magicsquare',magicSquareRouter) // }); app.get('/price/reef', getReefPrice); +app.get('/price/reef/gate-io', getReefPriceGateIo); app.get('/supply/reef', getReefSupply); app.get('/hc', getVersion); diff --git a/src/routes/price.ts b/src/routes/price.ts index 39f4bd3..90767fd 100644 --- a/src/routes/price.ts +++ b/src/routes/price.ts @@ -1,3 +1,4 @@ +import axios from "axios"; import {fetchReefPrice, Price} from "../services/utils"; import {NextFunction, Response} from 'express'; @@ -25,3 +26,22 @@ export const getReefPrice = async (_, res: Response, next: NextFunction) => { res.send({...currentPrice.price, timestamp: currentPrice.timestamp}); } + + +/** + * This function acts as a proxy to fetch the latest REEF price from Gate.io. + * It retrieves the REEF/USDT ticker data and returns it in JSON format. + */ +export const getReefPriceGateIo = async(_, res:Response) =>{ + try { + const { data } = await axios.get( + 'https://api.gateio.ws/api/v4/spot/tickers?currency_pair=REEF_USDT' + ) + res.setHeader('Content-Type', 'application/json') + res.end(JSON.stringify(data[0])) + } catch (err) { + console.error('Proxy error:', err.message) + res.statusCode = 500 + res.end(JSON.stringify({ error: 'Failed to fetch data from Gate.io' })) + } + } \ No newline at end of file