Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.analysis.extraPaths": [
"app/trading",
"app/tg-bot",
"app/wallet-tracker",
"app/cache-preloader",
],
"[python]": {
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
Expand Down
26 changes: 11 additions & 15 deletions app/cache-preloader/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,18 @@ version = "0.2.1"
description = "Cache preloading service for Solana Trading Bot"
authors = [{ name = "mkdir700", email = "[email protected]" }]
dependencies = [
"solbot-cache",
"solbot-db",
"solbot-services",
"solbot-common",
"solbot-yellowstone-grpc",
]
requires-python = "==3.10.*"
license = { text = "Apache-2.0" }

[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"

[tool.pdm]
distribution = false

[tool.pdm.dev-dependencies]
local = [
"solbot-cache @ file:///${PROJECT_ROOT}/libs/cache",
"solbot-db @ file:///${PROJECT_ROOT}/libs/db",
"solbot-services @ file:///${PROJECT_ROOT}/libs/services",
"solbot-common @ file:///${PROJECT_ROOT}/libs/common",
"solbot-yellowstone-grpc @ file:///${PROJECT_ROOT}/libs/yellowstone_grpc",
]
[tool.uv.sources]
solbot-cache = { path = "../../libs/cache", editable = true }
solbot-db = { path = "../../libs/db", editable = true }
solbot-services = { path = "../../libs/services", editable = true }
solbot-common = { path = "../../libs/common", editable = true }
solbot-yellowstone-grpc = { path = "../../libs/yellowstone_grpc", editable = true }
28 changes: 14 additions & 14 deletions app/tg-bot/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
name = "solbot-tgbot"
version = "0.2.1"
description = "Telegram bot for Solana trading"
authors = [
{ name = "mkdir700", email = "[email protected]" },
]
authors = [{ name = "mkdir700", email = "[email protected]" }]
dependencies = [
# Telegram Bot 框架
"aiogram>=3.15.0",
Expand Down Expand Up @@ -39,21 +37,23 @@ dependencies = [

# 监控
"sentry-sdk>=2.21.0",

# 本地依赖
"solbot-cache",
"solbot-db",
"solbot-services",
"solbot-common",
"solbot-yellowstone-grpc",
]
requires-python = "==3.10.*"
license = { text = "Apache-2.0" }

[tool.pdm]
distribution = false

[tool.pdm.dev-dependencies]
local = [
"solbot-cache @ file:///${PROJECT_ROOT}/libs/cache",
"solbot-db @ file:///${PROJECT_ROOT}/libs/db",
"solbot-services @ file:///${PROJECT_ROOT}/libs/services",
"solbot-common @ file:///${PROJECT_ROOT}/libs/common",
"solbot-yellowstone-grpc @ file:///${PROJECT_ROOT}/libs/yellowstone_grpc",
]
[tool.uv.sources]
solbot-cache = { path = "../../libs/cache", editable = true }
solbot-db = { path = "../../libs/db", editable = true }
solbot-services = { path = "../../libs/services", editable = true }
solbot-common = { path = "../../libs/common", editable = true }
solbot-yellowstone-grpc = { path = "../../libs/yellowstone_grpc", editable = true }

[tool.pytest.ini_options]
log_cli = true
Expand Down
24 changes: 13 additions & 11 deletions app/trading/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,20 @@ dependencies = [

# 监控
"sentry-sdk>=2.21.0",

# 本地依赖
"solbot-cache",
"solbot-db",
"solbot-services",
"solbot-common",
"solbot-yellowstone-grpc",
]
requires-python = "==3.10.*"
license = { text = "Apache-2.0" }

[tool.pdm]
distribution = false

[tool.pdm.dev-dependencies]
local = [
"solbot-cache @ file:///${PROJECT_ROOT}/libs/cache",
"solbot-db @ file:///${PROJECT_ROOT}/libs/db",
"solbot-services @ file:///${PROJECT_ROOT}/libs/services",
"solbot-common @ file:///${PROJECT_ROOT}/libs/common",
"solbot-yellowstone-grpc @ file:///${PROJECT_ROOT}/libs/yellowstone_grpc",
]
[tool.uv.sources]
solbot-cache = { path = "../../libs/cache", editable = true }
solbot-db = { path = "../../libs/db", editable = true }
solbot-services = { path = "../../libs/services", editable = true }
solbot-common = { path = "../../libs/common", editable = true }
solbot-yellowstone-grpc = { path = "../../libs/yellowstone_grpc", editable = true }
3 changes: 2 additions & 1 deletion app/trading/trading/transaction/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from trading.transaction.base import TransactionSender
from trading.transaction.builders.base import TransactionBuilder
from trading.transaction.factory import TradingService
from trading.transaction.factory import AggregateTransactionBuilder, TradingService
from trading.transaction.protocol import TradingRoute
from trading.transaction.sender import DefaultTransactionSender, JitoTransactionSender

__all__ = [
"AggregateTransactionBuilder",
"DefaultTransactionSender",
"JitoTransactionSender",
"TradingRoute",
Expand Down
1,405 changes: 1,405 additions & 0 deletions app/trading/uv.lock

Large diffs are not rendered by default.

31 changes: 13 additions & 18 deletions app/wallet-tracker/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,21 @@ version = "0.2.1"
description = "Wallet tracking service for Solana Trading Bot"
authors = [{ name = "mkdir700", email = "[email protected]" }]
dependencies = [
"solbot-cache",
"solbot-db",
"solbot-services",
"solbot-common",
"solbot-yellowstone-grpc",
]
requires-python = "==3.10.*"
license = { text = "Apache-2.0" }

[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"
[dependency-groups]
dev = ["pytest>=8.0.0", "pytest-asyncio>=0.24.0"]

[tool.pdm]
distribution = false

[tool.pdm.dev-dependencies]
local = [
"solbot-cache @ file:///${PROJECT_ROOT}/libs/cache",
"solbot-db @ file:///${PROJECT_ROOT}/libs/db",
"solbot-services @ file:///${PROJECT_ROOT}/libs/services",
"solbot-common @ file:///${PROJECT_ROOT}/libs/common",
"solbot-yellowstone-grpc @ file:///${PROJECT_ROOT}/libs/yellowstone_grpc",
]
dev = [
"pytest>=8.0.0",
"pytest-asyncio>=0.24.0",
]
[tool.uv.sources]
solbot-cache = { path = "../../libs/cache", editable = true }
solbot-db = { path = "../../libs/db", editable = true }
solbot-services = { path = "../../libs/services", editable = true }
solbot-common = { path = "../../libs/common", editable = true }
solbot-yellowstone-grpc = { path = "../../libs/yellowstone_grpc", editable = true }
8 changes: 5 additions & 3 deletions libs/cache/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dependencies = [
"pydantic-settings>=2.6.1",
"pydantic-settings-toml>=0.2.0",
"orjson>=3.10.11",
"aioredis[hiredis]>=2.0.1",
"pymysql>=1.1.1",
"anchorpy>=0.20.1",
"backoff>=2.2.1",
Expand All @@ -39,5 +38,8 @@ requires-python = "==3.10.*"
license = { text = "Apache-2.0" }

[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.uv.sources]
solbot-common = { path = "../common", editable = true }
13 changes: 5 additions & 8 deletions libs/common/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@ description = "Common utilities for Solana Trading Bot"
authors = [{ name = "mkdir700", email = "[email protected]" }]
dependencies = [
"pydantic>=2.0.0",
"pydantic-settings>=2.0.0",
"pydantic-settings>=2.6.1",
"pydantic-settings-toml>=0.2.0",
"loguru>=0.7.2",
"tomli>=2.0.0",
"tomli>=2.1.0",
"solana>=0.35.1",
"python-dotenv>=1.0.1",
"loguru>=0.7.2",
"solders>=0.25.0",
"base58>=2.1.1",
"tomli>=2.1.0",
"sqlmodel>=0.0.22",
"pydantic-settings>=2.6.1",
"pydantic-settings-toml>=0.2.0",
"orjson>=3.10.11",
"aioredis[hiredis]>=2.0.1",
"pymysql>=1.1.1",
Expand All @@ -42,5 +39,5 @@ readme = "README.md"
license = { text = "Apache-2.0" }

[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"
requires = ["hatchling"]
build-backend = "hatchling.build"
7 changes: 5 additions & 2 deletions libs/db/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ requires-python = "==3.10.*"
license = { text = "Apache-2.0" }

[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.uv.sources]
solbot-common = { path = "../common", editable = true }
11 changes: 7 additions & 4 deletions libs/services/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies = [
"solders>=0.25.0",
"base58>=2.1.1",
"tomli>=2.1.0",
"sqlmodel>=0.0.22",
"pydantic-settings>=2.6.1",
"pydantic-settings-toml>=0.2.0",
"orjson>=3.10.11",
Expand All @@ -33,7 +32,6 @@ dependencies = [
"aiogram>=3.15.0",
"aiohttp<3.11,>=3.9.0",
"jinja2>=3.1.4",
"sqlalchemy[asyncio]>=2.0.36",
"aiomysql>=0.2.0",
"jupiter-python-sdk>=0.0.2.0",
"aiocache[redis]>=0.12.3",
Expand All @@ -42,5 +40,10 @@ requires-python = "==3.10.*"
license = { text = "Apache-2.0" }

[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.uv.sources]
solbot-common = { path = "../common", editable = true }
solbot-db = { path = "../db", editable = true }
solbot-cache = { path = "../cache", editable = true }
19 changes: 8 additions & 11 deletions libs/yellowstone_grpc/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ requires-python = "==3.10.*"
license = { text = "Apache-2.0" }

[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.pdm]
distribution = true
[tool.hatch.build.targets.wheel]
packages = ["yellowstone_grpc"]

[tool.pdm.dev-dependencies]
dev = [
"pytest>=8.0.0",
"pytest-asyncio>=0.24.0",
]
[dependency-groups]
dev = ["pytest>=8.0.0", "pytest-asyncio>=0.24.0"]

[tool.pdm.scripts]
generate = { shell = "cd yellowstone-grpc-proto && ./generate.sh" }
[tool.uv.sources]
solbot-common = { path = "../common", editable = true }
39 changes: 20 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
name = "open-sol-bot"
version = "0.2.1"
description = "Open Solana Trading Bot"
authors = [
{ name = "mkdir700", email = "[email protected]" },
]
authors = [{ name = "mkdir700", email = "[email protected]" }]
requires-python = "==3.10.*"
readme = "README.md"
license = { text = "Apache-2.0" }
Expand Down Expand Up @@ -46,9 +44,12 @@ dev = [
"pytest-asyncio>=0.24.0",
"pytest-xprocess==0.18.1",
"py==1.10.0",
"ruff>=0.3.4",
"ruff>=0.14.10",
]

[tool.ty.environment]
root = ["./app"]

[tool.ruff]
target-version = "py310"
line-length = 100
Expand All @@ -67,25 +68,25 @@ select = [
"RUF", # ruff-specific rules
]
ignore = [
"E501", # line too long, handled by formatter
"E501", # line too long, handled by formatter
# 以下是暂时忽略的错误,后续可以逐步修复
"RUF001",
"RUF002",
"RUF003",
"B007", # Loop control variable not used within loop body
"B017", # pytest.raises(Exception) should be considered evil
"B019", # Use of functools.lru_cache on methods can lead to memory leaks
"B904", # Within an except clause, raise exceptions with raise ... from err
"C408", # Unnecessary dict call (rewrite as a literal)
"E402", # Module level import not at top of file
"E712", # Avoid equality comparisons to True/False
"F403", # from module import * used; unable to detect undefined names
"F841", # Local variable is assigned to but never used
"N801", # Class name should use CapWords convention
"N802", # Function name should be lowercase
"N805", # First argument of a method should be named self
"N806", # Variable in function should be lowercase
"N818", # Exception name should be named with an Error suffix
"B007", # Loop control variable not used within loop body
"B017", # pytest.raises(Exception) should be considered evil
"B019", # Use of functools.lru_cache on methods can lead to memory leaks
"B904", # Within an except clause, raise exceptions with raise ... from err
"C408", # Unnecessary dict call (rewrite as a literal)
"E402", # Module level import not at top of file
"E712", # Avoid equality comparisons to True/False
"F403", # from module import * used; unable to detect undefined names
"F841", # Local variable is assigned to but never used
"N801", # Class name should use CapWords convention
"N802", # Function name should be lowercase
"N805", # First argument of a method should be named self
"N806", # Variable in function should be lowercase
"N818", # Exception name should be named with an Error suffix
"SIM105", # Use contextlib.suppress instead of try-except-pass
"SIM108", # Use ternary operator instead of if-else-block
"SIM117", # Use a single with statement with multiple contexts
Expand Down
8 changes: 3 additions & 5 deletions tests/trading/transaction/test_trading_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
from solders.keypair import Keypair
from solders.transaction import VersionedTransaction
from trading.swap import SwapDirection
from trading.transaction import AggregateTransactionBuilder, TradingService
from trading.transaction.builders.base import TransactionBuilder
from trading.transaction.builders.gmgn import GMGNTransactionBuilder
from trading.transaction.builders.pump import PumpTransactionBuilder
from trading.transaction.builders.ray_v4 import RaydiumV4TransactionBuilder
from trading.transaction.factory import (AggregateTransactionBuilder,
TradingService)
from trading.transaction.protocol import TradingRoute


Expand Down Expand Up @@ -121,7 +119,7 @@ async def test_trading_service_route_selection():

# 测试无效路由
with pytest.raises(ValueError) as exc_info:
service.select_builder("INVALID_ROUTE")
service.select_builder("INVALID_ROUTE") # type: ignore[invalid-argument-type]
assert "Unsupported trading route" in str(exc_info.value)


Expand Down Expand Up @@ -152,7 +150,7 @@ async def test_trading_service_use_route():
swapper = service.use_route(TradingRoute.RAYDIUM_V4)
assert isinstance(swapper.builder, RaydiumV4TransactionBuilder)
mock_default_sender.assert_called_once()

# DEX
swapper = service.use_route(TradingRoute.DEX)
assert isinstance(swapper.builder, AggregateTransactionBuilder)
Expand Down
Loading