Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);

Expand Down
20 changes: 20 additions & 0 deletions src/routes/price.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import axios from "axios";
import {fetchReefPrice, Price} from "../services/utils";
import {NextFunction, Response} from 'express';

Expand Down Expand Up @@ -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' }))
}
}