-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Python implementation of rugcheck plugin (#204)
* feat: Add Python implementation of rugcheck plugin - Implement RugCheck API integration with JWT authentication - Add all endpoints from TypeScript implementation - Follow coingecko plugin Python structure - Include proper parameter definitions - Set up project configuration * chore: address PR feedback - remove empty init file, add README.md, fix pyproject.toml packages config Co-Authored-By: Agus Armellini Fischer <[email protected]> * Fix PR --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Agus Armellini Fischer <[email protected]> Co-authored-by: Agustin Armellini Fischer <[email protected]>
- Loading branch information
1 parent
f1cdc3b
commit 1bcd45c
Showing
11 changed files
with
260 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# GOAT SDK RugCheck Plugin | ||
|
||
A Python implementation of the RugCheck plugin for the GOAT SDK, providing access to RugCheck's token analysis and verification services. | ||
|
||
## Features | ||
|
||
- Get recently detected tokens | ||
- Get trending tokens in the last 24h | ||
- Get most voted tokens in the last 24h | ||
- Get recently verified tokens | ||
- Generate token report summaries | ||
|
||
## Installation | ||
|
||
```bash | ||
poetry install | ||
``` | ||
|
||
## Usage | ||
|
||
```python | ||
from goat_plugins.rugcheck import rugcheck, RugCheckPluginOptions | ||
|
||
# Initialize the plugin | ||
options = RugCheckPluginOptions(jwt_token="your_jwt_token") # JWT token is optional | ||
plugin = rugcheck(options) | ||
|
||
# Example: Get recently detected tokens | ||
async def get_recent_tokens(): | ||
service = plugin.services[0] | ||
tokens = await service.get_recently_detected_tokens({}) | ||
return tokens | ||
|
||
# Example: Generate a token report | ||
async def get_token_report(mint_address: str): | ||
service = plugin.services[0] | ||
report = await service.generate_token_report_summary({"mint": mint_address}) | ||
return report | ||
``` | ||
|
||
## Authentication | ||
|
||
The plugin supports JWT token authentication. While optional, some endpoints may require authentication for full access. | ||
|
||
## Rate Limiting | ||
|
||
The plugin includes built-in handling for rate limits (HTTP 429 responses) from the RugCheck API. | ||
|
||
## Development | ||
|
||
- Python 3.9+ | ||
- Uses `aiohttp` for async HTTP requests | ||
- Uses `pydantic` for parameter validation | ||
|
||
## License | ||
|
||
See the main GOAT SDK repository for license information. |
21 changes: 21 additions & 0 deletions
21
python/src/plugins/rugcheck/goat_plugins/rugcheck/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from dataclasses import dataclass | ||
|
||
from goat.classes.plugin_base import PluginBase | ||
from .service import RugCheckService | ||
|
||
|
||
@dataclass | ||
class RugCheckPluginOptions: | ||
jwt_token: str = "" | ||
|
||
|
||
class RugCheckPlugin(PluginBase): | ||
def __init__(self): | ||
super().__init__("rugcheck", [RugCheckService()]) | ||
|
||
def supports_chain(self, chain) -> bool: | ||
return True | ||
|
||
|
||
def rugcheck() -> RugCheckPlugin: | ||
return RugCheckPlugin() |
11 changes: 11 additions & 0 deletions
11
python/src/plugins/rugcheck/goat_plugins/rugcheck/parameters.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from pydantic import BaseModel, Field | ||
|
||
|
||
class GetTokenReportParameters(BaseModel): | ||
mint: str = Field( | ||
description="The token mint address to generate the report for" | ||
) | ||
|
||
|
||
class NoParameters(BaseModel): | ||
pass |
64 changes: 64 additions & 0 deletions
64
python/src/plugins/rugcheck/goat_plugins/rugcheck/service.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import aiohttp | ||
from goat.decorators.tool import Tool | ||
from .parameters import GetTokenReportParameters, NoParameters | ||
|
||
|
||
class RugCheckService: | ||
def __init__(self, jwt_token: str = ""): | ||
self.jwt_token = jwt_token | ||
self.base_url = "https://api.rugcheck.xyz/v1" | ||
|
||
async def _make_request(self, endpoint: str): | ||
headers = { | ||
"Content-Type": "application/json", | ||
} | ||
|
||
async with aiohttp.ClientSession() as session: | ||
url = f"{self.base_url}{endpoint}" | ||
async with session.get(url, headers=headers) as response: | ||
if not response.ok: | ||
if response.status == 429: | ||
raise Exception("RugCheck API rate limit exceeded") | ||
raise Exception(f"RugCheck API request failed: {response.status}") | ||
return await response.json() | ||
|
||
@Tool({ | ||
"description": "Get recently detected tokens from RugCheck", | ||
"parameters_schema": NoParameters | ||
}) | ||
async def get_recently_detected_tokens(self, parameters: dict): | ||
"""Get recently detected tokens from RugCheck""" | ||
return await self._make_request("/stats/new_tokens") | ||
|
||
@Tool({ | ||
"description": "Get trending tokens in the last 24h from RugCheck", | ||
"parameters_schema": NoParameters | ||
}) | ||
async def get_trending_tokens_24h(self, parameters: dict): | ||
"""Get trending tokens in the last 24h from RugCheck""" | ||
return await self._make_request("/stats/trending") | ||
|
||
@Tool({ | ||
"description": "Get tokens with the most votes in the last 24h from RugCheck", | ||
"parameters_schema": NoParameters | ||
}) | ||
async def get_most_voted_tokens_24h(self, parameters: dict): | ||
"""Get tokens with the most votes in the last 24h from RugCheck""" | ||
return await self._make_request("/stats/recent") | ||
|
||
@Tool({ | ||
"description": "Get recently verified tokens from RugCheck", | ||
"parameters_schema": NoParameters | ||
}) | ||
async def get_recently_verified_tokens(self, parameters: dict): | ||
"""Get recently verified tokens from RugCheck""" | ||
return await self._make_request("/stats/verified") | ||
|
||
@Tool({ | ||
"description": "Generate a report summary for the given token mint", | ||
"parameters_schema": GetTokenReportParameters | ||
}) | ||
async def generate_token_report_summary(self, parameters: dict): | ||
"""Generate a report summary for the given token mint""" | ||
mint = parameters["mint"] | ||
return await self._make_request(f"/tokens/{mint}/report/summary") |
Oops, something went wrong.