import { simulateVolatileTokenTransfer as e } from "../../API/simulate-transaction.mjs";
import { Logger as t } from "../../error-handling/logger.mjs";
import "../../error-handling/index.mjs";
import { TokenChecker as n } from "../../data-structures/token-price-fetcher/TokenChecker.mjs";
//#region libs/shared/common/src/functions/pre-transaction/getVolatileTransferAmount.ts
var r = async (r, i, a, o) => {
	try {
		let t = i.map((e, t) => {
			let r = a[t];
			return e && n.isPotentiallyVolatile(e) ? {
				tokenAddress: e.erc20TokenAddress,
				amount: r.toString(),
				...o === void 0 ? {} : { targetAddress: o },
				originalIndex: t
			} : null;
		}).filter((e) => e !== null);
		if (t.length === 0) return a;
		let s = await e(r, t);
		return a.map((e, n) => {
			let r = t.findIndex((e) => e.originalIndex === n);
			if (r !== -1 && s[r].success) {
				let t = s[r].balanceDifference;
				return t ? BigInt(t) : e;
			}
			return e;
		});
	} catch (e) {
		return t.error("Volatile transfer simulation failed:", e), a;
	}
};
//#endregion
export { r as modifyVolatileTokenAmountChanges };
