"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getMinimumSwapAmount = void 0;
const axios_1 = __importDefault(require("axios"));
async function getMinimumSwapAmount(AccountFrom, AccountTo) {
    try {
        const requestConfig = {
            method: "GET",
            url: `https://swap-stg.ledger-test.com/v5/quote`,
            params: {
                from: AccountFrom.currency.id,
                to: AccountTo.currency.id,
                amountFrom: 0.0001,
                addressFrom: AccountFrom.address,
                fiatForCounterValue: "USD",
                slippage: 1,
                networkFees: 0.001,
                networkFeesCurrency: AccountTo.currency.speculosApp.name.toLowerCase(),
                displayLanguage: "en",
                theme: "light",
                "providers-whitelist": "changelly,exodus,thorswap,uniswap,cic",
                tradeType: "INPUT",
                uniswapOrderType: "uniswapxv1",
            },
            headers: {
                accept: "application/json",
            },
        };
        const { data } = await (0, axios_1.default)(requestConfig);
        const minimumAmounts = data
            .filter((item) => item.parameter?.minAmount !== undefined)
            .map((item) => parseFloat(item.parameter.minAmount));
        const validMinimumAmounts = minimumAmounts.filter((amount) => !isNaN(amount));
        if (validMinimumAmounts.length === 0) {
            throw new Error("No valid minimum amounts returned from swap quote API.");
        }
        return Math.max(...validMinimumAmounts);
    }
    catch (error) {
        console.error(error);
    }
}
exports.getMinimumSwapAmount = getMinimumSwapAmount;
//# sourceMappingURL=swap.js.map