import { localhostNetwork as e, networkRegistry as t } from "../../constants/chains.constants.mjs";
import { zeroAddress as n } from "../../constants/protocol.constants.mjs";
import { callOdosAPI as r } from "../../API/callOdosAPI.mjs";
import { transactionErrorCodes as i } from "../../error-handling/error-codes.constants.mjs";
import { getAmountInWei as a } from "./etherFunctions.mjs";
import "../../constants/index.mjs";
import "../../error-handling/index.mjs";
//#region libs/shared/common/src/functions/web3/odosAPI.ts
var o = async (o, s, c, l, u = .7) => {
	try {
		let { odosResponse: i, status: d } = await r(o, {
			chainId: o === 31337 ? e : o,
			inputTokens: [{
				tokenAddress: s?.wrappedErc20TokenAddress ?? s.erc20TokenAddress,
				amount: a(s, l).toString()
			}],
			outputTokens: [{
				tokenAddress: c?.wrappedErc20TokenAddress ?? c.erc20TokenAddress,
				proportion: 1
			}],
			userAddr: t[o].contractData.odosExternalActionInstanceAddress || n,
			slippageLimitPercent: u,
			disableRFQs: !0
		});
		if (d !== "success") throw Error("Odos API Fetch Error");
		return {
			outSwapAmountValue: BigInt(i.outputTokens[0].amount),
			odosDataValue: i.transaction.data
		};
	} catch (e) {
		throw console.log({ error: e }), Error(i.NO_ODOS_PRICE);
	}
};
//#endregion
export { o as getOdosPrice };
