"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const abstractClient_1 = tslib_1.__importDefault(require("./abstractClient"));
const utils_1 = require("../utils");
class ProductionApiClient extends abstractClient_1.default {
    constructor(serverlessApiUrl, scraperApiUrl) {
        super(serverlessApiUrl, scraperApiUrl);
    }
    async getCoinGeckoData(l1Token, baseCurrency) {
        const result = await (0, utils_1.fetchWithTimeout)(`${this.getServerlessApiUrl()}/api/coingecko`, {
            l1Token,
            baseCurrency,
        });
        const price = baseCurrency === "usd" ? (0, utils_1.parseEther)(String(result.price)) : utils_1.BigNumber.from(result.price);
        return {
            price,
        };
    }
    async getSuggestedFees(amount, originToken, toChainid, fromChainid) {
        const result = await (0, utils_1.fetchWithTimeout)(`${this.getServerlessApiUrl()}/api/suggested-fees`, {
            token: originToken,
            destinationChainId: toChainid,
            originChainId: fromChainid,
            amount: amount.toString(),
            skipAmountLimit: true,
        });
        const relayFeePct = utils_1.BigNumber.from(result["relayFeePct"]);
        const relayFeeTotal = utils_1.BigNumber.from(result["relayFeeTotal"]);
        const capitalFeePct = utils_1.BigNumber.from(result["capitalFeePct"]);
        const capitalFeeTotal = utils_1.BigNumber.from(result["capitalFeeTotal"]);
        const relayGasFeePct = utils_1.BigNumber.from(result["relayGasFeePct"]);
        const relayGasFeeTotal = utils_1.BigNumber.from(result["relayGasFeeTotal"]);
        const isAmountTooLow = result["isAmountTooLow"];
        const quoteTimestamp = utils_1.BigNumber.from(result["timestamp"]);
        const quoteBlock = utils_1.BigNumber.from(result["quoteBlock"]);
        return {
            relayerFee: {
                pct: relayFeePct,
                total: relayFeeTotal,
            },
            relayerCapitalFee: {
                pct: capitalFeePct,
                total: capitalFeeTotal,
            },
            relayerGasFee: {
                pct: relayGasFeePct,
                total: relayGasFeeTotal,
            },
            isAmountTooLow,
            quoteTimestamp,
            quoteBlock,
        };
    }
    async getBridgeLimits(token, fromChainId, toChainId) {
        const data = await (0, utils_1.fetchWithTimeout)(`${this.getServerlessApiUrl()}/api/limits`, {
            token,
            originChainId: fromChainId,
            destinationChainId: toChainId,
        });
        return data;
    }
    async getAcrossStats() {
        const data = await (0, utils_1.fetchWithTimeout)(`${this.getScraperApiUrl()}/deposits/stats`);
        return data;
    }
}
exports.default = ProductionApiClient;
//# sourceMappingURL=productionClient.js.map