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