MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / getCryptoCryptoPrice

Method getCryptoCryptoPrice

rate/rate.ts:392–415  ·  view source on GitHub ↗
(crypto1: string, crypto2: string)

Source from the content-addressed store, hash-verified

390 const price = await this.fetchBinancePrice(`${crypto1}${crypto2}`);
391 return { price, lastUpdated: new Date() };
392 } catch {}
393
394 try {
395 const price = await this.fetchBinancePrice(`${crypto2}${crypto1}`);
396 return { price: 1 / price, lastUpdated: new Date() };
397 } catch {}
398
399 // 2. 通过稳定币桥接
400 const bridges = ['USDT', 'BUSD', 'USDC'];
401 for (const bridge of bridges) {
402 try {
403 const price1 = await this.fetchBinancePrice(`${crypto1}${bridge}`);
404 const price2 = await this.fetchBinancePrice(`${crypto2}${bridge}`);
405 return { price: price1 / price2, lastUpdated: new Date() };
406 } catch {}
407 }
408
409 throw new Error(`无法找到 ${crypto1} 和 ${crypto2} 之间的交易对`);
410 }
411
412 // 加密货币对法币
413 private async getCryptoFiatPrice(crypto: string, fiat: string): Promise<{ price: number, lastUpdated: Date }> {
414 const bridges = ['USDT', 'BUSD', 'USDC'];
415 let lastError: string = '';
416
417 for (const bridge of bridges) {
418 try {

Callers 1

getUniversalPriceMethod · 0.95

Calls 1

fetchBinancePriceMethod · 0.95

Tested by

no test coverage detected