@accret/api-client
Version:
A comprehensive SDK for blockchain data access via Moralis, Alchemy, and Shyft APIs
28 lines • 1.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getHistoricalPriceTokensAddress = getHistoricalPriceTokensAddress;
const constants_1 = require("../constants");
const config_1 = require("../config");
const supportedChain_1 = require("../utils/supportedChain");
/**
* Fetches the historical price data for a specific token address.
* @param tokenAddress - The address of the token to fetch historical price data for.
* @param network - The network the token is on.
* @param startTime - The start time for the historical price data.
* @param endTime - The end time for the historical price data.
* @param interval - The interval for the historical price data.
* @returns The historical price data for the specified token address.
*/
async function getHistoricalPriceTokensAddress(tokenAddress, network, startTime, endTime, interval) {
try {
const alchemy = (0, config_1.createAlchemyClient)(constants_1.API_KEYS.ALCHEMY_API_KEY, network);
const priceData = await alchemy.prices.getHistoricalPriceByAddress(network, tokenAddress, startTime, endTime, interval);
priceData.network = (0, supportedChain_1.getAccretSupportedChain)({ chain: network });
return priceData;
}
catch (error) {
console.error("Error fetching token price:", error);
throw error;
}
}
//# sourceMappingURL=historical-price-for-tokens.js.map