Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add channel for high potential meme coins #519

Open
StephanAkkerman opened this issue Mar 27, 2024 · 5 comments
Open

Add channel for high potential meme coins #519

StephanAkkerman opened this issue Mar 27, 2024 · 5 comments
Labels
Difficulty: Hard 😭 This issue is hard to solve, a lot of code needs to be changed New feature ⭐ New feature or request Priority: High 🥇 Assign this label if this issue is VERY important or often used

Comments

@StephanAkkerman
Copy link
Owner

StephanAkkerman commented Mar 27, 2024

Maybe use data from dexscreener.com or other sources to look for anomalies in the data after launch of a new coin.
Dexscreener code:

Check F12, Network, WS for dexscreener websocket connection.

@StephanAkkerman StephanAkkerman added Priority: High 🥇 Assign this label if this issue is VERY important or often used New feature ⭐ New feature or request Difficulty: Hard 😭 This issue is hard to solve, a lot of code needs to be changed labels Mar 27, 2024
@StephanAkkerman
Copy link
Owner Author

This is probably more like a side project, just like #6 and #65

@StephanAkkerman
Copy link
Owner Author

https://dexscreener.com/new-pairs, could not find an easy way to reach their API

@StephanAkkerman
Copy link
Owner Author

Can take inspiration from: https://github.com/farzadex-eth/tokenfinderbot

@StephanAkkerman
Copy link
Owner Author

https://github.com/liqtags/DexScreenerClient also has newpairs functionality

@StephanAkkerman
Copy link
Owner Author

Sample code (does not work because of cloudlflare):

import json
import ssl

import websocket

WS_TRENDING = "wss://io.dexscreener.com/dex/screener/pairs/h24/1?rankBy[key]=trendingScoreH6&rankBy[order]=desc"
WS_GAINERS = "wss://io.dexscreener.com/dex/screener/pairs/h24/1?rankBy[key]=priceChangeH24&rankBy[order]=desc&filters[liquidity][min]=25000&filters[txns][h24][min]=50&filters[volume][h24][min]=10000"
WS_NEWEST = "wss://io.dexscreener.com/dex/screener/pairs/h24/1?rankBy[key]=volume&rankBy[order]=desc&filters[pairAge][max]=24"


def get_pairs(uri):
    """
    Retrieves a list of pairs from the given URI.

    Args:
        uri (str): The URI to fetch data from.

    Returns:
        list: A list of pairs retrieved from the URI.

    """
    for i in range(5):
        data = call_websocket_load_json(uri)
        if pairs := data.get("pairs"):
            return pairs
        print(f"({i + 1}/{5}) -- {data}")
    return []


def call_websocket_load_json(uri) -> dict:
    """
    Calls a WebSocket URI and returns the received JSON data as a dictionary.

    Args:
        uri (str): The URI of the WebSocket server.

    Returns:
        dict: The received JSON data as a dictionary.
    """
    ws = websocket.WebSocket(sslopt={"cert_reqs": ssl.CERT_NONE})
    ws.connect(uri, header=get_header(), suppress_origin=True)
    return json.loads(ws.recv())


def get_header():
    """
    Returns the header dictionary containing the User-Agent and Origin values.

    Returns:
        dict: The header dictionary.
    """
    return {
        "User-Agent": " ".join(
            [
                "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)",
                "AppleWebKit/537.36 (KHTML, like Gecko)"
                "Chrome/113.0.0.0 Safari/537.36",
            ]
        ),
        "Origin": "https://dexscreener.com",
    }


print(get_pairs(WS_TRENDING))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Hard 😭 This issue is hard to solve, a lot of code needs to be changed New feature ⭐ New feature or request Priority: High 🥇 Assign this label if this issue is VERY important or often used
Projects
None yet
Development

No branches or pull requests

1 participant