var _a;
import assert from "assert";
import { CHAIN_IDs, TOKEN_SYMBOLS_MAP } from "@across-protocol/constants";
import { getDeployedAddress } from "@across-protocol/contracts";
import { asL2Provider } from "@eth-optimism/sdk";
import { CUSTOM_GAS_TOKENS } from "../../constants";
import { chainIsOPStack, isDefined, chainIsSvm, SvmAddress } from "../../utils";
import { QueryBase } from "./baseQuery";
import { DEFAULT_LOGGER, getDefaultRelayer } from "../relayFeeCalculator";
import { CustomGasTokenQueries } from "./customGasToken";
import { SvmQuery } from "./svmQuery";
/**
 * Some chains have a fixed gas price that is applied to the gas estimates. We should override
 * the gas markup for these chains.
 */
var fixedGasPrice = (_a = {},
    _a[CHAIN_IDs.BOBA] = 1e9,
    _a);
var QueryBase__factory = /** @class */ (function () {
    function QueryBase__factory() {
    }
    QueryBase__factory.create = function (chainId, provider, symbolMapping, spokePoolAddress, relayerAddress, coingeckoProApiKey, logger, coingeckoBaseCurrency) {
        if (symbolMapping === void 0) { symbolMapping = TOKEN_SYMBOLS_MAP; }
        if (spokePoolAddress === void 0) { spokePoolAddress = getDeployedAddress("SpokePool", chainId); }
        if (relayerAddress === void 0) { relayerAddress = getDefaultRelayer(chainId); }
        if (logger === void 0) { logger = DEFAULT_LOGGER; }
        if (coingeckoBaseCurrency === void 0) { coingeckoBaseCurrency = "eth"; }
        assert(isDefined(spokePoolAddress));
        var customGasTokenSymbol = CUSTOM_GAS_TOKENS[chainId];
        if (customGasTokenSymbol) {
            assert(relayerAddress.isEVM());
            return new CustomGasTokenQueries({
                queryBaseArgs: [
                    provider,
                    symbolMapping,
                    spokePoolAddress,
                    relayerAddress,
                    logger,
                    coingeckoProApiKey,
                    fixedGasPrice[chainId],
                    "usd",
                ],
                customGasTokenSymbol: customGasTokenSymbol,
            });
        }
        if (chainIsSvm(chainId)) {
            assert(relayerAddress.isSVM());
            return new SvmQuery(provider, symbolMapping, SvmAddress.from(spokePoolAddress), relayerAddress, logger, coingeckoProApiKey, fixedGasPrice[chainId], coingeckoBaseCurrency);
        }
        // For OPStack chains, we need to wrap the provider in an L2Provider
        provider = chainIsOPStack(chainId)
            ? asL2Provider(provider)
            : provider;
        assert(relayerAddress.isEVM());
        return new QueryBase(provider, symbolMapping, spokePoolAddress, relayerAddress, logger, coingeckoProApiKey, fixedGasPrice[chainId], coingeckoBaseCurrency);
    };
    return QueryBase__factory;
}());
export { QueryBase__factory };
//# sourceMappingURL=factory.js.map