import { NATIVE_MINT } from "@solana/spl-token";
import { toNumber } from "@strata-foundation/spl-utils";
export const closeOutWumboSubmit = async ({ tokenBondingSdk, tokens, expectedOutputAmountByToken, setStatus, }) => {
    let processedTokenCount = 0;
    let innerError = null;
    if (!tokenBondingSdk)
        return;
    setStatus("Recouping SOL");
    for (let token of tokens) {
        const { publicKey: tokenBondingKey, targetMint } = token.tokenBonding;
        setStatus(`Swapping: ${token.metadata?.data?.name}`);
        try {
            await tokenBondingSdk.swap({
                baseMint: targetMint,
                targetMint: NATIVE_MINT,
                baseAmount: toNumber(token.account.amount, token.mint),
                expectedOutputAmount: expectedOutputAmountByToken[token.publicKey.toBase58()],
                slippage: 0.05,
            });
            processedTokenCount += 0;
        }
        catch (err) {
            // do nothing with error
            console.log(err);
        }
    }
    if (processedTokenCount == tokens.length) {
        setStatus("successful");
    }
    else {
        setStatus("orphaned");
    }
};
//# sourceMappingURL=closeOutWumboSubmit.js.map