"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var axios_1 = tslib_1.__importDefault(require("axios"));
var abstractClient_1 = tslib_1.__importDefault(require("./abstractClient"));
var utils_1 = require("../utils");
var ProductionApiClient = (function (_super) {
    tslib_1.__extends(ProductionApiClient, _super);
    function ProductionApiClient(serverlessApiUrl, scraperApiUrl) {
        return _super.call(this, serverlessApiUrl, scraperApiUrl) || this;
    }
    ProductionApiClient.prototype.getCoinGeckoData = function (l1Token, baseCurrency) {
        return tslib_1.__awaiter(this, void 0, void 0, function () {
            var response, result, price;
            return tslib_1.__generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4, axios_1.default.get("".concat(this.getServerlessApiUrl(), "/api/coingecko"), {
                            params: {
                                l1Token: l1Token,
                                baseCurrency: baseCurrency,
                            },
                        })];
                    case 1:
                        response = _a.sent();
                        result = response.data;
                        price = baseCurrency === "usd" ? (0, utils_1.parseEther)(String(result.price)) : utils_1.BigNumber.from(result.price);
                        return [2, {
                                price: price,
                            }];
                }
            });
        });
    };
    ProductionApiClient.prototype.getSuggestedFees = function (amount, originToken, toChainid, fromChainid) {
        return tslib_1.__awaiter(this, void 0, void 0, function () {
            var response, result, relayFeePct, relayFeeTotal, capitalFeePct, capitalFeeTotal, relayGasFeePct, relayGasFeeTotal, isAmountTooLow, quoteTimestamp, quoteBlock;
            return tslib_1.__generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4, axios_1.default.get("".concat(this.getServerlessApiUrl(), "/api/suggested-fees"), {
                            params: {
                                token: originToken,
                                destinationChainId: toChainid,
                                originChainId: fromChainid,
                                amount: amount.toString(),
                                skipAmountLimit: true,
                            },
                        })];
                    case 1:
                        response = _a.sent();
                        result = response.data;
                        relayFeePct = utils_1.BigNumber.from(result["relayFeePct"]);
                        relayFeeTotal = utils_1.BigNumber.from(result["relayFeeTotal"]);
                        capitalFeePct = utils_1.BigNumber.from(result["capitalFeePct"]);
                        capitalFeeTotal = utils_1.BigNumber.from(result["capitalFeeTotal"]);
                        relayGasFeePct = utils_1.BigNumber.from(result["relayGasFeePct"]);
                        relayGasFeeTotal = utils_1.BigNumber.from(result["relayGasFeeTotal"]);
                        isAmountTooLow = result["isAmountTooLow"];
                        quoteTimestamp = utils_1.BigNumber.from(result["timestamp"]);
                        quoteBlock = utils_1.BigNumber.from(result["quoteBlock"]);
                        return [2, {
                                relayerFee: {
                                    pct: relayFeePct,
                                    total: relayFeeTotal,
                                },
                                relayerCapitalFee: {
                                    pct: capitalFeePct,
                                    total: capitalFeeTotal,
                                },
                                relayerGasFee: {
                                    pct: relayGasFeePct,
                                    total: relayGasFeeTotal,
                                },
                                isAmountTooLow: isAmountTooLow,
                                quoteTimestamp: quoteTimestamp,
                                quoteBlock: quoteBlock,
                            }];
                }
            });
        });
    };
    ProductionApiClient.prototype.getBridgeLimits = function (token, fromChainId, toChainId) {
        return tslib_1.__awaiter(this, void 0, void 0, function () {
            var data;
            return tslib_1.__generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4, axios_1.default.get("".concat(this.getServerlessApiUrl(), "/api/limits?token=").concat(token, "&originChainId=").concat(fromChainId, "&destinationChainId=").concat(toChainId))];
                    case 1:
                        data = (_a.sent()).data;
                        return [2, data];
                }
            });
        });
    };
    ProductionApiClient.prototype.getAcrossStats = function () {
        return tslib_1.__awaiter(this, void 0, void 0, function () {
            var axiosResponse;
            return tslib_1.__generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4, axios_1.default.get("".concat(this.getScraperApiUrl(), "/deposits/stats"))];
                    case 1:
                        axiosResponse = _a.sent();
                        return [2, axiosResponse.data];
                }
            });
        });
    };
    return ProductionApiClient;
}(abstractClient_1.default));
exports.default = ProductionApiClient;
//# sourceMappingURL=productionClient.js.map