Viewing File: /home/ubuntu/efiexchange-node-base/src/controllers/exchange/index.ts
import { startPollingExchangeRate } from "./providers/bvnk";
import { subscribeToExchangeRate } from "./functions/providerSelector";
import { getAllOKXSymbols } from "./providers/okx";
import { getAllSymbols } from "./functions/providerSymbols";
export const fetchOTCExchangeRate = async (
fromCurrency: string,
toCurrency: string,
user_id: string,
socket: any,
type: string,
currency_pair_id: string,
user_configuration: any,
) => {
try {
const isFiat = (curr: string) => ["USD", "EUR"].includes(curr);
const isToken = (curr: string) => ["USDT", "USDC"].includes(curr);
const bvnkCase =
(((isFiat(fromCurrency) && isToken(toCurrency)) ||
(isFiat(toCurrency) && isToken(fromCurrency))) &&
(user_configuration?.token_to_eur === "bvnk" ||
isFiat(fromCurrency) ||
isFiat(toCurrency))) ||
(isFiat(fromCurrency) && isFiat(toCurrency));
if (bvnkCase) {
await startPollingExchangeRate(fromCurrency, toCurrency, user_id, socket, type, currency_pair_id);
} else {
subscribeToExchangeRate(fromCurrency, toCurrency, user_id, socket, type, currency_pair_id);
}
} catch (error: any) {
console.log(`❌ Error for ${fromCurrency}-${toCurrency}`, error.message);
}
};
export async function getSymbolsList(req: any, res: any) {
try {
let okxsymbols = getAllOKXSymbols();
let binanceSymbols = getAllSymbols();
let responseData = {
okx: Array.from(okxsymbols).join(", "),
binance: Array.from(binanceSymbols).join(", "),
};
return res.sendResponse(responseData, "Symbols Fetched Succesfully");
} catch (error) {
return res.sendError(`Error: ${error.message}`);
}
}
Back to Directory
File Manager