sorry to bother but Im struggling since a couple of days. Im new on this but I want to learn. I have a script that listen new pools and try to make a swap. I have SOL on my wallet but keep saying that I do not have funds. Is there a way to determinate the minimun balance required from the pool?


SendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x28

And also I have a function to determinate initialrate but is always giving me zero and also that make the transacction fail.

async function getInitialRate(connection: Connection, poolKeys: LiquidityPoolKeys): Promise<number> {
    try {
        if (poolKeys.baseDecimals === 0 || poolKeys.quoteDecimals === 0) {
            throw new Error("Información del pool inválida: decimales no pueden ser cero");

        const rawAmountIn = 10000000; // 0.01 SOL en lamport
        const swapInDirection = true; // 
        const { executionPrice } = await calcAmountOut(
            connection, poolKeys, rawAmountIn, swapInDirection

        if (!executionPrice) {
            throw new Error("No se pudo calcular el precio de ejecución");

        const rate = parseFloat(executionPrice.toFixed(10));
        console.log('Exchange Rate:', rate);
        return rate;
    } catch (error) {
        console.error('Error calculando la tasa de cambio:', error);
        return 0;

can someone guide me?

thank you

  • What pool are you using? Which program are you listening to? Do you know how to call the program with the right instructions? It might be that you don’t wrap sol into wSOL first. Take a look at Jupiter’s guide
    – wei1769
    Jan 20 at 4:11
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Jan 21 at 14:44


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.