"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Allora = void 0;
const allora_sdk_1 = require("@alloralabs/allora-sdk");
const logger_1 = require("../logger/logger");
class Allora {
    constructor() {
        this.alloraClient = new allora_sdk_1.AlloraAPIClient({
            chainSlug: allora_sdk_1.ChainSlug.MAINNET,
            // apiKey: 'YOUR_API_KEY', // Have to ask on discord for API key
        });
    }
    async getPricePrediction(asset, timeframe) {
        logger_1.logger.info(`Fetching price prediction for asset: ${asset}, timeframe: ${timeframe}`);
        try {
            // Map asset and timeframe to SDK enums
            const assetEnum = allora_sdk_1.PriceInferenceToken[asset.toUpperCase()];
            const timeframeEnum = allora_sdk_1.PriceInferenceTimeframe[timeframe.toUpperCase().replace('-', '_')];
            if (!assetEnum || !timeframeEnum) {
                logger_1.logger.error('Invalid asset or timeframe provided.');
                throw new Error('Invalid asset or timeframe.');
            }
            // Fetch price inference
            const inference = await this.alloraClient.getPriceInference(assetEnum, timeframeEnum);
            logger_1.logger.info(`Found price prediction for asset: ${asset}`);
            logger_1.logger.info(inference);
            // Return the predicted price
            return inference.inference_data;
        }
        catch (error) {
            logger_1.logger.error(error);
            console.error('Error fetching price prediction:', error);
            return "Error fetching price prediction";
        }
    }
}
exports.Allora = Allora;
