"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.QueryBase__factory = void 0;
const tslib_1 = require("tslib");
const assert_1 = tslib_1.__importDefault(require("assert"));
const constants_1 = require("@across-protocol/constants");
const contracts_1 = require("@across-protocol/contracts");
const sdk_1 = require("@eth-optimism/sdk");
const constants_2 = require("../../constants");
const utils_1 = require("../../utils");
const baseQuery_1 = require("./baseQuery");
const relayFeeCalculator_1 = require("../relayFeeCalculator");
const customGasToken_1 = require("./customGasToken");
const svmQuery_1 = require("./svmQuery");
const fixedGasPrice = {
    [constants_1.CHAIN_IDs.BOBA]: 1e9,
};
class QueryBase__factory {
    static create(chainId, provider, symbolMapping = constants_1.TOKEN_SYMBOLS_MAP, spokePoolAddress = (0, contracts_1.getDeployedAddress)("SpokePool", chainId), relayerAddress = (0, relayFeeCalculator_1.getDefaultRelayer)(chainId), coingeckoProApiKey, logger = relayFeeCalculator_1.DEFAULT_LOGGER, coingeckoBaseCurrency = "eth") {
        (0, assert_1.default)((0, utils_1.isDefined)(spokePoolAddress));
        const customGasTokenSymbol = constants_2.CUSTOM_GAS_TOKENS[chainId];
        if ((0, utils_1.chainIsEvm)(chainId) && (0, utils_1.isDefined)(customGasTokenSymbol)) {
            (0, assert_1.default)(relayerAddress.isEVM());
            return new customGasToken_1.CustomGasTokenQueries({
                queryBaseArgs: [
                    provider,
                    symbolMapping,
                    spokePoolAddress,
                    relayerAddress,
                    logger,
                    coingeckoProApiKey,
                    fixedGasPrice[chainId],
                    "usd",
                ],
                customGasTokenSymbol,
            });
        }
        if ((0, utils_1.chainIsSvm)(chainId)) {
            (0, assert_1.default)(relayerAddress.isSVM());
            return new svmQuery_1.SvmQuery(provider, symbolMapping, utils_1.SvmAddress.from(spokePoolAddress), relayerAddress, logger, coingeckoProApiKey, fixedGasPrice[chainId], coingeckoBaseCurrency);
        }
        provider = (0, utils_1.chainIsOPStack)(chainId)
            ? (0, sdk_1.asL2Provider)(provider)
            : provider;
        (0, assert_1.default)(relayerAddress.isEVM());
        return new baseQuery_1.QueryBase(provider, symbolMapping, spokePoolAddress, relayerAddress, logger, coingeckoProApiKey, fixedGasPrice[chainId], coingeckoBaseCurrency);
    }
}
exports.QueryBase__factory = QueryBase__factory;
//# sourceMappingURL=factory.js.map