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 { chainIsEvm, 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.
 */
const fixedGasPrice = {
    [CHAIN_IDs.BOBA]: 1e9,
};
export class QueryBase__factory {
    static create(chainId, provider, symbolMapping = TOKEN_SYMBOLS_MAP, spokePoolAddress = getDeployedAddress("SpokePool", chainId), relayerAddress = getDefaultRelayer(chainId), coingeckoProApiKey, logger = DEFAULT_LOGGER, coingeckoBaseCurrency = "eth") {
        assert(isDefined(spokePoolAddress));
        const customGasTokenSymbol = CUSTOM_GAS_TOKENS[chainId];
        if (chainIsEvm(chainId) && isDefined(customGasTokenSymbol)) {
            assert(relayerAddress.isEVM());
            return new CustomGasTokenQueries({
                queryBaseArgs: [
                    provider,
                    symbolMapping,
                    spokePoolAddress,
                    relayerAddress,
                    logger,
                    coingeckoProApiKey,
                    fixedGasPrice[chainId],
                    "usd",
                ],
                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);
    }
}
//# sourceMappingURL=factory.js.map