-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Does not detect LAUNCHCOIN tokens that might already be in the wallet at startup. Proceeds to swap some SOL and still doesn't detect the swapped LAUNCHCOIN, causing it to create a single sided position (SOL only).
This fixes the second part (workaround - there's a problem with fetchBalances apparently):
// Fix: Get actual token balance from swap transaction (Jupiter uses different ATA)
const txInfo = await connection.getParsedTransaction(sig, {
maxSupportedTransactionVersion: 0, commitment: 'confirmed'
});
if (txInfo?.meta?.postTokenBalances) {
const myOutputBalance = txInfo.meta.postTokenBalances.find(
balance => balance.mint === outputMint &&
balance.owner === userKeypair.publicKey.toString() &&
balance.uiTokenAmount.amount !== '0'
);
if (myOutputBalance) {
const actualTokenBalance = new BN(myOutputBalance.uiTokenAmount.amount);
// Update balance directly instead of using fetchBalances for swapped token
if (outputMint === X_MINT) {
lamX = actualTokenBalance;
lamY = (await fetchBalances(connection, dlmmPool, userKeypair.publicKey)).lamY;
} else {
lamY = actualTokenBalance;
lamX = (await fetchBalances(connection, dlmmPool, userKeypair.publicKey)).lamX;
}
}
} else {
// Fallback to regular balance fetching if transaction parsing fails
({ lamX, lamY } = await fetchBalances(connection, dlmmPool, userKeypair.publicKey));
}
Metadata
Metadata
Assignees
Labels
No labels