import { isSolanaLike as e } from "../../constants/chains.constants.mjs";
import { zeroAddress as t } from "../../constants/protocol.constants.mjs";
import { transactionErrorCodes as n } from "../../error-handling/error-codes.constants.mjs";
import { getAmountInWei as r } from "./etherFunctions.mjs";
import { getLifiChainId as i } from "../../constants/lifi.constants.mjs";
import { callLifiAPI as a } from "../../API/callLifiAPI.mjs";
//#region libs/shared/common/src/functions/web3/lifiAPI.ts
var o = async (o, s, c, l, u, d) => {
	try {
		let n = r(o, c), { lifiResponse: f } = await a({
			fromChain: i(o.chainId),
			toChain: i(s.chainId),
			fromToken: o.erc20TokenAddress,
			toToken: s.erc20TokenAddress,
			fromAddress: u,
			fromAmount: n.toString(),
			order: "FASTEST",
			slippage: l,
			...d && { toAddress: d }
		});
		if (e(o.chainId)) return {
			lifiDataValue: f.transactionRequest.data,
			outSwapAmountValue: BigInt(f.estimate.toAmount),
			extraNativeTokenFee: 0n
		};
		let p = BigInt(f.transactionRequest.value || "0");
		return {
			lifiDataValue: f.transactionRequest.data,
			outSwapAmountValue: BigInt(f.estimate.toAmount),
			extraNativeTokenFee: o.erc20TokenAddress === t ? p - n : p
		};
	} catch {
		throw Error(n.NO_LIFI_PRICE);
	}
};
//#endregion
export { o as getLifiPrice };
