import AbstractApiClient from "./abstractClient";
import { BigNumber, fetchWithTimeout, parseEther } from "../utils";
/**
 * An implementation of AbstractApiClient that uses the production API.
 * @class
 * @extends AbstractApiClient
 * @note This implementation makes API calls to RESTful services.
 */
export default class ProductionApiClient extends AbstractApiClient {
    constructor(serverlessApiUrl, scraperApiUrl) {
        super(serverlessApiUrl, scraperApiUrl);
    }
    async getCoinGeckoData(l1Token, baseCurrency) {
        const result = await fetchWithTimeout(`${this.getServerlessApiUrl()}/api/coingecko`, {
            l1Token,
            baseCurrency,
        });
        const price = baseCurrency === "usd" ? parseEther(String(result.price)) : BigNumber.from(result.price);
        return {
            price,
        };
    }
    async getSuggestedFees(amount, originToken, toChainid, fromChainid) {
        const result = await fetchWithTimeout(`${this.getServerlessApiUrl()}/api/suggested-fees`, {
            token: originToken,
            destinationChainId: toChainid,
            originChainId: fromChainid,
            amount: amount.toString(),
            skipAmountLimit: true,
        });
        const relayFeePct = BigNumber.from(result["relayFeePct"]);
        const relayFeeTotal = BigNumber.from(result["relayFeeTotal"]);
        const capitalFeePct = BigNumber.from(result["capitalFeePct"]);
        const capitalFeeTotal = BigNumber.from(result["capitalFeeTotal"]);
        const relayGasFeePct = BigNumber.from(result["relayGasFeePct"]);
        const relayGasFeeTotal = BigNumber.from(result["relayGasFeeTotal"]);
        const isAmountTooLow = result["isAmountTooLow"];
        const quoteTimestamp = BigNumber.from(result["timestamp"]);
        const quoteBlock = 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 fetchWithTimeout(`${this.getServerlessApiUrl()}/api/limits`, {
            token,
            originChainId: fromChainId,
            destinationChainId: toChainId,
        });
        return data;
    }
    async getAcrossStats() {
        const data = await fetchWithTimeout(`${this.getScraperApiUrl()}/deposits/stats`);
        return data;
    }
}
//# sourceMappingURL=productionClient.js.map