rckprtr / pumpdotfun-sdk

PumpDotFun SDK
MIT License
316 stars 129 forks source link

API integration #33

Closed DreadNotplease closed 2 months ago

DreadNotplease commented 4 months ago

The bonding curve account info/mint is not found for about 20-30 seconds. Pump Portal websocket is getting this information in about 2-3 seconds, I've tried adding the bondingcurvekey into the Getbondingcurveaccount, but I keep running into issues.

What would I need to do this? I feel like it is being overridden somewhere

`const setupWebSocket = (mintAddress, callback) => { const ws = new WebSocket('wss://pumpportal.fun/api/data');

ws.on('open', () => {
    console.log('WebSocket connection opened.');

    // Subscribe to new token creation events
    const payload = {
        method: "subscribeNewToken"
    };
    ws.send(JSON.stringify(payload));
});

ws.on('message', (data) => {
    const parsedData = JSON.parse(data);

    // Only log the message if it matches the mint address
    if (parsedData.mint === mintAddress) {
        console.log('WebSocket message received for target mint:', parsedData);

        // Ensure bondingCurveKey is a PublicKey
        parsedData.bondingCurveKey = new web3_js_1.PublicKey(parsedData.bondingCurveKey);

        callback(parsedData);
    } else {
        console.log('WebSocket message received for different mint:', parsedData.mint);
    }
});

ws.on('error', (error) => {
    console.error('WebSocket error:', error);
});

ws.on('close', () => {
    console.log('WebSocket connection closed.');
});

return ws;

};`

mubarizkyc commented 4 months ago

https://github.com/mubarizkyc/pumphub

pjones1 commented 4 months ago

I'm running into the same exact issue. The web socket picks up that a new token was created, but when I try to get the data from the bonding curve it always fails. It only works a while later which at that point it's useless.

@rckprtr Any ideas on fixing this issue? Thanks!

LimaTechnologies commented 3 months ago

Friend if you use a third party api you'll be having third party issues, as you will be using basically two different nodes for doing the same job and those nodes will have different levels of information and one can be ahead than the others or delayed depending if it's a validator or not or if you got lucky to recieve the peer notifications early

LimaTechnologies commented 3 months ago

you also should consider the level of the notification (Max vs Confirmed) + language of choice, I had issues with something like this early on, and did built this https://github.com/Jay-Frontera/pumpdotfun-fast-listener but it's just for recieving new events as I do run Quant bots, solana is too fast for a bad language as this one that we use, idk if my solution may help you but this can be some issue related to that, when I used this sdk the issue was the decoding that when high volume appear it started dying due to language and O(n) stuff

RomanticBarracks commented 3 months ago

I'm on same issue too. Did you solve it?